Changeset 13481
- Timestamp:
- 05/17/2023 11:14:06 AM (16 months ago)
- Location:
- trunk/src
- Files:
-
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-blogs/bp-blogs-widgets.php
r13153 r13481 6 6 * @subpackage BlogsWidgets 7 7 * @since 1.0.0 8 * @deprecated 12.0.0 8 9 */ 9 10 … … 11 12 defined( 'ABSPATH' ) || exit; 12 13 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 149 149 150 150 if ( is_multisite() ) { 151 $includes[] = 'widgets';152 151 $includes[] = 'blocks'; 153 152 } -
trunk/src/bp-blogs/classes/class-bp-blogs-recent-posts-widget.php
r13436 r13481 6 6 * @subpackage BlogsWidgets 7 7 * @since 1.0.0 8 * @deprecated 12.0.0 8 9 */ 9 10 … … 11 12 defined( 'ABSPATH' ) || exit; 12 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' ) ); 15 13 16 /** 14 17 * The Recent Networkwide Posts widget. 15 18 * 16 19 * @since 1.0.0 20 * @deprecated 12.0.0 17 21 */ 18 class BP_Blogs_Recent_Posts_Widget extends WP_Widget{22 class BP_Blogs_Recent_Posts_Widget { 19 23 20 24 /** … … 23 27 * @since 1.5.0 24 28 * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options. 29 * @deprecated 12.0.0 25 30 */ 26 31 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' ); 34 33 } 35 34 … … 39 38 * @see WP_Widget::widget() for description of parameters. 40 39 * 40 * @deprecated 12.0.0 41 * 41 42 * @param array $args Widget arguments. 42 43 * @param array $instance Widget settings, as saved by the user. 43 44 */ 44 45 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' ); 128 47 } 129 48 130 49 /** 131 50 * Update the networkwide posts widget options. 51 * 52 * @deprecated 12.0.0 132 53 * 133 54 * @param array $new_instance The new instance options. … … 136 57 */ 137 58 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' ); 147 60 } 148 61 … … 150 63 * Output the networkwide posts widget options form. 151 64 * 65 * @deprecated 12.0.0 66 * 152 67 * @param array $instance Settings for this widget. 153 68 */ 154 69 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' ); 176 71 } 177 72 } -
trunk/src/bp-core/bp-core-filters.php
r13471 r13481 1122 1122 1123 1123 /** 1124 * Injects specific BuddyPress CSS classes into a widget sidebar.1125 *1126 * Helps to standardize styling of BuddyPress widgets within a theme that1127 * does not use dynamic CSS classes in their widget sidebar's 'before_widget'1128 * call.1129 *1130 * @since 2.4.01131 * @access private1132 *1133 * @global array $wp_registered_widgets Current registered widgets.1134 *1135 * @param array $params Current sidebar params.1136 * @return array1137 */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 class1150 // 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 /**1181 1124 * Add email link styles to rendered email template. 1182 1125 * -
trunk/src/bp-core/bp-core-functions.php
r13468 r13481 4664 4664 4665 4665 /** 4666 * Returns the upper limit on the "max" item count, for widgets that support it.4667 *4668 * @since 5.0.04669 *4670 * @param string $widget_class Optional. Class name of the calling widget.4671 * @return int4672 */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.04678 *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 /**4686 4666 * Add a new BP_Optout. 4687 4667 * -
trunk/src/bp-core/bp-core-options.php
r12893 r13481 98 98 // Ignore deprecated code. 99 99 '_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,108 100 ); 109 101 -
trunk/src/bp-core/bp-core-update.php
r13432 r13481 861 861 } 862 862 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 863 877 // Finally make sure to rebuilt permalinks at next page load. 864 878 bp_delete_rewrite_rules(); -
trunk/src/bp-core/bp-core-widgets.php
r13417 r13481 6 6 * @subpackage Core 7 7 * @since 1.0.0 8 * @deprecated 12.0.0 8 9 */ 9 10 … … 11 12 defined( 'ABSPATH' ) || exit; 12 13 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 6 6 * @subpackage Core 7 7 * @since 1.9.0 8 * @deprecated 12.0.0 8 9 */ 9 10 … … 11 12 defined( 'ABSPATH' ) || exit; 12 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' ) ); 15 13 16 /** 14 17 * BuddyPress Login Widget. 15 18 * 16 19 * @since 1.9.0 20 * @deprecated 12.0.0 17 21 */ 18 class BP_Core_Login_Widget extends WP_Widget{22 class BP_Core_Login_Widget { 19 23 20 24 /** … … 23 27 * @since 1.9.0 24 28 * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options. 29 * @deprecated 12.0.0 25 30 */ 26 31 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' ); 37 33 } 38 34 … … 41 37 * 42 38 * @since 1.9.0 39 * @deprecated 12.0.0 43 40 * 44 41 * @see WP_Widget::widget() for description of parameters. … … 48 45 */ 49 46 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' ); 149 48 } 150 49 … … 153 52 * 154 53 * @since 1.9.0 54 * @deprecated 12.0.0 155 55 * 156 56 * @param array $new_instance The new instance options. … … 159 59 */ 160 60 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' ); 165 62 } 166 63 … … 169 66 * 170 67 * @since 1.9.0 68 * @deprecated 12.0.0 171 69 * 172 70 * @param array $instance Settings for this widget. … … 174 72 */ 175 73 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' ); 191 75 } 192 76 } -
trunk/src/bp-core/deprecated/12.0.php
r13477 r13481 477 477 */ 478 478 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' ); 479 502 } 480 503 } … … 664 687 return $post_states; 665 688 } 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 */ 698 function 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 */ 709 function 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 */ 719 function 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 */ 729 function 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 */ 739 function 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 */ 748 function 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 */ 758 function 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 */ 768 function 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 */ 778 function 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 */ 798 function _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 */ 808 function 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 */ 818 function 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 */ 828 function 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 */ 838 function 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 */ 848 function 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 */ 858 function 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 */ 870 function 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 */ 882 function 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 */ 892 function 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 */ 902 function 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 } 1 window.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 6 6 * @subpackage FriendsWidgets 7 7 * @since 1.9.0 8 * @deprecated 12.0.0 8 9 */ 9 10 … … 11 12 defined( 'ABSPATH' ) || exit; 12 13 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 6 6 * @subpackage FriendsWidget 7 7 * @since 1.9.0 8 * @deprecated 12.0.0 8 9 */ 9 10 … … 11 12 defined( 'ABSPATH' ) || exit; 12 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' ) ); 15 13 16 /** 14 17 * The User Friends widget class. 15 18 * 16 19 * @since 1.9.0 20 * @deprecated 12.0.0 17 21 */ 18 class BP_Core_Friends_Widget extends WP_Widget{22 class BP_Core_Friends_Widget { 19 23 20 24 /** … … 23 27 * @since 1.9.0 24 28 * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options. 29 * @deprecated 12.0.0 25 30 */ 26 31 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' ); 38 33 } 39 34 … … 42 37 * 43 38 * @since 2.6.0 39 * @deprecated 12.0.0 44 40 */ 45 41 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' ); 48 43 } 49 44 … … 52 47 * 53 48 * @since 1.9.0 49 * @deprecated 12.0.0 54 50 * 55 51 * @global BP_Core_Members_Template $members_template The main member template loop class. … … 59 55 */ 60 56 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' ); 157 58 } 158 59 … … 161 62 * 162 63 * @since 1.9.0 64 * @deprecated 12.0.0 163 65 * 164 66 * @param array $new_instance The parameters saved by the user. … … 167 69 */ 168 70 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' ); 176 72 } 177 73 … … 180 76 * 181 77 * @since 1.9.0 78 * @deprecated 12.0.0 182 79 * 183 80 * @param array $instance The saved widget settings. 184 81 */ 185 82 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' ); 215 84 } 216 85 } -
trunk/src/bp-friends/classes/class-bp-friends-component.php
r13464 r13481 53 53 'template', 54 54 'functions', 55 'widgets',56 55 'blocks', 57 56 ); -
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 } 1 window.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 6 6 * @subpackage GroupsWidgets 7 7 * @since 1.0.0 8 * @deprecated 12.0.0 8 9 */ 9 10 … … 11 12 defined( 'ABSPATH' ) || exit; 12 13 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 141 141 'cache', 142 142 'filters', 143 'widgets',144 143 'template', 145 144 'adminbar', -
trunk/src/bp-groups/classes/class-bp-groups-widget.php
r13437 r13481 6 6 * @subpackage GroupsWidgets 7 7 * @since 1.0.0 8 * @deprecated 12.0.0 8 9 */ 9 10 … … 11 12 defined( 'ABSPATH' ) || exit; 12 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' ) ); 15 13 16 /** 14 17 * Groups widget. 15 18 * 16 19 * @since 1.0.3 20 * @deprecated 12.0.0 17 21 */ 18 class BP_Groups_Widget extends WP_Widget{22 class BP_Groups_Widget { 19 23 20 24 /** … … 23 27 * @since 1.0.3 24 28 * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options. 29 * @deprecated 12.0.0 25 30 */ 26 31 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' ); 38 33 } 39 34 … … 42 37 * 43 38 * @since 2.6.0 39 * @deprecated 12.0.0 44 40 */ 45 41 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' ); 48 43 } 49 44 … … 52 47 * 53 48 * @since 1.0.3 49 * @deprecated 12.0.0 54 50 * 55 51 * @param array $args Array of arguments for the widget. … … 57 53 */ 58 54 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' ); 180 56 } 181 57 … … 184 60 * 185 61 * @since 1.0.3 62 * @deprecated 12.0.0 186 63 * 187 64 * @param array $new_instance New instance data. … … 190 67 */ 191 68 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' ); 202 70 } 203 71 … … 206 74 * 207 75 * @since 1.0.3 76 * @deprecated 12.0.0 208 77 * 209 78 * @param array $instance Current instance. … … 211 80 */ 212 81 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' ); 250 83 } 251 84 } -
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 } 1 window.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 6 6 * @subpackage MembersWidgets 7 7 * @since 2.2.0 8 * @deprecated 12.0.0 8 9 */ 9 10 … … 11 12 defined( 'ABSPATH' ) || exit; 12 13 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 6 6 * @subpackage MembersWidgets 7 7 * @since 1.0.3 8 * @deprecated 12.0.0 8 9 */ 9 10 … … 11 12 defined( 'ABSPATH' ) || exit; 12 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' ) ); 15 13 16 /** 14 17 * Members Widget. 15 18 * 16 19 * @since 1.0.3 20 * @deprecated 12.0.0 17 21 */ 18 class BP_Core_Members_Widget extends WP_Widget{22 class BP_Core_Members_Widget { 19 23 20 24 /** … … 23 27 * @since 1.5.0 24 28 * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options. 29 * @deprecated 12.0.0 25 30 */ 26 31 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' ); 43 33 } 44 34 … … 47 37 * 48 38 * @since 2.6.0 39 * @deprecated 12.0.0 49 40 */ 50 41 public function enqueue_scripts() { 51 wp_enqueue_script( 'bp-widget-members' );42 _deprecated_function( __METHOD__, '12.0.0' ); 52 43 } 53 44 … … 56 47 * 57 48 * @since 1.0.3 49 * @deprecated 12.0.0 58 50 * 59 51 * @see WP_Widget::widget() for description of parameters. … … 63 55 */ 64 56 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' ); 171 58 } 172 59 … … 175 62 * 176 63 * @since 1.0.3 64 * @deprecated 12.0.0 177 65 * 178 66 * @param array $new_instance The new instance options. … … 181 69 */ 182 70 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' ); 193 72 } 194 73 … … 197 76 * 198 77 * @since 1.0.3 78 * @deprecated 12.0.0 199 79 * 200 80 * @param array $instance Widget instance settings. … … 202 82 */ 203 83 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' ); 244 85 } 245 86 … … 248 89 * 249 90 * @since 2.3.0 91 * @deprecated 12.0.0 250 92 * 251 93 * @param array $instance Widget instance settings. … … 253 95 */ 254 96 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' ); 265 98 } 266 99 } -
trunk/src/bp-members/classes/class-bp-core-recently-active-widget.php
r13108 r13481 6 6 * @subpackage MembersWidgets 7 7 * @since 1.0.3 8 * @deprecated 12.0.0 8 9 */ 9 10 … … 11 12 defined( 'ABSPATH' ) || exit; 12 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' ) ); 15 13 16 /** 14 17 * Recently Active Members Widget. 15 18 * 16 19 * @since 1.0.3 20 * @deprecated 12.0.0 17 21 */ 18 22 class BP_Core_Recently_Active_Widget extends WP_Widget { … … 23 27 * @since 1.5.0 24 28 * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options. 29 * @deprecated 12.0.0 25 30 */ 26 31 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' ); 35 33 } 36 34 … … 39 37 * 40 38 * @since 1.0.3 39 * @deprecated 12.0.0 41 40 * 42 41 * @see WP_Widget::widget() for description of parameters. … … 46 45 */ 47 46 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' ); 112 48 } 113 49 … … 116 52 * 117 53 * @since 1.0.3 54 * @deprecated 12.0.0 118 55 * 119 56 * @param array $new_instance The new instance options. … … 122 59 */ 123 60 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' ); 132 62 } 133 63 … … 136 66 * 137 67 * @since 1.0.3 68 * @deprecated 12.0.0 138 69 * 139 70 * @param array $instance Widget instance settings. … … 141 72 */ 142 73 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' ); 166 75 } 167 76 … … 170 79 * 171 80 * @since 2.3.0 81 * @deprecated 12.0.0 172 82 * 173 83 * @param array $instance Widget instance settings. … … 175 85 */ 176 86 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' ); 185 88 } 186 89 } -
trunk/src/bp-members/classes/class-bp-core-whos-online-widget.php
r13108 r13481 6 6 * @subpackage MembersWidgets 7 7 * @since 1.0.0 8 * @deprecated 12.0.0 8 9 */ 9 10 10 11 // Exit if accessed directly. 11 12 defined( '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' ) ); 12 15 13 16 /** … … 16 19 * @since 1.0.3 17 20 * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options. 21 * @deprecated 12.0.0 18 22 */ 19 23 class BP_Core_Whos_Online_Widget extends WP_Widget { … … 24 28 * @since 1.5.0 25 29 * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options. 30 * @deprecated 12.0.0 26 31 */ 27 32 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' ); 36 34 } 37 35 … … 40 38 * 41 39 * @since 1.0.3 40 * @deprecated 12.0.0 42 41 * 43 42 * @see WP_Widget::widget() for description of parameters. … … 47 46 */ 48 47 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' ); 112 49 } 113 50 … … 116 53 * 117 54 * @since 1.0.3 55 * @deprecated 12.0.0 118 56 * 119 57 * @param array $new_instance The new instance options. … … 122 60 */ 123 61 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' ); 132 63 } 133 64 … … 136 67 * 137 68 * @since 1.0.3 69 * @deprecated 12.0.0 138 70 * 139 71 * @param array $instance Widget instance settings. … … 141 73 */ 142 74 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' ); 166 76 } 167 77 … … 170 80 * 171 81 * @since 2.3.0 82 * @deprecated 12.0.0 172 83 * 173 84 * @param array $instance Widget instance settings. … … 175 86 */ 176 87 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' ); 185 89 } 186 90 } -
trunk/src/bp-members/classes/class-bp-members-component.php
r13471 r13481 105 105 'functions', 106 106 'blocks', 107 'widgets',108 107 'cache', 109 108 'invitations', -
trunk/src/bp-messages/bp-messages-widgets.php
r13153 r13481 6 6 * @subpackage MessagesWidgets 7 7 * @since 1.9.0 8 * @deprecated 12.0.0 8 9 */ 9 10 … … 11 12 defined( 'ABSPATH' ) || exit; 12 13 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 63 63 'template', 64 64 'functions', 65 'widgets',66 65 'blocks', 67 66 ); -
trunk/src/bp-messages/classes/class-bp-messages-sitewide-notices-widget.php
r13108 r13481 6 6 * @subpackage MessagesClasses 7 7 * @since 1.9.0 8 * @deprecated 12.0.0 8 9 */ 9 10 … … 11 12 defined( 'ABSPATH' ) || exit; 12 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' ) ); 15 13 16 /** 14 17 * A widget that displays sitewide notices. 15 18 * 16 19 * @since 1.9.0 20 * @deprecated 12.0.0 17 21 */ 18 22 class BP_Messages_Sitewide_Notices_Widget extends WP_Widget { … … 23 27 * @since 1.9.0 24 28 * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options. 29 * @deprecated 12.0.0 25 30 */ 26 31 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' ); 37 33 } 38 34 39 35 /** 40 36 * Render the widget. 37 * 38 * @deprecated 12.0.0 41 39 * 42 40 * @see WP_Widget::widget() for a description of parameters. … … 46 44 */ 47 45 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' ); 85 47 } 86 48 87 49 /** 88 50 * Process the saved settings for the widget. 51 * 52 * @deprecated 12.0.0 89 53 * 90 54 * @see WP_Widget::update() for a description of parameters and … … 96 60 */ 97 61 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' ); 101 63 } 102 64 103 65 /** 104 66 * Render the settings form for Appearance > Widgets. 67 * 68 * @deprecated 12.0.0 105 69 * 106 70 * @see WP_Widget::form() for a description of parameters. … … 109 73 */ 110 74 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' ); 126 76 } 127 77 } -
trunk/src/bp-templates/bp-nouveau/buddypress-functions.php
r13468 r13481 202 202 add_action( 'widgets_init', 'bp_nouveau_register_sidebars', 11 ); 203 203 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 209 204 // Modify "registration disabled" and welcome message if invitations are enabled. 210 205 add_action( 'bp_nouveau_feedback_messages', array( $this, 'filter_registration_messages' ), 99 ); -
trunk/src/bp-templates/bp-nouveau/includes/activity/loader.php
r13461 r13481 63 63 require $this->dir . 'template-tags.php'; 64 64 65 if ( bp_core_retain_legacy_widgets() ) {66 require $this->dir . 'widgets.php';67 }68 69 65 // Test suite requires the AJAX functions early. 70 66 if ( function_exists( 'tests_add_filter' ) ) { … … 94 90 add_action( 'bp_nouveau_enqueue_scripts', 'bp_nouveau_activity_enqueue_scripts' ); 95 91 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 }100 92 101 93 $bp = buddypress(); -
trunk/src/bp-templates/bp-nouveau/includes/activity/widgets.php
r12976 r13481 5 5 * @since 3.0.0 6 6 * @version 8.0.0 7 * @deprecated 12.0.0 7 8 */ 8 9 … … 10 11 defined( 'ABSPATH' ) || exit; 11 12 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 11 11 12 12 require 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 5 5 * @since 3.0.0 6 6 * @version 10.0.0 7 * @deprecated 12.0.0 7 8 */ 8 9 … … 10 11 defined( 'ABSPATH' ) || exit; 11 12 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 304 304 /** 305 305 * @since 3.0.0 306 * @deprecated 12.0.0 306 307 */ 307 308 function bp_nouveau_unregister_notices_widget() { 308 unregister_widget( 'BP_Messages_Sitewide_Notices_Widget' );309 _deprecated_function( __FUNCTION__, '12.0.0' ); 309 310 } 310 311 -
trunk/src/bp-templates/bp-nouveau/includes/messages/loader.php
r13461 r13481 69 69 add_action( 'bp_init', 'bp_nouveau_register_messages_ajax_actions' ); 70 70 71 // Notices72 add_action( 'widgets_init', 'bp_nouveau_unregister_notices_widget' );73 74 71 $hook = 'bp_parse_query'; 75 72 if ( 'rewrites' !== bp_core_get_query_parser() ) { -
trunk/src/class-buddypress.php
r13468 r13481 638 638 require $this->plugin_dir . 'bp-core/bp-core-attachments.php'; 639 639 require $this->plugin_dir . 'bp-core/bp-core-avatars.php'; 640 require $this->plugin_dir . 'bp-core/bp-core-widgets.php';641 640 require $this->plugin_dir . 'bp-core/bp-core-template.php'; 642 641 require $this->plugin_dir . 'bp-core/bp-core-adminbar.php'; … … 752 751 'BP_Optouts_List_Table' => 'core', 753 752 754 'BP_Core_Friends_Widget' => 'friends',755 753 'BP_REST_Friends_Endpoint' => 'friends', 756 754 … … 765 763 766 764 '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',770 765 'BP_Registration_Theme_Compat' => 'members', 771 766 'BP_Signup' => 'members',
Note: See TracChangeset
for help on using the changeset viewer.