Skip to:
Content

BuddyPress.org

Changeset 11805


Ignore:
Timestamp:
01/10/2018 12:49:30 PM (9 years ago)
Author:
djpaul
Message:

Groups: use bp_parse_args() in low-level parts of the codebase.

These replace calls to wp_parse_args(). Our version supports a before/after filter, giving flexibility to third-party developers.

Fixes #7529

Props dcavins, espellcaste.

Location:
trunk/src/bp-groups
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-activity.php

    r11763 r11805  
    340340        }
    341341
    342         $r = wp_parse_args( $args, array(
     342        $r = bp_parse_args( $args, array(
    343343                'id'                => false,
    344344                'user_id'           => bp_loggedin_user_id(),
    … …  
    353353                'hide_sitewide'     => $hide_sitewide,
    354354                'error_type'        => 'bool'
    355         ) );
     355        ), 'groups_record_activity' );
    356356
    357357        return bp_activity_add( $r );
  • trunk/src/bp-groups/bp-groups-functions.php

    r11792 r11805  
    4949         */
    5050        if ( ! is_numeric( $group_id ) ) {
    51                 $r = wp_parse_args( $group_id, array(
     51                $r = bp_parse_args( $group_id, array(
    5252                        'group_id'        => false,
    5353                        'load_users'      => false,
    5454                        'populate_extras' => false,
    55                 ) );
     55                ), 'groups_get_group' );
    5656
    5757                $group_id = $r['group_id'];
    … …  
    9898function groups_create_group( $args = '' ) {
    9999
    100         $defaults = array(
     100        $args = bp_parse_args( $args, array(
    101101                'group_id'     => 0,
    102102                'creator_id'   => 0,
    … …  
    108108                'enable_forum' => null,
    109109                'date_created' => null
    110         );
    111 
    112         $args = wp_parse_args( $args, $defaults );
     110        ), 'groups_create_group' );
     111
    113112        extract( $args, EXTR_SKIP );
    114113
    … …  
    256255        }
    257256
    258         $r = wp_parse_args( $args, array(
     257        $r = bp_parse_args( $args, array(
    259258                'group_id'       => bp_get_current_group_id(),
    260259                'name'           => null,
    … …  
    262261                'description'    => null,
    263262                'notify_members' => false,
    264         ) );
     263        ), 'groups_edit_base_group_details' );
    265264
    266265        if ( ! $r['group_id'] ) {
    … …  
    682681        }
    683682
    684         $r = wp_parse_args( $args, array(
     683        $r = bp_parse_args( $args, array(
    685684                'group_id'            => bp_get_current_group_id(),
    686685                'per_page'            => false,
    … …  
    692691                'search_terms'        => false,
    693692                'type'                => 'last_joined',
    694         ) );
     693        ), 'groups_get_group_members' );
    695694
    696695        // For legacy users. Use of BP_Groups_Member::get_all_for_group() is deprecated.
    … …  
    12661265        $bp = buddypress();
    12671266
    1268         $defaults = array(
     1267        $r = bp_parse_args( $args, array(
    12691268                'content'    => false,
    12701269                'user_id'    => bp_loggedin_user_id(),
    12711270                'group_id'   => 0,
    12721271                'error_type' => 'bool'
    1273         );
    1274 
    1275         $r = wp_parse_args( $args, $defaults );
     1272        ), 'groups_post_update' );
    12761273        extract( $r, EXTR_SKIP );
    12771274
    … …  
    13951392function groups_invite_user( $args = '' ) {
    13961393
    1397         $defaults = array(
     1394        $args = bp_parse_args( $args, array(
    13981395                'user_id'       => false,
    13991396                'group_id'      => false,
    … …  
    14011398                'date_modified' => bp_core_current_time(),
    14021399                'is_confirmed'  => 0
    1403         );
    1404 
    1405         $args = wp_parse_args( $args, $defaults );
     1400        ), 'groups_invite_user' );
    14061401        extract( $args, EXTR_SKIP );
    14071402
  • trunk/src/bp-groups/bp-groups-template.php

    r11782 r11805  
    922922                }
    923923
    924                 $r = wp_parse_args( $args, array(
     924                $r = bp_parse_args( $args, array(
    925925                        'relative' => true,
    926                 ) );
     926                ), 'group_last_active' );
    927927
    928928                $last_active = $group->last_activity;
    … …  
    13501350                global $groups_template;
    13511351
    1352                 $r = wp_parse_args( $args, array(
     1352                $r = bp_parse_args( $args, array(
    13531353                        'relative' => true,
    1354                 ) );
     1354                ), 'group_date_created' );
    13551355
    13561356                if ( empty( $group ) ) {
    … …  
    15581558                }
    15591559
    1560                 $defaults = array(
     1560                $r = bp_parse_args( $args, array(
    15611561                        'type'   => 'full',
    15621562                        'width'  => false,
    … …  
    15651565                        'id'     => false,
    15661566                        'alt'    => sprintf( __( 'Group creator profile photo of %s', 'buddypress' ),  bp_core_get_user_displayname( $group->creator_id ) )
    1567                 );
    1568 
    1569                 $r = wp_parse_args( $args, $defaults );
     1567                ), 'group_creator_avatar' );
    15701568                extract( $r, EXTR_SKIP );
    15711569
    … …  
    24452443                global $members_template, $groups_template;
    24462444
    2447                 $defaults = array(
     2445                $r = bp_parse_args( $args, array(
    24482446                        'user_id' => $members_template->member->user_id,
    24492447                        'group'   => &$groups_template->group
    2450                 );
    2451 
    2452                 $r = wp_parse_args( $args, $defaults );
     2448                ), 'group_member_promote_mod_link' );
    24532449                extract( $r, EXTR_SKIP );
    24542450
    … …  
    24882484                global $members_template, $groups_template;
    24892485
    2490                 $defaults = array(
     2486                $r = bp_parse_args( $args, array(
    24912487                        'user_id' => !empty( $members_template->member->user_id ) ? $members_template->member->user_id : false,
    24922488                        'group'   => &$groups_template->group
    2493                 );
    2494 
    2495                 $r = wp_parse_args( $args, $defaults );
     2489                ), 'group_member_promote_admin_link' );
    24962490                extract( $r, EXTR_SKIP );
    24972491
    … …  
    36973691        }
    36983692
    3699         $r = wp_parse_args( $args, array(
     3693        $r = bp_parse_args( $args, array(
    37003694                'group_id'            => bp_get_current_group_id(),
    37013695                'page'                => 1,
    … …  
    37083702                'search_terms'        => $search_terms_default,
    37093703                'type'                => 'last_joined',
    3710         ) );
     3704        ), 'group_has_members' );
    37113705
    37123706        /*
    … …  
    40834077                global $members_template;
    40844078
    4085                 $r = wp_parse_args( $args, array(
     4079                $r = bp_parse_args( $args, array(
    40864080                        'relative' => true,
    4087                 ) );
     4081                ), 'group_member_joined_since' );
    40884082
    40894083                // We do not want relative time, so return now.
    … …  
    50225016
    50235017                // Parse arguments.
    5024                 $r = wp_parse_args( $args, array(
     5018                $r = bp_parse_args( $args, array(
    50255019                        'user_id'   => bp_loggedin_user_id(),
    50265020                        'group_id'  => false,
    50275021                        'separator' => 'li'
    5028                 ) );
     5022                ), 'group_invite_friend_list' );
    50295023
    50305024                // No group passed, so look for new or current group ID's.
    … …  
    53745368        global $requests_template;
    53755369
    5376         $defaults = array(
     5370        $r = bp_parse_args( $args, array(
    53775371                'group_id' => bp_get_current_group_id(),
    53785372                'per_page' => 10,
    53795373                'page'     => 1,
    53805374                'max'      => false
    5381         );
    5382 
    5383         $r = wp_parse_args( $args, $defaults );
     5375        ), 'group_has_membership_requests' );
    53845376
    53855377        $requests_template = new BP_Groups_Membership_Requests_Template( $r );
    … …  
    56235615        global $invites_template, $group_id;
    56245616
    5625         $r = wp_parse_args( $args, array(
     5617        $r = bp_parse_args( $args, array(
    56265618                'group_id' => false,
    56275619                'user_id'  => bp_loggedin_user_id(),
    56285620                'per_page' => false,
    56295621                'page'     => 1,
    5630         ) );
     5622        ), 'group_has_invites' );
    56315623
    56325624        if ( empty( $r['group_id'] ) ) {
  • trunk/src/bp-groups/classes/class-bp-group-member-query.php

    r11792 r11805  
    8888                // values passed to the constructor will, as usual, override
    8989                // these defaults).
    90                 $this->query_vars = wp_parse_args( $this->query_vars, array(
     90                $this->query_vars = bp_parse_args( $this->query_vars, array(
    9191                        'group_id'     => 0,
    9292                        'group_role'   => array( 'member' ),
    … …  
    9595                        'inviter_id'   => null,
    9696                        'type'         => 'last_joined',
    97                 ) );
     97                ), 'bp_group_member_query_get_include_ids' );
    9898
    9999                $group_member_ids = $this->get_group_member_ids();
  • trunk/src/bp-groups/classes/class-bp-groups-group-members-template.php

    r11363 r11805  
    112112                }
    113113
    114                 $r = wp_parse_args( $args, array(
     114                $r = bp_parse_args( $args, array(
    115115                        'group_id'            => bp_get_current_group_id(),
    116116                        'page'                => 1,
    … …  
    124124                        'search_terms'        => false,
    125125                        'type'                => 'last_joined',
    126                 ) );
     126                ), 'group_members_template' );
    127127
    128128                $this->pag_arg  = sanitize_key( $r['page_arg'] );
  • trunk/src/bp-groups/classes/class-bp-groups-group.php

    r11763 r11805  
    10851085                );
    10861086
    1087                 $r = wp_parse_args( $args, $defaults );
     1087                $r = bp_parse_args( $args, $defaults, 'bp_groups_group_get' );
    10881088
    10891089                $bp = buddypress();
  • trunk/src/bp-groups/classes/class-bp-groups-invite-template.php

    r11606 r11805  
    9292                }
    9393
    94                 $r = wp_parse_args( $args, array(
     94                $r = bp_parse_args( $args, array(
    9595                        'page'     => 1,
    9696                        'per_page' => 10,
    … …  
    9898                        'user_id'  => bp_loggedin_user_id(),
    9999                        'group_id' => bp_get_current_group_id(),
    100                 ) );
     100                ), 'groups_invite_template' );
    101101
    102102                $this->pag_arg  = sanitize_key( $r['page_arg'] );
  • trunk/src/bp-groups/classes/class-bp-groups-membership-requests-template.php

    r11363 r11805  
    100100                }
    101101
    102                 $r = wp_parse_args( $args, array(
     102                $r = bp_parse_args( $args, array(
    103103                        'page'     => 1,
    104104                        'per_page' => 10,
    … …  
    107107                        'type'     => 'first_joined',
    108108                        'group_id' => bp_get_current_group_id(),
    109                 ) );
     109                ), 'groups_membership_requests_template' );
    110110
    111111                $this->pag_arg  = sanitize_key( $r['page_arg'] );
  • trunk/src/bp-groups/classes/class-bp-groups-template.php

    r11383 r11805  
    176176                );
    177177
    178                 $r = wp_parse_args( $args, $defaults );
     178                $r = bp_parse_args( $args, $defaults, 'groups_template' );
    179179                extract( $r );
    180180
  • trunk/src/bp-groups/classes/class-bp-groups-widget.php

    r11564 r11805  
    207207                        'link_title'    => false
    208208                );
    209                 $instance = wp_parse_args( (array) $instance, $defaults );
     209                $instance = bp_parse_args( (array) $instance, $defaults, 'groups_widget_form' );
    210210
    211211                $title         = strip_tags( $instance['title'] );
Note: See TracChangeset for help on using the changeset viewer.