- 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-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 }
Note: See TracChangeset
for help on using the changeset viewer.