Changeset 9687
- Timestamp:
- 04/03/2015 04:59:44 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-xprofile/bp-xprofile-template.php
r9686 r9687 11 11 defined( 'ABSPATH' ) || exit; 12 12 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 */ 13 20 class BP_XProfile_Data_Template { 14 21 … … 378 385 $css_classes = array(); 379 386 380 if ( $class )387 if ( empty( $class ) ) { 381 388 $css_classes[] = sanitize_title( esc_attr( $class ) ); 389 } 382 390 383 391 // Set a class with the field ID … … 397 405 $css_classes[] = 'visibility-' . esc_attr( bp_get_the_profile_field_visibility_level() ); 398 406 399 if ( $profile_template->current_field % 2 == 1 ) 407 if ( $profile_template->current_field % 2 == 1 ) { 400 408 $css_classes[] = 'alt'; 409 } 401 410 402 411 $css_classes[] = 'field_type_' . sanitize_title( $profile_template->field->type ); … … 429 438 global $profile_template; 430 439 431 if ( $profile_template->field_has_data )440 if ( ! empty( $profile_template->field_has_data ) ) { 432 441 return true; 442 } 433 443 434 444 return false; … … 644 654 * value as long as it's not empty and a required field. 645 655 */ 646 if ( ! isset( $field->data ) ) {656 if ( ! isset( $field->data ) ) { 647 657 $field->data = new stdClass; 648 658 } 649 659 650 if ( ! isset( $field->data->value ) ) {660 if ( ! isset( $field->data->value ) ) { 651 661 $field->data->value = ''; 652 662 } 653 663 654 664 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] ) ) { 656 666 $field->data->value = $_POST['field_' . $field->id]; 657 else667 } else { 658 668 $field->data->value = ''; 669 } 659 670 } 660 671 … … 789 800 790 801 foreach ( $field as $field_prop => $field_prop_value ) { 791 if ( ! isset( $field_obj->{$field_prop} ) ) 802 if ( ! isset( $field_obj->{$field_prop} ) ) { 792 803 $field_obj->{$field_prop} = $field_prop_value; 804 } 793 805 } 794 806 … … 814 826 815 827 // 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() ) { 817 829 $retval = false; 818 830 819 831 // All other users will use the field's setting 820 elseif ( isset( $field->is_required ) )832 } elseif ( isset( $field->is_required ) ) { 821 833 $retval = $field->is_required; 834 } 822 835 823 836 /** … … 892 905 * @param string $retval Field visibility level label. 893 906 */ 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'] ); 895 908 } 896 909 … … 911 924 function bp_get_profile_field_data( $args = '' ) { 912 925 913 $ defaults =array(926 $r = wp_parse_args( $args, array( 914 927 'field' => false, // Field name or ID. 915 928 'user_id' => bp_displayed_user_id() 916 ); 917 918 $r = wp_parse_args( $args, $defaults ); 919 extract( $r, EXTR_SKIP ); 929 ) ); 920 930 921 931 /** … … 926 936 * @param mixed $value Profile data for a specific field for the user. 927 937 */ 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'] ) ); 929 939 } 930 940 … … 1079 1089 $last_updated = bp_get_profile_last_updated(); 1080 1090 1081 if ( !$last_updated) {1091 if ( empty( $last_updated ) ) { 1082 1092 _e( 'Profile not recently updated', 'buddypress' ) . '.'; 1083 1093 } else { … … 1089 1099 $last_updated = bp_get_user_meta( bp_displayed_user_id(), 'profile_last_updated', true ); 1090 1100 1091 if ( $last_updated) {1101 if ( ! empty( $last_updated ) ) { 1092 1102 1093 1103 /** … … 1108 1118 } 1109 1119 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 ) ) { 1111 1122 $profile_group_id = 1; 1123 } 1112 1124 1113 1125 /** … … 1142 1154 $bp = buddypress(); 1143 1155 1144 bp_button( array 1156 bp_button( array( 1145 1157 'id' => 'edit_profile', 1146 1158 'component' => 'xprofile',
Note: See TracChangeset
for help on using the changeset viewer.