Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/17/2023 11:14:06 AM (22 months ago)
Author:
imath
Message:

Deprecate BP Legacy widgets

Deprecate all classes, functions, JavaScripts and files related to Legacy Widgets. Legacy Widgets are now available from the BP Classic plugin.

See #8869
Closes https://github.com/buddypress/buddypress/pull/99

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/classes/class-bp-core-whos-online-widget.php

    r13108 r13481  
    66 * @subpackage MembersWidgets
    77 * @since 1.0.0
     8 * @deprecated 12.0.0
    89 */
    910
    1011// Exit if accessed directly.
    1112defined( 'ABSPATH' ) || exit;
     13
     14_deprecated_file( basename( __FILE__ ), '12.0.0', '', __( 'BuddyPress does not include Legacy Widgets anymore, you can restore it using the BP Classic plugin', 'buddypress' ) );
    1215
    1316/**
     
    1619 * @since 1.0.3
    1720 * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options.
     21 * @deprecated 12.0.0
    1822 */
    1923class BP_Core_Whos_Online_Widget extends WP_Widget {
     
    2428     * @since 1.5.0
    2529     * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options.
     30     * @deprecated 12.0.0
    2631     */
    2732    public function __construct() {
    28         $name        = _x( "(BuddyPress) Who's Online", 'widget name', 'buddypress' );
    29         $description = __( 'Profile photos of online users', 'buddypress' );
    30         parent::__construct( false, $name, array(
    31             'description'                 => $description,
    32             'classname'                   => 'widget_bp_core_whos_online_widget buddypress widget',
    33             'customize_selective_refresh' => true,
    34             'show_instance_in_rest'       => true,
    35         ) );
     33        _deprecated_function( __METHOD__, '12.0.0' );
    3634    }
    3735
     
    4038     *
    4139     * @since 1.0.3
     40     * @deprecated 12.0.0
    4241     *
    4342     * @see WP_Widget::widget() for description of parameters.
     
    4746     */
    4847    public function widget( $args, $instance ) {
    49         global $members_template;
    50 
    51         // Get widget settings.
    52         $settings = $this->parse_settings( $instance );
    53 
    54         /**
    55          * Filters the title of the Who's Online widget.
    56          *
    57          * @since 1.8.0
    58          * @since 2.3.0 Added 'instance' and 'id_base' to arguments passed to filter.
    59          *
    60          * @param string $title    The widget title.
    61          * @param array  $settings The settings for the particular instance of the widget.
    62          * @param string $id_base  Root ID for all widgets of this type.
    63          */
    64         $title = apply_filters( 'widget_title', $settings['title'], $settings, $this->id_base );
    65 
    66         echo $args['before_widget'] . $args['before_title'] . $title . $args['after_title'];
    67 
    68         $max_limit   = bp_get_widget_max_count_limit( __CLASS__ );
    69         $max_members = $settings['max_members'] > $max_limit ? $max_limit : (int) $settings['max_members'];
    70 
    71         // Setup args for querying members.
    72         $members_args = array(
    73             'user_id'         => 0,
    74             'type'            => 'online',
    75             'per_page'        => $max_members,
    76             'max'             => $max_members,
    77             'populate_extras' => true,
    78             'search_terms'    => false,
    79         );
    80 
    81         // Back up global.
    82         $old_members_template = $members_template;
    83 
    84         ?>
    85 
    86         <?php if ( bp_has_members( $members_args ) ) : ?>
    87 
    88             <div class="avatar-block">
    89 
    90                 <?php while ( bp_members() ) : bp_the_member(); ?>
    91 
    92                     <div class="item-avatar">
    93                         <a href="<?php bp_member_permalink(); ?>" class="bp-tooltip" data-bp-tooltip="<?php bp_member_name(); ?>"><?php bp_member_avatar(); ?></a>
    94                     </div>
    95 
    96                 <?php endwhile; ?>
    97 
    98             </div>
    99 
    100         <?php else: ?>
    101 
    102             <div class="widget-error">
    103                 <?php esc_html_e( 'There are no users currently online', 'buddypress' ); ?>
    104             </div>
    105 
    106         <?php endif; ?>
    107 
    108         <?php echo $args['after_widget'];
    109 
    110         // Restore the global.
    111         $members_template = $old_members_template;
     48        _deprecated_function( __METHOD__, '12.0.0' );
    11249    }
    11350
     
    11653     *
    11754     * @since 1.0.3
     55     * @deprecated 12.0.0
    11856     *
    11957     * @param array $new_instance The new instance options.
     
    12260     */
    12361    public function update( $new_instance, $old_instance ) {
    124         $instance = $old_instance;
    125 
    126         $max_limit = bp_get_widget_max_count_limit( __CLASS__ );
    127 
    128         $instance['title']       = strip_tags( $new_instance['title'] );
    129         $instance['max_members'] = $new_instance['max_members'] > $max_limit ? $max_limit : intval( $new_instance['max_members'] );
    130 
    131         return $instance;
     62        _deprecated_function( __METHOD__, '12.0.0' );
    13263    }
    13364
     
    13667     *
    13768     * @since 1.0.3
     69     * @deprecated 12.0.0
    13870     *
    13971     * @param array $instance Widget instance settings.
     
    14173     */
    14274    public function form( $instance ) {
    143         $max_limit = bp_get_widget_max_count_limit( __CLASS__ );
    144 
    145         // Get widget settings.
    146         $settings    = $this->parse_settings( $instance );
    147         $title       = strip_tags( $settings['title'] );
    148         $max_members = $settings['max_members'] > $max_limit ? $max_limit : intval( $settings['max_members'] );
    149         ?>
    150 
    151         <p>
    152             <label for="<?php echo $this->get_field_id( 'title' ); ?>">
    153                 <?php esc_html_e( 'Title:', 'buddypress' ); ?>
    154                 <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" style="width: 100%" />
    155             </label>
    156         </p>
    157 
    158         <p>
    159             <label for="<?php echo $this->get_field_id( 'max_members' ); ?>">
    160                 <?php esc_html_e( 'Max members to show:', 'buddypress' ); ?>
    161                 <input class="widefat" id="<?php echo $this->get_field_id( 'max_members' ); ?>" name="<?php echo $this->get_field_name( 'max_members' ); ?>" type="number" min="1" max="<?php echo esc_attr( $max_limit ); ?>" value="<?php echo esc_attr( $max_members ); ?>" style="width: 30%" />
    162             </label>
    163         </p>
    164 
    165     <?php
     75        _deprecated_function( __METHOD__, '12.0.0' );
    16676    }
    16777
     
    17080     *
    17181     * @since 2.3.0
     82     * @deprecated 12.0.0
    17283     *
    17384     * @param array $instance Widget instance settings.
     
    17586     */
    17687    public function parse_settings( $instance = array() ) {
    177         return bp_parse_args(
    178             $instance,
    179             array(
    180                 'title'       => __( "Who's Online", 'buddypress' ),
    181                 'max_members' => 15,
    182             ),
    183             'members_widget_settings'
    184         );
     88        _deprecated_function( __METHOD__, '12.0.0' );
    18589    }
    18690}
Note: See TracChangeset for help on using the changeset viewer.