PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 12.3
Jetpack – WP Security, Backup, Speed, & Growth v12.3
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 14.1.1 14.2.2 14.3.1 All 501 releases
← All changes | modules/stats.php +14 -9 13.2.412.3 View file →
@@ -13,9 +13,8 @@
13 13 *
14 14 * @package automattic/jetpack
15 15 */
16 16
17 -use Automattic\Jetpack\Admin_UI\Admin_Menu;
18 17 use Automattic\Jetpack\Connection\Client;
19 18 use Automattic\Jetpack\Connection\Manager as Connection_Manager;
20 19 use Automattic\Jetpack\Connection\XMLRPC_Async_Call;
21 20 use Automattic\Jetpack\Redirect;
@@ -21,9 +20,8 @@
21 20 use Automattic\Jetpack\Redirect;
22 21 use Automattic\Jetpack\Stats\Main as Stats;
23 22 use Automattic\Jetpack\Stats\Options as Stats_Options;
24 23 use Automattic\Jetpack\Stats\Tracking_Pixel as Stats_Tracking_Pixel;
25 -use Automattic\Jetpack\Stats\WPCOM_Stats;
26 24 use Automattic\Jetpack\Stats\XMLRPC_Provider as Stats_XMLRPC;
27 25 use Automattic\Jetpack\Stats_Admin\Dashboard as Stats_Dashboard;
28 26 use Automattic\Jetpack\Stats_Admin\Main as Stats_Main;
29 27 use Automattic\Jetpack\Stats_Admin\Notices as Stats_Notices;
@@ -241,18 +239,19 @@
241 239 Stats_Main::update_new_stats_status( true );
242 240 }
243 241
244 242 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
245 - if ( ! Stats_Options::get_option( 'enable_odyssey_stats' ) || isset( $_GET['noheader'] ) ) {
243 + if ( ( new Host() )->is_woa_site() || ! Stats_Options::get_option( 'enable_odyssey_stats' ) || isset( $_GET['noheader'] ) ) {
246 244 // Show old Jetpack Stats interface for:
245 + // - Atomic sites.
247 246 // - When the "enable_odyssey_stats" option is disabled.
248 247 // - When being shown in the adminbar outside of wp-admin.
249 - $hook = Admin_Menu::add_menu( __( 'Stats', 'jetpack' ), __( 'Stats', 'jetpack' ), 'view_stats', 'stats', 'jetpack_admin_ui_stats_report_page_wrapper' );
248 + $hook = add_submenu_page( 'jetpack', __( 'Stats', 'jetpack' ), __( 'Stats', 'jetpack' ), 'view_stats', 'stats', 'jetpack_admin_ui_stats_report_page_wrapper' );
250 249 add_action( "load-$hook", 'stats_reports_load' );
251 250 } else {
252 251 // Enable the new Odyssey Stats experience.
253 252 $stats_dashboard = new Stats_Dashboard();
254 - $hook = Admin_Menu::add_menu( __( 'Stats', 'jetpack' ), __( 'Stats', 'jetpack' ), 'view_stats', 'stats', array( $stats_dashboard, 'render' ) );
253 + $hook = add_submenu_page( 'jetpack', __( 'Stats', 'jetpack' ), __( 'Stats', 'jetpack' ), 'view_stats', 'stats', array( $stats_dashboard, 'render' ) );
255 254 add_action( "load-$hook", array( $stats_dashboard, 'admin_init' ) );
256 255 }
257 256 }
258 257
@@ -522,9 +521,9 @@
522 521 }
523 522 } elseif ( null === $vals ) {
524 523 $q[ $var ] = '';
525 524 } elseif ( 'data' === $vals ) {
526 - if ( str_starts_with( $val, 'index.php' ) ) {
525 + if ( 'index.php' === substr( $val, 0, 9 ) ) {
527 526 $q[ $var ] = $val;
528 527 }
529 528 }
530 529 }
@@ -549,9 +548,9 @@
549 548 stats_print_wp_remote_error( $get, $url );
550 549 } else {
551 550 if ( ! empty( $get['headers']['content-type'] ) ) {
552 551 $type = $get['headers']['content-type'];
553 - if ( str_starts_with( $type, 'image' ) ) {
552 + if ( substr( $type, 0, 5 ) === 'image' ) {
554 553 $img = $get['body'];
555 554 header( 'Content-Type: ' . $type );
556 555 header( 'Content-Length: ' . strlen( $img ) );
557 556 echo $img; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
@@ -1738,8 +1737,14 @@
1738 1737 * @param array $stats_array The stats array.
1739 1738 * @return WP_Error|Object|null
1740 1739 */
1741 1740 function convert_stats_array_to_object( $stats_array ) {
1742 - _deprecated_function( __FUNCTION__, 'jetpack-13.2', 'Automattic\Jetpack\Stats\WPCOM_Stats->convert_stats_array_to_object' );
1743 1741
1744 - return ( new WPCOM_Stats() )->convert_stats_array_to_object( $stats_array );
1742 + if ( is_wp_error( $stats_array ) ) {
1743 + return $stats_array;
1744 + }
1745 + $encoded_array = wp_json_encode( $stats_array );
1746 + if ( ! $encoded_array ) {
1747 + return new WP_Error( 'stats_encoding_error', 'Failed to encode stats array' );
1748 + }
1749 + return json_decode( $encoded_array );
1745 1750 }