PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.5
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.5
16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 All 506 releases
← All changes | json-endpoints/class.wpcom-json-api-site-settings-v1-3-endpoint.php +7 -54 13.0.2 → 16.3-a.5 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',
@@ -118,8 +122,10 @@
118 122 );
119 123
120 124 /**
121 125 * Site settings v1_3 endpoint class.
126 + *
127 + * @phan-constructor-used-for-side-effects
122 128 */
123 129 class WPCOM_JSON_API_Site_Settings_V1_3_Endpoint extends WPCOM_JSON_API_Site_Settings_V1_2_Endpoint {
124 130
125 131 /**
@@ -133,59 +139,6 @@
133 139 'anonymize_ip' => false,
134 140 'ec_track_purchases' => false,
135 141 'ec_track_add_to_cart' => false,
136 142 );
137 - }
138 -
139 - /**
140 - * API Callback
141 - *
142 - * @param string $path - the path.
143 - * @param int $blog_id - the blog ID.
144 - *
145 - * @return array|WP_Error
146 - */
147 - public function callback( $path = '', $blog_id = 0 ) {
148 - add_filter( 'site_settings_endpoint_get', array( $this, 'filter_site_settings_endpoint_get' ) );
149 - add_filter( 'site_settings_update_wga', array( $this, 'filter_update_google_analytics' ), 10, 2 );
150 - return parent::callback( $path, $blog_id );
151 - }
152 -
153 - /**
154 - * Filter the parent's response to include the fields
155 - * added to 1.3 (and their defaults)
156 - *
157 - * @param array $settings - the settings array.
158 - *
159 - * @return array
160 - */
161 - public function filter_site_settings_endpoint_get( $settings ) {
162 - $option_name = $this->get_google_analytics_option_name();
163 - $option = get_option( $option_name, array() );
164 - $settings['wga'] = wp_parse_args( $option, $this->get_defaults() );
165 - return $settings;
166 - }
167 -
168 - /**
169 - * Filter the parent's response to consume our new fields
170 - *
171 - * @param array $wga - Array of existing Google Analytics settings.
172 - * @param array $new_values - the new values we're adding.
173 - *
174 - * @return array
175 - */
176 - public function filter_update_google_analytics( $wga, $new_values ) {
177 - $wga_keys = array_keys( $this->get_defaults() );
178 - foreach ( $wga_keys as $wga_key ) {
179 - // Skip code since the parent class has handled it
180 - if ( 'code' === $wga_key ) {
181 - continue;
182 - }
183 - // All our new keys are booleans, so let's coerce each key's value
184 - // before updating the value in settings
185 - if ( array_key_exists( $wga_key, $new_values ) ) {
186 - $wga[ $wga_key ] = WPCOM_JSON_API::is_truthy( $new_values[ $wga_key ] );
187 - }
188 - }
189 - return $wga;
190 143 }
191 144 }