| @@ -14,9 +14,8 @@ | ||
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * @param array $values |
| 17 | 17 | * @param bool|string[] $exclude |
| 18 | - * | |
| 19 | 18 | * @return array |
| 20 | 19 | */ |
| 21 | 20 | public static function validate( $values, $exclude = false ) { |
| 22 | 21 | FrmEntry::sanitize_entry_post( $values ); |
| @@ -23,12 +22,13 @@ | ||
| 23 | 22 | $errors = array(); |
| 24 | 23 | |
| 25 | 24 | if ( ! isset( $values['form_id'] ) || ! isset( $values['item_meta'] ) ) { |
| 26 | 25 | $errors['form'] = __( 'There was a problem with your submission. Please try again.', 'formidable' ); |
| 26 | + | |
| 27 | 27 | return $errors; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) { // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 30 | + if ( FrmAppHelper::is_admin() && is_user_logged_in() && ( ! isset( $values[ 'frm_submit_entry_' . $values['form_id'] ] ) || ! wp_verify_nonce( $values[ 'frm_submit_entry_' . $values['form_id'] ], 'frm_submit_entry_nonce' ) ) ) { | |
| 31 | 31 | $frm_settings = FrmAppHelper::get_settings(); |
| 32 | 32 | $errors['form'] = $frm_settings->admin_permission; |
| 33 | 33 | } |
| 34 | 34 | |
| @@ -44,9 +44,9 @@ | ||
| 44 | 44 | self::validate_field( $posted_field, $errors, $values, $args ); |
| 45 | 45 | unset( $posted_field ); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if ( ! $errors ) { | |
| 48 | + if ( empty( $errors ) ) { | |
| 49 | 49 | self::spam_check( $exclude, $values, $errors ); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
| @@ -83,15 +83,9 @@ | ||
| 83 | 83 | $_POST['item_meta'] = array(); |
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - /** | |
| 88 | - * @param array $values | |
| 89 | - * | |
| 90 | - * @return void | |
| 91 | - */ | |
| 92 | 87 | private static function set_item_key( &$values ) { |
| 93 | - // phpcs:ignore Universal.Operators.StrictComparisons | |
| 94 | 88 | if ( ! isset( $values['item_key'] ) || $values['item_key'] == '' ) { |
| 95 | 89 | global $wpdb; |
| 96 | 90 | $values['item_key'] = FrmAppHelper::get_unique_key( '', $wpdb->prefix . 'frm_items', 'item_key' ); |
| 97 | 91 | $_POST['item_key'] = $values['item_key']; |
| @@ -97,14 +91,8 @@ | ||
| 97 | 91 | $_POST['item_key'] = $values['item_key']; |
| 98 | 92 | } |
| 99 | 93 | } |
| 100 | 94 | |
| 101 | - /** | |
| 102 | - * @param array $values | |
| 103 | - * @param array|string $exclude | |
| 104 | - * | |
| 105 | - * @return array | |
| 106 | - */ | |
| 107 | 95 | private static function get_fields_to_validate( $values, $exclude ) { |
| 108 | 96 | $where = apply_filters( 'frm_posted_field_ids', array( 'fi.form_id' => $values['form_id'] ) ); |
| 109 | 97 | |
| 110 | 98 | // Don't get subfields |
| @@ -110,9 +98,9 @@ | ||
| 110 | 98 | // Don't get subfields |
| 111 | 99 | $where['fr.parent_form_id'] = array( null, 0 ); |
| 112 | 100 | |
| 113 | 101 | // Don't get excluded fields (like file upload fields in the ajax validation) |
| 114 | - if ( $exclude ) { | |
| 102 | + if ( ! empty( $exclude ) ) { | |
| 115 | 103 | $where['fi.type not'] = $exclude; |
| 116 | 104 | } |
| 117 | 105 | |
| 118 | 106 | $fields = FrmField::getAll( $where, 'field_order' ); |
| @@ -127,16 +115,8 @@ | ||
| 127 | 115 | */ |
| 128 | 116 | return apply_filters( 'frm_fields_to_validate', $fields, compact( 'values', 'exclude', 'where' ) ); |
| 129 | 117 | } |
| 130 | 118 | |
| 131 | - /** | |
| 132 | - * @param object $posted_field | |
| 133 | - * @param array $errors | |
| 134 | - * @param array $values | |
| 135 | - * @param array $args | |
| 136 | - * | |
| 137 | - * @return void | |
| 138 | - */ | |
| 139 | 119 | public static function validate_field( $posted_field, &$errors, $values, $args = array() ) { |
| 140 | 120 | $defaults = array( |
| 141 | 121 | 'id' => $posted_field->id, |
| 142 | 122 | // The id of the repeat or embed form. |
| @@ -146,18 +126,23 @@ | ||
| 146 | 126 | // Exclude these field types from validation. |
| 147 | 127 | 'exclude' => array(), |
| 148 | 128 | |
| 149 | 129 | ); |
| 150 | - $args = wp_parse_args( $args, $defaults ); | |
| 151 | - $value = empty( $args['parent_field_id'] ) ? ( $values['item_meta'][ $args['id'] ] ?? '' ) : $values; | |
| 130 | + $args = wp_parse_args( $args, $defaults ); | |
| 152 | 131 | |
| 132 | + if ( empty( $args['parent_field_id'] ) ) { | |
| 133 | + $value = isset( $values['item_meta'][ $args['id'] ] ) ? $values['item_meta'][ $args['id'] ] : ''; | |
| 134 | + } else { | |
| 135 | + // value is from a nested form | |
| 136 | + $value = $values; | |
| 137 | + } | |
| 138 | + | |
| 153 | 139 | // Check for values in "Other" fields |
| 154 | 140 | FrmEntriesHelper::maybe_set_other_validation( $posted_field, $value, $args ); |
| 155 | 141 | |
| 156 | 142 | self::maybe_clear_value_for_default_blank_setting( $posted_field, $value ); |
| 157 | 143 | |
| 158 | - $should_trim = is_array( $value ) && count( $value ) === 1 && isset( $value[0] ) && $posted_field->type !== 'checkbox'; | |
| 159 | - | |
| 144 | + $should_trim = is_array( $value ) && count( $value ) == 1 && isset( $value[0] ) && $posted_field->type !== 'checkbox'; | |
| 160 | 145 | if ( $should_trim ) { |
| 161 | 146 | $value = reset( $value ); |
| 162 | 147 | } |
| 163 | 148 | |
| @@ -164,9 +149,8 @@ | ||
| 164 | 149 | if ( ! is_array( $value ) ) { |
| 165 | 150 | $value = trim( $value ); |
| 166 | 151 | } |
| 167 | 152 | |
| 168 | - // phpcs:ignore Universal.Operators.StrictComparisons | |
| 169 | 153 | if ( $posted_field->required == '1' && FrmAppHelper::is_empty_value( $value ) ) { |
| 170 | 154 | $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'blank' ); |
| 171 | 155 | } elseif ( ! isset( $_POST['item_name'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 172 | 156 | self::maybe_add_item_name( $value, $posted_field ); |
| @@ -173,9 +157,8 @@ | ||
| 173 | 157 | } |
| 174 | 158 | |
| 175 | 159 | FrmEntriesHelper::set_posted_value( $posted_field, $value, $args ); |
| 176 | 160 | |
| 177 | - self::validate_options( $errors, $posted_field, $value, $args ); | |
| 178 | 161 | self::validate_field_types( $errors, $posted_field, $value, $args ); |
| 179 | 162 | |
| 180 | 163 | // Field might want to modify value before other parts of the system |
| 181 | 164 | // e.g. trim off excess values like in the case of fields with limit. |
| @@ -180,9 +163,8 @@ | ||
| 180 | 163 | // Field might want to modify value before other parts of the system |
| 181 | 164 | // e.g. trim off excess values like in the case of fields with limit. |
| 182 | 165 | $value = apply_filters( 'frm_modify_posted_field_value', $value, $errors, $posted_field, $args ); |
| 183 | 166 | |
| 184 | - // phpcs:ignore Universal.Operators.StrictComparisons | |
| 185 | 167 | if ( $value != '' ) { |
| 186 | 168 | self::validate_phone_field( $errors, $posted_field, $value, $args ); |
| 187 | 169 | } |
| 188 | 170 | |
| @@ -194,188 +176,8 @@ | ||
| 194 | 176 | } |
| 195 | 177 | } |
| 196 | 178 | |
| 197 | 179 | /** |
| 198 | - * @since 6.21 | |
| 199 | - * | |
| 200 | - * @param array $errors | |
| 201 | - * @param object $posted_field | |
| 202 | - * @param array|string $value | |
| 203 | - * @param array $args | |
| 204 | - * | |
| 205 | - * @return void | |
| 206 | - */ | |
| 207 | - private static function validate_options( &$errors, $posted_field, $value, $args ) { | |
| 208 | - if ( empty( $posted_field->options ) ) { | |
| 209 | - return; | |
| 210 | - } | |
| 211 | - | |
| 212 | - $option_is_valid = self::option_is_valid( $posted_field, $value, $posted_field->options ); | |
| 213 | - | |
| 214 | - /** | |
| 215 | - * @since 6.21 | |
| 216 | - * | |
| 217 | - * @param bool $option_is_valid | |
| 218 | - * @param array|string $value | |
| 219 | - * @param object $field | |
| 220 | - */ | |
| 221 | - $option_is_valid = (bool) apply_filters( 'frm_option_is_valid', $option_is_valid, $value, $posted_field ); | |
| 222 | - | |
| 223 | - if ( ! $option_is_valid ) { | |
| 224 | - $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $posted_field, 'invalid' ); | |
| 225 | - } | |
| 226 | - } | |
| 227 | - | |
| 228 | - /** | |
| 229 | - * Validate that value matches one of the options for the field. | |
| 230 | - * | |
| 231 | - * @since 6.21 | |
| 232 | - * | |
| 233 | - * @param stdClass $field | |
| 234 | - * @param array|string $value | |
| 235 | - * @param array $options | |
| 236 | - * | |
| 237 | - * @return bool | |
| 238 | - */ | |
| 239 | - private static function option_is_valid( $field, $value, $options ) { // phpcs:ignore SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh | |
| 240 | - if ( '' === $value ) { | |
| 241 | - return true; | |
| 242 | - } | |
| 243 | - | |
| 244 | - $field_object = FrmFieldFactory::get_field_type( $field->type, $field ); | |
| 245 | - | |
| 246 | - if ( ! $field_object->field_type_has_options_settings() ) { | |
| 247 | - return true; | |
| 248 | - } | |
| 249 | - | |
| 250 | - if ( in_array( $field->type, array( 'likert', 'ranking' ), true ) ) { | |
| 251 | - // Ignore these field types automatically. | |
| 252 | - return true; | |
| 253 | - } | |
| 254 | - | |
| 255 | - if ( 'product' === $field->type && 'user_def' === FrmField::get_option( $field, 'data_type' ) ) { | |
| 256 | - return true; | |
| 257 | - } | |
| 258 | - | |
| 259 | - if ( ! empty( $field->field_options['post_field'] ) ) { | |
| 260 | - return true; | |
| 261 | - } | |
| 262 | - | |
| 263 | - $value = (array) $value; | |
| 264 | - | |
| 265 | - foreach ( $value as $current_value ) { | |
| 266 | - $match = false; | |
| 267 | - | |
| 268 | - foreach ( $options as $key => $option ) { | |
| 269 | - if ( str_starts_with( $key, 'other_' ) ) { | |
| 270 | - // Always return true if an other option is found. | |
| 271 | - return true; | |
| 272 | - } | |
| 273 | - | |
| 274 | - if ( is_array( $option ) ) { | |
| 275 | - $separate_value = FrmField::get_option( $field, 'separate_value' ); | |
| 276 | - $option_value = $separate_value ? $option['value'] : $option['label']; | |
| 277 | - } else { | |
| 278 | - $option_value = $option; | |
| 279 | - } | |
| 280 | - | |
| 281 | - $match = trim( $current_value ) === trim( $option_value ); | |
| 282 | - | |
| 283 | - if ( $match ) { | |
| 284 | - break; | |
| 285 | - } | |
| 286 | - | |
| 287 | - $match = trim( $current_value ) === trim( do_shortcode( $option_value ) ); | |
| 288 | - | |
| 289 | - if ( $match ) { | |
| 290 | - break; | |
| 291 | - } | |
| 292 | - | |
| 293 | - $match = self::is_filtered_match( $current_value, $option_value ); | |
| 294 | - | |
| 295 | - if ( $match ) { | |
| 296 | - break; | |
| 297 | - } | |
| 298 | - | |
| 299 | - if ( is_numeric( $current_value ) ) { | |
| 300 | - $match = (int) $current_value === (int) $option_value; | |
| 301 | - | |
| 302 | - if ( $match ) { | |
| 303 | - break; | |
| 304 | - } | |
| 305 | - } | |
| 306 | - }//end foreach | |
| 307 | - | |
| 308 | - if ( ! $match ) { | |
| 309 | - return self::options_are_dynamic_based_on_hook( $field, $value ); | |
| 310 | - } | |
| 311 | - }//end foreach | |
| 312 | - | |
| 313 | - return true; | |
| 314 | - } | |
| 315 | - | |
| 316 | - /** | |
| 317 | - * Make an extra check after passing $option_value through the_content filter. | |
| 318 | - * This is to help catch cases where the option's formatting has been modified using | |
| 319 | - * the_content filter. | |
| 320 | - * | |
| 321 | - * @since 6.22 | |
| 322 | - * | |
| 323 | - * @param string $value | |
| 324 | - * @param string $option_value | |
| 325 | - * | |
| 326 | - * @return bool | |
| 327 | - */ | |
| 328 | - private static function is_filtered_match( $value, $option_value ) { | |
| 329 | - // First remove the wpautop filter so it doesn't add extra tags to $option_value. | |
| 330 | - $filter_priority = has_filter( 'the_content', 'wpautop' ); | |
| 331 | - | |
| 332 | - if ( is_numeric( $filter_priority ) ) { | |
| 333 | - remove_filter( 'the_content', 'wpautop', $filter_priority ); | |
| 334 | - } | |
| 335 | - | |
| 336 | - $filtered_option = apply_filters( 'the_content', $option_value ); | |
| 337 | - | |
| 338 | - if ( is_numeric( $filter_priority ) ) { | |
| 339 | - add_filter( 'the_content', 'wpautop', $filter_priority ); | |
| 340 | - } | |
| 341 | - | |
| 342 | - return trim( $value ) === trim( $filtered_option ); | |
| 343 | - } | |
| 344 | - | |
| 345 | - /** | |
| 346 | - * Do not validate options if they have been modified with a hook. | |
| 347 | - * This is to help avoid issues where the options could be based on a URL param for example. | |
| 348 | - * | |
| 349 | - * @since 6.21 | |
| 350 | - * | |
| 351 | - * @param object $field_object The field object. | |
| 352 | - * @param array|string $value The value to validate. | |
| 353 | - * | |
| 354 | - * @return bool | |
| 355 | - */ | |
| 356 | - private static function options_are_dynamic_based_on_hook( $field_object, $value ) { | |
| 357 | - $values = (array) $field_object; | |
| 358 | - $values['value'] = $value; | |
| 359 | - FrmFieldsHelper::prepare_new_front_field( $values, $field_object ); | |
| 360 | - | |
| 361 | - $separate_value = FrmField::get_option( $field_object, 'separate_value' ); | |
| 362 | - $map_callback = function ( $option ) use ( $separate_value ) { | |
| 363 | - if ( is_array( $option ) ) { | |
| 364 | - $option_value = $separate_value ? $option['value'] : $option['label']; | |
| 365 | - } else { | |
| 366 | - $option_value = $option; | |
| 367 | - } | |
| 368 | - return do_shortcode( $option_value ); | |
| 369 | - }; | |
| 370 | - | |
| 371 | - $values_options = array_map( $map_callback, $values['options'] ); | |
| 372 | - $field_object_options = array_map( $map_callback, $field_object->options ); | |
| 373 | - | |
| 374 | - return $values_options !== $field_object_options; | |
| 375 | - } | |
| 376 | - | |
| 377 | - /** | |
| 378 | 180 | * Maybe add item_name to $_POST to save it in items table. |
| 379 | 181 | * |
| 380 | 182 | * @since 5.2.02 |
| 381 | 183 | * |
| @@ -380,14 +182,11 @@ | ||
| 380 | 182 | * @since 5.2.02 |
| 381 | 183 | * |
| 382 | 184 | * @param array|string $value Field value. |
| 383 | 185 | * @param object $field Field object. |
| 384 | - * | |
| 385 | - * @return void | |
| 386 | 186 | */ |
| 387 | 187 | private static function maybe_add_item_name( $value, $field ) { |
| 388 | 188 | $item_name = false; |
| 389 | - | |
| 390 | 189 | if ( 'name' === $field->type ) { |
| 391 | 190 | $field_obj = FrmFieldFactory::get_field_object( $field ); |
| 392 | 191 | $item_name = $field_obj->get_display_value( $value ); |
| 393 | 192 | } elseif ( 'text' === $field->type ) { |
| @@ -404,14 +203,11 @@ | ||
| 404 | 203 | * Set $value to an empty string if it matches its label |
| 405 | 204 | * |
| 406 | 205 | * @param object $field |
| 407 | 206 | * @param string $value |
| 408 | - * | |
| 409 | - * @return void | |
| 410 | 207 | */ |
| 411 | 208 | private static function maybe_clear_value_for_default_blank_setting( $field, &$value ) { |
| 412 | 209 | $position = FrmField::get_option( $field, 'label' ); |
| 413 | - | |
| 414 | 210 | if ( ! $position ) { |
| 415 | 211 | $position = FrmStylesController::get_style_val( 'position', $field->form_id ); |
| 416 | 212 | } |
| 417 | 213 | |
| @@ -419,16 +215,8 @@ | ||
| 419 | 215 | $value = ''; |
| 420 | 216 | } |
| 421 | 217 | } |
| 422 | 218 | |
| 423 | - /** | |
| 424 | - * @param array $errors | |
| 425 | - * @param object $posted_field | |
| 426 | - * @param mixed $value | |
| 427 | - * @param array $args | |
| 428 | - * | |
| 429 | - * @return void | |
| 430 | - */ | |
| 431 | 219 | public static function validate_field_types( &$errors, $posted_field, $value, $args ) { |
| 432 | 220 | $field_obj = FrmFieldFactory::get_field_object( $posted_field ); |
| 433 | 221 | $args['value'] = $value; |
| 434 | 222 | $args['errors'] = $errors; |
| @@ -433,22 +221,13 @@ | ||
| 433 | 221 | $args['value'] = $value; |
| 434 | 222 | $args['errors'] = $errors; |
| 435 | 223 | |
| 436 | 224 | $new_errors = $field_obj->validate( $args ); |
| 437 | - | |
| 438 | - if ( $new_errors ) { | |
| 225 | + if ( ! empty( $new_errors ) ) { | |
| 439 | 226 | $errors = array_merge( $errors, $new_errors ); |
| 440 | 227 | } |
| 441 | 228 | } |
| 442 | 229 | |
| 443 | - /** | |
| 444 | - * @param array $errors | |
| 445 | - * @param object $field | |
| 446 | - * @param string $value | |
| 447 | - * @param array $args | |
| 448 | - * | |
| 449 | - * @return void | |
| 450 | - */ | |
| 451 | 230 | public static function validate_phone_field( &$errors, $field, $value, $args ) { |
| 452 | 231 | $format_value = FrmField::get_option( $field, 'format' ); |
| 453 | 232 | |
| 454 | 233 | if ( $field->type === 'phone' || ( $field->type === 'text' && $format_value && ! FrmCurrencyHelper::is_currency_format( $format_value ) ) ) { |
| @@ -459,13 +238,8 @@ | ||
| 459 | 238 | } |
| 460 | 239 | } |
| 461 | 240 | } |
| 462 | 241 | |
| 463 | - /** | |
| 464 | - * @param object $field | |
| 465 | - * | |
| 466 | - * @return string | |
| 467 | - */ | |
| 468 | 242 | public static function phone_format( $field ) { |
| 469 | 243 | if ( FrmField::is_option_empty( $field, 'format' ) ) { |
| 470 | 244 | $pattern = self::default_phone_format(); |
| 471 | 245 | } else { |
| @@ -477,19 +251,19 @@ | ||
| 477 | 251 | $pattern = html_entity_decode( $pattern ); |
| 478 | 252 | $pattern = apply_filters( 'frm_phone_pattern', $pattern, $field ); |
| 479 | 253 | |
| 480 | 254 | // Create a regexp if format is not already a regexp |
| 481 | - if ( ! str_starts_with( $pattern, '^' ) ) { | |
| 255 | + if ( strpos( $pattern, '^' ) !== 0 ) { | |
| 482 | 256 | $pattern = self::create_regular_expression_from_format( $pattern ); |
| 483 | 257 | } |
| 484 | 258 | |
| 485 | - return '/' . $pattern . '/'; | |
| 259 | + $pattern = '/' . $pattern . '/'; | |
| 260 | + | |
| 261 | + return $pattern; | |
| 486 | 262 | } |
| 487 | 263 | |
| 488 | 264 | /** |
| 489 | 265 | * @since 3.01 |
| 490 | - * | |
| 491 | - * @return string | |
| 492 | 266 | */ |
| 493 | 267 | private static function default_phone_format() { |
| 494 | 268 | return '^((\+\d{1,3}(-|.| )?\(?\d\)?(-| |.)?\d{1,5})|(\(?\d{2,6}\)?))(-|.| )?(\d{3,4})(-|.| )?(\d{4})(( x| ext)\d{1,5}){0,1}$'; |
| 495 | 269 | } |
| @@ -515,14 +289,13 @@ | ||
| 515 | 289 | $pattern = str_replace( 'a', '[a-zA-Z]', $pattern ); |
| 516 | 290 | $pattern = str_replace( '*', 'w', $pattern ); |
| 517 | 291 | $pattern = str_replace( '/', '\/', $pattern ); |
| 518 | 292 | |
| 519 | - if ( str_contains( $pattern, '\?' ) ) { | |
| 293 | + if ( strpos( $pattern, '\?' ) !== false ) { | |
| 520 | 294 | $parts = explode( '\?', $pattern ); |
| 521 | 295 | $pattern = ''; |
| 522 | - | |
| 523 | 296 | foreach ( $parts as $part ) { |
| 524 | - if ( ! $pattern ) { | |
| 297 | + if ( empty( $pattern ) ) { | |
| 525 | 298 | $pattern .= $part; |
| 526 | 299 | } else { |
| 527 | 300 | $pattern .= '(' . $part . ')?'; |
| 528 | 301 | } |
| @@ -527,45 +300,33 @@ | ||
| 527 | 300 | $pattern .= '(' . $part . ')?'; |
| 528 | 301 | } |
| 529 | 302 | } |
| 530 | 303 | } |
| 304 | + $pattern = '^' . $pattern . '$'; | |
| 531 | 305 | |
| 532 | - return '^' . $pattern . '$'; | |
| 306 | + return $pattern; | |
| 533 | 307 | } |
| 534 | 308 | |
| 535 | 309 | /** |
| 536 | - * Check for spam. | |
| 310 | + * Check for spam | |
| 537 | 311 | * |
| 538 | 312 | * @param bool $exclude |
| 539 | 313 | * @param array $values |
| 540 | 314 | * @param array $errors By reference. |
| 541 | - * | |
| 542 | - * @return void | |
| 543 | 315 | */ |
| 544 | 316 | public static function spam_check( $exclude, $values, &$errors ) { |
| 545 | - if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) { | |
| 546 | - // Do not check spam on importing. | |
| 547 | - return; | |
| 548 | - } | |
| 549 | - | |
| 550 | - if ( $exclude || empty( $values['item_meta'] ) || ! empty( $errors ) ) { | |
| 317 | + if ( ! empty( $exclude ) || empty( $values['item_meta'] ) || ! empty( $errors ) ) { | |
| 551 | 318 | // only check spam if there are no other errors |
| 552 | 319 | return; |
| 553 | 320 | } |
| 554 | 321 | |
| 555 | 322 | $antispam_check = self::is_antispam_check( $values['form_id'] ); |
| 556 | - $spam_msg = FrmAntiSpamController::get_default_spam_message(); | |
| 557 | - | |
| 558 | 323 | if ( is_string( $antispam_check ) ) { |
| 559 | 324 | $errors['spam'] = $antispam_check; |
| 560 | 325 | } elseif ( self::is_honeypot_spam( $values ) || self::is_spam_bot() ) { |
| 561 | - $errors['spam'] = $spam_msg; | |
| 562 | - } else { | |
| 563 | - $is_spam = FrmAntiSpamController::is_spam( $values ); | |
| 564 | - | |
| 565 | - if ( $is_spam ) { | |
| 566 | - $errors['spam'] = $is_spam; | |
| 567 | - } | |
| 326 | + $errors['spam'] = __( 'Your entry appears to be spam!', 'formidable' ); | |
| 327 | + } elseif ( self::blacklist_check( $values ) ) { | |
| 328 | + $errors['spam'] = __( 'Your entry appears to be blocked spam!', 'formidable' ); | |
| 568 | 329 | } |
| 569 | 330 | |
| 570 | 331 | if ( isset( $errors['spam'] ) || self::form_is_in_progress( $values ) ) { |
| 571 | 332 | return; |
| @@ -581,9 +342,8 @@ | ||
| 581 | 342 | * |
| 582 | 343 | * @since 5.0.13 |
| 583 | 344 | * |
| 584 | 345 | * @param array $values The values. |
| 585 | - * | |
| 586 | 346 | * @return bool |
| 587 | 347 | */ |
| 588 | 348 | private static function form_is_in_progress( $values ) { |
| 589 | 349 | return FrmAppHelper::pro_is_installed() && |
| @@ -602,9 +362,8 @@ | ||
| 602 | 362 | } |
| 603 | 363 | |
| 604 | 364 | /** |
| 605 | 365 | * @param array $values |
| 606 | - * | |
| 607 | 366 | * @return bool |
| 608 | 367 | */ |
| 609 | 368 | private static function is_honeypot_spam( $values ) { |
| 610 | 369 | $honeypot = new FrmHoneypot( $values['form_id'] ); |
| @@ -615,47 +374,83 @@ | ||
| 615 | 374 | * @return bool |
| 616 | 375 | */ |
| 617 | 376 | private static function is_spam_bot() { |
| 618 | 377 | $ip = FrmAppHelper::get_ip_address(); |
| 378 | + | |
| 619 | 379 | return empty( $ip ); |
| 620 | 380 | } |
| 621 | 381 | |
| 622 | 382 | /** |
| 623 | 383 | * @param array $values |
| 624 | - * | |
| 625 | 384 | * @return bool |
| 626 | 385 | */ |
| 627 | 386 | private static function is_akismet_spam( $values ) { |
| 628 | 387 | global $wpcom_api_key; |
| 629 | - return is_callable( 'Akismet::http_post' ) && ( get_option( 'wordpress_api_key' ) || $wpcom_api_key ) && self::akismet( $values ); | |
| 388 | + | |
| 389 | + return ( is_callable( 'Akismet::http_post' ) && ( get_option( 'wordpress_api_key' ) || $wpcom_api_key ) && self::akismet( $values ) ); | |
| 630 | 390 | } |
| 631 | 391 | |
| 632 | 392 | /** |
| 633 | 393 | * @param int $form_id |
| 634 | - * | |
| 635 | 394 | * @return bool |
| 636 | 395 | */ |
| 637 | 396 | private static function is_akismet_enabled_for_user( $form_id ) { |
| 638 | 397 | $form = FrmForm::getOne( $form_id ); |
| 639 | - return ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] !== 'logged' || ! is_user_logged_in() ); | |
| 398 | + | |
| 399 | + return ( ! empty( $form->options['akismet'] ) && ( $form->options['akismet'] !== 'logged' || ! is_user_logged_in() ) ); | |
| 640 | 400 | } |
| 641 | 401 | |
| 402 | + public static function blacklist_check( $values ) { | |
| 403 | + if ( ! apply_filters( 'frm_check_blacklist', true, $values ) ) { | |
| 404 | + return false; | |
| 405 | + } | |
| 406 | + | |
| 407 | + $mod_keys = trim( self::get_disallowed_words() ); | |
| 408 | + if ( empty( $mod_keys ) ) { | |
| 409 | + return false; | |
| 410 | + } | |
| 411 | + | |
| 412 | + $content = FrmEntriesHelper::entry_array_to_string( $values ); | |
| 413 | + | |
| 414 | + self::prepare_values_for_spam_check( $values ); | |
| 415 | + $ip = FrmAppHelper::get_ip_address(); | |
| 416 | + $user_agent = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ); | |
| 417 | + $user_info = self::get_spam_check_user_info( $values ); | |
| 418 | + | |
| 419 | + return self::check_disallowed_words( $user_info['comment_author'], $user_info['comment_author_email'], $user_info['comment_author_url'], $content, $ip, $user_agent ); | |
| 420 | + } | |
| 421 | + | |
| 642 | 422 | /** |
| 643 | - * Checks spam using WordPress disallowed words and Frm denylist. | |
| 423 | + * For WP 5.5 compatibility. | |
| 644 | 424 | * |
| 645 | - * @param array $values Entry values. | |
| 425 | + * @since 4.06.02 | |
| 426 | + */ | |
| 427 | + private static function check_disallowed_words( $author, $email, $url, $content, $ip, $user_agent ) { | |
| 428 | + if ( function_exists( 'wp_check_comment_disallowed_list' ) ) { | |
| 429 | + return wp_check_comment_disallowed_list( $author, $email, $url, $content, $ip, $user_agent ); | |
| 430 | + } | |
| 431 | + // phpcs:ignore WordPress.WP.DeprecatedFunctions.wp_blacklist_checkFound | |
| 432 | + return wp_blacklist_check( $author, $email, $url, $content, $ip, $user_agent ); | |
| 433 | + } | |
| 434 | + | |
| 435 | + /** | |
| 436 | + * For WP 5.5 compatibility. | |
| 646 | 437 | * |
| 647 | - * @return bool | |
| 438 | + * @since 4.06.02 | |
| 648 | 439 | */ |
| 649 | - public static function blacklist_check( $values ) { | |
| 650 | - return FrmAntiSpamController::contains_wp_disallowed_words( $values ) || FrmAntiSpamController::is_denylist_spam( $values ); | |
| 440 | + private static function get_disallowed_words() { | |
| 441 | + $keys = get_option( 'disallowed_keys' ); | |
| 442 | + if ( false === $keys ) { | |
| 443 | + // Fallback for WP < 5.5. | |
| 444 | + // phpcs:ignore WordPress.WP.DeprecatedParameterValues.Found | |
| 445 | + $keys = get_option( 'blacklist_keys' ); | |
| 446 | + } | |
| 447 | + return $keys; | |
| 651 | 448 | } |
| 652 | 449 | |
| 653 | 450 | /** |
| 654 | 451 | * Check entries for Akismet spam |
| 655 | 452 | * |
| 656 | - * @param array $values Entry values. | |
| 657 | - * | |
| 658 | 453 | * @return bool true if is spam |
| 659 | 454 | */ |
| 660 | 455 | public static function akismet( $values ) { |
| 661 | 456 | if ( empty( $values['item_meta'] ) ) { |
| @@ -678,18 +473,13 @@ | ||
| 678 | 473 | |
| 679 | 474 | $query_string = _http_build_query( $datas, '', '&' ); |
| 680 | 475 | $response = Akismet::http_post( $query_string, 'comment-check' ); |
| 681 | 476 | |
| 682 | - return is_array( $response ) && $response[1] === 'true'; | |
| 477 | + return ( is_array( $response ) && $response[1] === 'true' ); | |
| 683 | 478 | } |
| 684 | 479 | |
| 685 | 480 | /** |
| 686 | 481 | * @since 2.0 |
| 687 | - * | |
| 688 | - * @param array $datas The array of values being sent to Akismet. | |
| 689 | - * @param array $values Entry values. | |
| 690 | - * | |
| 691 | - * @return void | |
| 692 | 482 | */ |
| 693 | 483 | private static function parse_akismet_array( &$datas, $values ) { |
| 694 | 484 | self::add_site_info_to_akismet( $datas ); |
| 695 | 485 | self::add_server_values_to_akismet( $datas ); |
| @@ -700,13 +490,8 @@ | ||
| 700 | 490 | self::add_user_info_to_akismet( $datas, $values ); |
| 701 | 491 | self::add_comment_content_to_akismet( $datas, $values ); |
| 702 | 492 | } |
| 703 | 493 | |
| 704 | - /** | |
| 705 | - * @param array $datas | |
| 706 | - * | |
| 707 | - * @return void | |
| 708 | - */ | |
| 709 | 494 | private static function add_site_info_to_akismet( &$datas ) { |
| 710 | 495 | $datas['blog'] = FrmAppHelper::site_url(); |
| 711 | 496 | $datas['user_ip'] = preg_replace( '/[^0-9., ]/', '', FrmAppHelper::get_ip_address() ); |
| 712 | 497 | $datas['user_agent'] = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ); |
| @@ -718,14 +503,8 @@ | ||
| 718 | 503 | $datas['is_test'] = 'true'; |
| 719 | 504 | } |
| 720 | 505 | } |
| 721 | 506 | |
| 722 | - /** | |
| 723 | - * @param array $datas | |
| 724 | - * @param array $values | |
| 725 | - * | |
| 726 | - * @return void | |
| 727 | - */ | |
| 728 | 507 | private static function add_user_info_to_akismet( &$datas, $values ) { |
| 729 | 508 | $user_info = self::get_spam_check_user_info( $values ); |
| 730 | 509 | $datas = $datas + $user_info; |
| 731 | 510 | |
| @@ -737,15 +516,13 @@ | ||
| 737 | 516 | /** |
| 738 | 517 | * Gets user info for Akismet spam check. |
| 739 | 518 | * |
| 740 | 519 | * @since 5.0.13 Separate code for guest. Handle value of embedded|repeater. |
| 741 | - * @since 6.21 This changed from private to public. | |
| 742 | 520 | * |
| 743 | 521 | * @param array $values Entry values after running through {@see FrmEntryValidate::prepare_values_for_spam_check()}. |
| 744 | - * | |
| 745 | 522 | * @return array |
| 746 | 523 | */ |
| 747 | - public static function get_spam_check_user_info( $values ) { | |
| 524 | + private static function get_spam_check_user_info( $values ) { | |
| 748 | 525 | if ( ! is_user_logged_in() ) { |
| 749 | 526 | return self::get_spam_check_user_info_for_guest( $values ); |
| 750 | 527 | } |
| 751 | 528 | |
| @@ -765,9 +542,8 @@ | ||
| 765 | 542 | * |
| 766 | 543 | * @since 5.0.13 |
| 767 | 544 | * |
| 768 | 545 | * @param array $values Entry values after flattened. |
| 769 | - * | |
| 770 | 546 | * @return array |
| 771 | 547 | */ |
| 772 | 548 | private static function get_spam_check_user_info_for_guest( $values ) { |
| 773 | 549 | $datas = array( |
| @@ -799,10 +575,8 @@ | ||
| 799 | 575 | * |
| 800 | 576 | * @param array $datas Guest data. |
| 801 | 577 | * @param array $values The values. |
| 802 | 578 | * @param int|null $custom_index Custom index (or field ID). |
| 803 | - * | |
| 804 | - * @return void | |
| 805 | 579 | */ |
| 806 | 580 | private static function recursive_add_akismet_guest_info( &$datas, $values, $custom_index = null ) { |
| 807 | 581 | foreach ( $values as $index => $value ) { |
| 808 | 582 | if ( ! $datas['missing_keys'] ) { |
| @@ -815,12 +589,10 @@ | ||
| 815 | 589 | continue; |
| 816 | 590 | } |
| 817 | 591 | |
| 818 | 592 | $field_id = ! is_null( $custom_index ) ? $custom_index : $index; |
| 819 | - | |
| 820 | 593 | foreach ( $datas['missing_keys'] as $key_index => $key ) { |
| 821 | 594 | $found = self::is_akismet_guest_info_value( $key, $value, $field_id, $datas['name_field_ids'], $values ); |
| 822 | - | |
| 823 | 595 | if ( $found ) { |
| 824 | 596 | $datas[ $key ] = $value; |
| 825 | 597 | $datas['frm_duplicated'][] = $field_id; |
| 826 | 598 | unset( $datas['missing_keys'][ $key_index ] ); |
| @@ -848,12 +620,12 @@ | ||
| 848 | 620 | } |
| 849 | 621 | |
| 850 | 622 | switch ( $key ) { |
| 851 | 623 | case 'comment_author_email': |
| 852 | - return str_contains( $value, '@' ) && is_email( $value ); | |
| 624 | + return strpos( $value, '@' ) && is_email( $value ); | |
| 853 | 625 | |
| 854 | 626 | case 'comment_author_url': |
| 855 | - return str_starts_with( $value, 'http' ); | |
| 627 | + return 0 === strpos( $value, 'http' ); | |
| 856 | 628 | |
| 857 | 629 | case 'comment_author': |
| 858 | 630 | if ( $name_field_ids && in_array( $field_id, $name_field_ids, true ) ) { |
| 859 | 631 | // If there is name field in the form, we should always use it as author name. |
| @@ -858,9 +630,8 @@ | ||
| 858 | 630 | if ( $name_field_ids && in_array( $field_id, $name_field_ids, true ) ) { |
| 859 | 631 | // If there is name field in the form, we should always use it as author name. |
| 860 | 632 | return true; |
| 861 | 633 | } |
| 862 | - | |
| 863 | 634 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 864 | 635 | $fields = self::get_name_text_fields( $form_id ); |
| 865 | 636 | |
| 866 | 637 | foreach ( $fields as $index => $field ) { |
| @@ -866,14 +637,12 @@ | ||
| 866 | 637 | foreach ( $fields as $index => $field ) { |
| 867 | 638 | if ( 'Name' !== $field->name ) { |
| 868 | 639 | continue; |
| 869 | 640 | } |
| 870 | - | |
| 871 | 641 | if ( isset( $fields[ $index + 1 ] ) && 'Last' === $fields[ $index + 1 ]->name ) { |
| 872 | 642 | if ( empty( $values[ absint( $fields[ $index + 1 ]->id ) ] ) ) { |
| 873 | 643 | continue; |
| 874 | 644 | } |
| 875 | - | |
| 876 | 645 | $value .= ' ' . $values[ $fields[ $index + 1 ]->id ]; |
| 877 | 646 | return true; |
| 878 | 647 | } |
| 879 | 648 | } |
| @@ -887,18 +656,15 @@ | ||
| 887 | 656 | * |
| 888 | 657 | * @since 6.17 |
| 889 | 658 | * |
| 890 | 659 | * @param int $form_id |
| 891 | - * | |
| 892 | 660 | * @return array |
| 893 | 661 | */ |
| 894 | 662 | private static function get_name_text_fields( $form_id ) { |
| 895 | 663 | $name_text_fields_is_initialized = is_array( self::$name_text_fields ); |
| 896 | - | |
| 897 | 664 | if ( $name_text_fields_is_initialized && isset( self::$name_text_fields[ $form_id ] ) ) { |
| 898 | 665 | return self::$name_text_fields[ $form_id ]; |
| 899 | 666 | } |
| 900 | - | |
| 901 | 667 | if ( ! $name_text_fields_is_initialized ) { |
| 902 | 668 | self::$name_text_fields = array(); |
| 903 | 669 | } |
| 904 | 670 | self::$name_text_fields[ $form_id ] = FrmDb::get_results( |
| @@ -914,13 +680,8 @@ | ||
| 914 | 680 | |
| 915 | 681 | return self::$name_text_fields[ $form_id ]; |
| 916 | 682 | } |
| 917 | 683 | |
| 918 | - /** | |
| 919 | - * @param array $datas | |
| 920 | - * | |
| 921 | - * @return void | |
| 922 | - */ | |
| 923 | 684 | private static function add_server_values_to_akismet( &$datas ) { |
| 924 | 685 | foreach ( $_SERVER as $key => $value ) { |
| 925 | 686 | $include_value = is_string( $value ) && ! preg_match( '/^HTTP_COOKIE/', $key ) && preg_match( '/^(HTTP_|REMOTE_ADDR|REQUEST_URI|DOCUMENT_URI)/', $key ); |
| 926 | 687 | |
| @@ -938,10 +699,8 @@ | ||
| 938 | 699 | * @since 5.0.09 |
| 939 | 700 | * |
| 940 | 701 | * @param array $datas The array of values being sent to Akismet. |
| 941 | 702 | * @param array $values Entry values. |
| 942 | - * | |
| 943 | - * @return void | |
| 944 | 703 | */ |
| 945 | 704 | private static function add_comment_content_to_akismet( &$datas, $values ) { |
| 946 | 705 | if ( isset( $datas['frm_duplicated'] ) ) { |
| 947 | 706 | foreach ( $datas['frm_duplicated'] as $index ) { |
| @@ -962,14 +721,11 @@ | ||
| 962 | 721 | * |
| 963 | 722 | * @since 5.0.09 |
| 964 | 723 | * |
| 965 | 724 | * @param array $values Entry values. |
| 966 | - * | |
| 967 | - * @return void | |
| 968 | 725 | */ |
| 969 | 726 | private static function skip_adding_values_to_akismet( &$values ) { |
| 970 | 727 | $skipped_fields = self::get_akismet_skipped_field_ids( $values ); |
| 971 | - | |
| 972 | 728 | foreach ( $skipped_fields as $skipped_field ) { |
| 973 | 729 | if ( ! isset( $values['item_meta'][ $skipped_field->id ] ) ) { |
| 974 | 730 | continue; |
| 975 | 731 | } |
| @@ -975,9 +731,8 @@ | ||
| 975 | 731 | } |
| 976 | 732 | |
| 977 | 733 | if ( self::should_really_skip_field( $skipped_field, $values ) ) { |
| 978 | 734 | unset( $values['item_meta'][ $skipped_field->id ] ); |
| 979 | - | |
| 980 | 735 | if ( isset( $values['item_meta']['other'][ $skipped_field->id ] ) ) { |
| 981 | 736 | unset( $values['item_meta']['other'][ $skipped_field->id ] ); |
| 982 | 737 | } |
| 983 | 738 | } |
| @@ -990,9 +745,8 @@ | ||
| 990 | 745 | * @since 5.02.04 |
| 991 | 746 | * |
| 992 | 747 | * @param object $field_data Object contains `id` and `options`. |
| 993 | 748 | * @param array $values Entry values. |
| 994 | - * | |
| 995 | 749 | * @return bool |
| 996 | 750 | */ |
| 997 | 751 | private static function should_really_skip_field( $field_data, $values ) { |
| 998 | 752 | if ( empty( $field_data->options ) ) { |
| @@ -1000,18 +754,18 @@ | ||
| 1000 | 754 | return true; |
| 1001 | 755 | } |
| 1002 | 756 | |
| 1003 | 757 | FrmAppHelper::unserialize_or_decode( $field_data->options ); |
| 1004 | - | |
| 1005 | 758 | if ( ! $field_data->options ) { |
| 1006 | 759 | // Check if an error happens when unserializing, or empty options. |
| 1007 | 760 | return true; |
| 1008 | 761 | } |
| 1009 | 762 | |
| 1010 | - $last_key = array_key_last( $field_data->options ); | |
| 763 | + end( $field_data->options ); | |
| 764 | + $last_key = key( $field_data->options ); | |
| 1011 | 765 | |
| 1012 | 766 | // If a choice field has no Other option. |
| 1013 | - if ( is_numeric( $last_key ) || ! str_starts_with( $last_key, 'other_' ) ) { | |
| 767 | + if ( is_numeric( $last_key ) || 0 !== strpos( $last_key, 'other_' ) ) { | |
| 1014 | 768 | return true; |
| 1015 | 769 | } |
| 1016 | 770 | |
| 1017 | 771 | // If a choice field has Other option, but Other is not selected. |
| @@ -1020,10 +774,9 @@ | ||
| 1020 | 774 | } |
| 1021 | 775 | |
| 1022 | 776 | // Check if submitted value is same as one of field option. |
| 1023 | 777 | foreach ( $field_data->options as $option ) { |
| 1024 | - $option_value = ! is_array( $option ) ? $option : ( $option['value'] ?? '' ); | |
| 1025 | - | |
| 778 | + $option_value = ! is_array( $option ) ? $option : ( isset( $option['value'] ) ? $option['value'] : '' ); | |
| 1026 | 779 | if ( $values['item_meta']['other'][ $field_data->id ] === $option_value ) { |
| 1027 | 780 | return true; |
| 1028 | 781 | } |
| 1029 | 782 | } |
| @@ -1038,9 +791,8 @@ | ||
| 1038 | 791 | * @since 5.0.13 Move out get_all_form_ids_and_flatten_meta() call and get `form_ids` from `$values`. |
| 1039 | 792 | * @since 5.2.04 This method returns array of object contains `id` and `options` instead of array of `id` only. |
| 1040 | 793 | * |
| 1041 | 794 | * @param array $values Entry values after running through {@see FrmEntryValidate::prepare_values_for_spam_check()}. |
| 1042 | - * | |
| 1043 | 795 | * @return array |
| 1044 | 796 | */ |
| 1045 | 797 | private static function get_akismet_skipped_field_ids( $values ) { |
| 1046 | 798 | if ( empty( $values['form_ids'] ) ) { |
| @@ -1063,15 +815,12 @@ | ||
| 1063 | 815 | /** |
| 1064 | 816 | * Prepares values array for spam check. |
| 1065 | 817 | * |
| 1066 | 818 | * @since 5.0.13 |
| 1067 | - * @since 6.21 This changed from private to public. | |
| 1068 | 819 | * |
| 1069 | 820 | * @param array $values Entry values. |
| 1070 | - * | |
| 1071 | - * @return void | |
| 1072 | 821 | */ |
| 1073 | - public static function prepare_values_for_spam_check( &$values ) { | |
| 822 | + private static function prepare_values_for_spam_check( &$values ) { | |
| 1074 | 823 | $form_ids = self::get_all_form_ids_and_flatten_meta( $values ); |
| 1075 | 824 | $values['form_ids'] = $form_ids; |
| 1076 | 825 | } |
| 1077 | 826 | |
| @@ -1082,17 +831,15 @@ | ||
| 1082 | 831 | * @since 5.0.09 |
| 1083 | 832 | * @since 5.0.13 Convert name field value to string. |
| 1084 | 833 | * |
| 1085 | 834 | * @param array $values Entry values. |
| 1086 | - * | |
| 1087 | 835 | * @return array Form IDs. |
| 1088 | 836 | */ |
| 1089 | - private static function get_all_form_ids_and_flatten_meta( &$values ) { // phpcs:ignore SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh | |
| 837 | + private static function get_all_form_ids_and_flatten_meta( &$values ) { | |
| 1090 | 838 | $values['name_field_ids'] = array(); |
| 1091 | 839 | |
| 1092 | 840 | // Blacklist check for File field in the old version doesn't contain `form_id`. |
| 1093 | 841 | $form_ids = isset( $values['form_id'] ) ? array( absint( $values['form_id'] ) ) : array(); |
| 1094 | - | |
| 1095 | 842 | foreach ( $values['item_meta'] as $field_id => $value ) { |
| 1096 | 843 | if ( ! is_numeric( $field_id ) ) { |
| 1097 | 844 | // Maybe `other`. |
| 1098 | 845 | continue; |
| @@ -1126,15 +873,14 @@ | ||
| 1126 | 873 | } |
| 1127 | 874 | |
| 1128 | 875 | // Convert name array to string. |
| 1129 | 876 | if ( isset( $subsubvalue['first'] ) && isset( $subsubvalue['last'] ) ) { |
| 1130 | - $subsubvalue = trim( implode( ' ', $subsubvalue ) ); | |
| 877 | + $subsubvalue = trim( implode( ' ', $subsubvalue ) ); | |
| 878 | + | |
| 1131 | 879 | $values['name_field_ids'][] = $subsubindex; |
| 1132 | 880 | } |
| 1133 | 881 | |
| 1134 | - if ( is_array( $values['item_meta'][ $subsubindex ] ) ) { | |
| 1135 | - $values['item_meta'][ $subsubindex ][] = $subsubvalue; | |
| 1136 | - } | |
| 882 | + $values['item_meta'][ $subsubindex ][] = $subsubvalue; | |
| 1137 | 883 | } |
| 1138 | 884 | }//end foreach |
| 1139 | 885 | |
| 1140 | 886 | unset( $values['item_meta'][ $field_id ] ); |