Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/01/2015 04:18:13 AM (9 years ago)
Author:
tw2113
Message:

First pass of documentation cleanup for the XProfile Component.

See #6406.

File:
1 edited

Legend:

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

    r10140 r10163  
    116116     * @since 2.4.0 Introduced `$member_type` argument.
    117117     *
    118      * @param array $args {
     118     * @param array|string $args {
    119119     *     An array of arguments. All items are optional.
    120120     *
     
    134134    public function __construct( $args = '' ) {
    135135
    136         // Backward compatibility with old method of passing arguments
     136        // Backward compatibility with old method of passing arguments.
    137137        if ( ! is_array( $args ) || func_num_args() > 1 ) {
    138138            _deprecated_argument( __METHOD__, '2.3.0', 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__ ) );
     
    224224            do_action( 'xprofile_template_loop_end' );
    225225
    226             // Do some cleaning up after the loop
     226            // Do some cleaning up after the loop.
    227227            $this->rewind_groups();
    228228        }
     
    238238        $group = $this->next_group();
    239239
    240         // loop has just started
     240        // Loop has just started.
    241241        if ( 0 === $this->current_group ) {
    242242
     
    285285            return true;
    286286        } elseif ( $this->current_field + 1 == $this->field_count ) {
    287             // Do some cleaning up after the loop
     287            // Do some cleaning up after the loop.
    288288            $this->rewind_fields();
    289289        }
     
    297297        $field = $this->next_field();
    298298
    299         // Valid field values of 0 or '0' get caught by empty(), so we have an extra check for these. See #BP5731
     299        // Valid field values of 0 or '0' get caught by empty(), so we have an extra check for these. See #BP5731.
    300300        if ( ! empty( $field->data ) && ( ! empty( $field->data->value ) || ( '0' === $field->data->value ) ) ) {
    301301            $value = maybe_unserialize( $field->data->value );
     
    313313
    314314/**
    315  * Query for XProfile groups and fields
     315 * Query for XProfile groups and fields.
    316316 *
    317317 * @since 1.0.0
     
    320320 * @see BP_XProfile_Group::get() for full description of `$args` array.
    321321 *
    322  * @param array $args {
     322 * @param array|string $args {
    323323 *     Array of arguments. See BP_XProfile_Group::get() for full description. Those arguments whose defaults differ
    324324 *     from that method are described here:
     
    339339
    340340    // Only show empty fields if we're on the Dashboard, or we're on a user's
    341     // profile edit page, or this is a registration page
     341    // profile edit page, or this is a registration page.
    342342    $hide_empty_fields_default = ( ! is_network_admin() && ! is_admin() && ! bp_is_user_profile_edit() && ! bp_is_register_page() );
    343343
    344     // We only need to fetch visibility levels when viewing your own profile
     344    // We only need to fetch visibility levels when viewing your own profile.
    345345    if ( bp_is_my_profile() || bp_current_user_can( 'bp_moderate' ) || bp_is_register_page() ) {
    346346        $fetch_visibility_level_default = true;
     
    349349    }
    350350
    351     // Parse arguments
     351    // Parse arguments.
    352352    $r = bp_parse_args( $args, array(
    353353        'user_id'                => bp_displayed_user_id(),
     
    359359        'fetch_field_data'       => true,
    360360        'fetch_visibility_level' => $fetch_visibility_level_default,
    361         'exclude_groups'         => false, // Comma-separated list of profile field group IDs to exclude
    362         'exclude_fields'         => false, // Comma-separated list of profile field IDs to exclude
     361        'exclude_groups'         => false, // Comma-separated list of profile field group IDs to exclude.
     362        'exclude_fields'         => false, // Comma-separated list of profile field IDs to exclude.
    363363        'update_meta_cache'      => true,
    364364    ), 'has_profile' );
    365365
    366     // Populate the template loop global
     366    // Populate the template loop global.
    367367    $profile_template = new BP_XProfile_Data_Template( $r );
    368368
     
    405405        }
    406406
    407         // Set a class with the field ID
     407        // Set a class with the field ID.
    408408        $css_classes[] = 'field_' . $profile_template->field->id;
    409409
    410         // Set a class with the field name (sanitized)
     410        // Set a class with the field name (sanitized).
    411411        $css_classes[] = 'field_' . sanitize_title( $profile_template->field->name );
    412412
    413         // Set a class indicating whether the field is required or optional
     413        // Set a class indicating whether the field is required or optional.
    414414        if ( ! empty( $profile_template->field->is_required ) ) {
    415415            $css_classes[] = 'required-field';
     
    418418        }
    419419
    420         // Add the field visibility level
     420        // Add the field visibility level.
    421421        $css_classes[] = 'visibility-' . esc_attr( bp_get_the_profile_field_visibility_level() );
    422422
     
    531531        global $group;
    532532
    533         // Build the form action URL
     533        // Build the form action URL.
    534534        $form_action = trailingslashit( bp_displayed_user_domain() . bp_get_profile_slug() . '/edit/group/' . $group->id );
    535535
     
    750750
    751751/**
    752  * Returns the action name for any signup errors related to this profile field
     752 * Returns the action name for any signup errors related to this profile field.
    753753 *
    754754 * In the registration templates, signup errors are pulled from the global
     
    759759 *
    760760 * @since 1.8.0
    761  * @return string The _errors action name corresponding to this profile field
     761 *
     762 * @return string The _errors action name corresponding to this profile field.
    762763 */
    763764function bp_get_the_profile_field_errors_action() {
     
    767768
    768769/**
    769  * bp_the_profile_field_options()
    770  *
    771770 * Displays field options HTML for field types of 'selectbox', 'multiselectbox',
    772771 * 'radio', 'checkbox', and 'datebox'.
    773772 *
    774  * @package BuddyPress Xprofile
    775773 * @since 1.1.0
    776774 *
     
    783781}
    784782    /**
    785      * bp_get_the_profile_field_options()
    786      *
    787783     * Retrieves field options HTML for field types of 'selectbox', 'multiselectbox', 'radio', 'checkbox', and 'datebox'.
    788784     *
    789      * @package BuddyPress Xprofile
    790785     * @since 1.1.0
    791786     *
     
    795790     * @param array $args {
    796791     *     Array of optional arguments.
    797      *     @type string|bool $type Type of datebox. False if it's not a
    798      *           datebox, otherwise 'day, 'month', or 'year'. Default: false.
    799      *     @type int $user_id ID of the user whose profile values should be
    800      *           used when rendering options. Default: displayed user.
     792     *     @type string|bool $type    Type of datebox. False if it's not a
     793     *                                datebox, otherwise 'day, 'month', or 'year'. Default: false.
     794     *     @type int         $user_id ID of the user whose profile values should be
     795     *                                used when rendering options. Default: displayed user.
    801796     * }
     797     *
     798     * @return string $vaue Field options markup.
    802799     */
    803800    function bp_get_the_profile_field_options( $args = array() ) {
     
    839836        global $field;
    840837
    841         // Define locale variable(s)
     838        // Define locale variable(s).
    842839        $retval = false;
    843840
    844         // Super admins can skip required check
     841        // Super admins can skip required check.
    845842        if ( bp_current_user_can( 'bp_moderate' ) && !is_admin() ) {
    846843            $retval = false;
    847844
    848         // All other users will use the field's setting
     845        // All other users will use the field's setting.
    849846        } elseif ( isset( $field->is_required ) ) {
    850847            $retval = $field->is_required;
     
    862859
    863860/**
    864  * Echo the visibility level of this field
     861 * Echo the visibility level of this field.
    865862 */
    866863function bp_the_profile_field_visibility_level() {
     
    868865}
    869866    /**
    870      * Return the visibility level of this field
     867     * Return the visibility level of this field.
    871868     */
    872869    function bp_get_the_profile_field_visibility_level() {
     
    875872        // On the registration page, values stored in POST should take
    876873        // precedence over default visibility, so that submitted values
    877         // are not lost on failure
     874        // are not lost on failure.
    878875        if ( bp_is_register_page() && ! empty( $_POST['field_' . $field->id . '_visibility'] ) ) {
    879876            $retval = esc_attr( $_POST['field_' . $field->id . '_visibility'] );
     
    893890
    894891/**
    895  * Echo the visibility level label of this field
     892 * Echo the visibility level label of this field.
    896893 */
    897894function bp_the_profile_field_visibility_level_label() {
     
    899896}
    900897    /**
    901      * Return the visibility level label of this field
     898     * Return the visibility level label of this field.
    902899     */
    903900    function bp_get_the_profile_field_visibility_level_label() {
     
    906903        // On the registration page, values stored in POST should take
    907904        // precedence over default visibility, so that submitted values
    908         // are not lost on failure
     905        // are not lost on failure.
    909906        if ( bp_is_register_page() && ! empty( $_POST['field_' . $field->id . '_visibility'] ) ) {
    910907            $level = esc_html( $_POST['field_' . $field->id . '_visibility'] );
     
    959956 * Get all profile field groups.
    960957 *
    961  * @since  2.1.0
     958 * @since 2.1.0
    962959 *
    963960 * @return object $groups
     
    984981 * Check if there is more than one group of fields for the profile being edited.
    985982 *
    986  * @since  2.1.0
     983 * @since 2.1.0
    987984 *
    988985 * @return bool True if there is more than one profile field group.
     
    10051002 *
    10061003 * @since 1.0.0
    1007  *
    1008  * @return string Field group tabs markup.
    10091004 */
    10101005function bp_profile_group_tabs() {
     
    10211016
    10221017/**
    1023  * Return the XProfile group tabs
     1018 * Return the XProfile group tabs.
    10241019 *
    10251020 * @since 2.3.0
     
    10291024function bp_get_profile_group_tabs() {
    10301025
    1031     // Get field group data
     1026    // Get field group data.
    10321027    $groups     = bp_profile_get_field_groups();
    10331028    $group_name = bp_get_profile_group_name();
    10341029    $tabs       = array();
    10351030
    1036     // Loop through field groups and put a tab-lst together
     1031    // Loop through field groups and put a tab-lst together.
    10371032    for ( $i = 0, $count = count( $groups ); $i < $count; ++$i ) {
    10381033
    1039         // Setup the selected class
     1034        // Setup the selected class.
    10401035        $selected = '';
    10411036        if ( $group_name === $groups[ $i ]->name ) {
     
    10431038        }
    10441039
    1045         // Skip if group has no fields
     1040        // Skip if group has no fields.
    10461041        if ( empty( $groups[ $i ]->fields ) ) {
    10471042            continue;
    10481043        }
    10491044
    1050         // Build the profile field group link
     1045        // Build the profile field group link.
    10511046        $link   = trailingslashit( bp_displayed_user_domain() . bp_get_profile_slug() . '/edit/group/' . $groups[ $i ]->id );
    10521047
    1053         // Add tab to end of tabs array
     1048        // Add tab to end of tabs array.
    10541049        $tabs[] = sprintf(
    10551050            '<li %1$s><a href="%2$s">%3$s</a></li>',
     
    10831078    function bp_get_profile_group_name() {
    10841079
    1085         // Check action variable
     1080        // Check action variable.
    10861081        $group_id = bp_action_variable( 1 );
    10871082        if ( empty( $group_id ) || ! is_numeric( $group_id ) ) {
     
    10891084        }
    10901085
    1091         // Check for cached group
     1086        // Check for cached group.
    10921087        $group = new BP_XProfile_Group( $group_id );
    10931088
     
    11431138         * Filters the current profile group ID.
    11441139         *
    1145          * Possible values are admin/profile/edit/[group-id]
     1140         * Possible values are admin/profile/edit/[group-id].
    11461141         *
    11471142         * @since 1.1.0
     
    11831178
    11841179/**
    1185  * Echo the field visibility radio buttons
     1180 * Echo the field visibility radio buttons.
     1181 *
     1182 * @param array|string $args Args for the radio buttons.
    11861183 */
    11871184function bp_profile_visibility_radio_buttons( $args = '' ) {
     
    11891186}
    11901187    /**
    1191      * Return the field visibility radio buttons
     1188     * Return the field visibility radio buttons.
     1189     *
     1190     * @param array|string $args Args for the radio buttons.
     1191     *
     1192     * @return string $retval
    11921193     */
    11931194    function bp_profile_get_visibility_radio_buttons( $args = '' ) {
    11941195
    1195         // Parse optional arguments
     1196        // Parse optional arguments.
    11961197        $r = bp_parse_args( $args, array(
    11971198            'field_id'     => bp_get_the_profile_field_id(),
     
    12031204        ), 'xprofile_visibility_radio_buttons' );
    12041205
    1205         // Empty return value, filled in below if a valid field ID is found
     1206        // Empty return value, filled in below if a valid field ID is found.
    12061207        $retval = '';
    12071208
    1208         // Only do-the-do if there's a valid field ID
     1209        // Only do-the-do if there's a valid field ID.
    12091210        if ( ! empty( $r['field_id'] ) ) :
    12101211
    1211             // Start the output buffer
     1212            // Start the output buffer.
    12121213            ob_start();
    12131214
    1214             // Output anything before
     1215            // Output anything before.
    12151216            echo $r['before']; ?>
    12161217
     
    12321233            <?php endif;
    12331234
    1234             // Output anything after
     1235            // Output anything after.
    12351236            echo $r['after'];
    12361237
    1237             // Get the output buffer and empty it
     1238            // Get the output buffer and empty it.
    12381239            $retval = ob_get_clean();
    12391240        endif;
     
    12521253
    12531254/**
    1254  * Output the XProfile field visibility select list for settings
     1255 * Output the XProfile field visibility select list for settings.
    12551256 *
    12561257 * @since 2.0.0
     1258 *
     1259 * @param array|string $args Args for the select list.
    12571260 */
    12581261function bp_profile_settings_visibility_select( $args = '' ) {
     
    12601263}
    12611264    /**
    1262      * Return the XProfile field visibility select list for settings
     1265     * Return the XProfile field visibility select list for settings.
    12631266     *
    12641267     * @since 2.0.0
     1268     *
     1269     * @param array|string $args Args for the select list.
     1270     *
     1271     * @return string $retval
    12651272     */
    12661273    function bp_profile_get_settings_visibility_select( $args = '' ) {
    12671274
    1268         // Parse optional arguments
     1275        // Parse optional arguments.
    12691276        $r = bp_parse_args( $args, array(
    12701277            'field_id' => bp_get_the_profile_field_id(),
     
    12741281        ), 'xprofile_settings_visibility_select' );
    12751282
    1276         // Empty return value, filled in below if a valid field ID is found
     1283        // Empty return value, filled in below if a valid field ID is found.
    12771284        $retval = '';
    12781285
    1279         // Only do-the-do if there's a valid field ID
     1286        // Only do-the-do if there's a valid field ID.
    12801287        if ( ! empty( $r['field_id'] ) ) :
    12811288
    1282             // Start the output buffer
     1289            // Start the output buffer.
    12831290            ob_start();
    12841291
    1285             // Output anything before
     1292            // Output anything before.
    12861293            echo $r['before']; ?>
    12871294
     
    13051312            <?php endif;
    13061313
    1307             // Output anything after
     1314            // Output anything after.
    13081315            echo $r['after'];
    13091316
    1310             // Get the output buffer and empty it
     1317            // Get the output buffer and empty it.
    13111318            $retval = ob_get_clean();
    13121319        endif;
Note: See TracChangeset for help on using the changeset viewer.