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-groups/bp-groups-functions.php

    r13107 r13108  
    4949     */
    5050    if ( ! is_numeric( $group_id ) ) {
    51         $r = bp_parse_args( $group_id, array(
    52             'group_id'        => false,
    53             'load_users'      => false,
    54             'populate_extras' => false,
    55         ), 'groups_get_group' );
     51        $r = bp_parse_args(
     52            $group_id,
     53            array(
     54                'group_id'        => false,
     55                'load_users'      => false,
     56                'populate_extras' => false,
     57            ),
     58            'groups_get_group'
     59        );
    5660
    5761        $group_id = $r['group_id'];
     
    176180function groups_create_group( $args = '' ) {
    177181
    178     $args = bp_parse_args( $args, array(
    179         'group_id'     => 0,
    180         'creator_id'   => 0,
    181         'name'         => '',
    182         'description'  => '',
    183         'slug'         => '',
    184         'status'       => null,
    185         'parent_id'    => null,
    186         'enable_forum' => null,
    187         'date_created' => null
    188     ), 'groups_create_group' );
     182    $args = bp_parse_args(
     183        $args,
     184        array(
     185            'group_id'     => 0,
     186            'creator_id'   => 0,
     187            'name'         => '',
     188            'description'  => '',
     189            'slug'         => '',
     190            'status'       => null,
     191            'parent_id'    => null,
     192            'enable_forum' => null,
     193            'date_created' => null,
     194        ),
     195        'groups_create_group'
     196    );
    189197
    190198    extract( $args, EXTR_SKIP );
     
    334342    }
    335343
    336     $r = bp_parse_args( $args, array(
    337         'group_id'       => bp_get_current_group_id(),
    338         'name'           => null,
    339         'slug'           => null,
    340         'description'    => null,
    341         'notify_members' => false,
    342     ), 'groups_edit_base_group_details' );
     344    $r = bp_parse_args(
     345        $args,
     346        array(
     347            'group_id'       => bp_get_current_group_id(),
     348            'name'           => null,
     349            'slug'           => null,
     350            'description'    => null,
     351            'notify_members' => false,
     352        ),
     353        'groups_edit_base_group_details'
     354    );
    343355
    344356    if ( ! $r['group_id'] ) {
     
    816828    }
    817829
    818     $r = bp_parse_args( $args, array(
    819         'group_id'            => bp_get_current_group_id(),
    820         'per_page'            => false,
    821         'page'                => false,
    822         'exclude_admins_mods' => true,
    823         'exclude_banned'      => true,
    824         'exclude'             => false,
    825         'group_role'          => array(),
    826         'search_terms'        => false,
    827         'type'                => 'last_joined',
    828     ), 'groups_get_group_members' );
     830    $r = bp_parse_args(
     831        $args,
     832        array(
     833            'group_id'            => bp_get_current_group_id(),
     834            'per_page'            => false,
     835            'page'                => false,
     836            'exclude_admins_mods' => true,
     837            'exclude_banned'      => true,
     838            'exclude'             => false,
     839            'group_role'          => array(),
     840            'search_terms'        => false,
     841            'type'                => 'last_joined',
     842        ),
     843        'groups_get_group_members'
     844    );
    829845
    830846    // For legacy users. Use of BP_Groups_Member::get_all_for_group() is deprecated.
     
    910926function groups_get_groups( $args = '' ) {
    911927
    912     $defaults = array(
    913         'type'               => false,          // Active, newest, alphabetical, random, popular.
    914         'order'              => 'DESC',         // 'ASC' or 'DESC'
    915         'orderby'            => 'date_created', // date_created, last_activity, total_member_count, name, random, meta_id.
    916         'user_id'            => false,          // Pass a user_id to limit to only groups that this user is a member of.
    917         'include'            => false,          // Only include these specific groups (group_ids).
    918         'exclude'            => false,          // Do not include these specific groups (group_ids).
    919         'parent_id'          => null,           // Get groups that are children of the specified group(s).
    920         'slug'               => array(),        // Find a group or groups by slug.
    921         'search_terms'       => false,          // Limit to groups that match these search terms.
    922         'search_columns'     => array(),        // Select which columns to search.
    923         'group_type'         => '',             // Array or comma-separated list of group types to limit results to.
    924         'group_type__in'     => '',             // Array or comma-separated list of group types to limit results to.
    925         'group_type__not_in' => '',             // Array or comma-separated list of group types that will be excluded from results.
    926         'meta_query'         => false,          // Filter by groupmeta. See WP_Meta_Query for syntax.
    927         'show_hidden'        => false,          // Show hidden groups to non-admins.
    928         'status'             => array(),        // Array or comma-separated list of group statuses to limit results to.
    929         'per_page'           => 20,             // The number of results to return per page.
    930         'page'               => 1,              // The page to return if limiting per page.
    931         'update_meta_cache'  => true,           // Pre-fetch groupmeta for queried groups.
    932         'update_admin_cache' => false,
    933         'fields'             => 'all',          // Return BP_Groups_Group objects or a list of ids.
     928    $r = bp_parse_args(
     929        $args,
     930        array(
     931            'type'               => false,          // Active, newest, alphabetical, random, popular.
     932            'order'              => 'DESC',         // 'ASC' or 'DESC'
     933            'orderby'            => 'date_created', // date_created, last_activity, total_member_count, name, random, meta_id.
     934            'user_id'            => false,          // Pass a user_id to limit to only groups that this user is a member of.
     935            'include'            => false,          // Only include these specific groups (group_ids).
     936            'exclude'            => false,          // Do not include these specific groups (group_ids).
     937            'parent_id'          => null,           // Get groups that are children of the specified group(s).
     938            'slug'               => array(),        // Find a group or groups by slug.
     939            'search_terms'       => false,          // Limit to groups that match these search terms.
     940            'search_columns'     => array(),        // Select which columns to search.
     941            'group_type'         => '',             // Array or comma-separated list of group types to limit results to.
     942            'group_type__in'     => '',             // Array or comma-separated list of group types to limit results to.
     943            'group_type__not_in' => '',             // Array or comma-separated list of group types that will be excluded from results.
     944            'meta_query'         => false,          // Filter by groupmeta. See WP_Meta_Query for syntax.
     945            'show_hidden'        => false,          // Show hidden groups to non-admins.
     946            'status'             => array(),        // Array or comma-separated list of group statuses to limit results to.
     947            'per_page'           => 20,             // The number of results to return per page.
     948            'page'               => 1,              // The page to return if limiting per page.
     949            'update_meta_cache'  => true,           // Pre-fetch groupmeta for queried groups.
     950            'update_admin_cache' => false,
     951            'fields'             => 'all',          // Return BP_Groups_Group objects or a list of ids.
     952        ),
     953        'groups_get_groups'
    934954    );
    935 
    936     $r = bp_parse_args( $args, $defaults, 'groups_get_groups' );
    937955
    938956    $groups = BP_Groups_Group::get( array(
     
    10521070 */
    10531071function bp_get_user_groups( $user_id, $args = array() ) {
    1054     $r = bp_parse_args( $args, array(
    1055         'is_confirmed' => true,
    1056         'is_banned'    => false,
    1057         'is_admin'     => false,
    1058         'is_mod'       => false,
    1059         'invite_sent'  => null,
    1060         'orderby'      => 'group_id',
    1061         'order'        => 'ASC',
    1062     ), 'get_user_groups' );
     1072    $r = bp_parse_args(
     1073        $args,
     1074        array(
     1075            'is_confirmed' => true,
     1076            'is_banned'    => false,
     1077            'is_admin'     => false,
     1078            'is_mod'       => false,
     1079            'invite_sent'  => null,
     1080            'orderby'      => 'group_id',
     1081            'order'        => 'ASC',
     1082        ),
     1083        'get_user_groups'
     1084    );
    10631085
    10641086    $user_id = intval( $user_id );
     
    15941616function groups_invite_user( $args = '' ) {
    15951617
    1596     $r = bp_parse_args( $args, array(
    1597         'user_id'       => false,
    1598         'group_id'      => false,
    1599         'inviter_id'    => bp_loggedin_user_id(),
    1600         'date_modified' => bp_core_current_time(),
    1601         'content'       => '',
    1602         'send_invite'   => 0
    1603     ), 'groups_invite_user' );
     1618    $r = bp_parse_args(
     1619        $args,
     1620        array(
     1621            'user_id'       => false,
     1622            'group_id'      => false,
     1623            'inviter_id'    => bp_loggedin_user_id(),
     1624            'date_modified' => bp_core_current_time(),
     1625            'content'       => '',
     1626            'send_invite'   => 0,
     1627        ),
     1628        'groups_invite_user'
     1629    );
    16041630
    16051631    $inv_args = array(
     
    16091635        'date_modified' => $r['date_modified'],
    16101636        'content'       => $r['content'],
    1611         'send_invite'   => $r['send_invite']
     1637        'send_invite'   => $r['send_invite'],
    16121638    );
    16131639
     
    17981824    }
    17991825
    1800     $r = bp_parse_args( $args, array(
    1801         'user_id'       => false,
    1802         'invitee_email' => '',
    1803         'group_id'      => 0,
    1804         'inviter_id'    => bp_loggedin_user_id(),
    1805         'force_resend'  => false,
    1806     ), 'groups_send_invitation' );
    1807 
     1826    $r = bp_parse_args(
     1827        $args,
     1828        array(
     1829            'user_id'       => false,
     1830            'invitee_email' => '',
     1831            'group_id'      => 0,
     1832            'inviter_id'    => bp_loggedin_user_id(),
     1833            'force_resend'  => false,
     1834        ),
     1835        'groups_send_invitation'
     1836    );
    18081837
    18091838    $args = array(
     
    21392168    }
    21402169
    2141     $r = bp_parse_args( $args, array(
    2142         'user_id'       => false,
    2143         'group_id'      => false,
    2144         'content'       => '',
    2145         'date_modified' => bp_core_current_time(),
    2146     ), 'groups_send_membership_request' );
     2170    $r = bp_parse_args(
     2171        $args,
     2172        array(
     2173            'user_id'       => false,
     2174            'group_id'      => false,
     2175            'content'       => '',
     2176            'date_modified' => bp_core_current_time(),
     2177        ),
     2178        'groups_send_membership_request'
     2179    );
    21472180
    21482181    $inv_args = array(
     
    28252858    }
    28262859
    2827     $r = bp_parse_args( $args, array(
    2828         'has_directory'         => false,
    2829         'show_in_create_screen' => false,
    2830         'show_in_list'          => null,
    2831         'description'           => '',
    2832         'create_screen_checked' => false,
    2833         'labels'                => array(),
    2834         'code'                  => true,
    2835         'db_id'                 => 0,
    2836     ), 'register_group_type' );
     2860    $r = bp_parse_args(
     2861        $args,
     2862        array(
     2863            'has_directory'         => false,
     2864            'show_in_create_screen' => false,
     2865            'show_in_list'          => null,
     2866            'description'           => '',
     2867            'create_screen_checked' => false,
     2868            'labels'                => array(),
     2869            'code'                  => true,
     2870            'db_id'                 => 0,
     2871        ),
     2872        'register_group_type'
     2873    );
    28372874
    28382875    $group_type = sanitize_key( $group_type );
Note: See TracChangeset for help on using the changeset viewer.