Skip to:
Content

BuddyPress.org

Ticket #7529: 7529.02.diff

File 7529.02.diff, 14.4 KB (added by dcavins, 7 years ago)

Use bp_parse_args() instead of wp_parse_args() to take advantage of context-aware filter points.

  • src/bp-groups/bp-groups-activity.php

    diff --git a/src/bp-groups/bp-groups-activity.php b/src/bp-groups/bp-groups-activity.php
    index 93be3ef74..b771cd90e 100644
    a b function groups_record_activity( $args = '' ) { 
    339339                }
    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(),
    345345                'action'            => '',
    function groups_record_activity( $args = '' ) { 
    352352                'recorded_time'     => bp_core_current_time(),
    353353                'hide_sitewide'     => $hide_sitewide,
    354354                'error_type'        => 'bool'
    355         ) );
     355        ), 'groups_record_activity' );
    356356
    357357        return bp_activity_add( $r );
    358358}
  • src/bp-groups/bp-groups-functions.php

    diff --git a/src/bp-groups/bp-groups-functions.php b/src/bp-groups/bp-groups-functions.php
    index edcdb538d..7ed75532f 100644
    a b function groups_get_group( $group_id ) { 
    4848         * Old-style arguments take the form of an array or a query string.
    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'];
    5858        }
    function groups_get_group( $group_id ) { 
    9797 */
    9898function groups_create_group( $args = '' ) {
    9999
    100         $defaults = array(
     100        $args = bp_parse_args( $args, array(
    101101                'group_id'     => 0,
    102102                'creator_id'   => 0,
    103103                'name'         => '',
    function groups_create_group( $args = '' ) { 
    107107                'parent_id'    => null,
    108108                'enable_forum' => null,
    109109                'date_created' => null
    110         );
     110        ), 'groups_create_group' );
    111111
    112         $args = wp_parse_args( $args, $defaults );
    113112        extract( $args, EXTR_SKIP );
    114113
    115114        // Pass an existing group ID.
    function groups_edit_base_group_details( $args = array() ) { 
    255254                $args = bp_core_parse_args_array( $old_args_keys, func_get_args() );
    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,
    261260                'slug'           => null,
    262261                'description'    => null,
    263262                'notify_members' => false,
    264         ) );
     263        ), 'groups_edit_base_group_details' );
    265264
    266265        if ( ! $r['group_id'] ) {
    267266                return false;
    function groups_get_group_members( $args = array() ) { 
    681680                $args = bp_core_parse_args_array( $old_args_keys, func_get_args() );
    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,
    687686                'page'                => false,
    function groups_get_group_members( $args = array() ) { 
    691690                'group_role'          => array(),
    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.
    697696        if ( apply_filters( 'bp_use_legacy_group_member_query', false, __FUNCTION__, func_get_args() ) ) {
    function groups_post_update( $args = '' ) { 
    12651264
    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
    12781275        if ( empty( $group_id ) && !empty( $bp->groups->current_group->id ) )
    function groups_get_invite_count_for_user( $user_id = 0 ) { 
    13941391 */
    13951392function groups_invite_user( $args = '' ) {
    13961393
    1397         $defaults = array(
     1394        $args = bp_parse_args( $args, array(
    13981395                'user_id'       => false,
    13991396                'group_id'      => false,
    14001397                'inviter_id'    => bp_loggedin_user_id(),
    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
    14081403        if ( ! $user_id || ! $group_id || ! $inviter_id ) {
  • src/bp-groups/bp-groups-template.php

    diff --git a/src/bp-groups/bp-groups-template.php b/src/bp-groups/bp-groups-template.php
    index a68967718..ab0591ec1 100644
    a b function bp_group_last_active( $group = false, $args = array() ) { 
    921921                        $group =& $groups_template->group;
    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;
    929929                if ( ! $last_active ) {
    function bp_group_date_created( $group = false, $args = array() ) { 
    13491349        function bp_get_group_date_created( $group = false, $args = array() ) {
    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 ) ) {
    13571357                        $group =& $groups_template->group;
    function bp_group_creator_avatar( $group = false, $args = array() ) { 
    15571557                        $group =& $groups_template->group;
    15581558                }
    15591559
    1560                 $defaults = array(
     1560                $r = bp_parse_args( $args, array(
    15611561                        'type'   => 'full',
    15621562                        'width'  => false,
    15631563                        'height' => false,
    15641564                        'class'  => 'avatar',
    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
    15721570                $avatar = bp_core_fetch_avatar( array( 'item_id' => $group->creator_id, 'type' => $type, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height, 'alt' => $alt ) );
    function bp_group_member_promote_mod_link( $args = '' ) { 
    24442442        function bp_get_group_member_promote_mod_link( $args = '' ) {
    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
    24552451                /**
    function bp_group_member_promote_admin_link( $args = '' ) { 
    24872483        function bp_get_group_member_promote_admin_link( $args = '' ) {
    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
    24982492                /**
    function bp_group_has_members( $args = '' ) { 
    36963690                $search_terms_default = stripslashes( $_REQUEST[ $search_query_arg ] );
    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,
    37023696                'per_page'            => 20,
    function bp_group_has_members( $args = '' ) { 
    37073701                'group_role'          => false,
    37083702                'search_terms'        => $search_terms_default,
    37093703                'type'                => 'last_joined',
    3710         ) );
     3704        ), 'group_has_members' );
    37113705
    37123706        /*
    37133707         * If an empty search_terms string has been passed,
    function bp_group_member_joined_since( $args = array() ) { 
    40824076        function bp_get_group_member_joined_since( $args = array() ) {
    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.
    40904084                // @todo Should the 'bp_get_group_member_joined_since' filter be applied here?
    function bp_new_group_invite_friend_list( $args = array() ) { 
    50215015                }
    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.
    50315025                if ( empty( $r['group_id'] ) ) {
    function bp_custom_group_fields() { 
    53735367function bp_group_has_membership_requests( $args = '' ) {
    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 );
    53865378
    function bp_group_requests_pagination_count() { 
    56225614function bp_group_has_invites( $args = '' ) {
    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'] ) ) {
    56335625                if ( groups_get_current_group() ) {
  • src/bp-groups/classes/class-bp-group-member-query.php

    diff --git a/src/bp-groups/classes/class-bp-group-member-query.php b/src/bp-groups/classes/class-bp-group-member-query.php
    index 4bdaf0345..d872810e3 100644
    a b class BP_Group_Member_Query extends BP_User_Query { 
    8787                // We loop through to make sure that defaults are set (though
    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' ),
    9393                        'is_confirmed' => true,
    9494                        'invite_sent'  => null,
    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();
    100100
  • src/bp-groups/classes/class-bp-groups-group-members-template.php

    diff --git a/src/bp-groups/classes/class-bp-groups-group-members-template.php b/src/bp-groups/classes/class-bp-groups-group-members-template.php
    index 8b25d7509..78df766b6 100644
    a b class BP_Groups_Group_Members_Template { 
    111111                        $args = bp_core_parse_args_array( $old_args_keys, func_get_args() );
    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,
    117117                        'per_page'            => 20,
    class BP_Groups_Group_Members_Template { 
    123123                        'group_role'          => false,
    124124                        'search_terms'        => false,
    125125                        'type'                => 'last_joined',
    126                 ) );
     126                ), 'group_members_template' );
    127127
    128128                $this->pag_arg  = sanitize_key( $r['page_arg'] );
    129129                $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $r['page']     );
  • src/bp-groups/classes/class-bp-groups-group.php

    diff --git a/src/bp-groups/classes/class-bp-groups-group.php b/src/bp-groups/classes/class-bp-groups-group.php
    index 795404495..0add64940 100644
    a b class BP_Groups_Group { 
    10841084                        'fields'             => 'all',
    10851085                );
    10861086
    1087                 $r = wp_parse_args( $args, $defaults );
     1087                $r = bp_parse_args( $args, $defaults, 'bp_groups_group_get' );
    10881088
    10891089                $bp = buddypress();
    10901090
  • src/bp-groups/classes/class-bp-groups-invite-template.php

    diff --git a/src/bp-groups/classes/class-bp-groups-invite-template.php b/src/bp-groups/classes/class-bp-groups-invite-template.php
    index 6498cd45c..0d16db855 100644
    a b class BP_Groups_Invite_Template { 
    9191                        $args = bp_core_parse_args_array( $old_args_keys, func_get_args() );
    9292                }
    9393
    94                 $r = wp_parse_args( $args, array(
     94                $r = bp_parse_args( $args, array(
    9595                        'page'     => 1,
    9696                        'per_page' => 10,
    9797                        'page_arg' => 'invitepage',
    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'] );
    103103                $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $r['page']     );
  • src/bp-groups/classes/class-bp-groups-membership-requests-template.php

    diff --git a/src/bp-groups/classes/class-bp-groups-membership-requests-template.php b/src/bp-groups/classes/class-bp-groups-membership-requests-template.php
    index b0a011a19..a98a18a85 100644
    a b class BP_Groups_Membership_Requests_Template { 
    9999                        $args = bp_core_parse_args_array( $old_args_keys, func_get_args() );
    100100                }
    101101
    102                 $r = wp_parse_args( $args, array(
     102                $r = bp_parse_args( $args, array(
    103103                        'page'     => 1,
    104104                        'per_page' => 10,
    105105                        'page_arg' => 'mrpage',
    106106                        'max'      => false,
    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'] );
    112112                $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $r['page']     );
  • src/bp-groups/classes/class-bp-groups-template.php

    diff --git a/src/bp-groups/classes/class-bp-groups-template.php b/src/bp-groups/classes/class-bp-groups-template.php
    index ba5e41284..bb14a840e 100644
    a b class BP_Groups_Template { 
    175175                        'update_admin_cache' => false,
    176176                );
    177177
    178                 $r = wp_parse_args( $args, $defaults );
     178                $r = bp_parse_args( $args, $defaults, 'groups_template' );
    179179                extract( $r );
    180180
    181181                $this->pag_arg  = sanitize_key( $r['page_arg'] );
  • src/bp-groups/classes/class-bp-groups-widget.php

    diff --git a/src/bp-groups/classes/class-bp-groups-widget.php b/src/bp-groups/classes/class-bp-groups-widget.php
    index 049ab3127..d18301fb4 100644
    a b class BP_Groups_Widget extends WP_Widget { 
    206206                        'group_default' => 'active',
    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'] );
    212212                $max_groups    = strip_tags( $instance['max_groups'] );