Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
08/24/2021 04:16:17 AM (5 years ago)
Author:
espellcaste
Message:

Making PHPDoc Improvements to the BP Friends (component) files.

Also, adding several minor PHP changes.

See #8553

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-friends/classes/class-bp-core-friends-widget.php

    r12997 r13092  
    44 *
    55 * @package BuddyPress
    6  * @subpackage Friends
     6 * @subpackage FriendsWidget
    77 * @since 1.9.0
    88 */
    … …  
    2424         * @since 9.0.0 Adds the `show_instance_in_rest` property to Widget options.
    2525         */
    26         function __construct() {
     26        public function __construct() {
    2727                $widget_ops = array(
    2828                        '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' ),
    … …  
    5353         * @since 1.9.0
    5454         *
     55         * @global object $members_template
     56         *
    5557         * @param array $args Widget arguments.
    5658         * @param array $instance The widget settings, as saved by the user.
    5759         */
    58         function widget( $args, $instance ) {
     60        public function widget( $args, $instance ) {
    5961                global $members_template;
    6062
    … …  
    6567                }
    6668
    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() );
    6971                $instance['title'] = sprintf( __( "%s's Friends", 'buddypress' ), bp_get_displayed_user_fullname() );
    7072
    … …  
    159161         * @return array $instance The processed settings to save.
    160162         */
    161         function update( $new_instance, $old_instance ) {
     163        public function update( $new_instance, $old_instance ) {
    162164                $instance = $old_instance;
    163165
    … …  
    175177         *
    176178         * @param array $instance The saved widget settings.
    177          * @return void
    178          */
    179         function form( $instance ) {
     179         */
     180        public function form( $instance ) {
    180181                $defaults = array(
    181                         'max_friends'   => 5,
     182                        'max_friends'   => 5,
    182183                        'friend_default' => 'active',
    183                         'link_title'     => false
     184                        'link_title'     => false,
    184185                );
    185                 $instance = wp_parse_args( (array) $instance, $defaults );
    186 
    187                 $max_friends    = $instance['max_friends'];
     186
     187                $instance       = wp_parse_args( (array) $instance, $defaults );
     188                $max_friends    = $instance['max_friends'];
    188189                $friend_default = $instance['friend_default'];
    189                 $link_title     = (bool) $instance['link_title'];
     190                $link_title     = (bool) $instance['link_title'];
    190191                ?>
    191192
    192193                <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>
    193194
    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>
    195196
    196197                <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>
    198199                        <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>
    202203                        </select>
    203204                </p>
    204 
    205205        <?php
    206206        }
Note: See TracChangeset for help on using the changeset viewer.