Skip to:
Content

BuddyPress.org

Changeset 13481


Ignore:
Timestamp:
05/17/2023 11:14:06 AM (3 years 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

Location:
trunk/src
Files:
35 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-blogs/bp-blogs-widgets.php

    r13153 r13481  
    66 * @subpackage BlogsWidgets
    77 * @since 1.0.0
     8 * @deprecated 12.0.0
    89 */
    910
     
    1112defined( 'ABSPATH' ) || exit;
    1213
    13 /**
    14  * Registers the Recent Posts Legacy Widget.
    15  *
    16  * @since 10.0.0
    17  */
    18 function bp_blogs_register_recent_posts_widget() {
    19         register_widget( 'BP_Blogs_Recent_Posts_Widget' );
    20 }
    21 
    22 /**
    23  * Register the widgets for the Blogs component.
    24  */
    25 function bp_blogs_register_widgets() {
    26         global $wpdb;
    27 
    28         if ( bp_is_active( 'activity' ) && bp_is_root_blog( $wpdb->blogid ) ) {
    29                 add_action( 'widgets_init', 'bp_blogs_register_recent_posts_widget' );
    30         }
    31 }
    32 add_action( 'bp_register_widgets', 'bp_blogs_register_widgets' );
     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' ) );
  • trunk/src/bp-blogs/classes/class-bp-blogs-component.php

    r13471 r13481  
    149149
    150150                        if ( is_multisite() ) {
    151                                 $includes[] = 'widgets';
    152151                                $includes[] = 'blocks';
    153152                        }
  • trunk/src/bp-blogs/classes/class-bp-blogs-recent-posts-widget.php

    r13436 r13481  
    66 * @subpackage BlogsWidgets
    77 * @since 1.0.0
     8 * @deprecated 12.0.0
    89 */
    910
     
    1112defined( 'ABSPATH' ) || exit;
    1213
     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' ) );
     15
    1316/**
    1417 * The Recent Networkwide Posts widget.
    1518 *
    1619 * @since 1.0.0
     20 * @deprecated 12.0.0
    1721 */
    18 class BP_Blogs_Recent_Posts_Widget extends WP_Widget {
     22class BP_Blogs_Recent_Posts_Widget {
    1923
    2024        /**
     
    2327         * @since 1.5.0
    2428         * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options.
     29         * @deprecated 12.0.0
    2530         */
    2631        public function __construct() {
    27                 $widget_ops = array(
    28                         'description'                 => __( 'A list of recently published posts from across your network.', 'buddypress' ),
    29                         'classname'                   => 'widget_bp_blogs_widget buddypress widget',
    30                         'customize_selective_refresh' => true,
    31                         'show_instance_in_rest'       => true,
    32                 );
    33                 parent::__construct( false, $name = _x( '(BuddyPress) Recent Networkwide Posts', 'widget name', 'buddypress' ), $widget_ops );
     32                _deprecated_function( __METHOD__, '12.0.0' );
    3433        }
    3534
     
    3938         * @see WP_Widget::widget() for description of parameters.
    4039         *
     40         * @deprecated 12.0.0
     41         *
    4142         * @param array $args     Widget arguments.
    4243         * @param array $instance Widget settings, as saved by the user.
    4344         */
    4445        public function widget( $args, $instance ) {
    45                 global $activities_template;
    46 
    47                 $title = ! empty( $instance['title'] )
    48                         ? esc_html( $instance['title'] )
    49                         : __( 'Recent Networkwide Posts', 'buddypress' );
    50 
    51                 if ( ! empty( $instance['link_title'] ) ) {
    52                         $title = '<a href="' . bp_get_blogs_directory_url() . '">' . esc_html( $title ) . '</a>';
    53                 }
    54 
    55                 /**
    56                  * Filters the Blogs Recent Posts widget title.
    57                  *
    58                  * @since 2.2.0
    59                  * @since 2.3.0 Added 'instance' and 'id_base' to arguments passed to filter.
    60                  *
    61                  * @param string $title    The widget title.
    62                  * @param array  $instance The settings for the particular instance of the widget.
    63                  * @param string $id_base  Root ID for all widgets of this type.
    64                  */
    65                 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    66 
    67                 echo $args['before_widget'];
    68                 echo $args['before_title'] . $title . $args['after_title'];
    69 
    70                 $max_limit = bp_get_widget_max_count_limit( __CLASS__ );
    71                 if ( empty( $instance['max_posts'] ) || $instance['max_posts'] > $max_limit ) {
    72                         $instance['max_posts'] = 10;
    73                 }
    74 
    75                 $after_widget = $args['after_widget'];
    76 
    77                 // Override some of the contextually set parameters for bp_has_activities().
    78                 $args = array(
    79                         'action'     => 'new_blog_post',
    80                         'max'        => $instance['max_posts'],
    81                         'per_page'   => $instance['max_posts'],
    82                         'user_id'    => 0,
    83                         'scope'      => false,
    84                         'object'     => false,
    85                         'primary_id' => false
    86                 );
    87 
    88                 // Back up global.
    89                 $old_activities_template = $activities_template;
    90 
    91                 ?>
    92 
    93                 <?php if ( bp_has_activities( $args ) ) : ?>
    94 
    95                         <ul id="blog-post-list" class="activity-list item-list">
    96 
    97                                 <?php while ( bp_activities() ) : bp_the_activity(); ?>
    98 
    99                                         <li>
    100                                                 <div class="activity-content" style="margin: 0">
    101                                                         <div class="activity-header"><?php bp_activity_action(); ?></div>
    102 
    103                                                         <?php if ( bp_get_activity_content_body() ) : ?>
    104 
    105                                                                 <div class="activity-inner"><?php bp_activity_content_body(); ?></div>
    106 
    107                                                         <?php endif; ?>
    108 
    109                                                 </div>
    110                                         </li>
    111 
    112                                 <?php endwhile; ?>
    113 
    114                         </ul>
    115 
    116                 <?php else : ?>
    117 
    118                         <div id="message" class="info">
    119                                 <p><?php _e( 'Sorry, there were no posts found. Why not write one?', 'buddypress' ); ?></p>
    120                         </div>
    121 
    122                 <?php endif; ?>
    123 
    124                 <?php echo $after_widget;
    125 
    126                 // Restore the global.
    127                 $activities_template = $old_activities_template;
     46                _deprecated_function( __METHOD__, '12.0.0' );
    12847        }
    12948
    13049        /**
    13150         * Update the networkwide posts widget options.
     51         *
     52         * @deprecated 12.0.0
    13253         *
    13354         * @param array $new_instance The new instance options.
     
    13657         */
    13758        public function update( $new_instance, $old_instance ) {
    138                 $instance = $old_instance;
    139 
    140                 $max_limit = bp_get_widget_max_count_limit( __CLASS__ );
    141 
    142                 $instance['title']      = strip_tags( $new_instance['title'] );
    143                 $instance['max_posts']  = $new_instance['max_posts'] > $max_limit ? $max_limit : intval( $new_instance['max_posts'] );
    144                 $instance['link_title'] = ! empty( $new_instance['link_title'] );
    145 
    146                 return $instance;
     59                _deprecated_function( __METHOD__, '12.0.0' );
    14760        }
    14861
     
    15063         * Output the networkwide posts widget options form.
    15164         *
     65         * @deprecated 12.0.0
     66         *
    15267         * @param array $instance Settings for this widget.
    15368         */
    15469        public function form( $instance ) {
    155                 $instance = bp_parse_args(
    156                         (array) $instance,
    157                         array(
    158                                 'title'      => __( 'Recent Networkwide Posts', 'buddypress' ),
    159                                 'max_posts'  => 10,
    160                                 'link_title' => false,
    161                         )
    162                 );
    163 
    164                 $max_limit = bp_get_widget_max_count_limit( __CLASS__ );
    165 
    166                 $title      = strip_tags( $instance['title'] );
    167                 $max_posts  = $instance['max_posts'] > $max_limit ? $max_limit : intval( $instance['max_posts'] );
    168                 $link_title = (bool) $instance['link_title'];
    169 
    170                 ?>
    171 
    172                 <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _ex( 'Title:', 'Label for the Title field of the Recent Networkwide Posts widget', 'buddypress' ); ?> <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%;" /></label></p>
    173                 <p><label for="<?php echo $this->get_field_id( 'link_title' ); ?>"><input type="checkbox" name="<?php echo $this->get_field_name( 'link_title' ); ?>" value="1" <?php checked( $link_title ); ?> /> <?php _e( 'Link widget title to Blogs directory', 'buddypress' ); ?></label></p>
    174                 <p><label for="<?php echo $this->get_field_id( 'max_posts' ); ?>"><?php _e( 'Max posts to show:', 'buddypress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_posts' ); ?>" name="<?php echo $this->get_field_name( 'max_posts' ); ?>" type="number" min="1" max="<?php echo esc_attr( $max_limit ); ?>" value="<?php echo esc_attr( $max_posts ); ?>" style="width: 30%" /></label></p>
    175                 <?php
     70                _deprecated_function( __METHOD__, '12.0.0' );
    17671        }
    17772}
  • trunk/src/bp-core/bp-core-filters.php

    r13471 r13481  
    11221122
    11231123/**
    1124  * Injects specific BuddyPress CSS classes into a widget sidebar.
    1125  *
    1126  * Helps to standardize styling of BuddyPress widgets within a theme that
    1127  * does not use dynamic CSS classes in their widget sidebar's 'before_widget'
    1128  * call.
    1129  *
    1130  * @since 2.4.0
    1131  * @access private
    1132  *
    1133  * @global array $wp_registered_widgets Current registered widgets.
    1134  *
    1135  * @param array $params Current sidebar params.
    1136  * @return array
    1137  */
    1138 function _bp_core_inject_bp_widget_css_class( $params ) {
    1139         global $wp_registered_widgets;
    1140 
    1141         $widget_id = $params[0]['widget_id'];
    1142 
    1143         // If callback isn't an array, bail.
    1144         if ( false === is_array( $wp_registered_widgets[ $widget_id ]['callback'] ) ) {
    1145                 return $params;
    1146         }
    1147 
    1148         // If the current widget isn't a BuddyPress one, stop!
    1149         // We determine if a widget is a BuddyPress widget, if the widget class
    1150         // begins with 'bp_'.
    1151         if ( 0 !== strpos( $wp_registered_widgets[ $widget_id ]['callback'][0]->id_base, 'bp_' ) ) {
    1152                 return $params;
    1153         }
    1154 
    1155         // Dynamically add our widget CSS classes for BP widgets if not already there.
    1156         $classes = array();
    1157 
    1158         // Try to find 'widget' CSS class.
    1159         if ( false === strpos( $params[0]['before_widget'], 'widget ' ) ) {
    1160                 $classes[] = 'widget';
    1161         }
    1162 
    1163         // Try to find 'buddypress' CSS class.
    1164         if ( false === strpos( $params[0]['before_widget'], ' buddypress' ) ) {
    1165                 $classes[] = 'buddypress';
    1166         }
    1167 
    1168         // Stop if widget already has our CSS classes.
    1169         if ( empty( $classes ) ) {
    1170                 return $params;
    1171         }
    1172 
    1173         // CSS injection time!
    1174         $params[0]['before_widget'] = str_replace( 'class="', 'class="' . implode( ' ', $classes ) . ' ', $params[0]['before_widget'] );
    1175 
    1176         return $params;
    1177 }
    1178 add_filter( 'dynamic_sidebar_params', '_bp_core_inject_bp_widget_css_class' );
    1179 
    1180 /**
    11811124 * Add email link styles to rendered email template.
    11821125 *
  • trunk/src/bp-core/bp-core-functions.php

    r13468 r13481  
    46644664
    46654665/**
    4666  * Returns the upper limit on the "max" item count, for widgets that support it.
    4667  *
    4668  * @since 5.0.0
    4669  *
    4670  * @param string $widget_class Optional. Class name of the calling widget.
    4671  * @return int
    4672  */
    4673 function bp_get_widget_max_count_limit( $widget_class = '' ) {
    4674         /**
    4675          * Filters the upper limit on the "max" item count, for widgets that support it.
    4676          *
    4677          * @since 5.0.0
    4678          *
    4679          * @param int    $count        Defaults to 50.
    4680          * @param string $widget_class Class name of the calling widget.
    4681          */
    4682         return apply_filters( 'bp_get_widget_max_count_limit', 50, $widget_class );
    4683 }
    4684 
    4685 /**
    46864666 * Add a new BP_Optout.
    46874667 *
  • trunk/src/bp-core/bp-core-options.php

    r12893 r13481  
    9898                // Ignore deprecated code.
    9999                '_bp_ignore_deprecated_code'           => true,
    100 
    101                 /* Widgets **************************************************/
    102                 'widget_bp_core_login_widget'                => false,
    103                 'widget_bp_core_members_widget'              => false,
    104                 'widget_bp_core_whos_online_widget'          => false,
    105                 'widget_bp_core_recently_active_widget'      => false,
    106                 'widget_bp_groups_widget'                    => false,
    107                 'widget_bp_messages_sitewide_notices_widget' => false,
    108100        );
    109101
  • trunk/src/bp-core/bp-core-update.php

    r13432 r13481  
    861861                }
    862862
     863                /* Widgets **************************************************/
     864                $widget_options = array(
     865                        'widget_bp_core_login_widget',
     866                        'widget_bp_core_members_widget',
     867                        'widget_bp_core_whos_online_widget',
     868                        'widget_bp_core_recently_active_widget',
     869                        'widget_bp_groups_widget',
     870                        'widget_bp_messages_sitewide_notices_widget',
     871                );
     872
     873                foreach ( $widget_options as $widget_option ) {
     874                        bp_delete_option( $widget_option );
     875                }
     876
    863877                // Finally make sure to rebuilt permalinks at next page load.
    864878                bp_delete_rewrite_rules();
  • trunk/src/bp-core/bp-core-widgets.php

    r13417 r13481  
    66 * @subpackage Core
    77 * @since 1.0.0
     8 * @deprecated 12.0.0
    89 */
    910
     
    1112defined( 'ABSPATH' ) || exit;
    1213
    13 /**
    14  * Should BuddyPress load Legacy Widgets?
    15  *
    16  * @since 10.0.0
    17  *
    18  * @return bool False if BuddyPress shouldn't load Legacy Widgets. True otherwise.
    19  */
    20 function bp_core_retain_legacy_widgets() {
    21         $theme_supports = current_theme_supports( 'widgets-block-editor' );
    22 
    23         /** This filter is documented in wp-includes/widgets.php */
    24         $block_widgets_enabled = $theme_supports && apply_filters( 'use_widgets_block_editor', true );
    25 
    26         $retain_legacy_widgets = true;
    27         if ( $block_widgets_enabled ) {
    28                 $retain_legacy_widgets = false;
    29         }
    30 
    31         /**
    32          * Filter here to force Legacy Widgets to be retained or not.
    33          *
    34          * @since 10.0.0
    35          *
    36          * @param bool $retain_legacy_widgets False if BuddyPress shouldn't load Legacy Widgets. True otherwise.
    37          */
    38         return apply_filters( 'bp_core_retain_legacy_widgets', $retain_legacy_widgets );
    39 }
    40 
    41 /**
    42  * Registers the Login widget.
    43  *
    44  * @since 10.0.0
    45  */
    46 function bp_core_register_login_widget() {
    47         register_widget( 'BP_Core_Login_Widget' );
    48 }
    49 
    50 /**
    51  * Register bp-core widgets.
    52  *
    53  * @since 1.0.0
    54  */
    55 function bp_core_register_widgets() {
    56         add_action( 'widgets_init', 'bp_core_register_login_widget' );
    57 }
    58 add_action( 'bp_register_widgets', 'bp_core_register_widgets' );
    59 
    60 /**
    61  * Checks whether BuddyPress should unhook Legacy Widget registrations.
    62  *
    63  * @since 10.0.0
    64  */
    65 function bp_core_maybe_unhook_legacy_widgets() {
    66         if ( bp_core_retain_legacy_widgets() ) {
    67                 return;
    68         }
    69 
    70         $callbacks = array(
    71                 'BP_Core_Login_Widget'           => 'bp_core_register_login_widget',
    72                 'BP_Core_Members_Widget'         => 'bp_members_register_members_widget',
    73                 'BP_Core_Whos_Online_Widget'     => 'bp_members_register_whos_online_widget',
    74                 'BP_Core_Recently_Active_Widget' => 'bp_members_register_recently_active_widget',
    75         );
    76 
    77         if ( bp_is_active( 'friends' ) ) {
    78                 $callbacks['BP_Core_Friends_Widget'] = 'bp_friends_register_friends_widget';
    79         }
    80 
    81         if ( bp_is_active( 'groups' ) ) {
    82                 $callbacks['BP_Groups_Widget'] = 'bp_groups_register_groups_widget';
    83         }
    84 
    85         if ( bp_is_active( 'messages' ) ) {
    86                 $callbacks['BP_Messages_Sitewide_Notices_Widget'] = 'bp_messages_register_sitewide_notices_widget';
    87         }
    88 
    89         if ( bp_is_active( 'blogs' ) && bp_is_active( 'activity' ) && bp_is_root_blog() ) {
    90                 $callbacks['BP_Blogs_Recent_Posts_Widget'] = 'bp_blogs_register_recent_posts_widget';
    91         }
    92 
    93         foreach ( $callbacks as $widget_id => $callback ) {
    94                 $widget_base = strtolower( $widget_id );
    95 
    96                 // If there's an active widget, we need to carry on loading it.
    97                 if ( is_active_widget( false, false, $widget_base ) ) {
    98                         continue;
    99                 }
    100 
    101                 remove_action( 'widgets_init', $callback );
    102         }
    103 }
    104 add_action( 'widgets_init', 'bp_core_maybe_unhook_legacy_widgets', 0 );
     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' ) );
  • trunk/src/bp-core/classes/class-bp-core-login-widget.php

    r13441 r13481  
    66 * @subpackage Core
    77 * @since 1.9.0
     8 * @deprecated 12.0.0
    89 */
    910
     
    1112defined( 'ABSPATH' ) || exit;
    1213
     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' ) );
     15
    1316/**
    1417 * BuddyPress Login Widget.
    1518 *
    1619 * @since 1.9.0
     20 * @deprecated 12.0.0
    1721 */
    18 class BP_Core_Login_Widget extends WP_Widget {
     22class BP_Core_Login_Widget {
    1923
    2024        /**
     
    2327         * @since 1.9.0
    2428         * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options.
     29         * @deprecated 12.0.0
    2530         */
    2631        public function __construct() {
    27                 parent::__construct(
    28                         false,
    29                         _x( '(BuddyPress) Log In', 'Title of the login widget', 'buddypress' ),
    30                         array(
    31                                 'description'                 => __( 'Show a Log In form to logged-out visitors, and a Log Out link to those who are logged in.', 'buddypress' ),
    32                                 'classname'                   => 'widget_bp_core_login_widget buddypress widget',
    33                                 'customize_selective_refresh' => true,
    34                                 'show_instance_in_rest'       => true,
    35                         )
    36                 );
     32                _deprecated_function( __METHOD__, '12.0.0' );
    3733        }
    3834
     
    4137         *
    4238         * @since 1.9.0
     39         * @deprecated 12.0.0
    4340         *
    4441         * @see WP_Widget::widget() for description of parameters.
     
    4845         */
    4946        public function widget( $args, $instance ) {
    50                 $title = isset( $instance['title'] ) ? $instance['title'] : '';
    51 
    52                 /**
    53                  * Filters the title of the Login widget.
    54                  *
    55                  * @since 1.9.0
    56                  * @since 2.3.0 Added 'instance' and 'id_base' to arguments passed to filter.
    57                  *
    58                  * @param string $title    The widget title.
    59                  * @param array  $instance The settings for the particular instance of the widget.
    60                  * @param string $id_base  Root ID for all widgets of this type.
    61                  */
    62                 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    63 
    64                 echo $args['before_widget'];
    65 
    66                 echo $args['before_title'] . esc_html( $title ) . $args['after_title']; ?>
    67 
    68                 <?php if ( is_user_logged_in() ) : ?>
    69 
    70                         <?php
    71                         /**
    72                          * Fires before the display of widget content if logged in.
    73                          *
    74                          * @since 1.9.0
    75                          */
    76                         do_action( 'bp_before_login_widget_loggedin' ); ?>
    77 
    78                         <div class="bp-login-widget-user-avatar">
    79                                 <a href="<?php bp_loggedin_user_link(); ?>">
    80                                         <?php bp_loggedin_user_avatar( 'type=thumb&width=50&height=50' ); ?>
    81                                 </a>
    82                         </div>
    83 
    84                         <div class="bp-login-widget-user-links">
    85                                 <div class="bp-login-widget-user-link"><?php echo bp_core_get_userlink( bp_loggedin_user_id() ); ?></div>
    86                                 <div class="bp-login-widget-user-logout"><a class="logout" href="<?php echo wp_logout_url( bp_get_requested_url() ); ?>"><?php _e( 'Log Out', 'buddypress' ); ?></a></div>
    87                         </div>
    88 
    89                         <?php
    90 
    91                         /**
    92                          * Fires after the display of widget content if logged in.
    93                          *
    94                          * @since 1.9.0
    95                          */
    96                         do_action( 'bp_after_login_widget_loggedin' ); ?>
    97 
    98                 <?php else : ?>
    99 
    100                         <?php
    101 
    102                         /**
    103                          * Fires before the display of widget content if logged out.
    104                          *
    105                          * @since 1.9.0
    106                          */
    107                         do_action( 'bp_before_login_widget_loggedout' ); ?>
    108 
    109                         <form name="bp-login-form" id="bp-login-widget-form" class="standard-form" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post">
    110                                 <label for="bp-login-widget-user-login"><?php _e( 'Username', 'buddypress' ); ?></label>
    111                                 <input type="text" name="log" id="bp-login-widget-user-login" class="input" value="" />
    112 
    113                                 <label for="bp-login-widget-user-pass"><?php _e( 'Password', 'buddypress' ); ?></label>
    114                                 <input type="password" name="pwd" id="bp-login-widget-user-pass" class="input" value="" <?php bp_form_field_attributes( 'password' ) ?> />
    115 
    116                                 <div class="forgetmenot"><label for="bp-login-widget-rememberme"><input name="rememberme" type="checkbox" id="bp-login-widget-rememberme" value="forever" /> <?php _e( 'Remember Me', 'buddypress' ); ?></label></div>
    117 
    118                                 <input type="submit" name="wp-submit" id="bp-login-widget-submit" value="<?php esc_attr_e( 'Log In', 'buddypress' ); ?>" />
    119 
    120                                 <?php if ( bp_get_signup_allowed() ) : ?>
    121 
    122                                         <span class="bp-login-widget-register-link"><a href="<?php echo esc_url( bp_get_signup_page() ); ?>"><?php _e( 'Register', 'buddypress' ); ?></a></span>
    123 
    124                                 <?php endif; ?>
    125 
    126                                 <?php
    127 
    128                                 /**
    129                                  * Fires inside the display of the login widget form.
    130                                  *
    131                                  * @since 2.4.0
    132                                  */
    133                                 do_action( 'bp_login_widget_form' ); ?>
    134 
    135                         </form>
    136 
    137                         <?php
    138 
    139                         /**
    140                          * Fires after the display of widget content if logged out.
    141                          *
    142                          * @since 1.9.0
    143                          */
    144                         do_action( 'bp_after_login_widget_loggedout' ); ?>
    145 
    146                 <?php endif;
    147 
    148                 echo $args['after_widget'];
     47                _deprecated_function( __METHOD__, '12.0.0' );
    14948        }
    15049
     
    15352         *
    15453         * @since 1.9.0
     54         * @deprecated 12.0.0
    15555         *
    15656         * @param array $new_instance The new instance options.
     
    15959         */
    16060        public function update( $new_instance, $old_instance ) {
    161                 $instance             = $old_instance;
    162                 $instance['title']    = isset( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : '';
    163 
    164                 return $instance;
     61                _deprecated_function( __METHOD__, '12.0.0' );
    16562        }
    16663
     
    16966         *
    17067         * @since 1.9.0
     68         * @deprecated 12.0.0
    17169         *
    17270         * @param array $instance Settings for this widget.
     
    17472         */
    17573        public function form( $instance = array() ) {
    176 
    177                 $settings = bp_parse_args(
    178                         $instance,
    179                         array(
    180                                 'title' => '',
    181                         )
    182                 );
    183                 ?>
    184 
    185                 <p>
    186                         <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'buddypress' ); ?>
    187                         <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( $settings['title'] ); ?>" /></label>
    188                 </p>
    189 
    190                 <?php
     74                _deprecated_function( __METHOD__, '12.0.0' );
    19175        }
    19276}
  • trunk/src/bp-core/deprecated/12.0.php

    r13477 r13481  
    477477                 */
    478478                return apply_filters_deprecated( 'bp_get_blogs_directory_permalink', array( $url ), '12.0.0', 'bp_get_blogs_directory_url' );
     479        }
     480
     481        /**
     482         * Returns the upper limit on the "max" item count, for widgets that support it.
     483         *
     484         * @since 5.0.0
     485         * @deprecated 12.0.0
     486         *
     487         * @param string $widget_class Optional. Class name of the calling widget.
     488         * @return int
     489         */
     490        function bp_get_widget_max_count_limit( $widget_class = '' ) {
     491                _deprecated_function( __FUNCTION__, '12.0.0' );
     492                /**
     493                 * Filters the upper limit on the "max" item count, for widgets that support it.
     494                 *
     495                 * @since 5.0.0
     496                 * @deprecated 12.0.0
     497                 *
     498                 * @param int    $count        Defaults to 50.
     499                 * @param string $widget_class Class name of the calling widget.
     500                 */
     501                return apply_filters_deprecated( 'bp_get_widget_max_count_limit', array( 50, $widget_class ), '12.0.0' );
    479502        }
    480503}
     
    664687        return $post_states;
    665688}
     689
     690/**
     691 * Should BuddyPress load Legacy Widgets?
     692 *
     693 * @since 10.0.0
     694 * @deprecated 12.0.0
     695 *
     696 * @return bool False if BuddyPress shouldn't load Legacy Widgets. True otherwise.
     697 */
     698function bp_core_retain_legacy_widgets() {
     699        _deprecated_function( __FUNCTION__, '12.0.0' );
     700        return false;
     701}
     702
     703/**
     704 * Checks whether BuddyPress should unhook Legacy Widget registrations.
     705 *
     706 * @since 10.0.0
     707 * @deprecated 12.0.0
     708 */
     709function bp_core_maybe_unhook_legacy_widgets() {
     710        _deprecated_function( __FUNCTION__, '12.0.0' );
     711}
     712
     713/**
     714 * Registers the Login widget.
     715 *
     716 * @since 10.0.0
     717 * @deprecated 12.0.0
     718 */
     719function bp_core_register_login_widget() {
     720        _deprecated_function( __FUNCTION__, '12.0.0' );
     721}
     722
     723/**
     724 * Register bp-core widgets.
     725 *
     726 * @since 1.0.0
     727 * @deprecated 12.0.0
     728 */
     729function bp_core_register_widgets() {
     730        _deprecated_function( __FUNCTION__, '12.0.0' );
     731}
     732
     733/**
     734 * Registers the Recent Posts Legacy Widget.
     735 *
     736 * @since 10.0.0
     737 * @deprecated 12.0.0
     738 */
     739function bp_blogs_register_recent_posts_widget() {
     740        _deprecated_function( __FUNCTION__, '12.0.0' );
     741}
     742
     743/**
     744 * Register the widgets for the Blogs component.
     745 *
     746 * @deprecated 12.0.0
     747 */
     748function bp_blogs_register_widgets() {
     749        _deprecated_function( __FUNCTION__, '12.0.0' );
     750}
     751
     752/**
     753 * Registers the Friends Legacy Widget.
     754 *
     755 * @since 10.0.0
     756 * @deprecated 12.0.0
     757 */
     758function bp_friends_register_friends_widget() {
     759        _deprecated_function( __FUNCTION__, '12.0.0' );
     760}
     761
     762/**
     763 * Register the friends widget.
     764 *
     765 * @since 1.9.0
     766 * @deprecated 12.0.0
     767 */
     768function bp_friends_register_widgets() {
     769        _deprecated_function( __FUNCTION__, '12.0.0' );
     770}
     771
     772/**
     773 * Process AJAX pagination or filtering for the Friends widget.
     774 *
     775 * @since 1.9.0
     776 * @deprecated 12.0.0
     777 */
     778function bp_core_ajax_widget_friends() {
     779        _deprecated_function( __FUNCTION__, '12.0.0' );
     780}
     781
     782/**
     783 * Injects specific BuddyPress CSS classes into a widget sidebar.
     784 *
     785 * Helps to standardize styling of BuddyPress widgets within a theme that
     786 * does not use dynamic CSS classes in their widget sidebar's 'before_widget'
     787 * call.
     788 *
     789 * @since 2.4.0
     790 * @deprecated 12.0.0
     791 * @access private
     792 *
     793 * @global array $wp_registered_widgets Current registered widgets.
     794 *
     795 * @param array $params Current sidebar params.
     796 * @return array
     797 */
     798function _bp_core_inject_bp_widget_css_class( $params ) {
     799        _deprecated_function( __FUNCTION__, '12.0.0' );
     800}
     801
     802/**
     803 * Registers the Groups Legacy Widget.
     804 *
     805 * @since 10.0.0
     806 * @deprecated 12.0.0
     807 */
     808function bp_groups_register_groups_widget() {
     809        _deprecated_function( __FUNCTION__, '12.0.0' );
     810}
     811
     812/**
     813 * Register widgets for groups component.
     814 *
     815 * @since 1.0.0
     816 * @deprecated 12.0.0
     817 */
     818function groups_register_widgets() {
     819        _deprecated_function( __FUNCTION__, '12.0.0' );
     820}
     821
     822/**
     823 * AJAX callback for the Groups List widget.
     824 *
     825 * @since 1.0.0
     826 * @deprecated 12.0.0
     827 */
     828function groups_ajax_widget_groups_list() {
     829        _deprecated_function( __FUNCTION__, '12.0.0' );
     830}
     831
     832/**
     833 * Registers the Members Legacy Widget.
     834 *
     835 * @since 10.0.0
     836 * @deprecated 12.0.0
     837 */
     838function bp_members_register_members_widget() {
     839        _deprecated_function( __FUNCTION__, '12.0.0' );
     840}
     841
     842/**
     843 * Registers the "Who's online?" Legacy Widget.
     844 *
     845 * @since 10.0.0
     846 * @deprecated 12.0.0
     847 */
     848function bp_members_register_whos_online_widget() {
     849        _deprecated_function( __FUNCTION__, '12.0.0' );
     850}
     851
     852/**
     853 * Registers the "Recently Active" Legacy Widget.
     854 *
     855 * @since 10.0.0
     856 * @deprecated 12.0.0
     857 */
     858function bp_members_register_recently_active_widget() {
     859        _deprecated_function( __FUNCTION__, '12.0.0' );
     860}
     861
     862/**
     863 * Register bp-members widgets.
     864 *
     865 * Previously, these widgets were registered in bp-core.
     866 *
     867 * @since 2.2.0
     868 * @deprecated 12.0.0
     869 */
     870function bp_members_register_widgets() {
     871        _deprecated_function( __FUNCTION__, '12.0.0' );
     872}
     873
     874/**
     875 * AJAX request handler for Members widgets.
     876 *
     877 * @since 1.0.0
     878 * @deprecated 12.0.0
     879 *
     880 * @see BP_Core_Members_Widget
     881 */
     882function bp_core_ajax_widget_members() {
     883        _deprecated_function( __FUNCTION__, '12.0.0' );
     884}
     885
     886/**
     887 * Registers the Sitewide Notices Legacy Widget.
     888 *
     889 * @since 10.0.0
     890 * @deprecated 12.0.0
     891 */
     892function bp_messages_register_sitewide_notices_widget() {
     893        _deprecated_function( __FUNCTION__, '12.0.0' );
     894}
     895
     896/**
     897 * Register widgets for the Messages component.
     898 *
     899 * @since 1.9.0
     900 * @deprecated 12.0.0
     901 */
     902function bp_messages_register_widgets() {
     903        _deprecated_function( __FUNCTION__, '12.0.0' );
     904}
  • trunk/src/bp-core/js/widget-members.js

    r12856 r13481  
    1 jQuery( function() {
    2         member_widget_click_handler();
    3 
    4         // WP 4.5 - Customizer selective refresh support.
    5         if ( 'undefined' !== typeof wp && wp.customize && wp.customize.selectiveRefresh ) {
    6                 wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function() {
    7                         member_widget_click_handler();
    8                 } );
    9         }
    10 });
    11 
    12 function member_widget_click_handler() {
    13         jQuery('.widget div#members-list-options a').on('click',
    14                 function() {
    15                         var link = this;
    16                         jQuery(link).addClass('loading');
    17 
    18                         jQuery('.widget div#members-list-options a').removeClass('selected');
    19                         jQuery(this).addClass('selected');
    20 
    21                         jQuery.post( ajaxurl, {
    22                                 action: 'widget_members',
    23                                 'cookie': encodeURIComponent(document.cookie),
    24                                 '_wpnonce': jQuery('input#_wpnonce-members').val(),
    25                                 'max-members': jQuery('input#members_widget_max').val(),
    26                                 'filter': jQuery(this).attr('id')
    27                         },
    28                         function(response)
    29                         {
    30                                 jQuery(link).removeClass('loading');
    31                                 member_widget_response(response);
    32                         });
    33 
    34                         return false;
    35                 }
    36         );
    37 }
    38 
    39 function member_widget_response(response) {
    40         response = response.substr(0, response.length-1);
    41         response = response.split('[[SPLIT]]');
    42 
    43         if ( response[0] !== '-1' ) {
    44                 jQuery('.widget ul#members-list').fadeOut(200,
    45                         function() {
    46                                 jQuery('.widget ul#members-list').html(response[1]);
    47                                 jQuery('.widget ul#members-list').fadeIn(200);
    48                         }
    49                 );
    50 
    51         } else {
    52                 jQuery('.widget ul#members-list').fadeOut(200,
    53                         function() {
    54                                 var message = '<p>' + response[1] + '</p>';
    55                                 jQuery('.widget ul#members-list').html(message);
    56                                 jQuery('.widget ul#members-list').fadeIn(200);
    57                         }
    58                 );
    59         }
    60 }
     1window.console.log( '`widget-members.js` is deprecated since 12.0.0, please use the BP Classic plugin to use BP Legacy Widgets.' );
  • trunk/src/bp-friends/bp-friends-widgets.php

    r13153 r13481  
    66 * @subpackage FriendsWidgets
    77 * @since 1.9.0
     8 * @deprecated 12.0.0
    89 */
    910
     
    1112defined( 'ABSPATH' ) || exit;
    1213
    13 /**
    14  * Registers the Friends Legacy Widget.
    15  *
    16  * @since 10.0.0
    17  */
    18 function bp_friends_register_friends_widget() {
    19         register_widget( 'BP_Core_Friends_Widget' );
    20 }
    21 
    22 /**
    23  * Register the friends widget.
    24  *
    25  * @since 1.9.0
    26  */
    27 function bp_friends_register_widgets() {
    28         if ( ! bp_is_active( 'friends' ) ) {
    29                 return;
    30         }
    31 
    32         // The Friends widget works only when looking an a displayed user,
    33         // and the concept of "displayed user" doesn't exist on non-root blogs,
    34         // so we don't register the widget there.
    35         if ( ! bp_is_root_blog() ) {
    36                 return;
    37         }
    38 
    39         add_action( 'widgets_init', 'bp_friends_register_friends_widget' );
    40 }
    41 add_action( 'bp_register_widgets', 'bp_friends_register_widgets' );
    42 
    43 /** Widget AJAX ***************************************************************/
    44 
    45 /**
    46  * Process AJAX pagination or filtering for the Friends widget.
    47  *
    48  * @since 1.9.0
    49  */
    50 function bp_core_ajax_widget_friends() {
    51 
    52         check_ajax_referer( 'bp_core_widget_friends' );
    53 
    54         switch ( $_POST['filter'] ) {
    55                 case 'newest-friends':
    56                         $type = 'newest';
    57                         break;
    58 
    59                 case 'recently-active-friends':
    60                         $type = 'active';
    61                         break;
    62 
    63                 case 'popular-friends':
    64                         $type = 'popular';
    65                         break;
    66         }
    67 
    68         $members_args = array(
    69                 'user_id'         => bp_displayed_user_id(),
    70                 'type'            => $type,
    71                 'max'             => absint( $_POST['max-friends'] ),
    72                 'populate_extras' => 1,
    73         );
    74 
    75         if ( bp_has_members( $members_args ) ) : ?>
    76                 <?php echo '0[[SPLIT]]'; // Return valid result. TODO: remove this. ?>
    77                 <?php while ( bp_members() ) : bp_the_member(); ?>
    78                         <li class="vcard">
    79                                 <div class="item-avatar">
    80                                         <a href="<?php bp_member_permalink(); ?>"><?php bp_member_avatar(); ?></a>
    81                                 </div>
    82 
    83                                 <div class="item">
    84                                         <div class="item-title fn"><a href="<?php bp_member_permalink(); ?>"><?php bp_member_name(); ?></a></div>
    85                                         <?php if ( 'active' == $type ) : ?>
    86                                                 <div class="item-meta"><span class="activity" data-livestamp="<?php bp_core_iso8601_date( bp_get_member_last_active( array( 'relative' => false ) ) ); ?>"><?php bp_member_last_active(); ?></span></div>
    87                                         <?php elseif ( 'newest' == $type ) : ?>
    88                                                 <div class="item-meta"><span class="activity" data-livestamp="<?php bp_core_iso8601_date( bp_get_member_registered( array( 'relative' => false ) ) ); ?>"><?php bp_member_registered(); ?></span></div>
    89                                         <?php elseif ( bp_is_active( 'friends' ) ) : ?>
    90                                                 <div class="item-meta"><span class="activity"><?php bp_member_total_friend_count(); ?></span></div>
    91                                         <?php endif; ?>
    92                                 </div>
    93                         </li>
    94                 <?php endwhile; ?>
    95 
    96         <?php else: ?>
    97                 <?php echo "-1[[SPLIT]]<li>"; ?>
    98                 <?php esc_html_e( 'There were no members found, please try another filter.', 'buddypress' ); ?>
    99                 <?php echo "</li>"; ?>
    100         <?php endif;
    101 }
    102 add_action( 'wp_ajax_widget_friends', 'bp_core_ajax_widget_friends' );
    103 add_action( 'wp_ajax_nopriv_widget_friends', 'bp_core_ajax_widget_friends' );
     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' ) );
  • trunk/src/bp-friends/classes/class-bp-core-friends-widget.php

    r13443 r13481  
    66 * @subpackage FriendsWidget
    77 * @since 1.9.0
     8 * @deprecated 12.0.0
    89 */
    910
     
    1112defined( 'ABSPATH' ) || exit;
    1213
     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' ) );
     15
    1316/**
    1417 * The User Friends widget class.
    1518 *
    1619 * @since 1.9.0
     20 * @deprecated 12.0.0
    1721 */
    18 class BP_Core_Friends_Widget extends WP_Widget {
     22class BP_Core_Friends_Widget {
    1923
    2024        /**
     
    2327         * @since 1.9.0
    2428         * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options.
     29         * @deprecated 12.0.0
    2530         */
    2631        public function __construct() {
    27                 $widget_ops = array(
    28                         'description'                 => __( 'A dynamic list of recently active, popular, and newest Friends of the displayed member. Widget is only shown when viewing a member profile.', 'buddypress' ),
    29                         'classname'                   => 'widget_bp_core_friends_widget buddypress widget',
    30                         'customize_selective_refresh' => true,
    31                         'show_instance_in_rest'       => true,
    32                 );
    33                 parent::__construct( false, $name = _x( '(BuddyPress) Friends', 'widget name', 'buddypress' ), $widget_ops );
    34 
    35                 if ( is_customize_preview() || bp_is_widget_block_active( '', $this->id_base ) ) {
    36                         add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
    37                 }
     32                _deprecated_function( __METHOD__, '12.0.0' );
    3833        }
    3934
     
    4237         *
    4338         * @since 2.6.0
     39         * @deprecated 12.0.0
    4440         */
    4541        public function enqueue_scripts() {
    46                 $min = bp_core_get_minified_asset_suffix();
    47                 wp_enqueue_script( 'bp_core_widget_friends-js', buddypress()->plugin_url . "bp-friends/js/widget-friends{$min}.js", array( 'jquery' ), bp_get_version() );
     42                _deprecated_function( __METHOD__, '12.0.0' );
    4843        }
    4944
     
    5247         *
    5348         * @since 1.9.0
     49         * @deprecated 12.0.0
    5450         *
    5551         * @global BP_Core_Members_Template $members_template The main member template loop class.
     
    5955         */
    6056        public function widget( $args, $instance ) {
    61                 global $members_template;
    62 
    63                 extract( $args );
    64 
    65                 if ( ! bp_displayed_user_id() ) {
    66                         return;
    67                 }
    68 
    69                 $user_id           = bp_displayed_user_id();
    70                 $friends_slug      = bp_get_friends_slug();
    71                 $link              = bp_displayed_user_url(
    72                         array(
    73                                 'single_item_component' => bp_rewrites_get_slug( 'members', 'member_' . $friends_slug, $friends_slug ),
    74                         )
    75                 );
    76                 $instance['title'] = sprintf( __( "%s's Friends", 'buddypress' ), bp_get_displayed_user_fullname() );
    77 
    78                 if ( empty( $instance['friend_default'] ) ) {
    79                         $instance['friend_default'] = 'active';
    80                 }
    81 
    82                 /**
    83                  * Filters the Friends widget title.
    84                  *
    85                  * @since 1.8.0
    86                  * @since 2.3.0 Added 'instance' and 'id_base' to arguments passed to filter.
    87                  *
    88                  * @param string $title    The widget title.
    89                  * @param array  $instance The settings for the particular instance of the widget.
    90                  * @param string $id_base  Root ID for all widgets of this type.
    91                  */
    92                 $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
    93 
    94                 echo $before_widget;
    95 
    96                 $title = $instance['link_title'] ? '<a href="' . esc_url( $link ) . '">' . esc_html( $title ) . '</a>' : esc_html( $title );
    97 
    98                 echo $before_title . $title . $after_title;
    99 
    100                 $members_args = array(
    101                         'user_id'         => absint( $user_id ),
    102                         'type'            => sanitize_text_field( $instance['friend_default'] ),
    103                         'max'             => absint( $instance['max_friends'] ),
    104                         'populate_extras' => 1,
    105                 );
    106 
    107                 // Back up the global.
    108                 $old_members_template = $members_template;
    109 
    110                 ?>
    111 
    112                 <?php if ( bp_has_members( $members_args ) ) : ?>
    113                         <div class="item-options" id="friends-list-options">
    114                                 <a href="<?php bp_members_directory_permalink(); ?>" id="newest-friends" <?php if ( $instance['friend_default'] == 'newest' ) : ?>class="selected"<?php endif; ?>><?php _e( 'Newest', 'buddypress' ); ?></a>
    115                                 | <a href="<?php bp_members_directory_permalink(); ?>" id="recently-active-friends" <?php if ( $instance['friend_default'] == 'active' ) : ?>class="selected"<?php endif; ?>><?php _e( 'Active', 'buddypress' ); ?></a>
    116                                 | <a href="<?php bp_members_directory_permalink(); ?>" id="popular-friends" <?php if ( $instance['friend_default'] == 'popular' ) : ?>class="selected"<?php endif; ?>><?php _e( 'Popular', 'buddypress' ); ?></a>
    117                         </div>
    118 
    119                         <ul id="friends-list" class="item-list">
    120                                 <?php while ( bp_members() ) : bp_the_member(); ?>
    121                                         <li class="vcard">
    122                                                 <div class="item-avatar">
    123                                                         <a href="<?php bp_member_permalink(); ?>" class="bp-tooltip" data-bp-tooltip="<?php bp_member_name(); ?>"><?php bp_member_avatar(); ?></a>
    124                                                 </div>
    125 
    126                                                 <div class="item">
    127                                                         <div class="item-title fn"><a href="<?php bp_member_permalink(); ?>"><?php bp_member_name(); ?></a></div>
    128                                                         <div class="item-meta">
    129                                                                 <?php if ( 'newest' == $instance['friend_default'] ) : ?>
    130                                                                         <span class="activity" data-livestamp="<?php bp_core_iso8601_date( bp_get_member_registered( array( 'relative' => false ) ) ); ?>"><?php bp_member_registered(); ?></span>
    131                                                                 <?php elseif ( 'active' == $instance['friend_default'] ) : ?>
    132                                                                         <span class="activity" data-livestamp="<?php bp_core_iso8601_date( bp_get_member_last_active( array( 'relative' => false ) ) ); ?>"><?php bp_member_last_active(); ?></span>
    133                                                                 <?php else : ?>
    134                                                                         <span class="activity"><?php bp_member_total_friend_count(); ?></span>
    135                                                                 <?php endif; ?>
    136                                                         </div>
    137                                                 </div>
    138                                         </li>
    139 
    140                                 <?php endwhile; ?>
    141                         </ul>
    142                         <?php wp_nonce_field( 'bp_core_widget_friends', '_wpnonce-friends' ); ?>
    143                         <input type="hidden" name="friends_widget_max" id="friends_widget_max" value="<?php echo absint( $instance['max_friends'] ); ?>" />
    144 
    145                 <?php else: ?>
    146 
    147                         <div class="widget-error">
    148                                 <?php _e( 'Sorry, no members were found.', 'buddypress' ); ?>
    149                         </div>
    150 
    151                 <?php endif; ?>
    152 
    153                 <?php echo $after_widget;
    154 
    155                 // Restore the global.
    156                 $members_template = $old_members_template;
     57                _deprecated_function( __METHOD__, '12.0.0' );
    15758        }
    15859
     
    16162         *
    16263         * @since 1.9.0
     64         * @deprecated 12.0.0
    16365         *
    16466         * @param array $new_instance The parameters saved by the user.
     
    16769         */
    16870        public function update( $new_instance, $old_instance ) {
    169                 $instance = $old_instance;
    170 
    171                 $instance['max_friends']    = absint( $new_instance['max_friends'] );
    172                 $instance['friend_default'] = sanitize_text_field( $new_instance['friend_default'] );
    173                 $instance['link_title']     = ! empty( $new_instance['link_title'] );
    174 
    175                 return $instance;
     71                _deprecated_function( __METHOD__, '12.0.0' );
    17672        }
    17773
     
    18076         *
    18177         * @since 1.9.0
     78         * @deprecated 12.0.0
    18279         *
    18380         * @param array $instance The saved widget settings.
    18481         */
    18582        public function form( $instance ) {
    186                 $defaults = array(
    187                         'max_friends'    => 5,
    188                         'friend_default' => 'active',
    189                         'link_title'     => false,
    190                 );
    191 
    192                 $instance = bp_parse_args(
    193                         (array) $instance,
    194                         $defaults
    195                 );
    196 
    197                 $max_friends    = $instance['max_friends'];
    198                 $friend_default = $instance['friend_default'];
    199                 $link_title     = (bool) $instance['link_title'];
    200                 ?>
    201 
    202                 <p><label for="<?php echo $this->get_field_id( 'link_title' ); ?>"><input type="checkbox" name="<?php echo $this->get_field_name('link_title'); ?>" id="<?php echo $this->get_field_id( 'link_title' ); ?>" value="1" <?php checked( $link_title ); ?> /> <?php _e( 'Link widget title to Members directory', 'buddypress' ); ?></label></p>
    203 
    204                 <p><label for="<?php echo $this->get_field_id( 'max_friends' ); ?>"><?php esc_html_e( 'Max friends to show:', 'buddypress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_friends' ); ?>" name="<?php echo $this->get_field_name( 'max_friends' ); ?>" type="text" value="<?php echo absint( $max_friends ); ?>" style="width: 30%" /></label></p>
    205 
    206                 <p>
    207                         <label for="<?php echo $this->get_field_id( 'friend_default' ) ?>"><?php esc_html_e( 'Default friends to show:', 'buddypress' ); ?></label>
    208                         <select name="<?php echo $this->get_field_name( 'friend_default' ); ?>" id="<?php echo $this->get_field_id( 'friend_default' ); ?>">
    209                                 <option value="newest" <?php selected( $friend_default, 'newest' ); ?>><?php esc_html_e( 'Newest', 'buddypress' ); ?></option>
    210                                 <option value="active" <?php selected( $friend_default, 'active' ); ?>><?php esc_html_e( 'Active', 'buddypress' ); ?></option>
    211                                 <option value="popular"  <?php selected( $friend_default, 'popular' ); ?>><?php esc_html_e( 'Popular', 'buddypress' ); ?></option>
    212                         </select>
    213                 </p>
    214         <?php
     83                _deprecated_function( __METHOD__, '12.0.0' );
    21584        }
    21685}
  • trunk/src/bp-friends/classes/class-bp-friends-component.php

    r13464 r13481  
    5353                        'template',
    5454                        'functions',
    55                         'widgets',
    5655                        'blocks',
    5756                );
  • trunk/src/bp-friends/js/widget-friends.js

    r10793 r13481  
    1 jQuery(document).ready( function() {
    2         friend_widget_click_handler();
    3 
    4         // WP 4.5 - Customizer selective refresh support.
    5         if ( 'undefined' !== typeof wp && wp.customize && wp.customize.selectiveRefresh ) {
    6                 wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function() {
    7                         friend_widget_click_handler();
    8                 } );
    9         }
    10 });
    11 
    12 function friend_widget_click_handler() {
    13         jQuery('.widget div#friends-list-options a').on('click',
    14                 function() {
    15                         var link = this;
    16                         jQuery(link).addClass('loading');
    17 
    18                         jQuery('.widget div#friends-list-options a').removeClass('selected');
    19                         jQuery(this).addClass('selected');
    20 
    21                         jQuery.post( ajaxurl, {
    22                                 action: 'widget_friends',
    23                                 'cookie': encodeURIComponent(document.cookie),
    24                                 '_wpnonce': jQuery('input#_wpnonce-friends').val(),
    25                                 'max-friends': jQuery('input#friends_widget_max').val(),
    26                                 'filter': jQuery(this).attr('id')
    27                         },
    28                         function(response)
    29                         {
    30                                 jQuery(link).removeClass('loading');
    31                                 friend_widget_response(response);
    32                         });
    33 
    34                         return false;
    35                 }
    36         );
    37 }
    38 
    39 function friend_widget_response(response) {
    40         response = response.substr(0, response.length-1);
    41         response = response.split('[[SPLIT]]');
    42 
    43         if ( response[0] !== '-1' ) {
    44                 jQuery('.widget ul#friends-list').fadeOut(200,
    45                         function() {
    46                                 jQuery('.widget ul#friends-list').html(response[1]);
    47                                 jQuery('.widget ul#friends-list').fadeIn(200);
    48                         }
    49                 );
    50 
    51         } else {
    52                 jQuery('.widget ul#friends-list').fadeOut(200,
    53                         function() {
    54                                 var message = '<p>' + response[1] + '</p>';
    55                                 jQuery('.widget ul#friends-list').html(message);
    56                                 jQuery('.widget ul#friends-list').fadeIn(200);
    57                         }
    58                 );
    59         }
    60 }
     1window.console.log( '`widget-friends.js` is deprecated since 12.0.0, please use the BP Classic plugin to use BP Legacy Widgets.' );
  • trunk/src/bp-groups/bp-groups-widgets.php

    r13437 r13481  
    66 * @subpackage GroupsWidgets
    77 * @since 1.0.0
     8 * @deprecated 12.0.0
    89 */
    910
     
    1112defined( 'ABSPATH' ) || exit;
    1213
    13 /**
    14  * Registers the Groups Legacy Widget.
    15  *
    16  * @since 10.0.0
    17  */
    18 function bp_groups_register_groups_widget() {
    19         register_widget( 'BP_Groups_Widget' );
    20 }
    21 
    22 /**
    23  * Register widgets for groups component.
    24  *
    25  * @since 1.0.0
    26  */
    27 function groups_register_widgets() {
    28         add_action( 'widgets_init', 'bp_groups_register_groups_widget' );
    29 }
    30 add_action( 'bp_register_widgets', 'groups_register_widgets' );
    31 
    32 /**
    33  * AJAX callback for the Groups List widget.
    34  *
    35  * @since 1.0.0
    36  */
    37 function groups_ajax_widget_groups_list() {
    38 
    39         check_ajax_referer( 'groups_widget_groups_list' );
    40 
    41         switch ( $_POST['filter'] ) {
    42                 case 'newest-groups':
    43                         $type = 'newest';
    44                 break;
    45                 case 'recently-active-groups':
    46                         $type = 'active';
    47                 break;
    48                 case 'popular-groups':
    49                         $type = 'popular';
    50                 break;
    51                 case 'alphabetical-groups':
    52                         $type = 'alphabetical';
    53                 break;
    54         }
    55 
    56         $per_page = isset( $_POST['max_groups'] ) ? intval( $_POST['max_groups'] ) : 5;
    57 
    58         $groups_args = array(
    59                 'user_id'  => 0,
    60                 'type'     => $type,
    61                 'per_page' => $per_page,
    62                 'max'      => $per_page,
    63         );
    64 
    65         if ( bp_has_groups( $groups_args ) ) : ?>
    66                 <?php echo "0[[SPLIT]]"; ?>
    67                 <?php while ( bp_groups() ) : bp_the_group(); ?>
    68                         <li <?php bp_group_class(); ?>>
    69                                 <div class="item-avatar">
    70                                         <a href="<?php bp_group_url() ?>"><?php bp_group_avatar_thumb() ?></a>
    71                                 </div>
    72 
    73                                 <div class="item">
    74                                         <div class="item-title"><?php bp_group_link(); ?></div>
    75                                         <div class="item-meta">
    76                                                 <?php if ( 'newest-groups' === $_POST['filter'] ) : ?>
    77                                                         <span class="activity" data-livestamp="<?php bp_core_iso8601_date( bp_get_group_date_created( 0, array( 'relative' => false ) ) ); ?>">
    78                                                                 <?php
    79                                                                 /* translators: %s: date */
    80                                                                 printf( __( 'created %s', 'buddypress' ), bp_get_group_date_created() );
    81                                                                 ?>
    82                                                         </span>
    83                                                 <?php elseif ( 'popular-groups' === $_POST['filter'] ) : ?>
    84                                                         <span class="activity"><?php bp_group_member_count(); ?></span>
    85                                                 <?php else : ?>
    86                                                         <span class="activity" data-livestamp="<?php bp_core_iso8601_date( bp_get_group_last_active( 0, array( 'relative' => false ) ) ); ?>">
    87                                                                 <?php
    88                                                                 /* translators: %s: last activity timestamp (e.g. "Active 1 hour ago") */
    89                                                                 printf( _x( 'Active %s', 'last time the group was active', 'buddypress' ), bp_get_group_last_active() );
    90                                                                 ?>
    91                                                         </span>
    92                                                 <?php endif; ?>
    93                                         </div>
    94                                 </div>
    95                         </li>
    96                 <?php endwhile; ?>
    97 
    98                 <?php wp_nonce_field( 'groups_widget_groups_list', '_wpnonce-groups' ); ?>
    99                 <input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php echo esc_attr( $_POST['max_groups'] ); ?>" />
    100 
    101         <?php else: ?>
    102 
    103                 <?php echo "-1[[SPLIT]]<li>" . __( "No groups matched the current filter.", 'buddypress' ); ?>
    104 
    105         <?php endif;
    106 
    107 }
    108 add_action( 'wp_ajax_widget_groups_list',        'groups_ajax_widget_groups_list' );
    109 add_action( 'wp_ajax_nopriv_widget_groups_list', 'groups_ajax_widget_groups_list' );
     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' ) );
  • trunk/src/bp-groups/classes/class-bp-groups-component.php

    r13471 r13481  
    141141                        'cache',
    142142                        'filters',
    143                         'widgets',
    144143                        'template',
    145144                        'adminbar',
  • trunk/src/bp-groups/classes/class-bp-groups-widget.php

    r13437 r13481  
    66 * @subpackage GroupsWidgets
    77 * @since 1.0.0
     8 * @deprecated 12.0.0
    89 */
    910
     
    1112defined( 'ABSPATH' ) || exit;
    1213
     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' ) );
     15
    1316/**
    1417 * Groups widget.
    1518 *
    1619 * @since 1.0.3
     20 * @deprecated 12.0.0
    1721 */
    18 class BP_Groups_Widget extends WP_Widget {
     22class BP_Groups_Widget {
    1923
    2024        /**
     
    2327         * @since 1.0.3
    2428         * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options.
     29         * @deprecated 12.0.0
    2530         */
    2631        public function __construct() {
    27                 $widget_ops = array(
    28                         'description'                 => __( 'A dynamic list of recently active, popular, newest, or alphabetical groups', 'buddypress' ),
    29                         'classname'                   => 'widget_bp_groups_widget buddypress widget',
    30                         'customize_selective_refresh' => true,
    31                         'show_instance_in_rest'       => true,
    32                 );
    33                 parent::__construct( false, _x( '(BuddyPress) Groups', 'widget name', 'buddypress' ), $widget_ops );
    34 
    35                 if ( is_customize_preview() || bp_is_widget_block_active( '', $this->id_base ) ) {
    36                         add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
    37                 }
     32                _deprecated_function( __METHOD__, '12.0.0' );
    3833        }
    3934
     
    4237         *
    4338         * @since 2.6.0
     39         * @deprecated 12.0.0
    4440         */
    4541        public function enqueue_scripts() {
    46                 $min = bp_core_get_minified_asset_suffix();
    47                 wp_enqueue_script( 'groups_widget_groups_list-js', buddypress()->plugin_url . "bp-groups/js/widget-groups{$min}.js", array( 'jquery' ), bp_get_version() );
     42                _deprecated_function( __METHOD__, '12.0.0' );
    4843        }
    4944
     
    5247         *
    5348         * @since 1.0.3
     49         * @deprecated 12.0.0
    5450         *
    5551         * @param array $args     Array of arguments for the widget.
     
    5753         */
    5854        public function widget( $args, $instance ) {
    59                 global $groups_template;
    60 
    61                 /**
    62                  * Filters the user ID to use with the widget instance.
    63                  *
    64                  * @since 1.5.0
    65                  *
    66                  * @param string $value Empty user ID.
    67                  */
    68                 $user_id = apply_filters( 'bp_group_widget_user_id', '0' );
    69 
    70                 extract( $args );
    71 
    72                 if ( empty( $instance['group_default'] ) ) {
    73                         $instance['group_default'] = 'popular';
    74                 }
    75 
    76                 if ( empty( $instance['title'] ) ) {
    77                         $instance['title'] = __( 'Groups', 'buddypress' );
    78                 }
    79 
    80                 /**
    81                  * Filters the title of the Groups widget.
    82                  *
    83                  * @since 1.8.0
    84                  * @since 2.3.0 Added 'instance' and 'id_base' to arguments passed to filter.
    85                  *
    86                  * @param string $title    The widget title.
    87                  * @param array  $instance The settings for the particular instance of the widget.
    88                  * @param string $id_base  Root ID for all widgets of this type.
    89                  */
    90                 $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
    91 
    92                 /**
    93                  * Filters the separator of the group widget links.
    94                  *
    95                  * @since 2.4.0
    96                  *
    97                  * @param string $separator Separator string. Default '|'.
    98                  */
    99                 $separator = apply_filters( 'bp_groups_widget_separator', '|' );
    100 
    101                 echo $before_widget;
    102 
    103                 $title = ! empty( $instance['link_title'] ) ? '<a href="' . esc_url( bp_get_groups_directory_url() ) . '">' . $title . '</a>' : $title;
    104 
    105                 echo $before_title . $title . $after_title;
    106 
    107                 $max_limit  = bp_get_widget_max_count_limit( __CLASS__ );
    108                 $max_groups = ! empty( $instance['max_groups'] ) ? (int) $instance['max_groups'] : 5;
    109 
    110                 if ( $max_groups > $max_limit ) {
    111                         $max_groups = $max_limit;
    112                 }
    113 
    114                 $group_args = array(
    115                         'user_id'         => $user_id,
    116                         'type'            => $instance['group_default'],
    117                         'per_page'        => $max_groups,
    118                         'max'             => $max_groups,
    119                 );
    120 
    121                 // Back up the global.
    122                 $old_groups_template = $groups_template;
    123 
    124                 ?>
    125 
    126                 <?php if ( bp_has_groups( $group_args ) ) : ?>
    127                         <div class="item-options" id="groups-list-options">
    128                                 <a href="<?php bp_groups_directory_url(); ?>" id="newest-groups"<?php if ( $instance['group_default'] == 'newest' ) : ?> class="selected"<?php endif; ?>><?php _e("Newest", 'buddypress') ?></a>
    129                                 <span class="bp-separator" role="separator"><?php echo esc_html( $separator ); ?></span>
    130                                 <a href="<?php bp_groups_directory_url(); ?>" id="recently-active-groups"<?php if ( $instance['group_default'] == 'active' ) : ?> class="selected"<?php endif; ?>><?php _e("Active", 'buddypress') ?></a>
    131                                 <span class="bp-separator" role="separator"><?php echo esc_html( $separator ); ?></span>
    132                                 <a href="<?php bp_groups_directory_url(); ?>" id="popular-groups" <?php if ( $instance['group_default'] == 'popular' ) : ?> class="selected"<?php endif; ?>><?php _e("Popular", 'buddypress') ?></a>
    133                                 <span class="bp-separator" role="separator"><?php echo esc_html( $separator ); ?></span>
    134                                 <a href="<?php bp_groups_directory_url(); ?>" id="alphabetical-groups" <?php if ( $instance['group_default'] == 'alphabetical' ) : ?> class="selected"<?php endif; ?>><?php _e("Alphabetical", 'buddypress') ?></a>
    135                         </div>
    136 
    137                         <ul id="groups-list" class="item-list" aria-live="polite" aria-relevant="all" aria-atomic="true">
    138                                 <?php while ( bp_groups() ) : bp_the_group(); ?>
    139                                         <li <?php bp_group_class(); ?>>
    140                                                 <div class="item-avatar">
    141                                                         <a href="<?php bp_group_url() ?>" class="bp-tooltip" data-bp-tooltip="<?php bp_group_name() ?>"><?php bp_group_avatar_thumb() ?></a>
    142                                                 </div>
    143 
    144                                                 <div class="item">
    145                                                         <div class="item-title"><?php bp_group_link(); ?></div>
    146                                                         <div class="item-meta">
    147                                                                 <span class="activity">
    148                                                                 <?php
    149                                                                         if ( 'newest' == $instance['group_default'] ) {
    150                                                                                 printf( __( 'created %s', 'buddypress' ), bp_get_group_date_created() );
    151                                                                         } elseif ( 'popular' == $instance['group_default'] ) {
    152                                                                                 bp_group_member_count();
    153                                                                         } else {
    154                                                                                 /* translators: %s: last activity timestamp (e.g. "Active 1 hour ago") */
    155                                                                                 printf( __( 'Active %s', 'buddypress' ), bp_get_group_last_active() );
    156                                                                         }
    157                                                                 ?>
    158                                                                 </span>
    159                                                         </div>
    160                                                 </div>
    161                                         </li>
    162 
    163                                 <?php endwhile; ?>
    164                         </ul>
    165                         <?php wp_nonce_field( 'groups_widget_groups_list', '_wpnonce-groups' ); ?>
    166                         <input type="hidden" name="groups_widget_max" id="groups_widget_max" value="<?php echo esc_attr( $max_groups ); ?>" />
    167 
    168                 <?php else: ?>
    169 
    170                         <div class="widget-error">
    171                                 <?php _e('There are no groups to display.', 'buddypress') ?>
    172                         </div>
    173 
    174                 <?php endif; ?>
    175 
    176                 <?php echo $after_widget;
    177 
    178                 // Restore the global.
    179                 $groups_template = $old_groups_template;
     55                _deprecated_function( __METHOD__, '12.0.0' );
    18056        }
    18157
     
    18460         *
    18561         * @since 1.0.3
     62         * @deprecated 12.0.0
    18663         *
    18764         * @param array $new_instance New instance data.
     
    19067         */
    19168        public function update( $new_instance, $old_instance ) {
    192                 $instance = $old_instance;
    193 
    194                 $max_limit = bp_get_widget_max_count_limit( __CLASS__ );
    195 
    196                 $instance['title']         = strip_tags( $new_instance['title'] );
    197                 $instance['max_groups']    = $new_instance['max_groups'] > $max_limit ? $max_limit : intval( $new_instance['max_groups'] );
    198                 $instance['group_default'] = strip_tags( $new_instance['group_default'] );
    199                 $instance['link_title']    = ! empty( $new_instance['link_title'] );
    200 
    201                 return $instance;
     69                _deprecated_function( __METHOD__, '12.0.0' );
    20270        }
    20371
     
    20674         *
    20775         * @since 1.0.3
     76         * @deprecated 12.0.0
    20877         *
    20978         * @param array $instance Current instance.
     
    21180         */
    21281        public function form( $instance ) {
    213                 $defaults = array(
    214                         'title'         => __( 'Groups', 'buddypress' ),
    215                         'max_groups'    => 5,
    216                         'group_default' => 'active',
    217                         'link_title'    => false,
    218                 );
    219 
    220                 $instance = bp_parse_args(
    221                         (array) $instance,
    222                         $defaults,
    223                         'groups_widget_form'
    224                 );
    225 
    226                 $max_limit = bp_get_widget_max_count_limit( __CLASS__ );
    227 
    228                 $title         = strip_tags( $instance['title'] );
    229                 $max_groups    = $instance['max_groups'] > $max_limit ? $max_limit : intval( $instance['max_groups'] );
    230                 $group_default = strip_tags( $instance['group_default'] );
    231                 $link_title    = (bool) $instance['link_title'];
    232                 ?>
    233 
    234                 <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'buddypress'); ?> <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%" /></label></p>
    235 
    236                 <p><label for="<?php echo $this->get_field_id('link_title') ?>"><input type="checkbox" name="<?php echo $this->get_field_name('link_title') ?>" id="<?php echo $this->get_field_id('link_title') ?>" value="1" <?php checked( $link_title ) ?> /> <?php _e( 'Link widget title to Groups directory', 'buddypress' ) ?></label></p>
    237 
    238                 <p><label for="<?php echo $this->get_field_id( 'max_groups' ); ?>"><?php _e( 'Max groups to show:', 'buddypress' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_groups' ); ?>" name="<?php echo $this->get_field_name( 'max_groups' ); ?>" type="number" min="1" max="<?php echo esc_attr( $max_limit ); ?>" value="<?php echo esc_attr( $max_groups ); ?>" style="width: 30%" /></label></p>
    239 
    240                 <p>
    241                         <label for="<?php echo $this->get_field_id( 'group_default' ); ?>"><?php _e('Default groups to show:', 'buddypress'); ?></label>
    242                         <select name="<?php echo $this->get_field_name( 'group_default' ); ?>" id="<?php echo $this->get_field_id( 'group_default' ); ?>">
    243                                 <option value="newest" <?php selected( $group_default, 'newest' ); ?>><?php _e( 'Newest', 'buddypress' ) ?></option>
    244                                 <option value="active" <?php selected( $group_default, 'active' ); ?>><?php _e( 'Active', 'buddypress' ) ?></option>
    245                                 <option value="popular"  <?php selected( $group_default, 'popular' ); ?>><?php _e( 'Popular', 'buddypress' ) ?></option>
    246                                 <option value="alphabetical" <?php selected( $group_default, 'alphabetical' ); ?>><?php _e( 'Alphabetical', 'buddypress' ) ?></option>
    247                         </select>
    248                 </p>
    249         <?php
     82                _deprecated_function( __METHOD__, '12.0.0' );
    25083        }
    25184}
  • trunk/src/bp-groups/js/widget-groups.js

    r10793 r13481  
    1 jQuery(document).ready( function() {
    2         groups_widget_click_handler();
    3 
    4         // WP 4.5 - Customizer selective refresh support.
    5         if ( 'undefined' !== typeof wp && wp.customize && wp.customize.selectiveRefresh ) {
    6                 wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function() {
    7                         groups_widget_click_handler();
    8                 } );
    9         }
    10 });
    11 
    12 function groups_widget_click_handler() {
    13         jQuery('.widget div#groups-list-options a').on('click',
    14                 function() {
    15                         var link = this;
    16                         jQuery(link).addClass('loading');
    17 
    18                         jQuery('.widget div#groups-list-options a').removeClass('selected');
    19                         jQuery(this).addClass('selected');
    20 
    21                         jQuery.post( ajaxurl, {
    22                                 action: 'widget_groups_list',
    23                                 'cookie': encodeURIComponent(document.cookie),
    24                                 '_wpnonce': jQuery('input#_wpnonce-groups').val(),
    25                                 'max_groups': jQuery('input#groups_widget_max').val(),
    26                                 'filter': jQuery(this).attr('id')
    27                         },
    28                         function(response)
    29                         {
    30                                 jQuery(link).removeClass('loading');
    31                                 groups_widget_response(response);
    32                         });
    33 
    34                         return false;
    35                 }
    36         );
    37 }
    38 
    39 function groups_widget_response(response) {
    40         response = response.substr(0, response.length-1);
    41         response = response.split('[[SPLIT]]');
    42 
    43         if ( response[0] !== '-1' ) {
    44                 jQuery('.widget ul#groups-list').fadeOut(200,
    45                         function() {
    46                                 jQuery('.widget ul#groups-list').html(response[1]);
    47                                 jQuery('.widget ul#groups-list').fadeIn(200);
    48                         }
    49                 );
    50 
    51         } else {
    52                 jQuery('.widget ul#groups-list').fadeOut(200,
    53                         function() {
    54                                 var message = '<p>' + response[1] + '</p>';
    55                                 jQuery('.widget ul#groups-list').html(message);
    56                                 jQuery('.widget ul#groups-list').fadeIn(200);
    57                         }
    58                 );
    59         }
    60 }
     1window.console.log( '`widget-groups.js` is deprecated since 12.0.0, please use the BP Classic plugin to use BP Legacy Widgets.' );
  • trunk/src/bp-members/bp-members-widgets.php

    r13153 r13481  
    66 * @subpackage MembersWidgets
    77 * @since 2.2.0
     8 * @deprecated 12.0.0
    89 */
    910
     
    1112defined( 'ABSPATH' ) || exit;
    1213
    13 /**
    14  * Registers the Members Legacy Widget.
    15  *
    16  * @since 10.0.0
    17  */
    18 function bp_members_register_members_widget() {
    19         register_widget( 'BP_Core_Members_Widget' );
    20 }
    21 
    22 /**
    23  * Registers the "Who's online?" Legacy Widget.
    24  *
    25  * @since 10.0.0
    26  */
    27 function bp_members_register_whos_online_widget() {
    28         register_widget( 'BP_Core_Whos_Online_Widget' );
    29 }
    30 
    31 /**
    32  * Registers the "Recently Active" Legacy Widget.
    33  *
    34  * @since 10.0.0
    35  */
    36 function bp_members_register_recently_active_widget() {
    37         register_widget( 'BP_Core_Recently_Active_Widget' );
    38 }
    39 
    40 /**
    41  * Register bp-members widgets.
    42  *
    43  * Previously, these widgets were registered in bp-core.
    44  *
    45  * @since 2.2.0
    46  */
    47 function bp_members_register_widgets() {
    48         add_action( 'widgets_init', 'bp_members_register_members_widget' );
    49         add_action( 'widgets_init', 'bp_members_register_whos_online_widget' );
    50         add_action( 'widgets_init', 'bp_members_register_recently_active_widget' );
    51 }
    52 add_action( 'bp_register_widgets', 'bp_members_register_widgets' );
    53 
    54 /**
    55  * AJAX request handler for Members widgets.
    56  *
    57  * @since 1.0.0
    58  *
    59  * @see BP_Core_Members_Widget
    60  */
    61 function bp_core_ajax_widget_members() {
    62 
    63         check_ajax_referer( 'bp_core_widget_members' );
    64 
    65         // Setup some variables to check.
    66         $filter      = ! empty( $_POST['filter']      ) ? $_POST['filter']                : 'recently-active-members';
    67         $max_members = ! empty( $_POST['max-members'] ) ? absint( $_POST['max-members'] ) : 5;
    68 
    69         // Determine the type of members query to perform.
    70         switch ( $filter ) {
    71 
    72                 // Newest activated.
    73                 case 'newest-members' :
    74                         $type = 'newest';
    75                         break;
    76 
    77                 // Popular by friends.
    78                 case 'popular-members' :
    79                         if ( bp_is_active( 'friends' ) ) {
    80                                 $type = 'popular';
    81                         } else {
    82                                 $type = 'active';
    83                         }
    84                         break;
    85 
    86                 // Default.
    87                 case 'recently-active-members' :
    88                 default :
    89                         $type = 'active';
    90                         break;
    91         }
    92 
    93         // Setup args for querying members.
    94         $members_args = array(
    95                 'user_id'         => 0,
    96                 'type'            => $type,
    97                 'per_page'        => $max_members,
    98                 'max'             => $max_members,
    99                 'populate_extras' => true,
    100                 'search_terms'    => false,
    101         );
    102 
    103         // Query for members.
    104         if ( bp_has_members( $members_args ) ) : ?>
    105                 <?php echo '0[[SPLIT]]'; // Return valid result. TODO: remove this. ?>
    106                 <?php while ( bp_members() ) : bp_the_member(); ?>
    107                         <li class="vcard">
    108                                 <div class="item-avatar">
    109                                         <a href="<?php bp_member_permalink(); ?>"><?php bp_member_avatar(); ?></a>
    110                                 </div>
    111 
    112                                 <div class="item">
    113                                         <div class="item-title fn"><a href="<?php bp_member_permalink(); ?>"><?php bp_member_name(); ?></a></div>
    114                                         <?php if ( 'active' === $type ) : ?>
    115                                                 <div class="item-meta"><span class="activity"><?php bp_member_last_active(); ?></span></div>
    116                                         <?php elseif ( 'newest' === $type ) : ?>
    117                                                 <div class="item-meta"><span class="activity"><?php bp_member_registered(); ?></span></div>
    118                                         <?php elseif ( bp_is_active( 'friends' ) ) : ?>
    119                                                 <div class="item-meta"><span class="activity"><?php bp_member_total_friend_count(); ?></span></div>
    120                                         <?php endif; ?>
    121                                 </div>
    122                         </li>
    123 
    124                 <?php endwhile; ?>
    125 
    126         <?php else: ?>
    127                 <?php echo "-1[[SPLIT]]<li>"; ?>
    128                 <?php esc_html_e( 'There were no members found, please try another filter.', 'buddypress' ) ?>
    129                 <?php echo "</li>"; ?>
    130         <?php endif;
    131 }
    132 add_action( 'wp_ajax_widget_members', 'bp_core_ajax_widget_members' );
    133 add_action( 'wp_ajax_nopriv_widget_members', 'bp_core_ajax_widget_members' );
     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' ) );
  • trunk/src/bp-members/classes/class-bp-core-members-widget.php

    r13108 r13481  
    66 * @subpackage MembersWidgets
    77 * @since 1.0.3
     8 * @deprecated 12.0.0
    89 */
    910
     
    1112defined( 'ABSPATH' ) || exit;
    1213
     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' ) );
     15
    1316/**
    1417 * Members Widget.
    1518 *
    1619 * @since 1.0.3
     20 * @deprecated 12.0.0
    1721 */
    18 class BP_Core_Members_Widget extends WP_Widget {
     22class BP_Core_Members_Widget {
    1923
    2024        /**
     
    2327         * @since 1.5.0
    2428         * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options.
     29         * @deprecated 12.0.0
    2530         */
    2631        public function __construct() {
    27 
    28                 // Setup widget name & description.
    29                 $name        = _x( '(BuddyPress) Members', 'widget name', 'buddypress' );
    30                 $description = __( 'A dynamic list of recently active, popular, and newest members', 'buddypress' );
    31 
    32                 // Call WP_Widget constructor.
    33                 parent::__construct( false, $name, array(
    34                         'description'                 => $description,
    35                         'classname'                   => 'widget_bp_core_members_widget buddypress widget',
    36                         'customize_selective_refresh' => true,
    37                         'show_instance_in_rest'       => true,
    38                 ) );
    39 
    40                 if ( is_customize_preview() || bp_is_widget_block_active( '', $this->id_base ) ) {
    41                         add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
    42                 }
     32                _deprecated_function( __METHOD__, '12.0.0' );
    4333        }
    4434
     
    4737         *
    4838         * @since 2.6.0
     39         * @deprecated 12.0.0
    4940         */
    5041        public function enqueue_scripts() {
    51                 wp_enqueue_script( 'bp-widget-members' );
     42                _deprecated_function( __METHOD__, '12.0.0' );
    5243        }
    5344
     
    5647         *
    5748         * @since 1.0.3
     49         * @deprecated 12.0.0
    5850         *
    5951         * @see WP_Widget::widget() for description of parameters.
     
    6355         */
    6456        public function widget( $args, $instance ) {
    65                 global $members_template;
    66 
    67                 // Get widget settings.
    68                 $settings = $this->parse_settings( $instance );
    69 
    70                 /**
    71                  * Filters the title of the Members widget.
    72                  *
    73                  * @since 1.8.0
    74                  * @since 2.3.0 Added 'instance' and 'id_base' to arguments passed to filter.
    75                  *
    76                  * @param string $title    The widget title.
    77                  * @param array  $settings The settings for the particular instance of the widget.
    78                  * @param string $id_base  Root ID for all widgets of this type.
    79                  */
    80                 $title = apply_filters( 'widget_title', $settings['title'], $settings, $this->id_base );
    81                 $title = $settings['link_title'] ? '<a href="' . bp_get_members_directory_permalink() . '">' . $title . '</a>' : $title;
    82 
    83                 /**
    84                  * Filters the separator of the member widget links.
    85                  *
    86                  * @since 2.4.0
    87                  *
    88                  * @param string $separator Separator string. Default '|'.
    89                  */
    90                 $separator = apply_filters( 'bp_members_widget_separator', '|' );
    91 
    92                 // Output before widget HTMl, title (and maybe content before & after it).
    93                 echo $args['before_widget'] . $args['before_title'] . $title . $args['after_title'];
    94 
    95                 $max_limit   = bp_get_widget_max_count_limit( __CLASS__ );
    96                 $max_members = $settings['max_members'] > $max_limit ? $max_limit : (int) $settings['max_members'];
    97 
    98                 // Setup args for querying members.
    99                 $members_args = array(
    100                         'user_id'         => 0,
    101                         'type'            => $settings['member_default'],
    102                         'per_page'        => $max_members,
    103                         'max'             => $max_members,
    104                         'populate_extras' => true,
    105                         'search_terms'    => false,
    106                 );
    107 
    108                 // Back up the global.
    109                 $old_members_template = $members_template;
    110 
    111                 ?>
    112 
    113                 <?php if ( bp_has_members( $members_args ) ) : ?>
    114 
    115                         <div class="item-options" id="members-list-options">
    116                                 <a href="<?php bp_members_directory_permalink(); ?>" id="newest-members" <?php if ( 'newest' === $settings['member_default'] ) : ?>class="selected"<?php endif; ?>><?php esc_html_e( 'Newest', 'buddypress' ); ?></a>
    117                                 <span class="bp-separator" role="separator"><?php echo esc_html( $separator ); ?></span>
    118                                 <a href="<?php bp_members_directory_permalink(); ?>" id="recently-active-members" <?php if ( 'active' === $settings['member_default'] ) : ?>class="selected"<?php endif; ?>><?php esc_html_e( 'Active', 'buddypress' ); ?></a>
    119 
    120                                 <?php if ( bp_is_active( 'friends' ) ) : ?>
    121                                         <span class="bp-separator" role="separator"><?php echo esc_html( $separator ); ?></span>
    122                                         <a href="<?php bp_members_directory_permalink(); ?>" id="popular-members" <?php if ( 'popular' === $settings['member_default'] ) : ?>class="selected"<?php endif; ?>><?php esc_html_e( 'Popular', 'buddypress' ); ?></a>
    123 
    124                                 <?php endif; ?>
    125 
    126                         </div>
    127 
    128                         <ul id="members-list" class="item-list" aria-live="polite" aria-relevant="all" aria-atomic="true">
    129 
    130                                 <?php while ( bp_members() ) : bp_the_member(); ?>
    131 
    132                                         <li class="vcard">
    133                                                 <div class="item-avatar">
    134                                                         <a href="<?php bp_member_permalink() ?>" class="bp-tooltip" data-bp-tooltip="<?php bp_member_name(); ?>"><?php bp_member_avatar(); ?></a>
    135                                                 </div>
    136 
    137                                                 <div class="item">
    138                                                         <div class="item-title fn"><a href="<?php bp_member_permalink(); ?>"><?php bp_member_name(); ?></a></div>
    139                                                         <div class="item-meta">
    140                                                                 <?php if ( 'newest' == $settings['member_default'] ) : ?>
    141                                                                         <span class="activity" data-livestamp="<?php bp_core_iso8601_date( bp_get_member_registered( array( 'relative' => false ) ) ); ?>"><?php bp_member_registered(); ?></span>
    142                                                                 <?php elseif ( 'active' == $settings['member_default'] ) : ?>
    143                                                                         <span class="activity" data-livestamp="<?php bp_core_iso8601_date( bp_get_member_last_active( array( 'relative' => false ) ) ); ?>"><?php bp_member_last_active(); ?></span>
    144                                                                 <?php else : ?>
    145                                                                         <span class="activity"><?php bp_member_total_friend_count(); ?></span>
    146                                                                 <?php endif; ?>
    147                                                         </div>
    148                                                 </div>
    149                                         </li>
    150 
    151                                 <?php endwhile; ?>
    152 
    153                         </ul>
    154 
    155                         <?php wp_nonce_field( 'bp_core_widget_members', '_wpnonce-members', false ); ?>
    156 
    157                         <input type="hidden" name="members_widget_max" id="members_widget_max" value="<?php echo esc_attr( $settings['max_members'] ); ?>" />
    158 
    159                 <?php else: ?>
    160 
    161                         <div class="widget-error">
    162                                 <?php esc_html_e( 'No one has signed up yet!', 'buddypress' ); ?>
    163                         </div>
    164 
    165                 <?php endif; ?>
    166 
    167                 <?php echo $args['after_widget'];
    168 
    169                 // Restore the global.
    170                 $members_template = $old_members_template;
     57                _deprecated_function( __METHOD__, '12.0.0' );
    17158        }
    17259
     
    17562         *
    17663         * @since 1.0.3
     64         * @deprecated 12.0.0
    17765         *
    17866         * @param array $new_instance The new instance options.
     
    18169         */
    18270        public function update( $new_instance, $old_instance ) {
    183                 $instance = $old_instance;
    184 
    185                 $max_limit = bp_get_widget_max_count_limit( __CLASS__ );
    186 
    187                 $instance['title']          = strip_tags( $new_instance['title'] );
    188                 $instance['max_members']    = $new_instance['max_members'] > $max_limit ? $max_limit : intval( $new_instance['max_members'] );
    189                 $instance['member_default'] = strip_tags( $new_instance['member_default'] );
    190                 $instance['link_title']     = ! empty( $new_instance['link_title'] );
    191 
    192                 return $instance;
     71                _deprecated_function( __METHOD__, '12.0.0' );
    19372        }
    19473
     
    19776         *
    19877         * @since 1.0.3
     78         * @deprecated 12.0.0
    19979         *
    20080         * @param array $instance Widget instance settings.
     
    20282         */
    20383        public function form( $instance ) {
    204                 $max_limit = bp_get_widget_max_count_limit( __CLASS__ );
    205 
    206                 // Get widget settings.
    207                 $settings       = $this->parse_settings( $instance );
    208                 $title          = strip_tags( $settings['title'] );
    209                 $max_members    = $settings['max_members'] > $max_limit ? $max_limit : intval( $settings['max_members'] );
    210                 $member_default = strip_tags( $settings['member_default'] );
    211                 $link_title     = (bool) $settings['link_title']; ?>
    212 
    213                 <p>
    214                         <label for="<?php echo $this->get_field_id( 'title' ); ?>">
    215                                 <?php esc_html_e( 'Title:', 'buddypress' ); ?>
    216                                 <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%" />
    217                         </label>
    218                 </p>
    219 
    220                 <p>
    221                         <label for="<?php echo $this->get_field_id( 'link_title' ) ?>">
    222                                 <input type="checkbox" name="<?php echo $this->get_field_name( 'link_title' ) ?>" id="<?php echo $this->get_field_id( 'link_title' ) ?>" value="1" <?php checked( $link_title ) ?> />
    223                                 <?php esc_html_e( 'Link widget title to Members directory', 'buddypress' ); ?>
    224                         </label>
    225                 </p>
    226 
    227                 <p>
    228                         <label for="<?php echo $this->get_field_id( 'max_members' ); ?>">
    229                                 <?php esc_html_e( 'Max members to show:', 'buddypress' ); ?>
    230                                 <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%" />
    231                         </label>
    232                 </p>
    233 
    234                 <p>
    235                         <label for="<?php echo $this->get_field_id( 'member_default' ) ?>"><?php esc_html_e( 'Default members to show:', 'buddypress' ); ?></label>
    236                         <select name="<?php echo $this->get_field_name( 'member_default' ) ?>" id="<?php echo $this->get_field_id( 'member_default' ) ?>">
    237                                 <option value="newest"  <?php if ( 'newest'  === $member_default ) : ?>selected="selected"<?php endif; ?>><?php esc_html_e( 'Newest',  'buddypress' ); ?></option>
    238                                 <option value="active"  <?php if ( 'active'  === $member_default ) : ?>selected="selected"<?php endif; ?>><?php esc_html_e( 'Active',  'buddypress' ); ?></option>
    239                                 <option value="popular" <?php if ( 'popular' === $member_default ) : ?>selected="selected"<?php endif; ?>><?php esc_html_e( 'Popular', 'buddypress' ); ?></option>
    240                         </select>
    241                 </p>
    242 
    243         <?php
     84                _deprecated_function( __METHOD__, '12.0.0' );
    24485        }
    24586
     
    24889         *
    24990         * @since 2.3.0
     91         * @deprecated 12.0.0
    25092         *
    25193         * @param array $instance Widget instance settings.
     
    25395         */
    25496        public function parse_settings( $instance = array() ) {
    255                 return bp_parse_args(
    256                         $instance,
    257                         array(
    258                                 'title'              => __( 'Members', 'buddypress' ),
    259                                 'max_members'    => 5,
    260                                 'member_default' => 'active',
    261                                 'link_title'     => false,
    262                         ),
    263                         'members_widget_settings'
    264                 );
     97                _deprecated_function( __METHOD__, '12.0.0' );
    26598        }
    26699}
  • trunk/src/bp-members/classes/class-bp-core-recently-active-widget.php

    r13108 r13481  
    66 * @subpackage MembersWidgets
    77 * @since 1.0.3
     8 * @deprecated 12.0.0
    89 */
    910
     
    1112defined( 'ABSPATH' ) || exit;
    1213
     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' ) );
     15
    1316/**
    1417 * Recently Active Members Widget.
    1518 *
    1619 * @since 1.0.3
     20 * @deprecated 12.0.0
    1721 */
    1822class BP_Core_Recently_Active_Widget extends WP_Widget {
     
    2327         * @since 1.5.0
    2428         * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options.
     29         * @deprecated 12.0.0
    2530         */
    2631        public function __construct() {
    27                 $name        = _x( '(BuddyPress) Recently Active Members', 'widget name', 'buddypress' );
    28                 $description = __( 'Profile photos of recently active members', 'buddypress' );
    29                 parent::__construct( false, $name, array(
    30                         'description'                 => $description,
    31                         'classname'                   => 'widget_bp_core_recently_active_widget buddypress widget',
    32                         'customize_selective_refresh' => true,
    33                         'show_instance_in_rest'       => true,
    34                 ) );
     32                _deprecated_function( __METHOD__, '12.0.0' );
    3533        }
    3634
     
    3937         *
    4038         * @since 1.0.3
     39         * @deprecated 12.0.0
    4140         *
    4241         * @see WP_Widget::widget() for description of parameters.
     
    4645         */
    4746        public function widget( $args, $instance ) {
    48                 global $members_template;
    49 
    50                 // Get widget settings.
    51                 $settings = $this->parse_settings( $instance );
    52 
    53                 /**
    54                  * Filters the title of the Recently Active widget.
    55                  *
    56                  * @since 1.8.0
    57                  * @since 2.3.0 Added 'instance' and 'id_base' to arguments passed to filter.
    58                  *
    59                  * @param string $title    The widget title.
    60                  * @param array  $settings The settings for the particular instance of the widget.
    61                  * @param string $id_base  Root ID for all widgets of this type.
    62                  */
    63                 $title = apply_filters( 'widget_title', $settings['title'], $settings, $this->id_base );
    64 
    65                 echo $args['before_widget'];
    66                 echo $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'            => 'active',
    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 recently active members', '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;
     47                _deprecated_function( __METHOD__, '12.0.0' );
    11248        }
    11349
     
    11652         *
    11753         * @since 1.0.3
     54         * @deprecated 12.0.0
    11855         *
    11956         * @param array $new_instance The new instance options.
     
    12259         */
    12360        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;
     61                _deprecated_function( __METHOD__, '12.0.0' );
    13262        }
    13363
     
    13666         *
    13767         * @since 1.0.3
     68         * @deprecated 12.0.0
    13869         *
    13970         * @param array $instance Widget instance settings.
     
    14172         */
    14273        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
     74                _deprecated_function( __METHOD__, '12.0.0' );
    16675        }
    16776
     
    17079         *
    17180         * @since 2.3.0
     81         * @deprecated 12.0.0
    17282         *
    17383         * @param array $instance Widget instance settings.
     
    17585         */
    17686        public function parse_settings( $instance = array() ) {
    177                 return bp_parse_args(
    178                         $instance,
    179                         array(
    180                                 'title'           => __( 'Recently Active Members', 'buddypress' ),
    181                                 'max_members' => 15,
    182                         ),
    183                         'recently_active_members_widget_settings'
    184                 );
     87                _deprecated_function( __METHOD__, '12.0.0' );
    18588        }
    18689}
  • 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}
  • trunk/src/bp-members/classes/class-bp-members-component.php

    r13471 r13481  
    105105                        'functions',
    106106                        'blocks',
    107                         'widgets',
    108107                        'cache',
    109108                        'invitations',
  • trunk/src/bp-messages/bp-messages-widgets.php

    r13153 r13481  
    66 * @subpackage MessagesWidgets
    77 * @since 1.9.0
     8 * @deprecated 12.0.0
    89 */
    910
     
    1112defined( 'ABSPATH' ) || exit;
    1213
    13 /**
    14  * Registers the Sitewide Notices Legacy Widget.
    15  *
    16  * @since 10.0.0
    17  */
    18 function bp_messages_register_sitewide_notices_widget() {
    19         register_widget( 'BP_Messages_Sitewide_Notices_Widget' );
    20 }
    21 
    22 /**
    23  * Register widgets for the Messages component.
    24  *
    25  * @since 1.9.0
    26  */
    27 function bp_messages_register_widgets() {
    28         add_action( 'widgets_init', 'bp_messages_register_sitewide_notices_widget' );
    29 }
    30 add_action( 'bp_register_widgets', 'bp_messages_register_widgets' );
     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' ) );
  • trunk/src/bp-messages/classes/class-bp-messages-component.php

    r13464 r13481  
    6363                        'template',
    6464                        'functions',
    65                         'widgets',
    6665                        'blocks',
    6766                );
  • trunk/src/bp-messages/classes/class-bp-messages-sitewide-notices-widget.php

    r13108 r13481  
    66 * @subpackage MessagesClasses
    77 * @since 1.9.0
     8 * @deprecated 12.0.0
    89 */
    910
     
    1112defined( 'ABSPATH' ) || exit;
    1213
     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' ) );
     15
    1316/**
    1417 * A widget that displays sitewide notices.
    1518 *
    1619 * @since 1.9.0
     20 * @deprecated 12.0.0
    1721 */
    1822class BP_Messages_Sitewide_Notices_Widget extends WP_Widget {
     
    2327         * @since 1.9.0
    2428         * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options.
     29         * @deprecated 12.0.0
    2530         */
    2631        public function __construct() {
    27                 parent::__construct(
    28                         'bp_messages_sitewide_notices_widget',
    29                         __( '(BuddyPress) Sitewide Notices', 'buddypress' ),
    30                         array(
    31                                 'classname'                   => 'widget_bp_core_sitewide_messages buddypress widget',
    32                                 'description'                 => __( 'Display Sitewide Notices posted by the site administrator', 'buddypress' ),
    33                                 'customize_selective_refresh' => true,
    34                                 'show_instance_in_rest'       => true,
    35                         )
    36                 );
     32                _deprecated_function( __METHOD__, '12.0.0' );
    3733        }
    3834
    3935        /**
    4036         * Render the widget.
     37         *
     38         * @deprecated 12.0.0
    4139         *
    4240         * @see WP_Widget::widget() for a description of parameters.
     
    4644         */
    4745        public function widget( $args, $instance ) {
    48 
    49                 if ( ! is_user_logged_in() ) {
    50                         return;
    51                 }
    52 
    53                 // Don't display the widget if there are no Notices to show.
    54                 $notices = BP_Messages_Notice::get_active();
    55                 if ( empty( $notices ) ) {
    56                         return;
    57                 }
    58 
    59                 extract( $args );
    60 
    61                 $title = ! empty( $instance['title'] ) ? $instance['title'] : '';
    62 
    63                 /**
    64                  * Filters the title of the Messages widget.
    65                  *
    66                  * @since 1.9.0
    67                  * @since 2.3.0 Added 'instance' and 'id_base' to arguments passed to filter.
    68                  *
    69                  * @param string $title    The widget title.
    70                  * @param array  $instance The settings for the particular instance of the widget.
    71                  * @param string $id_base  Root ID for all widgets of this type.
    72                  */
    73                 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    74 
    75                 echo $before_widget;
    76                 echo $before_title . $title . $after_title; ?>
    77 
    78                 <div class="bp-site-wide-message">
    79                         <?php bp_message_get_notices(); ?>
    80                 </div>
    81 
    82                 <?php
    83 
    84                 echo $after_widget;
     46                _deprecated_function( __METHOD__, '12.0.0' );
    8547        }
    8648
    8749        /**
    8850         * Process the saved settings for the widget.
     51         *
     52         * @deprecated 12.0.0
    8953         *
    9054         * @see WP_Widget::update() for a description of parameters and
     
    9660         */
    9761        public function update( $new_instance, $old_instance ) {
    98                 $instance = $old_instance;
    99                 $instance['title'] = strip_tags( $new_instance['title'] );
    100                 return $instance;
     62                _deprecated_function( __METHOD__, '12.0.0' );
    10163        }
    10264
    10365        /**
    10466         * Render the settings form for Appearance > Widgets.
     67         *
     68         * @deprecated 12.0.0
    10569         *
    10670         * @see WP_Widget::form() for a description of parameters.
     
    10973         */
    11074        public function form( $instance ) {
    111                 $instance = bp_parse_args(
    112                         (array) $instance,
    113                         array(
    114                                 'title' => '',
    115                         )
    116                 );
    117 
    118                 $title = strip_tags( $instance['title'] ); ?>
    119 
    120                 <p>
    121                         <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'buddypress' ); ?></label>
    122                         <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 ); ?>" />
    123                 </p>
    124 
    125                 <?php
     75                _deprecated_function( __METHOD__, '12.0.0' );
    12676        }
    12777}
  • trunk/src/bp-templates/bp-nouveau/buddypress-functions.php

    r13468 r13481  
    202202                add_action( 'widgets_init', 'bp_nouveau_register_sidebars', 11 );
    203203
    204                 // Register the Primary Object nav widget.
    205                 if ( bp_core_retain_legacy_widgets() ) {
    206                         add_action( 'bp_widgets_init', array( 'BP_Nouveau_Object_Nav_Widget', 'register_widget' ) );
    207                 }
    208 
    209204                // Modify "registration disabled" and welcome message if invitations are enabled.
    210205                add_action( 'bp_nouveau_feedback_messages', array( $this, 'filter_registration_messages' ), 99 );
  • trunk/src/bp-templates/bp-nouveau/includes/activity/loader.php

    r13461 r13481  
    6363                require $this->dir . 'template-tags.php';
    6464
    65                 if ( bp_core_retain_legacy_widgets() ) {
    66                         require $this->dir . 'widgets.php';
    67                 }
    68 
    6965                // Test suite requires the AJAX functions early.
    7066                if ( function_exists( 'tests_add_filter' ) ) {
     
    9490                add_action( 'bp_nouveau_enqueue_scripts', 'bp_nouveau_activity_enqueue_scripts' );
    9591                add_action( 'bp_nouveau_notifications_init_filters', 'bp_nouveau_activity_notification_filters' );
    96 
    97                 if ( bp_core_retain_legacy_widgets() ) {
    98                         add_action( 'bp_widgets_init', array( 'BP_Latest_Activities', 'register_widget' ) );
    99                 }
    10092
    10193                $bp = buddypress();
  • trunk/src/bp-templates/bp-nouveau/includes/activity/widgets.php

    r12976 r13481  
    55 * @since 3.0.0
    66 * @version 8.0.0
     7 * @deprecated 12.0.0
    78 */
    89
     
    1011defined( 'ABSPATH' ) || exit;
    1112
    12 /**
    13  * A widget to display the latest activities of your community!
    14  *
    15  * @since 3.0.0
    16  */
    17 class BP_Latest_Activities extends WP_Widget {
    18         /**
    19          * Construct the widget.
    20          *
    21          * @since 3.0.0
    22          * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options.
    23          */
    24         public function __construct() {
    25 
    26                 /**
    27                  * Filters the widget options for the BP_Latest_Activities widget.
    28                  *
    29                  * @since 3.0.0
    30                  *
    31                  * @param array $value Array of widget options.
    32                  */
    33                 $widget_ops = apply_filters(
    34                         'bp_latest_activities', array(
    35                                 'classname'                   => 'bp-latest-activities buddypress',
    36                                 'description'                 => __( 'Display the latest updates of your community having the types of your choice.', 'buddypress' ),
    37                                 'customize_selective_refresh' => true,
    38                                 'show_instance_in_rest'       => true,
    39                         )
    40                 );
    41 
    42                 parent::__construct( false, __( '(BuddyPress) Latest Activities', 'buddypress' ), $widget_ops );
    43         }
    44 
    45         /**
    46          * Register the widget.
    47          *
    48          * @since 3.0.0
    49          */
    50         public static function register_widget() {
    51                 register_widget( 'BP_Latest_Activities' );
    52         }
    53 
    54         /**
    55          * Display the widget content.
    56          *
    57          * @since 3.0.0
    58          *
    59          * @param array $args     Widget arguments.
    60          * @param array $instance Widget settings, as saved by the user.
    61          */
    62         public function widget( $args, $instance ) {
    63                 // Default values
    64                 $title      = __( 'Latest updates', 'buddypress' );
    65                 $type       = array( 'activity_update' );
    66                 $max        = 5;
    67                 $bp_nouveau = bp_nouveau();
    68 
    69                 // Check instance for a custom title
    70                 if ( ! empty( $instance['title'] ) ) {
    71                         $title = $instance['title'];
    72                 }
    73 
    74                 /**
    75                  * Filters the BP_Latest_Activities widget title.
    76                  *
    77                  * @since 3.0.0
    78                  *
    79                  * @param string $title    The widget title.
    80                  * @param array  $instance The settings for the particular instance of the widget.
    81                  * @param string $id_base  Root ID for all widgets of this type.
    82                  */
    83                 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    84 
    85                 // Check instance for custom max number of activities to display.
    86                 if ( ! empty( $instance['max'] ) ) {
    87                         $max = (int) $instance['max'];
    88                 }
    89 
    90                 // Check instance for custom activity types.
    91                 if ( ! empty( $instance['type'] ) ) {
    92                         $type = maybe_unserialize( $instance['type'] );
    93                         if ( ! is_array( $type ) ) {
    94                                 $type = (array) maybe_unserialize( $type );
    95                         }
    96 
    97                         $classes = array_map( 'sanitize_html_class', array_merge( $type, array( 'bp-latest-activities' ) ) );
    98 
    99                         // Add classes to the container
    100                         $args['before_widget'] = str_replace( 'bp-latest-activities', join( ' ', $classes ), $args['before_widget'] );
    101                 }
    102 
    103                 echo $args['before_widget'];
    104 
    105                 if ( $title ) {
    106                         echo $args['before_title'] . $title . $args['after_title'];
    107                 }
    108 
    109                 $reset_activities_template = null;
    110                 if ( ! empty( $GLOBALS['activities_template'] ) ) {
    111                         $reset_activities_template = $GLOBALS['activities_template'];
    112                 }
    113 
    114                 /**
    115                  * Globalize the activity widget arguments.
    116                  * @see bp_nouveau_activity_widget_query() to override
    117                  */
    118                 $bp_nouveau->activity->widget_args = array(
    119                         'max'          => $max,
    120                         'scope'        => 'all',
    121                         'user_id'      => 0,
    122                         'object'       => false,
    123                         'action'       => join( ',', $type ),
    124                         'primary_id'   => 0,
    125                         'secondary_id' => 0,
    126                 );
    127 
    128                 bp_get_template_part( 'activity/widget' );
    129 
    130                 // Reset the globals
    131                 $GLOBALS['activities_template']    = $reset_activities_template;
    132                 $bp_nouveau->activity->widget_args = array();
    133 
    134                 echo $args['after_widget'];
    135         }
    136 
    137         /**
    138          * Update the widget settings.
    139          *
    140          * @since 3.0.0
    141          *
    142          * @param array $new_instance The new instance settings.
    143          * @param array $old_instance The old instance settings.
    144          *
    145          * @return array The widget settings.
    146          */
    147         public function update( $new_instance, $old_instance ) {
    148                 $instance = $old_instance;
    149 
    150                 $instance['title'] = strip_tags( $new_instance['title'] );
    151                 $instance['max']   = 5;
    152                 if ( ! empty( $new_instance['max'] ) ) {
    153                         $instance['max'] = $new_instance['max'];
    154                 }
    155 
    156                 $instance['type'] = maybe_serialize( array( 'activity_update' ) );
    157                 if ( ! empty( $new_instance['type'] ) ) {
    158                         $instance['type'] = maybe_serialize( $new_instance['type'] );
    159                 }
    160 
    161                 return $instance;
    162         }
    163 
    164         /**
    165          * Display the form to set the widget settings.
    166          *
    167          * @since 3.0.0
    168          *
    169          * @param array $instance Settings for this widget.
    170          *
    171          * @return string HTML output.
    172          */
    173         public function form( $instance ) {
    174                 $instance = bp_parse_args(
    175                         (array) $instance,
    176                         array(
    177                                 'title' => __( 'Latest updates', 'buddypress' ),
    178                                 'max'   => 5,
    179                                 'type'  => '',
    180                         ),
    181                         'widget_latest_activities'
    182                 );
    183 
    184                 $title = esc_attr( $instance['title'] );
    185                 $max   = (int) $instance['max'];
    186 
    187                 $type = array( 'activity_update' );
    188                 if ( ! empty( $instance['type'] ) ) {
    189                         $type = maybe_unserialize( $instance['type'] );
    190                         if ( ! is_array( $type ) ) {
    191                                 $type = (array) maybe_unserialize( $type );
    192                         }
    193                 }
    194                 ?>
    195                 <p>
    196                         <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'buddypress' ); ?></label>
    197                         <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 ); ?>" />
    198                 </p>
    199 
    200                 <p>
    201                         <label for="<?php echo $this->get_field_id( 'max' ); ?>"><?php _e( 'Maximum amount to display:', 'buddypress' ); ?></label>
    202                         <input type="number" class="widefat" id="<?php echo $this->get_field_id( 'max' ); ?>" name="<?php echo $this->get_field_name( 'max' ); ?>" value="<?php echo intval( $max ); ?>" step="1" min="1" max="20" />
    203                 </p>
    204                 <p>
    205                         <label for="<?php echo $this->get_field_id( 'type' ); ?>"><?php esc_html_e( 'Type:', 'buddypress' ); ?></label>
    206                         <select class="widefat" multiple="multiple" id="<?php echo $this->get_field_id( 'type' ); ?>" name="<?php echo $this->get_field_name( 'type' ); ?>[]">
    207                                 <?php foreach ( bp_nouveau_get_activity_filters() as $key => $name ) : ?>
    208                                         <option value="<?php echo esc_attr( $key ); ?>" <?php selected( in_array( $key, $type, true ) ); ?>><?php echo esc_html( $name ); ?></option>
    209                                 <?php endforeach; ?>
    210                         </select>
    211                 </p>
    212                 <?php
    213         }
    214 }
     13_deprecated_file( basename( __FILE__ ), '12.0.0', '', __( 'BuddyPress does not include Legacy Widgets anymore, you can restore it using the BP Classic plugin', 'buddypress' ) );
  • trunk/src/bp-templates/bp-nouveau/includes/classes.php

    r13153 r13481  
    1111
    1212require plugin_dir_path( __FILE__ ) . 'classes/class-bp-buttons-group.php';
    13 
    14 if ( bp_core_retain_legacy_widgets() ) {
    15         require plugin_dir_path( __FILE__ ) . 'classes/class-bp-nouveau-object-nav-widget.php';
    16 }
  • trunk/src/bp-templates/bp-nouveau/includes/classes/class-bp-nouveau-object-nav-widget.php

    r13153 r13481  
    55 * @since 3.0.0
    66 * @version 10.0.0
     7 * @deprecated 12.0.0
    78 */
    89
     
    1011defined( 'ABSPATH' ) || exit;
    1112
    12 /**
    13  * BP Sidebar Item Nav_Widget.
    14  *
    15  * Adds a widget to move avatar/item nav into the sidebar.
    16  *
    17  * @since 3.0.0
    18  */
    19 class BP_Nouveau_Object_Nav_Widget extends WP_Widget {
    20         /**
    21          * Constructor
    22          *
    23          * @since 3.0.0
    24          * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options.
    25          */
    26         public function __construct() {
    27                 $widget_ops = array(
    28                         'description'           => __( 'Displays BuddyPress primary nav in the sidebar of your site. Make sure to use it as the first widget of the sidebar and only once.', 'buddypress' ),
    29                         'classname'             => 'widget_nav_menu buddypress_object_nav',
    30                         'show_instance_in_rest' => true,
    31                 );
    32 
    33                 parent::__construct(
    34                         'bp_nouveau_sidebar_object_nav_widget',
    35                         __( '(BuddyPress) Primary navigation', 'buddypress' ),
    36                         $widget_ops
    37                 );
    38         }
    39 
    40         /**
    41          * Register the widget
    42          *
    43          * @since 3.0.0
    44          */
    45         public static function register_widget() {
    46                 register_widget( 'BP_Nouveau_Object_Nav_Widget' );
    47         }
    48 
    49         /**
    50          * Displays the output, the button to post new support topics
    51          *
    52          * @since 3.0.0
    53          *
    54          * @param mixed   $args     Arguments
    55          * @param unknown $instance
    56          */
    57         public function widget( $args, $instance ) {
    58                 if ( ! is_buddypress() || bp_is_group_create() ) {
    59                         return;
    60                 }
    61 
    62                 /**
    63                  * Filters the nav widget args for the BP_Nouveau_Object_Nav_Widget widget.
    64                  *
    65                  * @since 3.0.0
    66                  *
    67                  * @param array $value Array of arguments {
    68                  *     @param bool $bp_nouveau_widget_title Whether or not to assign a title for the widget.
    69                  * }
    70                  */
    71                 $item_nav_args = bp_parse_args(
    72                         $instance,
    73                         apply_filters(
    74                                 'bp_nouveau_object_nav_widget_args',
    75                                 array( 'bp_nouveau_widget_title' => true )
    76                         ),
    77                         'widget_object_nav'
    78                 );
    79 
    80                 $title = '';
    81 
    82                 if ( ! empty( $item_nav_args['bp_nouveau_widget_title'] ) ) {
    83                         if ( bp_is_group() ) {
    84                                 $title = bp_get_current_group_name();
    85                         } elseif ( bp_is_user() ) {
    86                                 $title = bp_get_displayed_user_fullname();
    87                         } elseif ( bp_get_directory_title( bp_current_component() ) ) {
    88                                 $title = bp_get_directory_title( bp_current_component() );
    89                         }
    90                 }
    91 
    92                 /**
    93                  * Filters the BP_Nouveau_Object_Nav_Widget widget title.
    94                  *
    95                  * @since 3.0.0
    96                  *
    97                  * @param string $title    The widget title.
    98                  * @param array  $instance The settings for the particular instance of the widget.
    99                  * @param string $id_base  Root ID for all widgets of this type.
    100                  */
    101                 $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
    102 
    103                 echo $args['before_widget'];
    104 
    105                 if ( ! empty( $title ) ) {
    106                         echo $args['before_title'] . $title . $args['after_title'];
    107                 }
    108 
    109                 if ( bp_is_user() ) {
    110                         bp_get_template_part( 'members/single/parts/item-nav' );
    111                 } elseif ( bp_is_group() ) {
    112                         bp_get_template_part( 'groups/single/parts/item-nav' );
    113                 } elseif ( bp_is_directory() ) {
    114                         bp_get_template_part( 'common/nav/directory-nav' );
    115                 }
    116 
    117                 echo $args['after_widget'];
    118         }
    119 
    120         /**
    121          * Update the new support topic widget options (title)
    122          *
    123          * @since 3.0.0
    124          *
    125          * @param array $new_instance The new instance options
    126          * @param array $old_instance The old instance options
    127          *
    128          * @return array the instance
    129          */
    130         public function update( $new_instance, $old_instance ) {
    131                 $instance                            = $old_instance;
    132                 $instance['bp_nouveau_widget_title'] = (bool) $new_instance['bp_nouveau_widget_title'];
    133 
    134                 return $instance;
    135         }
    136 
    137         /**
    138          * Output the new support topic widget options form
    139          *
    140          * @since 3.0.0
    141          *
    142          * @param $instance Instance
    143          *
    144          * @return string HTML Output
    145          */
    146         public function form( $instance ) {
    147                 $defaults = array(
    148                         'bp_nouveau_widget_title' => true,
    149                 );
    150 
    151                 $instance = bp_parse_args(
    152                         (array) $instance,
    153                         $defaults,
    154                         'widget_object_nav_form'
    155                 );
    156 
    157                 $bp_nouveau_widget_title = (bool) $instance['bp_nouveau_widget_title'];
    158                 ?>
    159 
    160                 <p>
    161                         <input class="checkbox" type="checkbox" <?php checked( $bp_nouveau_widget_title, true ); ?> id="<?php echo $this->get_field_id( 'bp_nouveau_widget_title' ); ?>" name="<?php echo $this->get_field_name( 'bp_nouveau_widget_title' ); ?>" />
    162                         <label for="<?php echo $this->get_field_id( 'bp_nouveau_widget_title' ); ?>"><?php esc_html_e( 'Include navigation title', 'buddypress' ); ?></label>
    163                 </p>
    164 
    165                 <?php
    166         }
    167 }
     13_deprecated_file( basename( __FILE__ ), '12.0.0', '', __( 'BuddyPress does not include Legacy Widgets anymore, you can restore it using the BP Classic plugin', 'buddypress' ) );
  • trunk/src/bp-templates/bp-nouveau/includes/messages/functions.php

    r13461 r13481  
    304304/**
    305305 * @since 3.0.0
     306 * @deprecated 12.0.0
    306307 */
    307308function bp_nouveau_unregister_notices_widget() {
    308         unregister_widget( 'BP_Messages_Sitewide_Notices_Widget' );
     309        _deprecated_function( __FUNCTION__, '12.0.0' );
    309310}
    310311
  • trunk/src/bp-templates/bp-nouveau/includes/messages/loader.php

    r13461 r13481  
    6969                add_action( 'bp_init', 'bp_nouveau_register_messages_ajax_actions' );
    7070
    71                 // Notices
    72                 add_action( 'widgets_init', 'bp_nouveau_unregister_notices_widget' );
    73 
    7471                $hook = 'bp_parse_query';
    7572                if ( 'rewrites' !== bp_core_get_query_parser() ) {
  • trunk/src/class-buddypress.php

    r13468 r13481  
    638638                require $this->plugin_dir . 'bp-core/bp-core-attachments.php';
    639639                require $this->plugin_dir . 'bp-core/bp-core-avatars.php';
    640                 require $this->plugin_dir . 'bp-core/bp-core-widgets.php';
    641640                require $this->plugin_dir . 'bp-core/bp-core-template.php';
    642641                require $this->plugin_dir . 'bp-core/bp-core-adminbar.php';
     
    752751                        'BP_Optouts_List_Table'                      => 'core',
    753752
    754                         'BP_Core_Friends_Widget'                     => 'friends',
    755753                        'BP_REST_Friends_Endpoint'                   => 'friends',
    756754
     
    765763
    766764                        'BP_Core_Members_Template'                   => 'members',
    767                         'BP_Core_Members_Widget'                     => 'members',
    768                         'BP_Core_Recently_Active_Widget'             => 'members',
    769                         'BP_Core_Whos_Online_Widget'                 => 'members',
    770765                        'BP_Registration_Theme_Compat'               => 'members',
    771766                        'BP_Signup'                                  => 'members',
Note: See TracChangeset for help on using the changeset viewer.