Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/08/2012 03:12:39 AM (14 years ago)
Author:
boonebgorges
Message:

Converts bp_has_groups() stack to accept parameters as an array.

Arguments passed in the old style are converted to an array automatically, for
backward compatibility.

See #3797

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-classes.php

    r6282 r6321  
    306306        }
    307307
    308         function get( $type = 'newest', $per_page = null, $page = null, $user_id = 0, $search_terms = false, $include = false, $populate_extras = true, $exclude = false, $show_hidden = false ) {
    309                 global $wpdb, $bp;
     308        function get( $args = array() ) {
     309                global $wpdb, $bp;
     310
     311                // Backward compatibility with old method of passing arguments
     312                if ( ! is_array( $args ) || func_num_args() > 1 ) {
     313                        _deprecated_argument( __METHOD__, '1.7', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) );
     314
     315                        $old_args_keys = array(
     316                                0 => 'type',
     317                                1 => 'per_page',
     318                                2 => 'page',
     319                                3 => 'user_id',
     320                                4 => 'search_terms',
     321                                5 => 'include',
     322                                6 => 'populate_extras',
     323                                7 => 'exclude',
     324                                8 => 'show_hidden',
     325                        );
     326
     327                        $func_args = func_get_args();
     328                        $args      = bp_core_parse_args_array( $old_args_keys, $func_args );
     329                }
     330
     331                $defaults = array(
     332                        'type'            => 'newest',
     333                        'per_page'        => null,
     334                        'page'            => null,
     335                        'user_id'         => 0,
     336                        'search_terms'    => false,
     337                        'include'         => false,
     338                        'populate_extras' => true,
     339                        'exclude'         => false,
     340                        'show_hidden'     => false
     341                );
     342
     343                $r = wp_parse_args( $args, $defaults );
     344                extract( $r );
    310345
    311346                $sql       = array();
Note: See TracChangeset for help on using the changeset viewer.