| @@ -16,9 +16,9 @@ | ||
| 16 | 16 | * The error descriptions. |
| 17 | 17 | * |
| 18 | 18 | * @since 12.1 |
| 19 | 19 | * |
| 20 | - * @var array | |
| 20 | + * @var array<string, string> | |
| 21 | 21 | */ |
| 22 | 22 | private static $error_descriptions = []; |
| 23 | 23 | |
| 24 | 24 | /** |
| @@ -63,9 +63,9 @@ | ||
| 63 | 63 | return sprintf( |
| 64 | 64 | /* translators: %1$s: amount of errors, %2$s: the admin page title */ |
| 65 | 65 | _n( 'The form contains %1$s error. %2$s', 'The form contains %1$s errors. %2$s', $error_count, 'wordpress-seo' ), |
| 66 | 66 | number_format_i18n( $error_count ), |
| 67 | - $admin_title | |
| 67 | + $admin_title, | |
| 68 | 68 | ); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | return $admin_title; |
| @@ -92,101 +92,8 @@ | ||
| 92 | 92 | return false; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
| 96 | - * Sets the error descriptions. | |
| 97 | - * | |
| 98 | - * @since 12.1 | |
| 99 | - * | |
| 100 | - * @param array $descriptions An associative array of error descriptions. | |
| 101 | - * For each entry, the key must be the setting variable. | |
| 102 | - */ | |
| 103 | - public static function set_error_descriptions( $descriptions = [] ) { | |
| 104 | - $defaults = [ | |
| 105 | - 'baiduverify' => sprintf( | |
| 106 | - /* translators: %s: additional message with the submitted invalid value */ | |
| 107 | - esc_html__( 'Baidu verification codes can only contain letters, numbers, hyphens, and underscores. %s', 'wordpress-seo' ), | |
| 108 | - self::get_dirty_value_message( 'baiduverify' ) | |
| 109 | - ), | |
| 110 | - 'facebook_site' => sprintf( | |
| 111 | - /* translators: %s: additional message with the submitted invalid value */ | |
| 112 | - esc_html__( 'Please check the format of the Facebook Page URL you entered. %s', 'wordpress-seo' ), | |
| 113 | - self::get_dirty_value_message( 'facebook_site' ) | |
| 114 | - ), | |
| 115 | - 'googleverify' => sprintf( | |
| 116 | - /* translators: %s: additional message with the submitted invalid value */ | |
| 117 | - esc_html__( 'Google verification codes can only contain letters, numbers, hyphens, and underscores. %s', 'wordpress-seo' ), | |
| 118 | - self::get_dirty_value_message( 'googleverify' ) | |
| 119 | - ), | |
| 120 | - 'instagram_url' => sprintf( | |
| 121 | - /* translators: %s: additional message with the submitted invalid value */ | |
| 122 | - esc_html__( 'Please check the format of the Instagram URL you entered. %s', 'wordpress-seo' ), | |
| 123 | - self::get_dirty_value_message( 'instagram_url' ) | |
| 124 | - ), | |
| 125 | - 'linkedin_url' => sprintf( | |
| 126 | - /* translators: %s: additional message with the submitted invalid value */ | |
| 127 | - esc_html__( 'Please check the format of the Linkedin URL you entered. %s', 'wordpress-seo' ), | |
| 128 | - self::get_dirty_value_message( 'linkedin_url' ) | |
| 129 | - ), | |
| 130 | - 'msverify' => sprintf( | |
| 131 | - /* translators: %s: additional message with the submitted invalid value */ | |
| 132 | - esc_html__( 'Bing confirmation codes can only contain letters from A to F, numbers, hyphens, and underscores. %s', 'wordpress-seo' ), | |
| 133 | - self::get_dirty_value_message( 'msverify' ) | |
| 134 | - ), | |
| 135 | - 'myspace_url' => sprintf( | |
| 136 | - /* translators: %s: additional message with the submitted invalid value */ | |
| 137 | - esc_html__( 'Please check the format of the MySpace URL you entered. %s', 'wordpress-seo' ), | |
| 138 | - self::get_dirty_value_message( 'myspace_url' ) | |
| 139 | - ), | |
| 140 | - 'pinterest_url' => sprintf( | |
| 141 | - /* translators: %s: additional message with the submitted invalid value */ | |
| 142 | - esc_html__( 'Please check the format of the Pinterest URL you entered. %s', 'wordpress-seo' ), | |
| 143 | - self::get_dirty_value_message( 'pinterest_url' ) | |
| 144 | - ), | |
| 145 | - 'pinterestverify' => sprintf( | |
| 146 | - /* translators: %s: additional message with the submitted invalid value */ | |
| 147 | - esc_html__( 'Pinterest confirmation codes can only contain letters from A to F, numbers, hyphens, and underscores. %s', 'wordpress-seo' ), | |
| 148 | - self::get_dirty_value_message( 'pinterestverify' ) | |
| 149 | - ), | |
| 150 | - 'twitter_site' => sprintf( | |
| 151 | - /* translators: %s: additional message with the submitted invalid value */ | |
| 152 | - esc_html__( 'Twitter usernames can only contain letters, numbers, and underscores. %s', 'wordpress-seo' ), | |
| 153 | - self::get_dirty_value_message( 'twitter_site' ) | |
| 154 | - ), | |
| 155 | - 'wikipedia_url' => sprintf( | |
| 156 | - /* translators: %s: additional message with the submitted invalid value */ | |
| 157 | - esc_html__( 'Please check the format of the Wikipedia URL you entered. %s', 'wordpress-seo' ), | |
| 158 | - self::get_dirty_value_message( 'wikipedia_url' ) | |
| 159 | - ), | |
| 160 | - 'yandexverify' => sprintf( | |
| 161 | - /* translators: %s: additional message with the submitted invalid value */ | |
| 162 | - esc_html__( 'Yandex confirmation codes can only contain letters from A to F, numbers, hyphens, and underscores. %s', 'wordpress-seo' ), | |
| 163 | - self::get_dirty_value_message( 'yandexverify' ) | |
| 164 | - ), | |
| 165 | - 'youtube_url' => sprintf( | |
| 166 | - /* translators: %s: additional message with the submitted invalid value */ | |
| 167 | - esc_html__( 'Please check the format of the Youtube URL you entered. %s', 'wordpress-seo' ), | |
| 168 | - self::get_dirty_value_message( 'youtube_url' ) | |
| 169 | - ), | |
| 170 | - ]; | |
| 171 | - | |
| 172 | - $descriptions = wp_parse_args( $descriptions, $defaults ); | |
| 173 | - | |
| 174 | - self::$error_descriptions = $descriptions; | |
| 175 | - } | |
| 176 | - | |
| 177 | - /** | |
| 178 | - * Gets all the error descriptions. | |
| 179 | - * | |
| 180 | - * @since 12.1 | |
| 181 | - * | |
| 182 | - * @return array An associative array of error descriptions. | |
| 183 | - */ | |
| 184 | - public static function get_error_descriptions() { | |
| 185 | - return self::$error_descriptions; | |
| 186 | - } | |
| 187 | - | |
| 188 | - /** | |
| 189 | 96 | * Gets a specific error description. |
| 190 | 97 | * |
| 191 | 98 | * @since 12.1 |
| 192 | 99 | * |
| @@ -277,50 +184,6 @@ | ||
| 277 | 184 | // phpcs:ignore WordPress.WP.GlobalVariablesOverride -- This is a deliberate action. |
| 278 | 185 | $wp_settings_errors[ $index ]['yoast_dirty_value'] = $dirty_value; |
| 279 | 186 | } |
| 280 | 187 | } |
| 281 | - } | |
| 282 | - | |
| 283 | - /** | |
| 284 | - * Gets an invalid submitted value. | |
| 285 | - * | |
| 286 | - * @since 12.1 | |
| 287 | - * | |
| 288 | - * @param string $error_code Code of the error set via `add_settings_error()`, normally the variable name. | |
| 289 | - * | |
| 290 | - * @return string The submitted invalid input field value. | |
| 291 | - */ | |
| 292 | - public static function get_dirty_value( $error_code ) { | |
| 293 | - $errors = get_settings_errors(); | |
| 294 | - | |
| 295 | - foreach ( $errors as $error ) { | |
| 296 | - if ( $error['code'] === $error_code && isset( $error['yoast_dirty_value'] ) ) { | |
| 297 | - return $error['yoast_dirty_value']; | |
| 298 | - } | |
| 299 | - } | |
| 300 | - | |
| 301 | - return ''; | |
| 302 | - } | |
| 303 | - | |
| 304 | - /** | |
| 305 | - * Gets a specific invalid value message. | |
| 306 | - * | |
| 307 | - * @since 12.1 | |
| 308 | - * | |
| 309 | - * @param string $error_code Code of the error set via `add_settings_error()`, normally the variable name. | |
| 310 | - * | |
| 311 | - * @return string The error invalid value message or empty string. | |
| 312 | - */ | |
| 313 | - public static function get_dirty_value_message( $error_code ) { | |
| 314 | - $dirty_value = self::get_dirty_value( $error_code ); | |
| 315 | - | |
| 316 | - if ( $dirty_value ) { | |
| 317 | - return sprintf( | |
| 318 | - /* translators: %s: form value as submitted. */ | |
| 319 | - esc_html__( 'The submitted value was: %s', 'wordpress-seo' ), | |
| 320 | - esc_html( $dirty_value ) | |
| 321 | - ); | |
| 322 | - } | |
| 323 | - | |
| 324 | - return ''; | |
| 325 | 188 | } |
| 326 | 189 | } |