PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
16.3-beta 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 All 507 releases
← All changes | jetpack_vendor/automattic/jetpack-stats-admin/src/class-main.php +58 -2 12.3.2 → 16.3-beta View file →
@@ -8,8 +8,9 @@
8 8 namespace Automattic\Jetpack\Stats_Admin;
9 9
10 10 use Automattic\Jetpack\Connection\Manager;
11 11 use Automattic\Jetpack\Stats\Options as Stats_Options;
12 +use Automattic\Jetpack\Status\Host;
12 13 use Automattic\Jetpack\Tracking;
13 14
14 15 /**
15 16 * Stats Main class.
@@ -21,9 +22,9 @@
21 22 class Main {
22 23 /**
23 24 * Stats version.
24 25 */
25 - const VERSION = '0.11.0';
26 + const VERSION = '0.38.2';
26 27
27 28 /**
28 29 * Singleton Main instance.
29 30 *
@@ -50,9 +51,64 @@
50 51 *
51 52 * @return void
52 53 */
53 54 private function __construct() {
54 - add_action( 'rest_api_init', array( new REST_Controller(), 'register_rest_routes' ) );
55 + add_action( 'rest_api_init', array( REST_Controller::class, 'register' ) );
56 + // Disable JITM assets on the Stats page.
57 + // JITM is handled separately by Stats: https://github.com/Automattic/wp-calypso/pull/95273.
58 + add_filter(
59 + 'jetpack_display_jitms_on_screen',
60 + function ( $show, $screen_id ) {
61 + if ( 'jetpack_page_stats' === $screen_id ) {
62 + return false;
63 + }
64 + return $show;
65 + },
66 + 10,
67 + 2
68 + );
69 +
70 + // Register stats-admin transient prefix for cleanup by the stats package.
71 + add_filter( 'jetpack_stats_transient_cleanup_prefixes', array( $this, 'register_transient_cleanup_prefix' ) );
72 +
73 + if ( self::needs_own_dashboard() ) {
74 + Dashboard::init();
75 + }
76 + }
77 +
78 + /**
79 + * Whether the site can talk to WordPress.com.
80 + *
81 + * Simple sites always can, and hold no Jetpack blog token to check.
82 + *
83 + * @return bool
84 + */
85 + public static function is_site_connected() {
86 + return ( new Host() )->is_wpcom_simple() || ( new Manager( 'jetpack' ) )->is_connected();
87 + }
88 +
89 + /**
90 + * Whether Stats has to register its own dashboard because nothing else will.
91 + *
92 + * The Jetpack plugin registers the Stats menu from its stats module, and modules are not
93 + * loaded until the site is connected. Registering the dashboard here keeps Stats reachable
94 + * before that happens, where the app offers a plan and drives the connection itself.
95 + *
96 + * @return bool
97 + */
98 + private static function needs_own_dashboard() {
99 + return ! self::is_site_connected();
100 + }
101 +
102 + /**
103 + * Register the stats-admin transient prefix for cleanup.
104 + *
105 + * @param array $prefixes List of transient prefixes to clean up.
106 + * @return array Modified list of prefixes.
107 + */
108 + public function register_transient_cleanup_prefix( $prefixes ) {
109 + $prefixes[] = WPCOM_Client::CACHE_TRANSIENT_PREFIX;
110 + return $prefixes;
55 111 }
56 112
57 113 /**
58 114 * Update New Stats status.