← All changes
|
json-endpoints/class.wpcom-json-api-site-settings-v1-3-endpoint.php
+7
-55
12.5.2
→
16.3-a.7
View file →
| @@ -1,6 +1,10 @@ | ||
| 1 | 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | 2 | |
| 3 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 4 | + exit( 0 ); | |
| 5 | +} | |
| 6 | + | |
| 3 | 7 | new WPCOM_JSON_API_Site_Settings_V1_3_Endpoint( |
| 4 | 8 | array( |
| 5 | 9 | 'description' => 'Get detailed settings information about a site.', |
| 6 | 10 | 'group' => '__do_not_document', |
| @@ -67,9 +71,9 @@ | ||
| 67 | 71 | 'comments_notify' => '(bool) Email me when someone comments?', |
| 68 | 72 | 'moderation_notify' => '(bool) Email me when a comment is helf for moderation?', |
| 69 | 73 | 'social_notifications_like' => '(bool) Email me when someone likes my post?', |
| 70 | 74 | 'social_notifications_reblog' => '(bool) Email me when someone reblogs my post?', |
| 71 | - 'social_notifications_subscribe' => '(bool) Email me when someone follows my blog?', | |
| 75 | + 'social_notifications_subscribe' => '(bool) Email me when someone subscribes to my blog?', | |
| 72 | 76 | 'comment_moderation' => '(bool) Moderate comments for manual approval?', |
| 73 | 77 | 'comment_previously_approved' => '(bool) Moderate comments unless author has a previously-approved comment?', |
| 74 | 78 | 'comment_max_links' => '(int) Moderate comments that contain X or more links', |
| 75 | 79 | 'moderation_keys' => '(string) Words or phrases that trigger comment moderation, one per line', |
| @@ -98,9 +102,8 @@ | ||
| 98 | 102 | 'jetpack_portfolio_posts_per_page' => '(int) Number of portfolio projects to show per page', |
| 99 | 103 | Jetpack_SEO_Utils::FRONT_PAGE_META_OPTION => '(string) The SEO meta description for the site.', |
| 100 | 104 | Jetpack_SEO_Titles::TITLE_FORMATS_OPTION => '(array) SEO meta title formats. Allowed keys: front_page, posts, pages, groups, archives', |
| 101 | 105 | 'verification_services_codes' => '(array) Website verification codes. Allowed keys: google, pinterest, bing, yandex, facebook', |
| 102 | - 'amp_is_enabled' => '(bool) Whether AMP is enabled for this site', | |
| 103 | 106 | 'podcasting_archive' => '(string) The post category, if any, used for publishing podcasts', |
| 104 | 107 | 'site_icon' => '(int) Media attachment ID to use as site icon. Set to zero or an otherwise empty value to clear', |
| 105 | 108 | 'api_cache' => '(bool) Turn on/off the Jetpack JSON API cache', |
| 106 | 109 | 'posts_per_page' => '(int) Number of posts to show on blog pages', |
| @@ -119,8 +122,10 @@ | ||
| 119 | 122 | ); |
| 120 | 123 | |
| 121 | 124 | /** |
| 122 | 125 | * Site settings v1_3 endpoint class. |
| 126 | + * | |
| 127 | + * @phan-constructor-used-for-side-effects | |
| 123 | 128 | */ |
| 124 | 129 | class WPCOM_JSON_API_Site_Settings_V1_3_Endpoint extends WPCOM_JSON_API_Site_Settings_V1_2_Endpoint { |
| 125 | 130 | |
| 126 | 131 | /** |
| @@ -134,59 +139,6 @@ | ||
| 134 | 139 | 'anonymize_ip' => false, |
| 135 | 140 | 'ec_track_purchases' => false, |
| 136 | 141 | 'ec_track_add_to_cart' => false, |
| 137 | 142 | ); |
| 138 | - } | |
| 139 | - | |
| 140 | - /** | |
| 141 | - * API Callback | |
| 142 | - * | |
| 143 | - * @param string $path - the path. | |
| 144 | - * @param int $blog_id - the blog ID. | |
| 145 | - * | |
| 146 | - * @return array|WP_Error | |
| 147 | - */ | |
| 148 | - public function callback( $path = '', $blog_id = 0 ) { | |
| 149 | - add_filter( 'site_settings_endpoint_get', array( $this, 'filter_site_settings_endpoint_get' ) ); | |
| 150 | - add_filter( 'site_settings_update_wga', array( $this, 'filter_update_google_analytics' ), 10, 2 ); | |
| 151 | - return parent::callback( $path, $blog_id ); | |
| 152 | - } | |
| 153 | - | |
| 154 | - /** | |
| 155 | - * Filter the parent's response to include the fields | |
| 156 | - * added to 1.3 (and their defaults) | |
| 157 | - * | |
| 158 | - * @param array $settings - the settings array. | |
| 159 | - * | |
| 160 | - * @return array | |
| 161 | - */ | |
| 162 | - public function filter_site_settings_endpoint_get( $settings ) { | |
| 163 | - $option_name = defined( 'IS_WPCOM' ) && IS_WPCOM ? 'wga' : 'jetpack_wga'; | |
| 164 | - $option = get_option( $option_name, array() ); | |
| 165 | - $settings['wga'] = wp_parse_args( $option, $this->get_defaults() ); | |
| 166 | - return $settings; | |
| 167 | - } | |
| 168 | - | |
| 169 | - /** | |
| 170 | - * Filter the parent's response to consume our new fields | |
| 171 | - * | |
| 172 | - * @param array $wga - Array of existing Google Analytics settings. | |
| 173 | - * @param array $new_values - the new values we're adding. | |
| 174 | - * | |
| 175 | - * @return array | |
| 176 | - */ | |
| 177 | - public function filter_update_google_analytics( $wga, $new_values ) { | |
| 178 | - $wga_keys = array_keys( $this->get_defaults() ); | |
| 179 | - foreach ( $wga_keys as $wga_key ) { | |
| 180 | - // Skip code since the parent class has handled it | |
| 181 | - if ( 'code' === $wga_key ) { | |
| 182 | - continue; | |
| 183 | - } | |
| 184 | - // All our new keys are booleans, so let's coerce each key's value | |
| 185 | - // before updating the value in settings | |
| 186 | - if ( array_key_exists( $wga_key, $new_values ) ) { | |
| 187 | - $wga[ $wga_key ] = WPCOM_JSON_API::is_truthy( $new_values[ $wga_key ] ); | |
| 188 | - } | |
| 189 | - } | |
| 190 | - return $wga; | |
| 191 | 143 | } |
| 192 | 144 | } |