__( 'A dynamic list of recently active, popular, and newest Friends of the displayed member. Widget is only shown when viewing a member profile.', 'buddypress' ), 'classname' => 'widget_bp_core_friends_widget buddypress widget', 'customize_selective_refresh' => true, 'show_instance_in_rest' => true, ); parent::__construct( false, $name = _x( '(BuddyPress) Friends', 'widget name', 'buddypress' ), $widget_ops ); if ( is_customize_preview() || bp_is_widget_block_active( '', $this->id_base ) ) { add_action( 'bp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); } } /** * Enqueue scripts. * * @since 2.6.0 */ public function enqueue_scripts() { $min = bp_core_get_minified_asset_suffix(); wp_enqueue_script( 'bp_core_widget_friends-js', buddypress()->plugin_url . "bp-friends/js/widget-friends{$min}.js", array( 'jquery' ), bp_get_version() ); } /** * Display the widget. * * @since 1.9.0 * * @global BP_Core_Members_Template $members_template * * @param array $args Widget arguments. * @param array $instance The widget settings, as saved by the user. */ public function widget( $args, $instance ) { global $members_template; extract( $args ); if ( ! bp_displayed_user_id() ) { return; } $user_id = bp_displayed_user_id(); $link = trailingslashit( bp_displayed_user_domain() . bp_get_friends_slug() ); $instance['title'] = sprintf( __( "%s's Friends", 'buddypress' ), bp_get_displayed_user_fullname() ); if ( empty( $instance['friend_default'] ) ) { $instance['friend_default'] = 'active'; } /** * Filters the Friends widget title. * * @since 1.8.0 * @since 2.3.0 Added 'instance' and 'id_base' to arguments passed to filter. * * @param string $title The widget title. * @param array $instance The settings for the particular instance of the widget. * @param string $id_base Root ID for all widgets of this type. */ $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); echo $before_widget; $title = $instance['link_title'] ? '' . esc_html( $title ) . '' : esc_html( $title ); echo $before_title . $title . $after_title; $members_args = array( 'user_id' => absint( $user_id ), 'type' => sanitize_text_field( $instance['friend_default'] ), 'max' => absint( $instance['max_friends'] ), 'populate_extras' => 1, ); // Back up the global. $old_members_template = $members_template; ?>
class="selected"> | class="selected"> | class="selected">
5, 'friend_default' => 'active', 'link_title' => false, ); $instance = bp_parse_args( (array) $instance, $defaults ); $max_friends = $instance['max_friends']; $friend_default = $instance['friend_default']; $link_title = (bool) $instance['link_title']; ?>