Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/12/2021 08:43:39 PM (4 years ago)
Author:
espellcaste
Message:

Update all references from wp_parse_args to bp_parse_args.

Also, add WPCS improvements to align bp_parse_args correctly.

Props imath
Fixes #8564

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/bp-members-template.php

    r13105 r13108  
    390390
    391391    // Type: active ( default ) | random | newest | popular | online | alphabetical.
    392     $r = bp_parse_args( $args, array(
    393         'type'                => 'active',
    394         'page'                => 1,
    395         'per_page'            => 20,
    396         'max'                 => false,
    397 
    398         'page_arg'            => 'upage',  // See https://buddypress.trac.wordpress.org/ticket/3679.
    399 
    400         'include'             => false,    // Pass a user_id or a list (comma-separated or array) of user_ids to only show these users.
    401         'exclude'             => false,    // Pass a user_id or a list (comma-separated or array) of user_ids to exclude these users.
    402         'user_ids'            => false,
    403 
    404         'user_id'             => $user_id, // Pass a user_id to only show friends of this user.
    405         'member_type'         => $member_type,
    406         'member_type__in'     => '',
    407         'member_type__not_in' => '',
    408         'search_terms'        => $search_terms_default,
    409 
    410         'meta_key'            => false,    // Only return users with this usermeta.
    411         'meta_value'          => false,    // Only return users where the usermeta value matches. Requires meta_key.
    412 
    413         'xprofile_query'      => false,
    414         'populate_extras'     => true      // Fetch usermeta? Friend count, last active etc.
    415     ), 'has_members' );
     392    $r = bp_parse_args(
     393        $args,
     394        array(
     395            'type'                => 'active',
     396            'page'                => 1,
     397            'per_page'            => 20,
     398            'max'                 => false,
     399
     400            'page_arg'            => 'upage',  // See https://buddypress.trac.wordpress.org/ticket/3679.
     401
     402            'include'             => false,    // Pass a user_id or a list (comma-separated or array) of user_ids to only show these users.
     403            'exclude'             => false,    // Pass a user_id or a list (comma-separated or array) of user_ids to exclude these users.
     404            'user_ids'            => false,
     405
     406            'user_id'             => $user_id, // Pass a user_id to only show friends of this user.
     407            'member_type'         => $member_type,
     408            'member_type__in'     => '',
     409            'member_type__not_in' => '',
     410            'search_terms'        => $search_terms_default,
     411
     412            'meta_key'            => false,    // Only return users with this usermeta.
     413            'meta_value'          => false,    // Only return users where the usermeta value matches. Requires meta_key.
     414
     415            'xprofile_query'      => false,
     416            'populate_extras'     => true,     // Fetch usermeta? Friend count, last active etc.
     417        ),
     418        'has_members'
     419    );
    416420
    417421    // Pass a filter if ?s= is set.
     
    843847            : $members_template->member->display_name;
    844848
    845         $r = wp_parse_args(
     849        $r = bp_parse_args(
    846850            $args,
    847851            array(
     
    903907        global $members_template;
    904908
     909        $permalink = bp_core_get_user_domain(
     910            $members_template->member->id,
     911            $members_template->member->user_nicename,
     912            $members_template->member->user_login
     913        );
     914
    905915        /**
    906916         * Filters the permalink for the current member in the loop.
     
    908918         * @since 1.2.0
    909919         *
    910          * @param string $value Permalink for the current member in the loop.
    911          */
    912         return apply_filters( 'bp_get_member_permalink', bp_core_get_user_domain( $members_template->member->id, $members_template->member->user_nicename, $members_template->member->user_login ) );
     920         * @param string $permalink Permalink for the current member in the loop.
     921         */
     922        return apply_filters( 'bp_get_member_permalink', $permalink );
    913923    }
    914924
     
    974984
    975985            foreach ( $name_stack as $source ) {
    976                 if ( !empty( $members_template->member->{$source} ) ) {
     986                if ( ! empty( $members_template->member->{$source} ) ) {
    977987                    // When a value is found, set it as fullname and be done with it.
    978988                    $members_template->member->fullname = $members_template->member->{$source};
     
    10271037
    10281038        // Parse the activity format.
    1029         $r = bp_parse_args( $args, array(
    1030             'active_format' => true,
    1031             'relative'      => true,
    1032         ) );
     1039        $r = bp_parse_args(
     1040            $args,
     1041            array(
     1042                'active_format' => true,
     1043                'relative'      => true,
     1044            )
     1045        );
    10331046
    10341047        // Backwards compatibility for anyone forcing a 'true' active_format.
     
    10971110        $defaults = array(
    10981111            'length'    => 225,
    1099             'view_link' => true
     1112            'view_link' => true,
    11001113        );
    11011114
    1102         $r = wp_parse_args( $args, $defaults );
     1115        $r = bp_parse_args(
     1116            $args,
     1117            $defaults
     1118        );
     1119
    11031120        extract( $r );
    11041121
     
    11951212        );
    11961213
    1197         $r = wp_parse_args( $args, $defaults );
     1214        $r = bp_parse_args(
     1215            $args,
     1216            $defaults
     1217        );
    11981218
    11991219        // If we're in a members loop, get the data from the global.
     
    12751295        global $members_template;
    12761296
    1277         $r = wp_parse_args( $args, array(
    1278             'relative' => true,
    1279         ) );
     1297        $r = bp_parse_args(
     1298            $args,
     1299            array(
     1300                'relative' => true,
     1301            )
     1302        );
    12801303
    12811304        // We do not want relative time, so return now.
     
    13861409         * @since 1.2.0
    13871410         *
    1388          * @param int $value Number-formatted total site member count.
     1411         * @param string $value Number-formatted total site member count.
    13891412         */
    13901413        return apply_filters( 'bp_get_total_site_member_count', bp_core_number_format( bp_core_get_total_member_count() ) );
     
    16361659    function bp_get_loggedin_user_avatar( $args = '' ) {
    16371660
    1638         $r = wp_parse_args( $args, array(
    1639             'item_id' => bp_loggedin_user_id(),
    1640             'type'    => 'thumb',
    1641             'width'   => false,
    1642             'height'  => false,
    1643             'html'    => true,
    1644             'alt'     => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_loggedin_user_fullname() )
    1645         ) );
     1661        $r = bp_parse_args(
     1662            $args,
     1663            array(
     1664                'item_id' => bp_loggedin_user_id(),
     1665                'type'    => 'thumb',
     1666                'width'   => false,
     1667                'height'  => false,
     1668                'html'    => true,
     1669                'alt'     => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_loggedin_user_fullname() )
     1670            )
     1671        );
    16461672
    16471673        /**
     
    16911717    function bp_get_displayed_user_avatar( $args = '' ) {
    16921718
    1693         $r = wp_parse_args( $args, array(
    1694             'item_id' => bp_displayed_user_id(),
    1695             'type'    => 'thumb',
    1696             'width'   => false,
    1697             'height'  => false,
    1698             'html'    => true,
    1699             'alt'     => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_displayed_user_fullname() )
    1700         ) );
     1719        $r = bp_parse_args(
     1720            $args,
     1721            array(
     1722                'item_id' => bp_displayed_user_id(),
     1723                'type'    => 'thumb',
     1724                'width'   => false,
     1725                'height'  => false,
     1726                'html'    => true,
     1727                'alt'     => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_displayed_user_fullname() )
     1728            )
     1729        );
    17011730
    17021731        /**
     
    22282257        $has_label = ! empty( $r['label'] );
    22292258
    2230         $labels = wp_parse_args(
     2259        $labels = bp_parse_args(
    22312260            $r['label'],
    22322261            array(
     
    23632392 * @since 1.5.0
    23642393 *
    2365  * @return boolean True if page and template exist, false if not.
     2394 * @return bool True if page and template exist, false if not.
    23662395 */
    23672396function bp_has_custom_activation_page() {
    23682397    static $has_page = false;
    23692398
    2370     if ( empty( $has_page ) )
     2399    if ( empty( $has_page ) ) {
    23712400        $has_page = bp_get_activate_slug() && bp_locate_template( array( 'registration/activate.php', 'members/activate.php', 'activate.php' ), false );
     2401    }
    23722402
    23732403    return (bool) $has_page;
     
    27532783     */
    27542784    function bp_get_current_signup_step() {
    2755         return buddypress()->signup->step;
     2785        return (string) buddypress()->signup->step;
    27562786    }
    27572787
     
    27882818    function bp_get_signup_avatar( $args = '' ) {
    27892819        $bp = buddypress();
    2790 
    2791         $defaults = array(
    2792             'size'  => bp_core_avatar_full_width(),
    2793             'class' => 'avatar',
    2794             'alt'   => __( 'Your Profile Photo', 'buddypress' ),
     2820        $r  = bp_parse_args(
     2821            $args,
     2822            array(
     2823                'size'  => bp_core_avatar_full_width(),
     2824                'class' => 'avatar',
     2825                'alt'   => __( 'Your Profile Photo', 'buddypress' ),
     2826            )
    27952827        );
    27962828
    2797         $r = wp_parse_args( $args, $defaults );
    27982829        extract( $r, EXTR_SKIP );
    27992830
     
    29302961     * @since 1.5.0
    29312962     *
     2963     * @global BuddyPress $bp The one true BuddyPress instance.
     2964     *
    29322965     * @param string       $component  ID of the component (eg 'friends').
    29332966     * @param string       $action     Optional. 'action' slug (eg 'invites').
     
    30373070 */
    30383071function bp_has_members_invitations( $args = '' ) {
     3072    $bp = buddypress();
    30393073
    30403074    // Get the user ID.
     
    30453079    }
    30463080
    3047     // Set the search terms (by default an empty string to get all notifications)
     3081    // Set the search terms (by default an empty string to get all notifications).
    30483082    $search_terms = '';
    30493083
     
    30533087
    30543088    // Parse the args.
    3055     $r = bp_parse_args( $args, array(
    3056         'id'                => false,
    3057         'inviter_id'        => $user_id,
    3058         'invitee_email'     => false,
    3059         'item_id'           => false,
    3060         'type'              => 'invite',
    3061         'invite_sent'       => 'all',
    3062         'accepted'          => 'pending',
    3063         'search_terms'      => $search_terms,
    3064         'order_by'          => 'date_modified',
    3065         'sort_order'        => 'DESC',
    3066         'page'              => 1,
    3067         'per_page'          => 25,
    3068         'fields'            => 'all',
    3069 
    3070         // These are additional arguments that are not available in
    3071         // BP_Invitations_Invitation::get().
    3072         'page_arg'          => 'ipage',
    3073     ), 'has_members_invitations' );
     3089    $r = bp_parse_args(
     3090        $args,
     3091        array(
     3092            'id'            => false,
     3093            'inviter_id'    => $user_id,
     3094            'invitee_email' => false,
     3095            'item_id'       => false,
     3096            'type'          => 'invite',
     3097            'invite_sent'   => 'all',
     3098            'accepted'      => 'pending',
     3099            'search_terms'  => $search_terms,
     3100            'order_by'      => 'date_modified',
     3101            'sort_order'    => 'DESC',
     3102            'page'          => 1,
     3103            'per_page'      => 25,
     3104            'fields'        => 'all',
     3105
     3106            // These are additional arguments that are not available in
     3107            // BP_Invitations_Invitation::get().
     3108            'page_arg'      => 'ipage',
     3109        ),
     3110        'has_members_invitations'
     3111    );
    30743112
    30753113    // Get the notifications.
     
    30773115
    30783116    // Setup the global query loop.
    3079     buddypress()->members->invitations->query_loop = $query_loop;
     3117    $bp->members->invitations->query_loop = $query_loop;
    30803118
    30813119    /**
     
    32883326
    32893327        // Parse.
    3290         $r = wp_parse_args( $args, array(
    3291             'before' => '',
    3292             'after'  => '',
    3293             'sep'    => ' | ',
    3294             'links'  => array(
    3295                 bp_get_the_members_invitation_resend_link( $inviter_id ),
    3296                 bp_get_the_members_invitation_delete_link( $inviter_id )
     3328        $r = bp_parse_args(
     3329            $args,
     3330            array(
     3331                'before' => '',
     3332                'after'  => '',
     3333                'sep'    => ' | ',
     3334                'links'  => array(
     3335                    bp_get_the_members_invitation_resend_link( $inviter_id ),
     3336                    bp_get_the_members_invitation_delete_link( $inviter_id )
     3337                )
    32973338            )
    3298         ) );
     3339        );
    32993340
    33003341        // Build the links.
Note: See TracChangeset for help on using the changeset viewer.