Skip to:
Content

BuddyPress.org

Changeset 9687


Ignore:
Timestamp:
04/03/2015 04:59:44 PM (10 years ago)
Author:
johnjamesjacoby
Message:

XProfile: General code formatting cleanup to bp-xprofile-template.php. See #6347.

File:
1 edited

Legend:

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

    r9686 r9687  
    1111defined( 'ABSPATH' ) || exit;
    1212
     13/**
     14 * The main profile template loop class.
     15 *
     16 * This is responsible for loading profile field, group, and data and displaying it.
     17 *
     18 * @since BuddyPress (1.0.0)
     19 */
    1320class BP_XProfile_Data_Template {
    1421
     
    378385        $css_classes = array();
    379386
    380         if ( $class )
     387        if ( empty( $class ) ) {
    381388            $css_classes[] = sanitize_title( esc_attr( $class ) );
     389        }
    382390
    383391        // Set a class with the field ID
     
    397405        $css_classes[] = 'visibility-' . esc_attr( bp_get_the_profile_field_visibility_level() );
    398406
    399         if ( $profile_template->current_field % 2 == 1 )
     407        if ( $profile_template->current_field % 2 == 1 ) {
    400408            $css_classes[] = 'alt';
     409        }
    401410
    402411        $css_classes[] = 'field_type_' . sanitize_title( $profile_template->field->type );
     
    429438    global $profile_template;
    430439
    431     if ( $profile_template->field_has_data )
     440    if ( ! empty( $profile_template->field_has_data ) ) {
    432441        return true;
     442    }
    433443
    434444    return false;
     
    644654         * value as long as it's not empty and a required field.
    645655         */
    646         if ( !isset( $field->data ) ) {
     656        if ( ! isset( $field->data ) ) {
    647657            $field->data = new stdClass;
    648658        }
    649659
    650         if ( !isset( $field->data->value ) ) {
     660        if ( ! isset( $field->data->value ) ) {
    651661            $field->data->value = '';
    652662        }
    653663
    654664        if ( isset( $_POST['field_' . $field->id] ) && $field->data->value != $_POST['field_' . $field->id] ) {
    655             if ( !empty( $_POST['field_' . $field->id] ) )
     665            if ( ! empty( $_POST['field_' . $field->id] ) ) {
    656666                $field->data->value = $_POST['field_' . $field->id];
    657             else
     667            } else {
    658668                $field->data->value = '';
     669            }
    659670        }
    660671
     
    789800
    790801            foreach ( $field as $field_prop => $field_prop_value ) {
    791                 if ( ! isset( $field_obj->{$field_prop} ) )
     802                if ( ! isset( $field_obj->{$field_prop} ) ) {
    792803                    $field_obj->{$field_prop} = $field_prop_value;
     804                }
    793805            }
    794806
     
    814826
    815827        // Super admins can skip required check
    816         if ( bp_current_user_can( 'bp_moderate' ) && !is_admin() )
     828        if ( bp_current_user_can( 'bp_moderate' ) && !is_admin() ) {
    817829            $retval = false;
    818830
    819831        // All other users will use the field's setting
    820         elseif ( isset( $field->is_required ) )
     832        } elseif ( isset( $field->is_required ) ) {
    821833            $retval = $field->is_required;
     834        }
    822835
    823836        /**
     
    892905         * @param string $retval Field visibility level label.
    893906         */
    894         return apply_filters( 'bp_get_the_profile_field_visibility_level_label', $fields[$level]['label'] );
     907        return apply_filters( 'bp_get_the_profile_field_visibility_level_label', $fields[ $level ]['label'] );
    895908    }
    896909
     
    911924    function bp_get_profile_field_data( $args = '' ) {
    912925
    913         $defaults = array(
     926        $r = wp_parse_args( $args, array(
    914927            'field'   => false, // Field name or ID.
    915928            'user_id' => bp_displayed_user_id()
    916         );
    917 
    918         $r = wp_parse_args( $args, $defaults );
    919         extract( $r, EXTR_SKIP );
     929        ) );
    920930
    921931        /**
     
    926936         * @param mixed $value Profile data for a specific field for the user.
    927937         */
    928         return apply_filters( 'bp_get_profile_field_data', xprofile_get_field_data( $field, $user_id ) );
     938        return apply_filters( 'bp_get_profile_field_data', xprofile_get_field_data( $r['field'], $r['user_id'] ) );
    929939    }
    930940
     
    10791089    $last_updated = bp_get_profile_last_updated();
    10801090
    1081     if ( !$last_updated ) {
     1091    if ( empty( $last_updated ) ) {
    10821092        _e( 'Profile not recently updated', 'buddypress' ) . '.';
    10831093    } else {
     
    10891099        $last_updated = bp_get_user_meta( bp_displayed_user_id(), 'profile_last_updated', true );
    10901100
    1091         if ( $last_updated ) {
     1101        if ( ! empty( $last_updated ) ) {
    10921102
    10931103            /**
     
    11081118}
    11091119    function bp_get_current_profile_group_id() {
    1110         if ( !$profile_group_id = bp_action_variable( 1 ) )
     1120        $profile_group_id = bp_action_variable( 1 );
     1121        if ( empty( $profile_group_id ) ) {
    11111122            $profile_group_id = 1;
     1123        }
    11121124
    11131125        /**
     
    11421154    $bp = buddypress();
    11431155
    1144     bp_button( array (
     1156    bp_button( array(
    11451157        'id'                => 'edit_profile',
    11461158        'component'         => 'xprofile',
Note: See TracChangeset for help on using the changeset viewer.