← All changes
|
json-endpoints/class.wpcom-json-api-site-settings-endpoint.php
+18
-2
16.2
→
16.3-a.7
View file →
| @@ -10,8 +10,10 @@ | ||
| 10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | 11 | exit( 0 ); |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | +require_once dirname( __DIR__ ) . '/modules/verification-tools/verification-tools-utils.php'; | |
| 15 | + | |
| 14 | 16 | new WPCOM_JSON_API_Site_Settings_Endpoint( |
| 15 | 17 | array( |
| 16 | 18 | 'description' => 'Get detailed settings information about a site.', |
| 17 | 19 | 'group' => '__do_not_document', |
| @@ -466,8 +468,9 @@ | ||
| 466 | 468 | 'markdown_supported' => true, |
| 467 | 469 | 'site_icon' => $this->get_cast_option_value_or_null( 'site_icon', 'intval' ), |
| 468 | 470 | Jetpack_SEO_Utils::FRONT_PAGE_META_OPTION => get_option( Jetpack_SEO_Utils::FRONT_PAGE_META_OPTION, '' ), |
| 469 | 471 | Jetpack_SEO_Titles::TITLE_FORMATS_OPTION => get_option( Jetpack_SEO_Titles::TITLE_FORMATS_OPTION, array() ), |
| 472 | + 'verification_services_codes' => get_option( 'verification_services_codes', null ), | |
| 470 | 473 | 'api_cache' => $api_cache, |
| 471 | 474 | 'posts_per_page' => (int) get_option( 'posts_per_page' ), |
| 472 | 475 | 'posts_per_rss' => (int) get_option( 'posts_per_rss' ), |
| 473 | 476 | 'rss_use_excerpt' => (bool) get_option( 'rss_use_excerpt' ), |
| @@ -644,9 +647,8 @@ | ||
| 644 | 647 | |
| 645 | 648 | if ( function_exists( 'wpcom_switch_to_user_locale' ) ) { |
| 646 | 649 | // Compare the locales before/after switch to decide if we should switch back |
| 647 | 650 | $locale_before = determine_locale(); |
| 648 | - // @phan-suppress-next-line PhanUndeclaredFunction -- Checked above. See also https://github.com/phan/phan/issues/1204. | |
| 649 | 651 | wpcom_switch_to_user_locale(); |
| 650 | 652 | $switched_locale = determine_locale() !== $locale_before; |
| 651 | 653 | } |
| 652 | 654 | |
| @@ -1232,9 +1234,23 @@ | ||
| 1232 | 1234 | } |
| 1233 | 1235 | break; |
| 1234 | 1236 | |
| 1235 | 1237 | case 'verification_services_codes': |
| 1236 | - $verification_codes = jetpack_verification_validate( $value ); | |
| 1238 | + foreach ( $value as $raw_code ) { | |
| 1239 | + if ( '' === $raw_code || null === $raw_code || false === $raw_code ) { | |
| 1240 | + continue; | |
| 1241 | + } | |
| 1242 | + | |
| 1243 | + if ( false === jetpack_verification_validate_code( $raw_code ) ) { | |
| 1244 | + return new WP_Error( | |
| 1245 | + 'invalid_input', | |
| 1246 | + __( 'Invalid site verification code. Enter a verification code or verification tag.', 'jetpack' ), | |
| 1247 | + 400 | |
| 1248 | + ); | |
| 1249 | + } | |
| 1250 | + } | |
| 1251 | + | |
| 1252 | + $verification_codes = jetpack_verification_validate_codes( $value ); | |
| 1237 | 1253 | |
| 1238 | 1254 | if ( update_option( 'verification_services_codes', $verification_codes ) ) { |
| 1239 | 1255 | $updated[ $key ] = $verification_codes; |
| 1240 | 1256 | } |