- Timestamp:
- 01/06/2023 11:35:55 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.