PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3
Jetpack – WP Security, Backup, Speed, & Growth v16.3
16.3 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 All 508 releases
← All changes | jetpack_vendor/automattic/jetpack-jitm/src/class-jitm.php +247 -18 13.0.2 → 16.3 View file →
@@ -10,9 +10,14 @@
10 10 use Automattic\Jetpack\Assets;
11 11 use Automattic\Jetpack\Assets\Logo as Jetpack_Logo;
12 12 use Automattic\Jetpack\Connection\Manager as Connection_Manager;
13 13 use Automattic\Jetpack\Status;
14 +use Automattic\Jetpack\Status\Host;
14 15
16 +if ( ! defined( 'ABSPATH' ) ) {
17 + exit( 0 );
18 +}
19 +
15 20 /**
16 21 * Jetpack just in time messaging through out the admin
17 22 *
18 23 * @since 1.1.0
@@ -19,16 +24,71 @@
19 24 * @since-jetpack 5.6.0
20 25 */
21 26 class JITM {
22 27
23 - const PACKAGE_VERSION = '3.0.2';
28 + const PACKAGE_VERSION = '5.1.1';
24 29
25 30 /**
31 + * List of screen IDs where JITMs are allowed to display.
32 + *
33 + * @var string[]
34 + */
35 + const APPROVED_SCREEN_IDS = array(
36 + 'jetpack',
37 + 'woo',
38 + 'shop',
39 + 'product',
40 + );
41 +
42 + /**
43 + * The lazily-resolved JITM instance used by the hooks registered in configure().
44 + *
45 + * @var Post_Connection_JITM|Pre_Connection_JITM|null
46 + */
47 + private static $configured_instance;
48 +
49 + /**
26 50 * The configuration method that is called from the jetpack-config package.
51 + *
52 + * Registers the JITM hooks directly (rather than building a JITM instance up
53 + * front) and binds the instance-dependent callbacks to a lazily-resolved
54 + * instance, so the connection-specific JITM subclass and its dependencies are
55 + * only loaded when one of these hooks actually fires instead of on every
56 + * request. JITMs only render on admin screens and via the REST API.
27 57 */
28 58 public static function configure() {
29 - $jitm = self::get_instance();
30 - $jitm->register();
59 + if ( did_action( 'jetpack_registered_jitms' ) ) {
60 + // JITMs have already been registered.
61 + return;
62 + }
63 +
64 + if ( ! self::are_jitms_enabled() ) {
65 + // Do nothing.
66 + return;
67 + }
68 +
69 + add_action( 'rest_api_init', array( __NAMESPACE__ . '\\Rest_Api_Endpoints', 'register_endpoints' ) );
70 +
71 + add_action(
72 + 'current_screen',
73 + static function ( $screen ) {
74 + self::get_configured_instance()->prepare_jitms( $screen );
75 + }
76 + );
77 +
78 + /**
79 + * These are sync actions that we need to keep track of for jitms.
80 + */
81 + add_filter(
82 + 'jetpack_sync_before_send_updated_option',
83 + static function ( $params ) {
84 + return self::get_configured_instance()->jetpack_track_last_sync_callback( $params );
85 + },
86 + 99
87 + );
88 +
89 + /** This action is documented in projects/packages/jitm/src/class-jitm.php */
90 + do_action( 'jetpack_registered_jitms' );
31 91 }
32 92
33 93 /**
34 94 * Pre/Post Connection JITM factory metod
@@ -35,9 +95,9 @@
35 95 *
36 96 * @return Post_Connection_JITM|Pre_Connection_JITM JITM instance.
37 97 */
38 98 public static function get_instance() {
39 - if ( ( new Connection_Manager() )->is_connected() ) {
99 + if ( self::is_connected() ) {
40 100 $jitm = new Post_Connection_JITM();
41 101 } else {
42 102 $jitm = new Pre_Connection_JITM();
43 103 }
@@ -44,8 +104,80 @@
44 104 return $jitm;
45 105 }
46 106
47 107 /**
108 + * Lazily resolve and cache the connection-appropriate JITM instance used by
109 + * the hooks registered in configure().
110 + *
111 + * @return Post_Connection_JITM|Pre_Connection_JITM JITM instance.
112 + */
113 + private static function get_configured_instance() {
114 + if ( null === self::$configured_instance ) {
115 + self::$configured_instance = self::get_instance();
116 + }
117 + return self::$configured_instance;
118 + }
119 +
120 + /**
121 + * Clears admin notices from the current screen, keeping JITMs.
122 + *
123 + * A screen that opted out through `jetpack_display_jitms_on_screen` has nothing
124 + * to keep, so it stays silent.
125 + *
126 + * @since 5.1.0
127 + *
128 + * @return void
129 + */
130 + public static function suppress_foreign_admin_notices() {
131 + foreach ( array( 'admin_notices', 'all_admin_notices' ) as $hook ) {
132 + $ours = self::collect_own_callbacks( $hook );
133 +
134 + remove_all_actions( $hook );
135 +
136 + foreach ( $ours as $priority => $callbacks ) {
137 + foreach ( $callbacks as $callback ) {
138 + add_action( $hook, $callback['function'], $priority, $callback['accepted_args'] );
139 + }
140 + }
141 + }
142 + }
143 +
144 + /**
145 + * Returns our callbacks on $hook, keyed by priority.
146 + *
147 + * Matched by class: `prepare_jitms()` hooks the cached instance and
148 + * `get_instance()` builds a fresh one, so comparing objects would miss.
149 + *
150 + * @since 5.1.0
151 + *
152 + * @param string $hook Hook name.
153 + * @return array<int, array<int, array{function: callable, accepted_args: int}>>
154 + */
155 + private static function collect_own_callbacks( $hook ) {
156 + global $wp_filter;
157 +
158 + $kept = array();
159 +
160 + if ( ! isset( $wp_filter[ $hook ] ) || ! is_object( $wp_filter[ $hook ] ) ) {
161 + return $kept;
162 + }
163 +
164 + foreach ( $wp_filter[ $hook ]->callbacks as $priority => $callbacks ) {
165 + foreach ( $callbacks as $callback ) {
166 + if (
167 + is_array( $callback['function'] )
168 + && isset( $callback['function'][0] )
169 + && $callback['function'][0] instanceof self
170 + ) {
171 + $kept[ $priority ][] = $callback;
172 + }
173 + }
174 + }
175 +
176 + return $kept;
177 + }
178 +
179 + /**
48 180 * Sets up JITM action callbacks if needed.
49 181 */
50 182 public function register() {
51 183 if ( did_action( 'jetpack_registered_jitms' ) ) {
@@ -82,8 +214,18 @@
82 214 *
83 215 * @return bool True if JITMs are enabled, else false.
84 216 */
85 217 public function jitms_enabled() {
218 + return self::are_jitms_enabled();
219 + }
220 +
221 + /**
222 + * Static variant of jitms_enabled() so the enabled state can be checked
223 + * without building a JITM instance (used by configure()).
224 + *
225 + * @return bool True if JITMs are enabled, else false.
226 + */
227 + private static function are_jitms_enabled() {
86 228 /**
87 229 * Filter to turn off all just in time messages
88 230 *
89 231 * @since 1.1.0
@@ -130,12 +272,46 @@
130 272 }
131 273 }
132 274
133 275 /**
276 + * Check if the current page is a Jetpack or WooCommerce admin page.
277 + * Noting that this is a very basic check, and pages from other plugins may also match.
278 + *
279 + * @since 3.1.0
280 + *
281 + * @return bool True if the current page is a Jetpack or WooCommerce admin page, else false.
282 + */
283 + public function is_a8c_admin_page() {
284 + if ( ! function_exists( 'get_current_screen' ) ) {
285 + return false;
286 + }
287 +
288 + $current_screen = get_current_screen();
289 +
290 + // We never want to show JITMs on the block editor.
291 + if (
292 + method_exists( $current_screen, 'is_block_editor' )
293 + && $current_screen->is_block_editor()
294 + ) {
295 + return false;
296 + }
297 +
298 + return (
299 + $current_screen
300 + && $current_screen->id
301 + && (bool) preg_match(
302 + '/' . implode( '|', self::APPROVED_SCREEN_IDS ) . '/',
303 + $current_screen->id
304 + )
305 + );
306 + }
307 +
308 + /**
134 309 * Function to enqueue jitm css and js
135 310 */
136 311 public function jitm_enqueue_files() {
137 - if ( $this->is_gutenberg_page() ) {
312 + // Only load those files on the Jetpack or Woo admin pages.
313 + if ( ! $this->is_a8c_admin_page() ) {
138 314 return;
139 315 }
140 316
141 317 Assets::register_script(
@@ -143,12 +319,12 @@
143 319 '../build/index.js',
144 320 __FILE__,
145 321 array(
146 322 'in_footer' => true,
147 - 'dependencies' => array( 'jquery' ),
323 + 'dependencies' => array(),
324 + 'enqueue' => true,
148 325 )
149 326 );
150 - Assets::enqueue_script( 'jetpack-jitm' );
151 327 wp_localize_script(
152 328 'jetpack-jitm',
153 329 'jitm_config',
154 330 array(
@@ -166,10 +342,13 @@
166 342 * Is the current page a block editor page?
167 343 *
168 344 * @since 1.1.0
169 345 * @since-jetpack 8.0.0
346 + *
347 + * @deprecated 3.1.0
170 348 */
171 349 public function is_gutenberg_page() {
350 + _deprecated_function( __METHOD__, '3.1.0' );
172 351 $current_screen = get_current_screen();
173 352 return ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() );
174 353 }
175 354
@@ -191,10 +370,10 @@
191 370 if ( ! is_admin() ) {
192 371 return;
193 372 }
194 373
195 - // do not display on Gutenberg pages.
196 - if ( $this->is_gutenberg_page() ) {
374 + // Only add this to specifically allowed pages.
375 + if ( ! $this->is_a8c_admin_page() ) {
197 376 return;
198 377 }
199 378
200 379 $message_path = $this->get_message_path();
@@ -220,8 +399,13 @@
220 399 * @param string $content_icon Icon type name.
221 400 * @param bool $full_jp_logo_exists Is there a big JP logo already displayed on this screen.
222 401 */
223 402 public function generate_icon( $content_icon, $full_jp_logo_exists ) {
403 + $date_now = new \DateTime( 'now', wp_timezone() );
404 + $feb_4_date = new \DateTime( '02-04-2025', wp_timezone() );
405 + // Don't show the new Woo svg logo until after Feb 4th, 2025
406 + $show_new_logo = $date_now >= $feb_4_date;
407 +
224 408 switch ( $content_icon ) {
225 409 case 'jetpack':
226 410 $jetpack_logo = new Jetpack_Logo();
227 411 $content_icon = '<div class="jp-emblem">' . ( ( $full_jp_logo_exists ) ? $jetpack_logo->get_jp_emblem() : $jetpack_logo->get_jp_emblem_larger() ) . '</div>';
@@ -226,17 +410,47 @@
226 410 $jetpack_logo = new Jetpack_Logo();
227 411 $content_icon = '<div class="jp-emblem">' . ( ( $full_jp_logo_exists ) ? $jetpack_logo->get_jp_emblem() : $jetpack_logo->get_jp_emblem_larger() ) . '</div>';
228 412 break;
229 413 case 'woocommerce':
230 - $content_icon = '<div class="jp-emblem"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" viewBox="0 0 168 100" xml:space="preserve" enable-background="new 0 0 168 100" width="50" height="30"><style type="text/css">
231 - .st0{clip-path:url(#SVGID_2_);enable-background:new ;}
232 - .st1{clip-path:url(#SVGID_4_);}
233 - .st2{clip-path:url(#SVGID_6_);}
234 - .st3{clip-path:url(#SVGID_8_);fill:#7F54B3;}
235 - .st4{clip-path:url(#SVGID_10_);fill:#FFFFFE;}
236 - .st5{clip-path:url(#SVGID_12_);fill:#FFFFFE;}
237 - .st6{clip-path:url(#SVGID_14_);fill:#FFFFFE;}
238 - </style><g><defs><polygon id="SVGID_1_" points="83.8 100 0 100 0 0.3 83.8 0.3 167.6 0.3 167.6 100 "/></defs><clipPath id="SVGID_2_"><use xlink:href="#SVGID_1_" overflow="visible"/></clipPath><g class="st0"><g><defs><rect id="SVGID_3_" width="168" height="100"/></defs><clipPath id="SVGID_4_"><use xlink:href="#SVGID_3_" overflow="visible"/></clipPath><g class="st1"><defs><path id="SVGID_5_" d="M15.6 0.3H152c8.6 0 15.6 7 15.6 15.6v52c0 8.6-7 15.6-15.6 15.6h-48.9l6.7 16.4L80.2 83.6H15.6C7 83.6 0 76.6 0 67.9v-52C0 7.3 7 0.3 15.6 0.3"/></defs><clipPath id="SVGID_6_"><use xlink:href="#SVGID_5_" overflow="visible"/></clipPath><g class="st2"><defs><rect id="SVGID_7_" width="168" height="100"/></defs><clipPath id="SVGID_8_"><use xlink:href="#SVGID_7_" overflow="visible"/></clipPath><rect x="-10" y="-9.7" class="st3" width="187.6" height="119.7"/></g></g></g></g></g><g><defs><path id="SVGID_9_" d="M8.4 14.5c1-1.3 2.4-2 4.3-2.1 3.5-0.2 5.5 1.4 6 4.9 2.1 14.3 4.4 26.4 6.9 36.4l15-28.6c1.4-2.6 3.1-3.9 5.2-4.1 3-0.2 4.9 1.7 5.6 5.7 1.7 9.1 3.9 16.9 6.5 23.4 1.8-17.4 4.8-30 9-37.7 1-1.9 2.5-2.9 4.5-3 1.6-0.1 3 0.3 4.3 1.4 1.3 1 2 2.3 2.1 3.9 0.1 1.2-0.1 2.3-0.7 3.3 -2.7 5-4.9 13.2-6.6 24.7 -1.7 11.1-2.3 19.8-1.9 26.1 0.1 1.7-0.1 3.2-0.8 4.5 -0.8 1.5-2 2.4-3.7 2.5 -1.8 0.1-3.6-0.7-5.4-2.5C52.4 66.7 47.4 57 43.7 44.1c-4.4 8.8-7.7 15.3-9.9 19.7 -4 7.7-7.5 11.7-10.3 11.9 -1.9 0.1-3.5-1.4-4.8-4.7 -3.5-9-7.3-26.3-11.3-52C7.1 17.3 7.5 15.8 8.4 14.5"/></defs><clipPath id="SVGID_10_"><use xlink:href="#SVGID_9_" overflow="visible"/></clipPath><rect x="-2.7" y="-0.6" class="st4" width="90.6" height="86.4"/></g><g><defs><path id="SVGID_11_" d="M155.6 25.2c-2.5-4.3-6.1-6.9-11-7.9 -1.3-0.3-2.5-0.4-3.7-0.4 -6.6 0-11.9 3.4-16.1 10.2 -3.6 5.8-5.3 12.3-5.3 19.3 0 5.3 1.1 9.8 3.3 13.6 2.5 4.3 6.1 6.9 11 7.9 1.3 0.3 2.5 0.4 3.7 0.4 6.6 0 12-3.4 16.1-10.2 3.6-5.9 5.3-12.4 5.3-19.4C159 33.4 157.9 28.9 155.6 25.2zM147 44.2c-0.9 4.5-2.7 7.9-5.2 10.1 -2 1.8-3.9 2.5-5.5 2.2 -1.7-0.3-3-1.8-4-4.4 -0.8-2.1-1.2-4.2-1.2-6.2 0-1.7 0.2-3.4 0.5-5 0.6-2.8 1.8-5.5 3.6-8.1 2.3-3.3 4.7-4.8 7.1-4.2 1.7 0.3 3 1.8 4 4.4 0.8 2.1 1.2 4.2 1.2 6.2C147.5 40.9 147.3 42.6 147 44.2z"/></defs><clipPath id="SVGID_12_"><use xlink:href="#SVGID_11_" overflow="visible"/></clipPath><rect x="109.6" y="6.9" class="st5" width="59.4" height="71.4"/></g><g><defs><path id="SVGID_13_" d="M112.7 25.2c-2.5-4.3-6.1-6.9-11-7.9 -1.3-0.3-2.5-0.4-3.7-0.4 -6.6 0-11.9 3.4-16.1 10.2 -3.5 5.8-5.3 12.3-5.3 19.3 0 5.3 1.1 9.8 3.3 13.6 2.5 4.3 6.1 6.9 11 7.9 1.3 0.3 2.5 0.4 3.7 0.4 6.6 0 12-3.4 16.1-10.2 3.5-5.9 5.3-12.4 5.3-19.4C116 33.4 114.9 28.9 112.7 25.2zM104.1 44.2c-0.9 4.5-2.7 7.9-5.2 10.1 -2 1.8-3.9 2.5-5.5 2.2 -1.7-0.3-3-1.8-4-4.4 -0.8-2.1-1.2-4.2-1.2-6.2 0-1.7 0.2-3.4 0.5-5 0.6-2.8 1.8-5.5 3.6-8.1 2.3-3.3 4.7-4.8 7.1-4.2 1.7 0.3 3 1.8 4 4.4 0.8 2.1 1.2 4.2 1.2 6.2C104.6 40.9 104.4 42.6 104.1 44.2z"/></defs><clipPath id="SVGID_14_"><use xlink:href="#SVGID_13_" overflow="visible"/></clipPath><rect x="66.7" y="6.9" class="st6" width="59.4" height="71.4"/></g></svg></div>';
414 + // After Feb 4th 2025, we can remove this date condition check ( & filter) and the old svg logo.
415 + /**
416 + * Filter to force display the new Woo logo in Woo JITM's, or not.
417 + *
418 + * @since 4.0.5
419 + *
420 + * @param bool $show_woo_logo Whether to show the new Woo logo or not.
421 + */
422 + $content_icon = apply_filters( 'jetpack_jitm_use_new_woo_logo', $show_new_logo )
423 + // New Woo logo
424 + ? '<div class="jp-emblem"><svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
425 + viewBox="0 0 183.6 47.5" style="enable-background:new 0 0 183.6 47.5;" xml:space="preserve">
426 + <style type="text/css">
427 + .st0{fill-rule:evenodd;clip-rule:evenodd;fill:#873EFF;}
428 + .st1{fill-rule:evenodd;clip-rule:evenodd;}
429 + .st2{fill:#873EFF;}
430 + .st3{fill-rule:evenodd;clip-rule:evenodd;fill:#FFFFFF;}
431 + .st4{fill:#FFFFFF;}
432 + </style>
433 + <g>
434 + <path class="st0" d="M77.4,0c-4.3,0-7.1,1.4-9.6,6.1L56.4,27.6V8.5c0-5.7-2.7-8.5-7.7-8.5s-7.1,1.7-9.6,6.5L28.3,27.6V8.7
435 + c0-6.1-2.5-8.7-8.6-8.7H7.3C2.6,0,0,2.2,0,6.2s2.5,6.4,7.1,6.4h5.1v24.1c0,6.8,4.6,10.8,11.2,10.8s9.6-2.6,12.9-8.7l7.2-13.5v11.4
436 + c0,6.7,4.4,10.8,11.1,10.8s9.2-2.3,13-8.7l16.6-28C87.8,4.7,85.3,0,77.3,0C77.3,0,77.3,0,77.4,0z"/>
437 + <path class="st0" d="M108.6,0C95,0,84.7,10.1,84.7,23.8s10.4,23.7,23.9,23.7s23.8-10.1,23.9-23.7C132.5,10.1,122.1,0,108.6,0z
438 + M108.6,32.9c-5.1,0-8.6-3.8-8.6-9.1s3.5-9.2,8.6-9.2s8.6,3.9,8.6,9.2S113.8,32.9,108.6,32.9z"/>
439 + <path class="st0" d="M159.7,0c-13.5,0-23.9,10.1-23.9,23.8s10.4,23.7,23.9,23.7s23.9-10.1,23.9-23.7S173.2,0,159.7,0z M159.7,32.9
440 + c-5.2,0-8.5-3.8-8.5-9.1s3.4-9.2,8.5-9.2s8.6,3.9,8.6,9.2S164.9,32.9,159.7,32.9z"/>
441 + </g>
442 + </svg></div>'
443 + // Old Woo logo
444 + : '<div class="jp-emblem"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" viewBox="0 0 168 100" xml:space="preserve" enable-background="new 0 0 168 100" width="50" height="30"><style type="text/css">
445 + .st0{clip-path:url(#SVGID_2_);enable-background:new ;}
446 + .st1{clip-path:url(#SVGID_4_);}
447 + .st2{clip-path:url(#SVGID_6_);}
448 + .st3{clip-path:url(#SVGID_8_);fill:#7F54B3;}
449 + .st4{clip-path:url(#SVGID_10_);fill:#FFFFFE;}
450 + .st5{clip-path:url(#SVGID_12_);fill:#FFFFFE;}
451 + .st6{clip-path:url(#SVGID_14_);fill:#FFFFFE;}
452 + </style><g><defs><polygon id="SVGID_1_" points="83.8 100 0 100 0 0.3 83.8 0.3 167.6 0.3 167.6 100 "/></defs><clipPath id="SVGID_2_"><use xlink:href="#SVGID_1_" overflow="visible"/></clipPath><g class="st0"><g><defs><rect id="SVGID_3_" width="168" height="100"/></defs><clipPath id="SVGID_4_"><use xlink:href="#SVGID_3_" overflow="visible"/></clipPath><g class="st1"><defs><path id="SVGID_5_" d="M15.6 0.3H152c8.6 0 15.6 7 15.6 15.6v52c0 8.6-7 15.6-15.6 15.6h-48.9l6.7 16.4L80.2 83.6H15.6C7 83.6 0 76.6 0 67.9v-52C0 7.3 7 0.3 15.6 0.3"/></defs><clipPath id="SVGID_6_"><use xlink:href="#SVGID_5_" overflow="visible"/></clipPath><g class="st2"><defs><rect id="SVGID_7_" width="168" height="100"/></defs><clipPath id="SVGID_8_"><use xlink:href="#SVGID_7_" overflow="visible"/></clipPath><rect x="-10" y="-9.7" class="st3" width="187.6" height="119.7"/></g></g></g></g></g><g><defs><path id="SVGID_9_" d="M8.4 14.5c1-1.3 2.4-2 4.3-2.1 3.5-0.2 5.5 1.4 6 4.9 2.1 14.3 4.4 26.4 6.9 36.4l15-28.6c1.4-2.6 3.1-3.9 5.2-4.1 3-0.2 4.9 1.7 5.6 5.7 1.7 9.1 3.9 16.9 6.5 23.4 1.8-17.4 4.8-30 9-37.7 1-1.9 2.5-2.9 4.5-3 1.6-0.1 3 0.3 4.3 1.4 1.3 1 2 2.3 2.1 3.9 0.1 1.2-0.1 2.3-0.7 3.3 -2.7 5-4.9 13.2-6.6 24.7 -1.7 11.1-2.3 19.8-1.9 26.1 0.1 1.7-0.1 3.2-0.8 4.5 -0.8 1.5-2 2.4-3.7 2.5 -1.8 0.1-3.6-0.7-5.4-2.5C52.4 66.7 47.4 57 43.7 44.1c-4.4 8.8-7.7 15.3-9.9 19.7 -4 7.7-7.5 11.7-10.3 11.9 -1.9 0.1-3.5-1.4-4.8-4.7 -3.5-9-7.3-26.3-11.3-52C7.1 17.3 7.5 15.8 8.4 14.5"/></defs><clipPath id="SVGID_10_"><use xlink:href="#SVGID_9_" overflow="visible"/></clipPath><rect x="-2.7" y="-0.6" class="st4" width="90.6" height="86.4"/></g><g><defs><path id="SVGID_11_" d="M155.6 25.2c-2.5-4.3-6.1-6.9-11-7.9 -1.3-0.3-2.5-0.4-3.7-0.4 -6.6 0-11.9 3.4-16.1 10.2 -3.6 5.8-5.3 12.3-5.3 19.3 0 5.3 1.1 9.8 3.3 13.6 2.5 4.3 6.1 6.9 11 7.9 1.3 0.3 2.5 0.4 3.7 0.4 6.6 0 12-3.4 16.1-10.2 3.6-5.9 5.3-12.4 5.3-19.4C159 33.4 157.9 28.9 155.6 25.2zM147 44.2c-0.9 4.5-2.7 7.9-5.2 10.1 -2 1.8-3.9 2.5-5.5 2.2 -1.7-0.3-3-1.8-4-4.4 -0.8-2.1-1.2-4.2-1.2-6.2 0-1.7 0.2-3.4 0.5-5 0.6-2.8 1.8-5.5 3.6-8.1 2.3-3.3 4.7-4.8 7.1-4.2 1.7 0.3 3 1.8 4 4.4 0.8 2.1 1.2 4.2 1.2 6.2C147.5 40.9 147.3 42.6 147 44.2z"/></defs><clipPath id="SVGID_12_"><use xlink:href="#SVGID_11_" overflow="visible"/></clipPath><rect x="109.6" y="6.9" class="st5" width="59.4" height="71.4"/></g><g><defs><path id="SVGID_13_" d="M112.7 25.2c-2.5-4.3-6.1-6.9-11-7.9 -1.3-0.3-2.5-0.4-3.7-0.4 -6.6 0-11.9 3.4-16.1 10.2 -3.5 5.8-5.3 12.3-5.3 19.3 0 5.3 1.1 9.8 3.3 13.6 2.5 4.3 6.1 6.9 11 7.9 1.3 0.3 2.5 0.4 3.7 0.4 6.6 0 12-3.4 16.1-10.2 3.5-5.9 5.3-12.4 5.3-19.4C116 33.4 114.9 28.9 112.7 25.2zM104.1 44.2c-0.9 4.5-2.7 7.9-5.2 10.1 -2 1.8-3.9 2.5-5.5 2.2 -1.7-0.3-3-1.8-4-4.4 -0.8-2.1-1.2-4.2-1.2-6.2 0-1.7 0.2-3.4 0.5-5 0.6-2.8 1.8-5.5 3.6-8.1 2.3-3.3 4.7-4.8 7.1-4.2 1.7 0.3 3 1.8 4 4.4 0.8 2.1 1.2 4.2 1.2 6.2C104.6 40.9 104.4 42.6 104.1 44.2z"/></defs><clipPath id="SVGID_14_"><use xlink:href="#SVGID_13_" overflow="visible"/></clipPath><rect x="66.7" y="6.9" class="st6" width="59.4" height="71.4"/></g></svg></div>';
239 453 break;
240 454 default:
241 455 $content_icon = '';
242 456 break;
@@ -308,6 +522,21 @@
308 522 }
309 523 }
310 524
311 525 return $params;
526 + }
527 +
528 + /**
529 + * Check if the current site is connected.
530 + * On WordPress.com Simple, it is always connected.
531 + *
532 + * @return bool true if the site is connected, false otherwise.
533 + */
534 + private static function is_connected() {
535 + if ( ( new Host() )->is_wpcom_simple() ) {
536 + return true;
537 + }
538 +
539 + $connection = new Connection_Manager();
540 + return $connection->is_connected();
312 541 }
313 542 }