Changeset 13392
- Timestamp:
- 01/06/2023 11:35:55 PM (21 months ago)
- Location:
- trunk/src/bp-xprofile
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-xprofile/bp-xprofile-admin.php
r13126 r13392 604 604 } 605 605 606 if ( ! empty( $_POST[ "sort_order_{$field->type}"] ) ) {607 $field->order_by = $_POST[ "sort_order_{$field->type}"];606 if ( ! empty( $_POST[ "sort_order_{$field->type}" ] ) ) { 607 $field->order_by = $_POST[ "sort_order_{$field->type}" ]; 608 608 } 609 609 … … 1190 1190 } 1191 1191 1192 if ( isset( $categories[ $the_category] ) ) {1193 $categories[ $the_category][] = array( $field_name, $field_type_obj );1192 if ( isset( $categories[ $the_category ] ) ) { 1193 $categories[ $the_category ][] = array( $field_name, $field_type_obj ); 1194 1194 } else { 1195 $categories[ $the_category] = array( array( $field_name, $field_type_obj ) );1195 $categories[ $the_category ] = array( array( $field_name, $field_type_obj ) ); 1196 1196 } 1197 1197 } -
trunk/src/bp-xprofile/bp-xprofile-cssjs.php
r12886 r13392 74 74 if ( isset( $field::$supported_features ) && is_array( $field::$supported_features ) ) { 75 75 foreach ( $field::$supported_features as $feature => $support ) { 76 if ( isset( $strings[ 'hide_' . $feature . '_metabox'] ) && ! $support ) {77 $strings[ 'hide_' . $feature . '_metabox'][] = $field_type;76 if ( isset( $strings[ 'hide_' . $feature . '_metabox' ] ) && ! $support ) { 77 $strings[ 'hide_' . $feature . '_metabox' ][] = $field_type; 78 78 } 79 79 } -
trunk/src/bp-xprofile/bp-xprofile-functions.php
r13121 r13392 193 193 194 194 $field = bp_xprofile_get_field_types(); 195 $class = isset( $field[ $type] ) ? $field[$type] : '';195 $class = isset( $field[ $type ] ) ? $field[ $type ] : ''; 196 196 197 197 /** … … 558 558 } 559 559 560 $current_visibility_levels[ $field_id] = $visibility_level;560 $current_visibility_levels[ $field_id ] = $visibility_level; 561 561 562 562 return bp_update_user_meta( $user_id, 'bp_xprofile_visibility_levels', $current_visibility_levels ); … … 1361 1361 // the user-provided setting with the default specified by the admin. 1362 1362 if ( isset( $defaults['allow_custom'] ) && isset( $defaults['default'] ) && 'disabled' == $defaults['allow_custom'] ) { 1363 $user_visibility_levels[ $d_field_id] = $defaults['default'];1363 $user_visibility_levels[ $d_field_id ] = $defaults['default']; 1364 1364 } 1365 1365 } … … 1375 1375 if ( in_array( 1, $field_ids ) ) { 1376 1376 $key = array_search( 1, $field_ids ); 1377 unset( $field_ids[ $key] );1377 unset( $field_ids[ $key ] ); 1378 1378 } 1379 1379 … … 1391 1391 */ 1392 1392 function bp_xprofile_maybe_format_datebox_post_data( $field_id ) { 1393 if ( ! isset( $_POST[ 'field_' . $field_id] ) ) {1394 if ( ! empty( $_POST[ 'field_' . $field_id . '_day'] ) && ! empty( $_POST['field_' . $field_id . '_month'] ) && ! empty( $_POST['field_' . $field_id . '_year'] ) ) {1393 if ( ! isset( $_POST[ 'field_' . $field_id ] ) ) { 1394 if ( ! empty( $_POST[ 'field_' . $field_id . '_day' ] ) && ! empty( $_POST[ 'field_' . $field_id . '_month' ] ) && ! empty( $_POST[ 'field_' . $field_id . '_year' ] ) ) { 1395 1395 // Concatenate the values. 1396 $date_value = $_POST[ 'field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year'];1396 $date_value = $_POST[ 'field_' . $field_id . '_day' ] . ' ' . $_POST[ 'field_' . $field_id . '_month' ] . ' ' . $_POST[ 'field_' . $field_id . '_year' ]; 1397 1397 1398 1398 // Check that the concatenated value can be turned into a timestamp. 1399 1399 if ( $timestamp = strtotime( $date_value ) ) { 1400 1400 // Add the timestamp to the global $_POST that should contain the datebox data. 1401 $_POST[ 'field_' . $field_id] = date( 'Y-m-d H:i:s', $timestamp );1401 $_POST[ 'field_' . $field_id ] = date( 'Y-m-d H:i:s', $timestamp ); 1402 1402 } 1403 1403 } -
trunk/src/bp-xprofile/bp-xprofile-template.php
r13358 r13392 615 615 616 616 // Was a new value posted? If so, use it instead. 617 if ( isset( $_POST[ 'field_' . $field->id] ) ) {617 if ( isset( $_POST[ 'field_' . $field->id ] ) ) { 618 618 619 619 // This is sanitized via the filter below (based on the field type). 620 $field->data->value = $_POST[ 'field_' . $field->id];620 $field->data->value = $_POST[ 'field_' . $field->id ]; 621 621 } 622 622 … … 860 860 // precedence over default visibility, so that submitted values 861 861 // are not lost on failure. 862 if ( bp_is_register_page() && ! empty( $_POST[ 'field_' . $field->id . '_visibility'] ) ) {863 $retval = esc_attr( $_POST[ 'field_' . $field->id . '_visibility'] );862 if ( bp_is_register_page() && ! empty( $_POST[ 'field_' . $field->id . '_visibility' ] ) ) { 863 $retval = esc_attr( $_POST[ 'field_' . $field->id . '_visibility' ] ); 864 864 } else { 865 865 $retval = ! empty( $field->visibility_level ) ? $field->visibility_level : 'public'; … … 898 898 // precedence over default visibility, so that submitted values 899 899 // are not lost on failure. 900 if ( bp_is_register_page() && ! empty( $_POST[ 'field_' . $field->id . '_visibility'] ) ) {901 $level = esc_html( $_POST[ 'field_' . $field->id . '_visibility'] );900 if ( bp_is_register_page() && ! empty( $_POST[ 'field_' . $field->id . '_visibility' ] ) ) { 901 $level = esc_html( $_POST[ 'field_' . $field->id . '_visibility' ] ); 902 902 } else { 903 903 $level = ! empty( $field->visibility_level ) ? $field->visibility_level : 'public'; -
trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-checkbox.php
r13372 r13392 127 127 // Check for updated posted values, but errors preventing them from 128 128 // being saved first time. 129 if ( isset( $_POST[ 'field_' . $this->field_obj->id] ) && $option_values != maybe_serialize( $_POST['field_' . $this->field_obj->id] ) ) {130 if ( ! empty( $_POST[ 'field_' . $this->field_obj->id] ) ) {131 $option_values = array_map( 'sanitize_text_field', $_POST[ 'field_' . $this->field_obj->id] );129 if ( isset( $_POST[ 'field_' . $this->field_obj->id ] ) && $option_values != maybe_serialize( $_POST[ 'field_' . $this->field_obj->id ] ) ) { 130 if ( ! empty( $_POST[ 'field_' . $this->field_obj->id ] ) ) { 131 $option_values = array_map( 'sanitize_text_field', $_POST[ 'field_' . $this->field_obj->id ] ); 132 132 } 133 133 } … … 141 141 // Run the allowed option name through the before_save filter, 142 142 // so we'll be sure to get a match. 143 $allowed_options = xprofile_sanitize_data_value_before_save( $options[ $k]->name, false, false );144 145 if ( $option_values[ $j] === $allowed_options || in_array( $allowed_options, $option_values ) ) {143 $allowed_options = xprofile_sanitize_data_value_before_save( $options[ $k ]->name, false, false ); 144 145 if ( $option_values[ $j ] === $allowed_options || in_array( $allowed_options, $option_values ) ) { 146 146 $selected = ' checked="checked"'; 147 147 break; … … 151 151 // If the user has not yet supplied a value for this field, check to 152 152 // see whether there is a default value available. 153 if ( empty( $selected ) && $select_default_option && ! empty( $options[ $k]->is_default_option ) ) {153 if ( empty( $selected ) && $select_default_option && ! empty( $options[ $k ]->is_default_option ) ) { 154 154 $selected = ' checked="checked"'; 155 155 } … … 159 159 esc_attr( bp_get_the_profile_field_input_name() . '[]' ), 160 160 esc_attr( "field_{$options[$k]->id}_{$k}" ), 161 esc_attr( stripslashes( $options[ $k]->name ) ),162 esc_html( stripslashes( $options[ $k]->name ) )161 esc_attr( stripslashes( $options[ $k ]->name ) ), 162 esc_html( stripslashes( $options[ $k ]->name ) ) 163 163 ); 164 164 … … 174 174 * @param string $k Current index in the foreach loop. 175 175 */ 176 $html .= apply_filters( 'bp_get_the_profile_field_options_checkbox', $new_html, $options[ $k], $this->field_obj->id, $selected, $k );176 $html .= apply_filters( 'bp_get_the_profile_field_options_checkbox', $new_html, $options[ $k ], $this->field_obj->id, $selected, $k ); 177 177 } 178 178 -
trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-datebox.php
r13372 r13392 193 193 // Check for updated posted values, and errors preventing them from 194 194 // being saved first time. 195 if ( ! empty( $_POST[ 'field_' . $this->field_obj->id . '_day'] ) ) {196 $new_day = (int) $_POST[ 'field_' . $this->field_obj->id . '_day'];195 if ( ! empty( $_POST[ 'field_' . $this->field_obj->id . '_day' ] ) ) { 196 $new_day = (int) $_POST[ 'field_' . $this->field_obj->id . '_day' ]; 197 197 $day = ( $day != $new_day ) ? $new_day : $day; 198 198 } 199 199 200 if ( ! empty( $_POST[ 'field_' . $this->field_obj->id . '_month'] ) ) {201 if ( in_array( $_POST[ 'field_' . $this->field_obj->id . '_month'], $eng_months ) ) {202 $new_month = $_POST[ 'field_' . $this->field_obj->id . '_month'];200 if ( ! empty( $_POST[ 'field_' . $this->field_obj->id . '_month' ] ) ) { 201 if ( in_array( $_POST[ 'field_' . $this->field_obj->id . '_month' ], $eng_months ) ) { 202 $new_month = $_POST[ 'field_' . $this->field_obj->id . '_month' ]; 203 203 } else { 204 204 $new_month = $month; … … 208 208 } 209 209 210 if ( ! empty( $_POST[ 'field_' . $this->field_obj->id . '_year'] ) ) {211 $new_year = (int) $_POST[ 'field_' . $this->field_obj->id . '_year'];210 if ( ! empty( $_POST[ 'field_' . $this->field_obj->id . '_year' ] ) ) { 211 $new_year = (int) $_POST[ 'field_' . $this->field_obj->id . '_year' ]; 212 212 $year = ( $year != $new_year ) ? $new_year : $year; 213 213 } … … 242 242 243 243 for ( $i = 0; $i < 12; ++$i ) { 244 $html .= sprintf( '<option value="%1$s" %2$s>%3$s</option>', esc_attr( $eng_months[ $i] ), selected( $month, $eng_months[$i], false ), $months[$i] );244 $html .= sprintf( '<option value="%1$s" %2$s>%3$s</option>', esc_attr( $eng_months[ $i ] ), selected( $month, $eng_months[ $i ], false ), $months[ $i ] ); 245 245 } 246 246 break; -
trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-multiselectbox.php
r13372 r13392 136 136 $html = ''; 137 137 138 if ( empty( $original_option_values ) && ! empty( $_POST[ 'field_' . $this->field_obj->id] ) ) {139 $original_option_values = sanitize_text_field( $_POST[ 'field_' . $this->field_obj->id] );138 if ( empty( $original_option_values ) && ! empty( $_POST[ 'field_' . $this->field_obj->id ] ) ) { 139 $original_option_values = sanitize_text_field( $_POST[ 'field_' . $this->field_obj->id ] ); 140 140 } 141 141 … … 147 147 // being saved first time. 148 148 foreach( $option_values as $i => $option_value ) { 149 if ( isset( $_POST[ 'field_' . $this->field_obj->id] ) && $_POST['field_' . $this->field_obj->id][$i] != $option_value ) {150 if ( ! empty( $_POST[ 'field_' . $this->field_obj->id][$i] ) ) {151 $option_values[] = sanitize_text_field( $_POST[ 'field_' . $this->field_obj->id][$i] );149 if ( isset( $_POST[ 'field_' . $this->field_obj->id ] ) && $_POST[ 'field_' . $this->field_obj->id ][ $i ] != $option_value ) { 150 if ( ! empty( $_POST[ 'field_' . $this->field_obj->id ][ $i ] ) ) { 151 $option_values[] = sanitize_text_field( $_POST[ 'field_' . $this->field_obj->id ][ $i ] ); 152 152 } 153 153 } … … 156 156 // Run the allowed option name through the before_save filter, so 157 157 // we'll be sure to get a match. 158 $allowed_options = xprofile_sanitize_data_value_before_save( $options[ $k]->name, false, false );158 $allowed_options = xprofile_sanitize_data_value_before_save( $options[ $k ]->name, false, false ); 159 159 160 160 // First, check to see whether the user-entered value matches. … … 164 164 165 165 // Then, if the user has not provided a value, check for defaults. 166 if ( ! is_array( $original_option_values ) && empty( $option_values ) && ! empty( $options[ $k]->is_default_option ) ) {166 if ( ! is_array( $original_option_values ) && empty( $option_values ) && ! empty( $options[ $k ]->is_default_option ) ) { 167 167 $selected = ' selected="selected"'; 168 168 } … … 179 179 * @param string $k Current index in the foreach loop. 180 180 */ 181 $html .= apply_filters( 'bp_get_the_profile_field_options_multiselect', '<option' . $selected . ' value="' . esc_attr( stripslashes( $options[ $k]->name ) ) . '">' . esc_html( stripslashes( $options[$k]->name ) ) . '</option>', $options[$k], $this->field_obj->id, $selected, $k );181 $html .= apply_filters( 'bp_get_the_profile_field_options_multiselect', '<option' . $selected . ' value="' . esc_attr( stripslashes( $options[ $k ]->name ) ) . '">' . esc_html( stripslashes( $options[ $k ]->name ) ) . '</option>', $options[ $k ], $this->field_obj->id, $selected, $k ); 182 182 } 183 183 -
trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-radiobutton.php
r13372 r13392 125 125 // Check for updated posted values, but errors preventing them from 126 126 // being saved first time. 127 if ( isset( $_POST[ 'field_' . $this->field_obj->id] ) && $option_value != $_POST['field_' . $this->field_obj->id] ) {128 if ( ! empty( $_POST[ 'field_' . $this->field_obj->id] ) ) {129 $option_value = sanitize_text_field( $_POST[ 'field_' . $this->field_obj->id] );127 if ( isset( $_POST[ 'field_' . $this->field_obj->id ] ) && $option_value != $_POST[ 'field_' . $this->field_obj->id ] ) { 128 if ( ! empty( $_POST[ 'field_' . $this->field_obj->id ] ) ) { 129 $option_value = sanitize_text_field( $_POST[ 'field_' . $this->field_obj->id ] ); 130 130 } 131 131 } … … 133 133 // Run the allowed option name through the before_save filter, so 134 134 // we'll be sure to get a match. 135 $allowed_options = xprofile_sanitize_data_value_before_save( $options[ $k]->name, false, false );135 $allowed_options = xprofile_sanitize_data_value_before_save( $options[ $k ]->name, false, false ); 136 136 $selected = ''; 137 137 138 if ( $option_value === $allowed_options || ( empty( $option_value ) && ! empty( $options[ $k]->is_default_option ) ) ) {138 if ( $option_value === $allowed_options || ( empty( $option_value ) && ! empty( $options[ $k ]->is_default_option ) ) ) { 139 139 $selected = ' checked="checked"'; 140 140 } … … 144 144 esc_attr( bp_get_the_profile_field_input_name() ), 145 145 esc_attr( "option_{$options[$k]->id}" ), 146 esc_attr( stripslashes( $options[ $k]->name ) ),147 esc_html( stripslashes( $options[ $k]->name ) )146 esc_attr( stripslashes( $options[ $k ]->name ) ), 147 esc_html( stripslashes( $options[ $k ]->name ) ) 148 148 ); 149 149 … … 159 159 * @param string $k Current index in the foreach loop. 160 160 */ 161 $html .= apply_filters( 'bp_get_the_profile_field_options_radio', $new_html, $options[ $k], $this->field_obj->id, $selected, $k );161 $html .= apply_filters( 'bp_get_the_profile_field_options_radio', $new_html, $options[ $k ], $this->field_obj->id, $selected, $k ); 162 162 } 163 163 -
trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-selectbox.php
r13372 r13392 107 107 $html = '<option value="">' . /* translators: no option picked in select box */ esc_html__( '----', 'buddypress' ) . '</option>'; 108 108 109 if ( empty( $original_option_values ) && !empty( $_POST[ 'field_' . $this->field_obj->id] ) ) {110 $original_option_values = sanitize_text_field( $_POST[ 'field_' . $this->field_obj->id] );109 if ( empty( $original_option_values ) && !empty( $_POST[ 'field_' . $this->field_obj->id ] ) ) { 110 $original_option_values = sanitize_text_field( $_POST[ 'field_' . $this->field_obj->id ] ); 111 111 } 112 112 … … 118 118 // being saved first time. 119 119 foreach( $option_values as $i => $option_value ) { 120 if ( isset( $_POST[ 'field_' . $this->field_obj->id] ) && $_POST['field_' . $this->field_obj->id] != $option_value ) {121 if ( ! empty( $_POST[ 'field_' . $this->field_obj->id] ) ) {122 $option_values[ $i] = sanitize_text_field( $_POST['field_' . $this->field_obj->id] );120 if ( isset( $_POST[ 'field_' . $this->field_obj->id ] ) && $_POST[ 'field_' . $this->field_obj->id ] != $option_value ) { 121 if ( ! empty( $_POST[ 'field_' . $this->field_obj->id ] ) ) { 122 $option_values[ $i ] = sanitize_text_field( $_POST[ 'field_' . $this->field_obj->id ] ); 123 123 } 124 124 } … … 127 127 // Run the allowed option name through the before_save filter, so 128 128 // we'll be sure to get a match. 129 $allowed_options = xprofile_sanitize_data_value_before_save( $options[ $k]->name, false, false );129 $allowed_options = xprofile_sanitize_data_value_before_save( $options[ $k ]->name, false, false ); 130 130 131 131 // First, check to see whether the user-entered value matches. … … 135 135 136 136 // Then, if the user has not provided a value, check for defaults. 137 if ( ! is_array( $original_option_values ) && empty( $option_values ) && $options[ $k]->is_default_option ) {137 if ( ! is_array( $original_option_values ) && empty( $option_values ) && $options[ $k ]->is_default_option ) { 138 138 $selected = ' selected="selected"'; 139 139 } … … 150 150 * @param string $k Current index in the foreach loop. 151 151 */ 152 $html .= apply_filters( 'bp_get_the_profile_field_options_select', '<option' . $selected . ' value="' . esc_attr( stripslashes( $options[ $k]->name ) ) . '">' . esc_html( stripslashes( $options[$k]->name ) ) . '</option>', $options[$k], $this->field_obj->id, $selected, $k );152 $html .= apply_filters( 'bp_get_the_profile_field_options_select', '<option' . $selected . ' value="' . esc_attr( stripslashes( $options[ $k ]->name ) ) . '">' . esc_html( stripslashes( $options[ $k ]->name ) ) . '</option>', $options[ $k ], $this->field_obj->id, $selected, $k ); 153 153 } 154 154 -
trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type.php
r13372 r13392 370 370 $i = 1; 371 371 372 while ( isset( $_POST[ $type . '_option'][$i] ) ) {372 while ( isset( $_POST[ $type . '_option' ][ $i ] ) ) { 373 373 374 374 // Multiselectbox and checkboxes support MULTIPLE default options; all other core types support only ONE. 375 if ( $current_type_obj->supports_options && ! $current_type_obj->supports_multiple_defaults && isset( $_POST[ "isDefault_{$type}_option"][$i] ) && (int) $_POST["isDefault_{$type}_option"] === $i ) {375 if ( $current_type_obj->supports_options && ! $current_type_obj->supports_multiple_defaults && isset( $_POST[ "isDefault_{$type}_option" ][ $i ] ) && (int) $_POST[ "isDefault_{$type}_option" ] === $i ) { 376 376 $is_default_option = true; 377 } elseif ( isset( $_POST[ "isDefault_{$type}_option"][$i] ) ) {378 $is_default_option = (bool) $_POST[ "isDefault_{$type}_option"][$i];377 } elseif ( isset( $_POST[ "isDefault_{$type}_option" ][ $i ] ) ) { 378 $is_default_option = (bool) $_POST[ "isDefault_{$type}_option" ][ $i ]; 379 379 } else { 380 380 $is_default_option = false; … … 385 385 'id' => -1, 386 386 'is_default_option' => $is_default_option, 387 'name' => sanitize_text_field( stripslashes( $_POST[ $type . '_option'][$i] ) ),387 'name' => sanitize_text_field( stripslashes( $_POST[ $type . '_option' ][ $i ] ) ), 388 388 ); 389 389 … … 420 420 esc_html_e( 'Add an option', 'buddypress' ); 421 421 ?></label> 422 <input type="text" name="<?php echo esc_attr( "{$type}_option[{$j}]" ); ?>" id="<?php echo esc_attr( "{$type}_option{$j}" ); ?>" value="<?php echo esc_attr( stripslashes( $options[ $i]->name ) ); ?>" />422 <input type="text" name="<?php echo esc_attr( "{$type}_option[{$j}]" ); ?>" id="<?php echo esc_attr( "{$type}_option{$j}" ); ?>" value="<?php echo esc_attr( stripslashes( $options[ $i ]->name ) ); ?>" /> 423 423 <label for="<?php echo esc_attr( "{$type}_option{$default_name}" ); ?>"> 424 <input type="<?php echo esc_attr( $control_type ); ?>" id="<?php echo esc_attr( "{$type}_option{$default_name}" ); ?>" name="<?php echo esc_attr( "isDefault_{$type}_option{$default_name}" ); ?>" <?php checked( $options[ $i]->is_default_option, true ); ?> value="<?php echo esc_attr( $j ); ?>" />424 <input type="<?php echo esc_attr( $control_type ); ?>" id="<?php echo esc_attr( "{$type}_option{$default_name}" ); ?>" name="<?php echo esc_attr( "isDefault_{$type}_option{$default_name}" ); ?>" <?php checked( $options[ $i ]->is_default_option, true ); ?> value="<?php echo esc_attr( $j ); ?>" /> 425 425 <?php _e( 'Default Value', 'buddypress' ); ?> 426 426 </label> -
trunk/src/bp-xprofile/classes/class-bp-xprofile-field.php
r13372 r13392 476 476 477 477 // Allow plugins to filter the field's child options (i.e. the items in a selectbox). 478 $post_option = ! empty( $_POST[ "{$this->type}_option"] ) ? $_POST["{$this->type}_option"] : '';479 $post_default = ! empty( $_POST[ "isDefault_{$this->type}_option"] ) ? $_POST["isDefault_{$this->type}_option"] : '';478 $post_option = ! empty( $_POST[ "{$this->type}_option" ] ) ? $_POST[ "{$this->type}_option" ] : ''; 479 $post_default = ! empty( $_POST[ "isDefault_{$this->type}_option" ] ) ? $_POST[ "isDefault_{$this->type}_option" ] : ''; 480 480 481 481 /** … … 1248 1248 $this->field_order = $_POST['field_order']; 1249 1249 1250 if ( ! empty( $_POST[ "sort_order_{$this->type}"] ) ) {1251 $this->order_by = $_POST[ "sort_order_{$this->type}"];1250 if ( ! empty( $_POST[ "sort_order_{$this->type}" ] ) ) { 1251 $this->order_by = $_POST[ "sort_order_{$this->type}" ]; 1252 1252 } 1253 1253 } -
trunk/src/bp-xprofile/classes/class-bp-xprofile-group.php
r13372 r13392 214 214 if ( ! empty( $this->fields ) ) { 215 215 for ( $i = 0, $count = count( $this->fields ); $i < $count; ++$i ) { 216 BP_XProfile_ProfileData::delete_for_field( $this->fields[ $i]->id );216 BP_XProfile_ProfileData::delete_for_field( $this->fields[ $i ]->id ); 217 217 } 218 218 } -
trunk/src/bp-xprofile/classes/class-bp-xprofile-meta-query.php
r10740 r13392 68 68 69 69 // BP_XProfile_Query sets 'object_type' = '' by default. 70 if ( isset( $qv[ 'object_type' ] ) && ( '' !== $qv[ 'object_type' ] ) && ( ! is_array( $qv[ 'object_type' ] ) || $qv[ 'object_type'] ) ) {71 $meta_query[0]['object'] = $qv[ 'object_type'];70 if ( isset( $qv['object_type'] ) && ( '' !== $qv['object_type'] ) && ( ! is_array( $qv['object_type'] ) || $qv['object_type'] ) ) { 71 $meta_query[0]['object'] = $qv['object_type']; 72 72 } 73 73 -
trunk/src/bp-xprofile/classes/class-bp-xprofile-profiledata.php
r13372 r13392 641 641 for ( $i = 0, $count = count( $fields ); $i < $count; ++$i ) { 642 642 if ( $i == 0 ) { 643 $field_sql .= $wpdb->prepare( "AND ( f.name = %s ", $fields[ $i] );643 $field_sql .= $wpdb->prepare( "AND ( f.name = %s ", $fields[ $i ] ); 644 644 } else { 645 $field_sql .= $wpdb->prepare( "OR f.name = %s ", $fields[ $i] );645 $field_sql .= $wpdb->prepare( "OR f.name = %s ", $fields[ $i ] ); 646 646 } 647 647 } … … 664 664 for ( $i = 0, $count = count( $values ); $i < $count; ++$i ) { 665 665 for ( $j = 0; $j < count( $fields ); $j++ ) { 666 if ( $values[ $i]->name == $fields[$j] ) {667 $new_values[ $fields[$j]] = $values[$i]->value;668 } elseif ( !array_key_exists( $fields[ $j], $new_values ) ) {669 $new_values[ $fields[$j]] = NULL;666 if ( $values[ $i ]->name == $fields[ $j ] ) { 667 $new_values[ $fields[ $j ] ] = $values[ $i ]->value; 668 } elseif ( !array_key_exists( $fields[ $j ], $new_values ) ) { 669 $new_values[ $fields[ $j ] ] = NULL; 670 670 } 671 671 } -
trunk/src/bp-xprofile/classes/class-bp-xprofile-user-admin.php
r13108 r13392 174 174 175 175 $is_required[ $field_id ] = xprofile_check_is_required_field( $field_id ) && ! bp_current_user_can( 'bp_moderate' ); 176 if ( $is_required[ $field_id ] && empty( $_POST[ 'field_' . $field_id ] ) ) {176 if ( $is_required[ $field_id ] && empty( $_POST[ 'field_' . $field_id ] ) ) { 177 177 $redirect_to = add_query_arg( 'error', '2', $redirect_to ); 178 178 bp_core_redirect( $redirect_to ); … … 192 192 * get overwritten by the default on the next edit. 193 193 */ 194 $value = isset( $_POST[ 'field_' . $field_id] ) ? $_POST['field_' . $field_id] : '';195 196 $visibility_level = ! empty( $_POST[ 'field_' . $field_id . '_visibility'] ) ? $_POST['field_' . $field_id . '_visibility'] : 'public';194 $value = isset( $_POST[ 'field_' . $field_id ] ) ? $_POST[ 'field_' . $field_id ] : ''; 195 196 $visibility_level = ! empty( $_POST[ 'field_' . $field_id . '_visibility' ] ) ? $_POST[ 'field_' . $field_id . '_visibility' ] : 'public'; 197 197 /* 198 198 * Save the old and new values. They will be -
trunk/src/bp-xprofile/screens/edit.php
r12869 r13392 59 59 60 60 $is_required[ $field_id ] = xprofile_check_is_required_field( $field_id ) && ! bp_current_user_can( 'bp_moderate' ); 61 if ( $is_required[ $field_id] && empty( $_POST['field_' . $field_id] ) ) {61 if ( $is_required[ $field_id ] && empty( $_POST[ 'field_' . $field_id ] ) ) { 62 62 $errors = true; 63 63 } … … 79 79 80 80 // Certain types of fields (checkboxes, multiselects) may come through empty. Save them as an empty array so that they don't get overwritten by the default on the next edit. 81 $value = isset( $_POST[ 'field_' . $field_id] ) ? $_POST['field_' . $field_id] : '';81 $value = isset( $_POST[ 'field_' . $field_id ] ) ? $_POST[ 'field_' . $field_id ] : ''; 82 82 83 $visibility_level = !empty( $_POST[ 'field_' . $field_id . '_visibility'] ) ? $_POST['field_' . $field_id . '_visibility'] : 'public';83 $visibility_level = !empty( $_POST[ 'field_' . $field_id . '_visibility' ] ) ? $_POST[ 'field_' . $field_id . '_visibility' ] : 'public'; 84 84 85 85 // Save the old and new values. They will be -
trunk/src/bp-xprofile/screens/settings-profile.php
r12534 r13392 93 93 $visibility_level = 'public'; 94 94 95 if ( !empty( $_POST[ 'field_' . $field_id . '_visibility'] ) ) {96 $visibility_level = $_POST[ 'field_' . $field_id . '_visibility'];95 if ( !empty( $_POST[ 'field_' . $field_id . '_visibility' ] ) ) { 96 $visibility_level = $_POST[ 'field_' . $field_id . '_visibility' ]; 97 97 } 98 98
Note: See TracChangeset
for help on using the changeset viewer.