PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
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 13.9.2 14.0.1 All 504 releases
← All changes | class-jetpack-xmlrpc-methods.php +7 -28 13.9.216.3-a.1 View file →
@@ -115,9 +115,9 @@
115 115 $verify_api_user_args = $args[1];
116 116
117 117 $method = (string) $json_api_args[0];
118 118 $url = (string) $json_api_args[1];
119 - $post_body = $json_api_args[2] === null ? null : (string) $json_api_args[2];
119 + $post_body = is_scalar( $json_api_args[2] ) ? (string) $json_api_args[2] : null;
120 120 $user_details = (array) $json_api_args[4];
121 121 $locale = (string) $json_api_args[5];
122 122
123 123 if ( ! $verify_api_user_args ) {
@@ -136,29 +136,8 @@
136 136 return false;
137 137 }
138 138 }
139 139
140 - if ( 'en' !== $locale ) {
141 - // .org mo files are named slightly different from .com, and all we have is this the locale -- try to guess them.
142 - $new_locale = $locale;
143 - if ( str_contains( $locale, '-' ) ) {
144 - $locale_pieces = explode( '-', $locale );
145 - $new_locale = $locale_pieces[0];
146 - $new_locale .= ( ! empty( $locale_pieces[1] ) ) ? '_' . strtoupper( $locale_pieces[1] ) : '';
147 - } else { // phpcs:ignore Universal.ControlStructures.DisallowLonelyIf.Found
148 - // .com might pass 'fr' because thats what our language files are named as, where core seems
149 - // to do fr_FR - so try that if we don't think we can load the file.
150 - if ( ! file_exists( WP_LANG_DIR . '/' . $locale . '.mo' ) ) {
151 - $new_locale = $locale . '_' . strtoupper( $locale );
152 - }
153 - }
154 -
155 - if ( file_exists( WP_LANG_DIR . '/' . $new_locale . '.mo' ) ) {
156 - unload_textdomain( 'default' );
157 - load_textdomain( 'default', WP_LANG_DIR . '/' . $new_locale . '.mo' );
158 - }
159 - }
160 -
161 140 $old_user = wp_get_current_user();
162 141 wp_set_current_user( $user_id );
163 142
164 143 if ( $user_id ) {
@@ -164,9 +143,9 @@
164 143 if ( $user_id ) {
165 144 $token_key = false;
166 145 } else {
167 146 $verified = ( new Connection_Manager() )->verify_xml_rpc_signature();
168 - $token_key = $verified['token_key'];
147 + $token_key = $verified['token_key'] ?? false;
169 148 }
170 149
171 150 $token = ( new Tokens() )->get_access_token( $user_id, $token_key );
172 151 if ( ! $token || is_wp_error( $token ) ) {
@@ -175,14 +154,14 @@
175 154
176 155 define( 'REST_API_REQUEST', true );
177 156 define( 'WPCOM_JSON_API__BASE', 'public-api.wordpress.com/rest/v1' );
178 157
179 - // needed?
180 - require_once ABSPATH . 'wp-admin/includes/admin.php';
181 -
182 158 require_once JETPACK__PLUGIN_DIR . 'class.json-api.php';
183 159 $api = WPCOM_JSON_API::init( $method, $url, $post_body );
184 160 $api->token_details['user'] = $user_details;
161 +
162 + $api->init_locale( $locale );
163 +
185 164 require_once JETPACK__PLUGIN_DIR . 'class.json-api-endpoints.php';
186 165
187 166 $display_errors = ini_set( 'display_errors', 0 ); // phpcs:ignore WordPress.PHP.IniSet
188 167 ob_start();
@@ -192,14 +171,14 @@
192 171
193 172 $nonce = wp_generate_password( 10, false );
194 173 $hmac = hash_hmac( 'md5', $nonce . $output, $token->secret );
195 174
196 - wp_set_current_user( isset( $old_user->ID ) ? $old_user->ID : 0 );
175 + wp_set_current_user( $old_user->ID ?? 0 );
197 176
198 177 return array(
199 178 (string) $output,
200 179 (string) $nonce,
201 - (string) $hmac,
180 + $hmac,
202 181 );
203 182 }
204 183
205 184 /**