- Timestamp:
- 08/24/2021 04:16:17 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-friends/classes/class-bp-core-friends-widget.php
r12997 r13092 4 4 * 5 5 * @package BuddyPress 6 * @subpackage Friends 6 * @subpackage FriendsWidget 7 7 * @since 1.9.0 8 8 */ … … 24 24 * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options. 25 25 */ 26 function __construct() {26 public function __construct() { 27 27 $widget_ops = array( 28 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' ), … … 53 53 * @since 1.9.0 54 54 * 55 * @global object $members_template 56 * 55 57 * @param array $args Widget arguments. 56 58 * @param array $instance The widget settings, as saved by the user. 57 59 */ 58 function widget( $args, $instance ) {60 public function widget( $args, $instance ) { 59 61 global $members_template; 60 62 … … 65 67 } 66 68 67 $user_id = bp_displayed_user_id();68 $link = trailingslashit( bp_displayed_user_domain() . bp_get_friends_slug() );69 $user_id = bp_displayed_user_id(); 70 $link = trailingslashit( bp_displayed_user_domain() . bp_get_friends_slug() ); 69 71 $instance['title'] = sprintf( __( "%s's Friends", 'buddypress' ), bp_get_displayed_user_fullname() ); 70 72 … … 159 161 * @return array $instance The processed settings to save. 160 162 */ 161 function update( $new_instance, $old_instance ) {163 public function update( $new_instance, $old_instance ) { 162 164 $instance = $old_instance; 163 165 … … 175 177 * 176 178 * @param array $instance The saved widget settings. 177 * @return void 178 */ 179 function form( $instance ) { 179 */ 180 public function form( $instance ) { 180 181 $defaults = array( 181 'max_friends' 182 'max_friends' => 5, 182 183 'friend_default' => 'active', 183 'link_title' => false184 'link_title' => false, 184 185 ); 185 $instance = wp_parse_args( (array) $instance, $defaults ); 186 187 $max_friends 186 187 $instance = wp_parse_args( (array) $instance, $defaults ); 188 $max_friends = $instance['max_friends']; 188 189 $friend_default = $instance['friend_default']; 189 $link_title 190 $link_title = (bool) $instance['link_title']; 190 191 ?> 191 192 192 193 <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> 193 194 194 <p><label for="<?php echo $this->get_field_id( 'max_friends' ); ?>"><?php _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>195 <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> 195 196 196 197 <p> 197 <label for="<?php echo $this->get_field_id( 'friend_default' ) ?>"><?php _e( 'Default friends to show:', 'buddypress' ); ?></label>198 <label for="<?php echo $this->get_field_id( 'friend_default' ) ?>"><?php esc_html_e( 'Default friends to show:', 'buddypress' ); ?></label> 198 199 <select name="<?php echo $this->get_field_name( 'friend_default' ); ?>" id="<?php echo $this->get_field_id( 'friend_default' ); ?>"> 199 <option value="newest" <?php selected( $friend_default, 'newest' ); ?>><?php _e( 'Newest', 'buddypress' ); ?></option>200 <option value="active" <?php selected( $friend_default, 'active' ); ?>><?php_e( 'Active', 'buddypress' ); ?></option>201 <option value="popular" <?php selected( $friend_default, 'popular' ); ?>><?php _e( 'Popular', 'buddypress' ); ?></option>200 <option value="newest" <?php selected( $friend_default, 'newest' ); ?>><?php esc_html_e( 'Newest', 'buddypress' ); ?></option> 201 <option value="active" <?php selected( $friend_default, 'active' ); ?>><?php esc_html_e( 'Active', 'buddypress' ); ?></option> 202 <option value="popular" <?php selected( $friend_default, 'popular' ); ?>><?php esc_html_e( 'Popular', 'buddypress' ); ?></option> 202 203 </select> 203 204 </p> 204 205 205 <?php 206 206 }
Note: See TracChangeset
for help on using the changeset viewer.