.*?<\/\1>/', '', $value), [ 'a' => ['href' => [], 'title' => [], 'class' => [], 'target' => [], 'rel' => []], 'abbr' => ['title' => []], 'b' => [], 'br' => [], 'em' => [], 's' => [], 'strike' => [], 'strong' => [], 'pre' => [], ], ['http', 'https'] ); // wp_kses() encodes a plain "&", "<" or ">". Only removed markup is reported. if (wp_specialchars_decode($validated) !== wp_specialchars_decode($value)) { $message = empty($validated) ? __('The value on this settings field is not allowed.', 'admin-options-pages') : __('Some of the value on this settings field is not allowed.', 'admin-options-pages'); add_settings_error( $optionName, 'aop-textfield', sprintf( '%1$s ', esc_html($message), esc_attr($optionName), esc_html($optionName) ), 'error' ); } return $validated; } /** * A hex color with a leading "#". A wrong value gives back $current. * * @param string $value * @param string $optionName * @param mixed $current The value to keep when the new one is wrong. * * @return mixed */ public static function color($value, string $optionName, $current) { if (substr($value, 0, 1) !== '#') { $value = '#' . $value; } $validated = (new Validation())->isColorHex($value) ? $value : $current; if ($validated !== $value) { add_settings_error( $optionName, 'aop-colorpicker', sprintf( '%1$s ', esc_html(__('This is not a correct formatted Hex color.', 'admin-options-pages')), esc_attr($optionName) ), 'error' ); } return $validated; } }