| @@ -24,8 +24,9 @@ | ||
| 24 | 24 | $frm_settings = FrmAppHelper::get_settings(); |
| 25 | 25 | $errors['form'] = $frm_settings->admin_permission; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | + self::maybe_fix_item_meta(); | |
| 28 | 29 | self::set_item_key( $values ); |
| 29 | 30 | |
| 30 | 31 | $posted_fields = self::get_fields_to_validate( $values, $exclude ); |
| 31 | 32 | |
| @@ -58,8 +59,23 @@ | ||
| 58 | 59 | _doing_it_wrong( __FUNCTION__, 'Only arrays should be returned when using the frm_validate_entry filter.', '6.3' ); |
| 59 | 60 | } |
| 60 | 61 | |
| 61 | 62 | return $errors; |
| 63 | + } | |
| 64 | + | |
| 65 | + /** | |
| 66 | + * In case $_POST['item_meta'] is not an array, change it to an empty array. | |
| 67 | + * This helps to avoid some warnings and errors when $_POST['item_meta'] is updated. | |
| 68 | + * | |
| 69 | + * @since 6.6 | |
| 70 | + * | |
| 71 | + * @return void | |
| 72 | + */ | |
| 73 | + private static function maybe_fix_item_meta() { | |
| 74 | + // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated | |
| 75 | + if ( ! isset( $_POST['item_meta'] ) || ! is_array( $_POST['item_meta'] ) ) { | |
| 76 | + $_POST['item_meta'] = array(); | |
| 77 | + } | |
| 62 | 78 | } |
| 63 | 79 | |
| 64 | 80 | private static function set_item_key( &$values ) { |
| 65 | 81 | if ( ! isset( $values['item_key'] ) || $values['item_key'] == '' ) { |