Skip to:
Content

BuddyPress.org

Changeset 8785


Ignore:
Timestamp:
08/10/2014 08:33:24 PM (11 years ago)
Author:
boonebgorges
Message:

Introduce bp_xprofile_get_groups() procedural wrapper for BP_XProfile_Group::get()

This wrapper includes a filter on the return values, so that plugin authors can
manipulate data programatically.

Also includes some documentation improvements, and implements new function
throughout BP.

See #5657

Props tw2113

Location:
trunk/src/bp-xprofile
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-xprofile/bp-xprofile-admin.php

    r8705 r8785  
    3737    $type = preg_replace( '|[^a-z]|i', '', $type );
    3838
    39     $groups = BP_XProfile_Group::get( array(
     39    $groups = bp_xprofile_get_groups( array(
    4040        'fetch_fields' => true
    4141    ) );
     
    288288                do_action( 'xprofile_fields_saved_field', $field );
    289289
    290                 $groups = BP_XProfile_Group::get();
     290                $groups = bp_xprofile_get_groups();
    291291                xprofile_admin( $message, $type );
    292292            }
  • trunk/src/bp-xprofile/bp-xprofile-classes.php

    r8672 r8785  
    109109     * @global BuddyPress $bp The one true BuddyPress instance
    110110     *
    111      * @param array $args Takes an array of parameters:
    112      *      'profile_group_id' - Limit results to a single profile group
    113      *      'user_id' - Required if you want to load a specific user's data
    114      *      'hide_empty_groups' - Hide groups without any fields
    115      *      'hide_empty_fields' - Hide fields where the user has not provided data
    116      *      'fetch_fields' - Load each group's fields
    117      *      'fetch_field_data' - Load each field's data. Requires a user_id
    118      *      'exclude_groups' - Comma-separated list of groups to exclude
    119      *      'exclude_fields' - Comma-separated list of fields to exclude
    120      *      'update_meta_cache' - Whether to pre-fetch xprofilemeta
    121      *         for all retrieved groups, fields, and data
    122      *
     111     * @param array $args {
     112     *  Array of optional arguments:
     113     *  @type int $profile_group_id Limit results to a single profile
     114     *        group.
     115     *      @type int $user_id Required if you want to load a specific
     116     *            user's data. Default: displayed user's ID.
     117     *      @type bool $hide_empty_groups True to hide groups that don't
     118     *            have any fields. Default: false.
     119     *  @type bool $hide_empty_fields True to hide fields where the
     120     *        user has not provided data. Default: false.
     121     *      @type bool $fetch_fields Whether to fetch each group's fields.
     122     *            Default: false.
     123     *      @type bool $fetch_field_data Whether to fetch data for each
     124     *            field. Requires a $user_id. Default: false.
     125     *      @type array $exclude_groups Comma-separated list or array of
     126     *            group IDs to exclude.
     127     *      @type array $exclude_fields Comma-separated list or array of
     128     *            field IDs to exclude.
     129     *      @type bool $update_meta_cache Whether to pre-fetch xprofilemeta
     130     *            for all retrieved groups, fields, and data. Default: true.
     131     * }
    123132     * @return array $groups
    124133     */
     
    12241233        global $wpdb, $bp;
    12251234
    1226         $groups = BP_XProfile_Group::get( array(
     1235        $groups = bp_xprofile_get_groups( array(
    12271236            'user_id'                => $user_id,
    12281237            'hide_empty_groups'      => true,
  • trunk/src/bp-xprofile/bp-xprofile-functions.php

    r8753 r8785  
    1717
    1818/*** Field Group Management **************************************************/
     19
     20/**
     21 * Fetch a set of field groups, populated with fields and field data.
     22 *
     23 * Procedural wrapper for BP_XProfile_Group::get() method.
     24 *
     25 * @since BuddyPress (2.1.0)
     26 *
     27 * @param array $args See {@link BP_XProfile_Group::get()} for description of
     28 *        arguments.
     29 * @return array $groups
     30 */
     31function bp_xprofile_get_groups( $args = array() ) {
     32
     33    $groups = BP_XProfile_Group::get( $args );
     34
     35    return apply_filters( 'bp_xprofile_get_groups', $groups, $args );
     36}
    1937
    2038function xprofile_insert_field_group( $args = '' ) {
  • trunk/src/bp-xprofile/bp-xprofile-template.php

    r8688 r8785  
    2626
    2727    function __construct( $user_id, $profile_group_id, $hide_empty_groups = false, $fetch_fields = false, $fetch_field_data = false, $exclude_groups = false, $exclude_fields = false, $hide_empty_fields = false, $fetch_visibility_level = false, $update_meta_cache = true ) {
    28         $this->groups = BP_XProfile_Group::get( array(
     28        $this->groups = bp_xprofile_get_groups( array(
    2929            'profile_group_id'    => $profile_group_id,
    3030            'user_id'             => $user_id,
     
    601601
    602602    if ( empty( $groups ) ) {
    603         $groups = BP_XProfile_Group::get( array( 'fetch_fields' => true ) );
     603        $groups = bp_xprofile_get_groups( array( 'fetch_fields' => true ) );
    604604        wp_cache_set( 'xprofile_groups_inc_empty', $groups, 'bp' );
    605605    }
Note: See TracChangeset for help on using the changeset viewer.