Skip to:
Content

BuddyPress.org

Changeset 9299


Ignore:
Timestamp:
01/06/2015 03:14:59 AM (12 years ago)
Author:
tw2113
Message:

Adds hooks documentation to bp-xprofile-template.php.

See #5949.

File:
1 edited

Legend:

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

    r8971 r9299  
    5757
    5858                if( ! empty( $this->group->fields ) ) {
     59
     60                        /**
     61                         * Filters the group fields for the next_group method.
     62                         *
     63                         * @since BuddyPress (1.1.0)
     64                         *
     65                         * @param array $fields Array of fields for the group.
     66                         * @param int   $id     ID of the field group.
     67                         */
    5968                        $this->group->fields = apply_filters( 'xprofile_group_fields', $this->group->fields, $this->group->id );
    6069                        $this->field_count   = count( $this->group->fields );
    … …  
    7584                        return true;
    7685                } elseif ( $this->current_group + 1 == $this->group_count ) {
     86
     87                        /**
     88                         * Fires right before the rewinding of profile groups.
     89                         *
     90                         * @since BuddyPress (1.1.0)
     91                         */
    7792                        do_action('xprofile_template_loop_end');
    7893                        // Do some cleaning up after the loop
    … …  
    91106
    92107                if ( 0 == $this->current_group ) // loop has just started
     108
     109                        /**
     110                         * Fires if the current group is the first in the loop.
     111                         *
     112                         * @since BuddyPress (1.1.0)
     113                         */
    93114                        do_action('xprofile_template_loop_start');
    94115        }
    … …  
    189210
    190211        $profile_template = new BP_XProfile_Data_Template( $user_id, $profile_group_id, $hide_empty_groups, $fetch_fields, $fetch_field_data, $exclude_groups, $exclude_fields, $hide_empty_fields, $fetch_visibility_level, $update_meta_cache );
     212
     213        /**
     214         * Filters whether or not a group has a profile to display.
     215         *
     216         * @since BuddyPress (1.1.0)
     217         *
     218         * @param bool   $has_groups       Whether or not there are group profiles to display.
     219         * @param string $profile_template Current profile template being used.
     220         */
    191221        return apply_filters( 'bp_has_profile', $profile_template->has_groups(), $profile_template );
    192222}
    … …  
    238268
    239269                $css_classes[] = 'field_type_' . sanitize_title( $profile_template->field->type );
     270
     271                /**
     272                 * Filters the field classes to be applied to a field.
     273                 *
     274                 * @since BuddyPress (1.1.0)
     275                 *
     276                 * @parm array $css_classes Array of classes to be applied to field. Passed by reference.
     277                 */
    240278                $css_classes = apply_filters_ref_array( 'bp_field_css_classes', array( &$css_classes ) );
    241279
     280                /**
     281                 * Filters the class HTML attribute to be used on a field.
     282                 *
     283                 * @since BuddyPress (1.1.0)
     284                 *
     285                 * @param string $value class HTML attribute with imploded classes.
     286                 */
    242287                return apply_filters( 'bp_get_field_css_class', ' class="' . implode( ' ', $css_classes ) . '"' );
    243288        }
    … …  
    262307        function bp_get_the_profile_group_id() {
    263308                global $group;
     309
     310                /**
     311                 * Filters the profile group ID.
     312                 *
     313                 * @since BuddyPress (1.1.0)
     314                 *
     315                 * @param int $id ID for the profile group.
     316                 */
    264317                return apply_filters( 'bp_get_the_profile_group_id', $group->id );
    265318        }
    … …  
    270323        function bp_get_the_profile_group_name() {
    271324                global $group;
     325
     326                /**
     327                 * Filters the profile group name.
     328                 *
     329                 * @since BuddyPress (1.0.0)
     330                 *
     331                 * @param string $name Name for the profile group.
     332                 */
    272333                return apply_filters( 'bp_get_the_profile_group_name', $group->name );
    273334        }
    … …  
    278339        function bp_get_the_profile_group_slug() {
    279340                global $group;
     341
     342                /**
     343                 * Filters the profile group slug.
     344                 *
     345                 * @since BuddyPress (1.1.0)
     346                 *
     347                 * @param string $value Slug for the profile group.
     348                 */
    280349                return apply_filters( 'bp_get_the_profile_group_slug', sanitize_title( $group->name ) );
    281350        }
    … …  
    286355        function bp_get_the_profile_group_description() {
    287356                global $group;
     357
     358                /**
     359                 * Filters the profile group description.
     360                 *
     361                 * @since BuddyPress (1.0.0)
     362                 *
     363                 * @param string $description Description for the profile group.
     364                 */
    288365                return apply_filters( 'bp_get_the_profile_group_description', $group->description );
    289366        }
    … …  
    295372                global $bp, $group;
    296373
     374                /**
     375                 * Filters the action for the profile group edit form.
     376                 *
     377                 * @since BuddyPress (1.1.0)
     378                 *
     379                 * @param string $value URL for the action attribute on the
     380                 *                      profile group edit form.
     381                 */
    297382                return apply_filters( 'bp_get_the_profile_group_edit_form_action', trailingslashit( bp_displayed_user_domain() . $bp->profile->slug . '/edit/group/' . $group->id ) );
    298383        }
    … …  
    342427                $field_ids = implode( ',', wp_parse_id_list( $field_ids ) );
    343428
     429                /**
     430                 * Filters the comma-separated list of field IDs.
     431                 *
     432                 * @since BuddyPress (2.1.0)
     433                 *
     434                 * @param string $field_ids Comma-separated field IDs.
     435                 */
    344436                return apply_filters( 'bp_get_the_profile_field_ids', $field_ids );
    345437        }
    … …  
    360452        function bp_get_the_profile_field_id() {
    361453                global $field;
     454
     455                /**
     456                 * Filters the profile field ID.
     457                 *
     458                 * @since BuddyPress (1.1.0)
     459                 *
     460                 * @param int $id ID for the profile field.
     461                 */
    362462                return apply_filters( 'bp_get_the_profile_field_id', $field->id );
    363463        }
    … …  
    369469                global $field;
    370470
     471                /**
     472                 * Filters the profile field name.
     473                 *
     474                 * @since BuddyPress (1.0.0)
     475                 *
     476                 * @param string $name Name for the profile field.
     477                 */
    371478                return apply_filters( 'bp_get_the_profile_field_name', $field->name );
    372479        }
    … …  
    380487                $field->data->value = bp_unserialize_profile_field( $field->data->value );
    381488
     489                /**
     490                 * Filters the profile field value.
     491                 *
     492                 * @since BuddyPress (1.0.0)
     493                 *
     494                 * @param string $value Value for the profile field.
     495                 * @param string $type  Type for the profile field.
     496                 * @param int    $id    ID for the profile field.
     497                 */
    382498                return apply_filters( 'bp_get_the_profile_field_value', $field->data->value, $field->type, $field->id );
    383499        }
    … …  
    410526                $field_value = isset( $field->data->value ) ? bp_unserialize_profile_field( $field->data->value ) : '';
    411527
     528                /**
     529                 * Filters the profile field edit value.
     530                 *
     531                 * @since BuddyPress (1.1.0)
     532                 *
     533                 * @param string $field_value Current field edit value.
     534                 * @param string $type        Type for the profile field.
     535                 * @param int    $id          ID for the profile field.
     536                 */
    412537                return apply_filters( 'bp_get_the_profile_field_edit_value', $field_value, $field->type, $field->id );
    413538        }
    … …  
    419544                global $field;
    420545
     546                /**
     547                 * Filters the profile field type.
     548                 *
     549                 * @since BuddyPress (1.1.0)
     550                 *
     551                 * @param string $type Type for the profile field.
     552                 */
    421553                return apply_filters( 'bp_the_profile_field_type', $field->type );
    422554        }
    … …  
    428560                global $field;
    429561
     562                /**
     563                 * Filters the profile field description.
     564                 *
     565                 * @since BuddyPress (1.1.0)
     566                 *
     567                 * @param string $description Description for the profile field.
     568                 */
    430569                return apply_filters( 'bp_get_the_profile_field_description', $field->description );
    431570        }
    … …  
    437576                global $field;
    438577
     578                /**
     579                 * Filters the profile field input name.
     580                 *
     581                 * @since BuddyPress (1.1.0)
     582                 *
     583                 * @param string $value Value used for the name attribute on an input.
     584                 */
    439585                return apply_filters( 'bp_get_the_profile_field_input_name', 'field_' . $field->id );
    440586        }
    … …  
    449595 *   do_action( bp_get_the_profile_field_errors_action() );
    450596 *
    451  * @since BuddyPress (1.8)
     597 * @since BuddyPress (1.8.0)
    452598 * @return string The _errors action name corresponding to this profile field
    453599 */
    … …  
    464610 *
    465611 * @package BuddyPress Xprofile
    466  * @since BuddyPress (1.1)
     612 * @since BuddyPress (1.1.0)
    467613 *
    468614 * @uses bp_get_the_profile_field_options()
    … …  
    479625         *
    480626         * @package BuddyPress Xprofile
    481          * @since BuddyPress (1.1)
     627         * @since BuddyPress (1.1.0)
    482628         *
    483629         * @uses BP_XProfile_Field::get_children()
    … …  
    540686                        $retval = $field->is_required;
    541687
     688                /**
     689                 * Filters whether or not a profile field is required.
     690                 *
     691                 * @since BuddyPress (1.1.0)
     692                 *
     693                 * @param bool $retval Whether or not the field is required.
     694                 */
    542695                return apply_filters( 'bp_get_the_profile_field_is_required', (bool) $retval );
    543696        }
    … …  
    564717                }
    565718
     719                /**
     720                 * Filters the profile field visibility level.
     721                 *
     722                 * @since BuddyPress (1.6.0)
     723                 *
     724                 * @param string $retval Field visibility level.
     725                 */
    566726                return apply_filters( 'bp_get_the_profile_field_visibility_level', $retval );
    567727        }
    … …  
    590750                $fields = bp_xprofile_get_visibility_levels();
    591751
     752                /**
     753                 * Filters the profile field visibility level label.
     754                 *
     755                 * @since BuddyPress (1.6.0)
     756                 *
     757                 * @param string $retval Field visibility level label.
     758                 */
    592759                return apply_filters( 'bp_get_the_profile_field_visibility_level_label', $fields[$level]['label'] );
    593760        }
    … …  
    617784                extract( $r, EXTR_SKIP );
    618785
     786                /**
     787                 * Filters the profile field data.
     788                 *
     789                 * @since BuddyPress (1.2.0)
     790                 *
     791                 * @param mixed $value Profile data for a specific field for the user.
     792                 */
    619793                return apply_filters( 'bp_get_profile_field_data', xprofile_get_field_data( $field, $user_id ) );
    620794        }
    … …  
    635809        }
    636810
     811        /**
     812         * Filters all profile field groups.
     813         *
     814         * @since BuddyPress (2.1.0)
     815         *
     816         * @param array $groups Array of available profile field groups.
     817         */
    637818        return apply_filters( 'bp_profile_get_field_groups', $groups );
    638819}
    … …  
    647828function bp_profile_has_multiple_groups() {
    648829        $has_multiple_groups = count( (array) bp_profile_get_field_groups() ) > 1;
     830
     831        /**
     832         * Filters if there is more than one group of fields for the profile being edited.
     833         *
     834         * @since BuddyPress (2.1.0)
     835         *
     836         * @param bool $has_multiple_groups Whether or not there are multiple groups.
     837         */
    649838        return (bool) apply_filters( 'bp_profile_has_multiple_groups', $has_multiple_groups );
    650839}
    … …  
    676865        }
    677866
     867        /**
     868         * Filters the tabs to display for profile field groups.
     869         *
     870         * @since BuddyPress (1.5.0)
     871         *
     872         * @param array  $tabs       Array of tabs to display.
     873         * @param array  $groups     Array of profile groups.
     874         * @param string $group_name Name of the current group displayed.
     875         */
    678876        $tabs = apply_filters( 'xprofile_filter_profile_group_tabs', $tabs, $groups, $group_name );
    679877        foreach ( (array) $tabs as $tab )
    680878                echo $tab;
    681879
     880        /**
     881         * Fires at the end of the tab output for switching between profile field groups.
     882         *
     883         * @since BuddyPress (1.0.0)
     884         */
    682885        do_action( 'xprofile_profile_group_tabs' );
    683886}
    … …  
    702905                }
    703906
     907                /**
     908                 * Filters the profile group name.
     909                 *
     910                 * @since BuddyPress (1.0.0)
     911                 *
     912                 * @param string $name Name of the profile group.
     913                 */
    704914                return apply_filters( 'bp_get_profile_group_name', $group->name );
    705915        }
    … …  
    719929                $last_updated = bp_get_user_meta( bp_displayed_user_id(), 'profile_last_updated', true );
    720930
    721                 if ( $last_updated )
    722                         return apply_filters( 'bp_get_profile_last_updated', sprintf( __('Profile updated %s', 'buddypress'), bp_core_time_since( strtotime( $last_updated ) ) ) );
     931                if ( $last_updated ) {
     932
     933                        /**
     934                         * Filters the formatted string used to display when a profile was last updated.
     935                         *
     936                         * @since BuddyPress (1.0.0)
     937                         *
     938                         * @param string $value Formatted last updated indicator string.
     939                         */
     940                        return apply_filters( 'bp_get_profile_last_updated', sprintf( __( 'Profile updated %s', 'buddypress' ), bp_core_time_since( strtotime( $last_updated ) ) ) );
     941                }
    723942
    724943                return false;
    … …  
    732951                        $profile_group_id = 1;
    733952
    734                 return apply_filters( 'bp_get_current_profile_group_id', $profile_group_id ); // admin/profile/edit/[group-id]
     953                /**
     954                 * Filters the current profile group ID.
     955                 *
     956                 * Possible values are admin/profile/edit/[group-id]
     957                 *
     958                 * @since BuddyPress (1.1.0)
     959                 *
     960                 * @param string $profile_group_id Current profile group ID.
     961                 */
     962                return apply_filters( 'bp_get_current_profile_group_id', $profile_group_id );
    735963        }
    736964
    … …  
    741969                global $bp;
    742970
     971                /**
     972                 * Filters the link used for deleting an avatar.
     973                 *
     974                 * @since BuddyPress (1.1.0)
     975                 *
     976                 * @param string $value Nonced URL used for deleting an avatar.
     977                 */
    743978                return apply_filters( 'bp_get_avatar_delete_link', wp_nonce_url( bp_displayed_user_domain() . $bp->profile->slug . '/change-avatar/delete-avatar/', 'bp_delete_avatar_link' ) );
    744979        }
    … …  
    8181053                endif;
    8191054
     1055                /**
     1056                 * Filters the radio buttons for setting visibility.
     1057                 *
     1058                 * @since BuddyPress (1.6.0)
     1059                 *
     1060                 * @param string $retval HTML output for the visibility radio buttons.
     1061                 * @param array  $r      Parsed arguments to be used with display.
     1062                 * @param array  $args   Original passed in arguments to be used with display.
     1063                 */
    8201064                return apply_filters( 'bp_profile_get_visibility_radio_buttons', $retval, $r, $args );
    8211065        }
    … …  
    8811125                endif;
    8821126
    883                 // Output the dropdown list
     1127                /**
     1128                 * Filters the dropdown list for setting visibility.
     1129                 *
     1130                 * @since BuddyPress (2.0.0)
     1131                 *
     1132                 * @param string $retval HTML output for the visibility dropdown list.
     1133                 * @param array  $r      Parsed arguments to be used with display.
     1134                 * @param array  $args   Original passed in arguments to be used with display.
     1135                 */
    8841136                return apply_filters( 'bp_profile_settings_visibility_select', $retval, $r, $args );
    8851137        }
Note: See TracChangeset for help on using the changeset viewer.