- Timestamp:
- 07/31/2020 02:26:24 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type.php
r12694 r12697 32 32 * @var array Field type allowed values. 33 33 */ 34 protected $validation_ whitelist= array();34 protected $validation_allowed_values = array(); 35 35 36 36 /** … … 154 154 155 155 /** 156 * Add a value to this type's whitelist that profile data will be asserted against. 156 * Add a value to this type's list of allowed values that profile data will be asserted against. 157 * 158 * @since 2.0.0 159 * @deprecated 7.0.0 Use set_allowed_values() instead. 160 * 161 * @param string|array $values Whitelisted values. 162 * @return BP_XProfile_Field_Type 163 */ 164 public function set_whitelist_values( $values ) { 165 _deprecated_function( __METHOD__, '7.0.0', 'BP_XProfile_Field_Type::set_allowed_values()' ); 166 $this->set_allowed_values( $values ); 167 } 168 169 /** 170 * Add a value to this type's list of allowed values that profile data will be asserted against. 157 171 * 158 172 * You can call this method multiple times to set multiple formats. When validation is performed, 159 173 * it's successful as long as the new value matches any one of the registered formats. 160 174 * 161 * @since 2.0.0162 * 163 * @param string|array $values Whitelisted values.175 * @since 7.0.0 176 * 177 * @param string|array $values Allowed values. 164 178 * @return BP_XProfile_Field_Type 165 179 */ 166 public function set_ whitelist_values( $values ) {180 public function set_allowed_values( $values ) { 167 181 foreach ( (array) $values as $value ) { 168 182 169 183 /** 170 * Filters values for field type's whitelistthat profile data will be asserted against.184 * Filters values for field type's list of allowed values that profile data will be asserted against. 171 185 * 172 186 * @since 2.0.0 187 * @deprecated 7.0.0 Use 'bp_xprofile_field_type_set_allowed_values' instead. 173 188 * 174 189 * @param string $value Field value. … … 176 191 * @param BP_XProfile_Field_Type $this Current instance of the BP_XProfile_Field_Type class. 177 192 */ 178 $this->validation_whitelist[] = apply_filters( 'bp_xprofile_field_type_set_whitelist_values', $value, $values, $this ); 193 $this->validation_allowed_values[] = apply_filters_deprecated( 'bp_xprofile_field_type_set_whitelist_values', array( $value, $values, $this ), '7.0.0', 'bp_xprofile_field_type_set_allowed_values' ); 194 195 /** 196 * Filters values for field type's list of allowed values that profile data will be asserted against. 197 * 198 * @since 7.0.0 199 * 200 * @param string $value Field value. 201 * @param array $values Original array of values. 202 * @param BP_XProfile_Field_Type $this Current instance of the BP_XProfile_Field_Type class. 203 */ 204 $this->validation_allowed_values[] = apply_filters( 'bp_xprofile_field_type_set_allowed_values', $value, $values, $this ); 179 205 } 180 206 … … 215 241 } 216 242 217 // If there's a whitelist set, make sure that each value is a whitelisted value.218 if ( ( true === $validated ) && ! empty( $values ) && ! empty( $this->validation_ whitelist) ) {243 // If there's a list of allowed values, make sure that each value is on that list. 244 if ( ( true === $validated ) && ! empty( $values ) && ! empty( $this->validation_allowed_values ) ) { 219 245 foreach ( (array) $values as $value ) { 220 if ( ! in_array( $value, $this->validation_ whitelist, true ) ) {246 if ( ! in_array( $value, $this->validation_allowed_values, true ) ) { 221 247 $validated = false; 222 248 break;
Note: See TracChangeset
for help on using the changeset viewer.