Completed
Push — fix/remove-unused-emblem-funct... ( 75bae5 )
by
unknown
102:52 queued 96:48
created

JITM::get_emblem()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Jetpack's JITM class.
4
 *
5
 * @package automattic/jetpack-jitm
6
 */
7
8
namespace Automattic\Jetpack;
9
10
use Automattic\Jetpack\Assets;
11
use Automattic\Jetpack\Connection\Manager as Jetpack_Connection;
12
use Automattic\Jetpack\Connection\Client;
13
use Automattic\Jetpack\Assets\Logo as Jetpack_Logo;
14
use Automattic\Jetpack\Tracking;
15
use Automattic\Jetpack\Connection\Manager;
16
17
/**
18
 * Jetpack just in time messaging through out the admin
19
 *
20
 * @since 5.6.0
21
 */
22
class JITM {
23
24
	const PACKAGE_VERSION = '1.0'; // TODO: Keep in sync with version specified in composer.json.
25
26
	/**
27
	 * Tracking object.
28
	 *
29
	 * @var Automattic\Jetpack\Tracking
30
	 *
31
	 * @access private
32
	 */
33
	private $tracking;
34
35
	/**
36
	 * JITM constructor.
37
	 */
38
	public function __construct() {
39
		$this->tracking = new Tracking();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Automattic\Jetpack\Tracking() of type object<Automattic\Jetpack\Tracking> is incompatible with the declared type object<Automattic\Jetpac...attic\Jetpack\Tracking> of property $tracking.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
40
	}
41
42
	/**
43
	 * Determines if JITMs are enabled.
44
	 *
45
	 * @return bool Enable JITMs.
46
	 */
47
	public function register() {
48
		/**
49
		 * Filter to turn off all just in time messages
50
		 *
51
		 * @since 3.7.0
52
		 * @since 5.4.0 Correct docblock to reflect default arg value
53
		 *
54
		 * @param bool false Whether to show just in time messages.
55
		 */
56
		if ( ! apply_filters( 'jetpack_just_in_time_msgs', false ) ) {
57
			return false;
58
		}
59
		add_action( 'current_screen', array( $this, 'prepare_jitms' ) );
60
		return true;
61
	}
62
63
	/**
64
	 * Prepare actions according to screen and post type.
65
	 *
66
	 * @since 3.8.2
67
	 *
68
	 * @uses Jetpack_Autoupdate::get_possible_failures()
69
	 *
70
	 * @param \WP_Screen $screen WP Core's screen object.
71
	 */
72
	public function prepare_jitms( $screen ) {
73
		if ( ! in_array(
74
			$screen->id,
75
			array(
76
				'jetpack_page_stats',
77
				'jetpack_page_akismet-key-config',
78
				'admin_page_jetpack_modules',
79
			),
80
			true
81
		) ) {
82
			add_action( 'admin_enqueue_scripts', array( $this, 'jitm_enqueue_files' ) );
83
			add_action( 'admin_notices', array( $this, 'ajax_message' ) );
84
			add_action( 'edit_form_top', array( $this, 'ajax_message' ) );
85
86
			// Not really a JITM. Don't know where else to put this :) .
87
			add_action( 'admin_notices', array( $this, 'delete_user_update_connection_owner_notice' ) );
88
		}
89
	}
90
91
	/**
92
	 * A special filter for WooCommerce, to set a message based on local state.
93
	 *
94
	 * @param string $content The current message.
95
	 *
96
	 * @return array The new message.
97
	 */
98
	public static function jitm_woocommerce_services_msg( $content ) {
99
		if ( ! function_exists( 'wc_get_base_location' ) ) {
100
			return $content;
101
		}
102
103
		$base_location = wc_get_base_location();
104
105
		switch ( $base_location['country'] ) {
106
			case 'US':
107
				$content->message = esc_html__( 'New free service: Show USPS shipping rates on your store! Added bonus: print shipping labels without leaving WooCommerce.', 'jetpack' );
108
				break;
109
			case 'CA':
110
				$content->message = esc_html__( 'New free service: Show Canada Post shipping rates on your store!', 'jetpack' );
111
				break;
112
			default:
113
				$content->message = '';
114
		}
115
116
		return $content;
117
	}
118
119
	/**
120
	 * A special filter for WooCommerce Call To Action button
121
	 *
122
	 * @return string The new CTA
123
	 */
124
	public static function jitm_jetpack_woo_services_install() {
125
		return wp_nonce_url(
126
			add_query_arg(
127
				array(
128
					'wc-services-action' => 'install',
129
				),
130
				admin_url( 'admin.php?page=wc-settings' )
131
			),
132
			'wc-services-install'
133
		);
134
	}
135
136
	/**
137
	 * A special filter for WooCommerce Call To Action button.
138
	 *
139
	 * @return string The new CTA
140
	 */
141
	public static function jitm_jetpack_woo_services_activate() {
142
		return wp_nonce_url(
143
			add_query_arg(
144
				array(
145
					'wc-services-action' => 'activate',
146
				),
147
				admin_url( 'admin.php?page=wc-settings' )
148
			),
149
			'wc-services-install'
150
		);
151
	}
152
153
	/**
154
	 * This is an entire admin notice dedicated to messaging and handling of the case where a user is trying to delete
155
	 * the connection owner.
156
	 */
157
	public function delete_user_update_connection_owner_notice() {
158
		global $current_screen;
159
160
		/*
161
		 * phpcs:disable WordPress.Security.NonceVerification.Recommended
162
		 *
163
		 * This function is firing within wp-admin and checks (below) if it is in the midst of a deletion on the users
164
		 * page. Nonce will be already checked by WordPress, so we do not need to check ourselves.
165
		 */
166
167
		if ( ! isset( $current_screen->base ) || 'users' !== $current_screen->base ) {
168
			return;
169
		}
170
171
		if ( ! isset( $_REQUEST['action'] ) || 'delete' !== $_REQUEST['action'] ) {
172
			return;
173
		}
174
175
		// Get connection owner or bail.
176
		$connection_manager  = new Manager();
177
		$connection_owner_id = $connection_manager->get_connection_owner_id();
178
		if ( ! $connection_owner_id ) {
179
			return;
180
		}
181
		$connection_owner_userdata = get_userdata( $connection_owner_id );
182
183
		// Bail if we're not trying to delete connection owner.
184
		$user_ids_to_delete = array();
185
		if ( isset( $_REQUEST['users'] ) ) {
186
			$user_ids_to_delete = $_REQUEST['users'];
187
		} elseif ( isset( $_REQUEST['user'] ) ) {
188
			$user_ids_to_delete[] = $_REQUEST['user'];
189
		}
190
191
		// phpcs:enable
192
193
		$deleting_connection_owner = in_array( $connection_owner_id, (array) $user_ids_to_delete, true );
194
		if ( ! $deleting_connection_owner ) {
195
			return;
196
		}
197
198
		// Bail if they're trying to delete themselves to avoid confusion.
199
		if ( get_current_user_id() === $connection_owner_id ) {
200
			return;
201
		}
202
203
		// Track it!
204
		if ( method_exists( $this->tracking, 'record_user_event' ) ) {
205
			$this->tracking->record_user_event( 'delete_connection_owner_notice_view' );
206
		}
207
208
		$connection_manager = new Manager();
209
		$connected_admins   = $connection_manager->get_connected_users( 'jetpack_disconnect' );
210
		$user               = is_a( $connection_owner_userdata, 'WP_User' ) ? esc_html( $connection_owner_userdata->data->user_login ) : '';
211
212
		echo "<div class='notice notice-warning' id='jetpack-notice-switch-connection-owner'>";
213
		echo '<h2>' . esc_html__( 'Important notice about your Jetpack connection:', 'jetpack' ) . '</h2>';
214
		echo '<p>' . sprintf(
215
			/* translators: WordPress User, if available. */
216
			esc_html__( 'Warning! You are about to delete the Jetpack connection owner (%s) for this site, which may cause some of your Jetpack features to stop working.', 'jetpack' ),
217
			esc_html( $user )
218
		) . '</p>';
219
220
		if ( ! empty( $connected_admins ) && count( $connected_admins ) > 1 ) {
221
			echo '<form id="jp-switch-connection-owner" action="" method="post">';
222
			echo "<label for='owner'>" . esc_html__( 'You can choose to transfer connection ownership to one of these already-connected admins:', 'jetpack' ) . ' </label>';
223
224
			$connected_admin_ids = array_map(
225
				function( $connected_admin ) {
226
						return $connected_admin->ID;
227
				},
228
				$connected_admins
229
			);
230
231
			wp_dropdown_users(
232
				array(
233
					'name'    => 'owner',
234
					'include' => array_diff( $connected_admin_ids, array( $connection_owner_id ) ),
235
					'show'    => 'display_name_with_login',
236
				)
237
			);
238
239
			echo '<p>';
240
			submit_button( esc_html__( 'Set new connection owner', 'jetpack' ), 'primary', 'jp-switch-connection-owner-submit', false );
241
			echo '</p>';
242
243
			echo "<div id='jp-switch-user-results'></div>";
244
			echo '</form>';
245
			?>
246
			<script type="text/javascript">
247
				jQuery( document ).ready( function( $ ) {
248
					$( '#jp-switch-connection-owner' ).on( 'submit', function( e ) {
249
						var formData = $( this ).serialize();
250
						var submitBtn = document.getElementById( 'jp-switch-connection-owner-submit' );
251
						var results = document.getElementById( 'jp-switch-user-results' );
252
253
						submitBtn.disabled = true;
254
255
						$.ajax( {
256
							type        : "POST",
257
							url         : "<?php echo esc_url( get_rest_url() . 'jetpack/v4/connection/owner' ); ?>",
258
							data        : formData,
259
							headers     : {
260
								'X-WP-Nonce': "<?php echo esc_js( wp_create_nonce( 'wp_rest' ) ); ?>",
261
							},
262
							success: function() {
263
								results.innerHTML = "<?php esc_html_e( 'Success!', 'jetpack' ); ?>";
264
								setTimeout( function() {
265
									$( '#jetpack-notice-switch-connection-owner' ).hide( 'slow' );
266
								}, 1000 );
267
							}
268
						} ).done( function() {
269
							submitBtn.disabled = false;
270
						} );
271
272
						e.preventDefault();
273
						return false;
274
					} );
275
				} );
276
			</script>
277
			<?php
278
		} else {
279
			echo '<p>' . esc_html__( 'Every Jetpack site needs at least one connected admin for the features to work properly. Please connect to your WordPress.com account via the button below. Once you connect, you may refresh this page to see an option to change the connection owner.', 'jetpack' ) . '</p>';
280
			$connect_url = \Jetpack::init()->build_connect_url( false, false, 'delete_connection_owner_notice' );
281
			echo "<a href='" . esc_url( $connect_url ) . "' target='_blank' rel='noopener noreferrer' class='button-primary'>" . esc_html__( 'Connect to WordPress.com', 'jetpack' ) . '</a>';
282
		}
283
284
		echo '<p>';
285
		printf(
286
			wp_kses(
287
				/* translators: URL to Jetpack support doc regarding the primary user. */
288
				__( "<a href='%s' target='_blank' rel='noopener noreferrer'>Learn more</a> about the connection owner and what will break if you do not have one.", 'jetpack' ),
289
				array(
290
					'a' => array(
291
						'href'   => true,
292
						'target' => true,
293
						'rel'    => true,
294
					),
295
				)
296
			),
297
			'https://jetpack.com/support/primary-user/'
298
		);
299
		echo '</p>';
300
		echo '<p>';
301
		printf(
302
			wp_kses(
303
				/* translators: URL to contact Jetpack support. */
304
				__( 'As always, feel free to <a href="%s" target="_blank" rel="noopener noreferrer">contact our support team</a> if you have any questions.', 'jetpack' ),
305
				array(
306
					'a' => array(
307
						'href'   => true,
308
						'target' => true,
309
						'rel'    => true,
310
					),
311
				)
312
			),
313
			'https://jetpack.com/contact-support'
314
		);
315
		echo '</p>';
316
		echo '</div>';
317
	}
318
319
	/**
320
	 * Injects the dom to show a JITM inside of wp-admin.
321
	 */
322
	public function ajax_message() {
323
		if ( ! is_admin() ) {
324
			return;
325
		}
326
		$message_path   = $this->get_message_path();
327
		$query_string   = _http_build_query( $_GET, '', ',' ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
328
		$current_screen = wp_unslash( $_SERVER['REQUEST_URI'] );
329
		?>
330
		<div class="jetpack-jitm-message"
331
			data-nonce="<?php echo esc_attr( wp_create_nonce( 'wp_rest' ) ); ?>"
332
			data-message-path="<?php echo esc_attr( $message_path ); ?>"
333
			data-query="<?php echo urlencode_deep( $query_string ); ?>"
334
			data-redirect="<?php echo urlencode_deep( $current_screen ); ?>"
335
		></div>
336
		<?php
337
	}
338
339
	/**
340
	 * Get's the current message path for display of a JITM
341
	 *
342
	 * @return string The message path
343
	 */
344
	public function get_message_path() {
345
		$screen = get_current_screen();
346
347
		return 'wp:' . $screen->id . ':' . current_filter();
348
	}
349
350
	/**
351
	 * Function to enqueue jitm css and js
352
	 */
353
	public function jitm_enqueue_files() {
354
		$min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
355
		wp_register_style(
356
			'jetpack-jitm-css',
357
			plugins_url( "assets/jetpack-admin-jitm{$min}.css", __DIR__ ),
358
			false,
359
			self::PACKAGE_VERSION .
360
			'-201243242'
361
		);
362
		wp_style_add_data( 'jetpack-jitm-css', 'rtl', 'replace' );
363
		wp_style_add_data( 'jetpack-jitm-css', 'suffix', $min );
364
		wp_enqueue_style( 'jetpack-jitm-css' );
365
366
		wp_enqueue_script(
367
			'jetpack-jitm-new',
368
			Assets::get_file_url_for_environment( '_inc/build/jetpack-jitm.min.js', '_inc/jetpack-jitm.js' ),
369
			array( 'jquery' ),
370
			self::PACKAGE_VERSION,
371
			true
372
		);
373
		wp_localize_script(
374
			'jetpack-jitm-new',
375
			'jitm_config',
376
			array(
377
				'api_root'               => esc_url_raw( rest_url() ),
378
				'activate_module_text'   => esc_html__( 'Activate', 'jetpack' ),
379
				'activated_module_text'  => esc_html__( 'Activated', 'jetpack' ),
380
				'activating_module_text' => esc_html__( 'Activating', 'jetpack' ),
381
			)
382
		);
383
	}
384
385
	/**
386
	 * Dismisses a JITM feature class so that it will no longer be shown.
387
	 *
388
	 * @param string $id The id of the JITM that was dismissed.
389
	 * @param string $feature_class The feature class of the JITM that was dismissed.
390
	 *
391
	 * @return bool Always true.
392
	 */
393
	public function dismiss( $id, $feature_class ) {
394
		$this->tracking->record_user_event(
395
			'jitm_dismiss_client',
396
			array(
397
				'jitm_id'       => $id,
398
				'feature_class' => $feature_class,
399
			)
400
		);
401
402
		$hide_jitm = \Jetpack_Options::get_option( 'hide_jitm' );
403
		if ( ! is_array( $hide_jitm ) ) {
404
			$hide_jitm = array();
405
		}
406
407
		if ( isset( $hide_jitm[ $feature_class ] ) ) {
408
			if ( ! is_array( $hide_jitm[ $feature_class ] ) ) {
409
				$hide_jitm[ $feature_class ] = array(
410
					'last_dismissal' => 0,
411
					'number'         => 0,
412
				);
413
			}
414
		} else {
415
			$hide_jitm[ $feature_class ] = array(
416
				'last_dismissal' => 0,
417
				'number'         => 0,
418
			);
419
		}
420
421
		$number = $hide_jitm[ $feature_class ]['number'];
422
423
		$hide_jitm[ $feature_class ] = array(
424
			'last_dismissal' => time(),
425
			'number'         => $number + 1,
426
		);
427
428
		\Jetpack_Options::update_option( 'hide_jitm', $hide_jitm );
429
430
		return true;
431
	}
432
433
	/**
434
	 * Asks the wpcom API for the current message to display keyed on query string and message path
435
	 *
436
	 * @param string $message_path The message path to ask for.
437
	 * @param string $query The query string originally from the front end.
438
	 *
439
	 * @return array The JITM's to show, or an empty array if there is nothing to show
440
	 */
441
	public function get_messages( $message_path, $query ) {
442
		// Custom filters go here.
443
		add_filter( 'jitm_woocommerce_services_msg', array( $this, 'jitm_woocommerce_services_msg' ) );
444
		add_filter( 'jitm_jetpack_woo_services_install', array( $this, 'jitm_jetpack_woo_services_install' ) );
445
		add_filter( 'jitm_jetpack_woo_services_activate', array( $this, 'jitm_jetpack_woo_services_activate' ) );
446
447
		$user = wp_get_current_user();
448
449
		// Unauthenticated or invalid requests just bail.
450
		if ( ! $user ) {
451
			return array();
452
		}
453
454
		$user_roles = implode( ',', $user->roles );
455
		$site_id    = \Jetpack_Options::get_option( 'id' );
456
457
		// Build our jitm request.
458
		$path = add_query_arg(
459
			array(
460
				'external_user_id' => urlencode_deep( $user->ID ),
461
				'user_roles'       => urlencode_deep( $user_roles ),
462
				'query_string'     => urlencode_deep( $query ),
463
				'mobile_browser'   => jetpack_is_mobile( 'smart' ) ? 1 : 0,
464
				'_locale'          => get_user_locale(),
465
			),
466
			sprintf( '/sites/%d/jitm/%s', $site_id, $message_path )
467
		);
468
469
		// Attempt to get from cache.
470
		$envelopes = get_transient( 'jetpack_jitm_' . substr( md5( $path ), 0, 31 ) );
471
472
		// If something is in the cache and it was put in the cache after the last sync we care about, use it.
473
		$use_cache = false;
474
475
		/** This filter is documented in class.jetpack.php */
476
		if ( apply_filters( 'jetpack_just_in_time_msg_cache', false ) ) {
477
			$use_cache = true;
478
		}
479
480
		if ( $use_cache ) {
481
			$last_sync  = (int) get_transient( 'jetpack_last_plugin_sync' );
482
			$from_cache = $envelopes && $last_sync > 0 && $last_sync < $envelopes['last_response_time'];
483
		} else {
484
			$from_cache = false;
485
		}
486
487
		// Otherwise, ask again.
488
		if ( ! $from_cache ) {
489
			$wpcom_response = Client::wpcom_json_api_request_as_blog(
490
				$path,
491
				'2',
492
				array(
493
					'user_id'    => $user->ID,
494
					'user_roles' => implode( ',', $user->roles ),
495
				),
496
				null,
497
				'wpcom'
498
			);
499
500
			// silently fail...might be helpful to track it?
501
			if ( is_wp_error( $wpcom_response ) ) {
502
				return array();
503
			}
504
505
			$envelopes = json_decode( $wpcom_response['body'] );
506
507
			if ( ! is_array( $envelopes ) ) {
508
				return array();
509
			}
510
511
			$expiration = isset( $envelopes[0] ) ? $envelopes[0]->ttl : 300;
512
513
			// Do not cache if expiration is 0 or we're not using the cache.
514
			if ( 0 !== $expiration && $use_cache ) {
515
				$envelopes['last_response_time'] = time();
516
517
				set_transient( 'jetpack_jitm_' . substr( md5( $path ), 0, 31 ), $envelopes, $expiration );
518
			}
519
		}
520
521
		$hidden_jitms = \Jetpack_Options::get_option( 'hide_jitm' );
522
		unset( $envelopes['last_response_time'] );
523
524
		/**
525
		 * Allow adding your own custom JITMs after a set of JITMs has been received.
526
		 *
527
		 * @since 6.9.0
528
		 *
529
		 * @param array $envelopes array of existing JITMs.
530
		 */
531
		$envelopes = apply_filters( 'jetpack_jitm_received_envelopes', $envelopes );
532
533
		foreach ( $envelopes as $idx => &$envelope ) {
534
535
			$dismissed_feature = isset( $hidden_jitms[ $envelope->feature_class ] ) && is_array( $hidden_jitms[ $envelope->feature_class ] ) ? $hidden_jitms[ $envelope->feature_class ] : null;
536
537
			// If the this feature class has been dismissed and the request has not passed the ttl, skip it as it's been dismissed.
538
			if ( is_array( $dismissed_feature ) && ( time() - $dismissed_feature['last_dismissal'] < $envelope->expires || $dismissed_feature['number'] >= $envelope->max_dismissal ) ) {
539
				unset( $envelopes[ $idx ] );
540
				continue;
541
			}
542
543
			$this->tracking->record_user_event(
544
				'jitm_view_client',
545
				array(
546
					'jitm_id' => $envelope->id,
547
				)
548
			);
549
550
			$normalized_site_url = \Jetpack::build_raw_urls( get_home_url() );
551
552
			$url_params = array(
553
				'source' => "jitm-$envelope->id",
554
				'site'   => $normalized_site_url,
555
				'u'      => $user->ID,
556
			);
557
558
			if ( ! class_exists( 'Jetpack_Affiliate' ) ) {
559
				require_once JETPACK__PLUGIN_DIR . 'class.jetpack-affiliate.php';
560
			}
561
			// Get affiliate code and add it to the array of URL parameters.
562
			$aff = \Jetpack_Affiliate::init()->get_affiliate_code();
563
			if ( '' !== $aff ) {
564
				$url_params['aff'] = $aff;
565
			}
566
567
			$envelope->url = add_query_arg( $url_params, 'https://jetpack.com/redirect/' );
568
569
			$envelope->jitm_stats_url = \Jetpack::build_stats_url( array( 'x_jetpack-jitm' => $envelope->id ) );
570
571
			// phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
572
			// $CTA is not valid per PHPCS, but it is part of the return from WordPress.com, so allowing.
573
			if ( $envelope->CTA->hook ) {
574
				$envelope->url = apply_filters( 'jitm_' . $envelope->CTA->hook, $envelope->url );
575
				unset( $envelope->CTA->hook );
576
			}
577
			// phpcs:enable
578
579
			if ( isset( $envelope->content->hook ) ) {
580
				$envelope->content = apply_filters( 'jitm_' . $envelope->content->hook, $envelope->content );
581
				unset( $envelope->content->hook );
582
			}
583
584
			// No point in showing an empty message.
585
			if ( empty( $envelope->content->message ) ) {
586
				unset( $envelopes[ $idx ] );
587
				continue;
588
			}
589
590
			switch ( $envelope->content->icon ) {
591
				case 'jetpack':
592
					$jetpack_logo            = new Jetpack_Logo();
593
					$envelope->content->icon = '<div class="jp-emblem">' . $jetpack_logo->get_jp_emblem() . '</div>';
594
					break;
595
				case 'woocommerce':
596
					$envelope->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">
597
					.st0{clip-path:url(#SVGID_2_);enable-background:new    ;}
598
					.st1{clip-path:url(#SVGID_4_);}
599
					.st2{clip-path:url(#SVGID_6_);}
600
					.st3{clip-path:url(#SVGID_8_);fill:#8F567F;}
601
					.st4{clip-path:url(#SVGID_10_);fill:#FFFFFE;}
602
					.st5{clip-path:url(#SVGID_12_);fill:#FFFFFE;}
603
					.st6{clip-path:url(#SVGID_14_);fill:#FFFFFE;}
604
				</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>';
605
					break;
606
				default:
607
					$envelope->content->icon = '';
608
					break;
609
			}
610
611
			$jetpack = \Jetpack::init();
612
			$jetpack->stat( 'jitm', $envelope->id . '-viewed-' . JETPACK__VERSION );
613
			$jetpack->do_stats( 'server_side' );
614
		}
615
616
		return $envelopes;
617
	}
618
}
619