- Timestamp:
- 05/17/2023 11:14:06 AM (22 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.