Completed
Push — add/redirect-everything ( 072b68 )
by
unknown
83:16 queued 66:54
created

Jetpack_IDC::get_safe_mod_doc_url()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
use Automattic\Jetpack\Assets;
4
use Automattic\Jetpack\Assets\Logo as Jetpack_Logo;
5
6
/**
7
 * This class will handle everything involved with fixing an Identity Crisis.
8
 *
9
 * @since 4.4.0
10
 */
11
class Jetpack_IDC {
12
13
	/**
14
	 * @var Jetpack_IDC
15
	 **/
16
	private static $instance = null;
17
18
	/**
19
	 * The wpcom value of the home URL
20
	 *
21
	 * @var string
22
	 */
23
	static $wpcom_home_url;
24
25
	/**
26
	 * Has safe mode been confirmed?
27
	 *
28
	 * @var bool
29
	 */
30
	static $is_safe_mode_confirmed;
31
32
	/**
33
	 * The current screen, which is set if the current user is a non-admin and this is an admin page.
34
	 *
35
	 * @var WP_Screen
36
	 */
37
	static $current_screen;
38
39
	static function init() {
40
		if ( is_null( self::$instance ) ) {
41
			self::$instance = new Jetpack_IDC();
42
		}
43
44
		return self::$instance;
45
	}
46
47
	private function __construct() {
48
		add_action( 'jetpack_sync_processed_actions', array( $this, 'maybe_clear_migrate_option' ) );
49
		if ( false === $urls_in_crisis = Jetpack::check_identity_crisis() ) {
50
			return;
51
		}
52
53
		self::$wpcom_home_url = $urls_in_crisis['wpcom_home'];
54
		add_action( 'init', array( $this, 'wordpress_init' ) );
55
	}
56
57
	/**
58
	 * Gets the link to the support document used to explain Safe Mode to users
59
	 *
60
	 * @return string
61
	 */
62
	public static function get_safe_mod_doc_url() {
63
		return \Jetpack::build_redirect_url( 'jp-support-safe-mode' );
64
	}
65
66
	/**
67
	 * This method loops through the array of processed items from sync and checks if one of the items was the
68
	 * home_url or site_url callable. If so, then we delete the jetpack_migrate_for_idc option.
69
	 *
70
	 * @param $processed_items array Array of processed items that were synced to WordPress.com
71
	 */
72
	function maybe_clear_migrate_option( $processed_items ) {
73
		foreach ( (array) $processed_items as $item ) {
74
75
			// First, is this item a jetpack_sync_callable action? If so, then proceed.
76
			$callable_args = ( is_array( $item ) && isset( $item[0], $item[1] ) && 'jetpack_sync_callable' === $item[0] )
77
				? $item[1]
78
				: null;
79
80
			// Second, if $callable_args is set, check if the callable was home_url or site_url. If so,
81
			// clear the migrate option.
82
			if (
83
				isset( $callable_args, $callable_args[0] )
84
				&& ( 'home_url' === $callable_args[0] || 'site_url' === $callable_args[1] )
85
			) {
86
				Jetpack_Options::delete_option( 'migrate_for_idc' );
87
				break;
88
			}
89
		}
90
	}
91
92
	function wordpress_init() {
93
		if ( ! current_user_can( 'jetpack_disconnect' ) && is_admin() ) {
94
			add_action( 'admin_notices', array( $this, 'display_non_admin_idc_notice' ) );
95
			add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_idc_notice_files' ) );
96
			add_action( 'current_screen', array( $this, 'non_admins_current_screen_check' ) );
97
			return;
98
		}
99
100
		if (
101
			isset( $_GET['jetpack_idc_clear_confirmation'], $_GET['_wpnonce'] ) &&
102
			wp_verify_nonce( $_GET['_wpnonce'], 'jetpack_idc_clear_confirmation' )
103
		) {
104
			Jetpack_Options::delete_option( 'safe_mode_confirmed' );
105
			self::$is_safe_mode_confirmed = false;
106
		} else {
107
			self::$is_safe_mode_confirmed = (bool) Jetpack_Options::get_option( 'safe_mode_confirmed' );
108
		}
109
110
		// 121 Priority so that it's the most inner Jetpack item in the admin bar.
111
		add_action( 'admin_bar_menu', array( $this, 'display_admin_bar_button' ), 121 );
112
		add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_bar_css' ) );
113
114
		if ( is_admin() && ! self::$is_safe_mode_confirmed ) {
115
			add_action( 'admin_notices', array( $this, 'display_idc_notice' ) );
116
			add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_idc_notice_files' ) );
117
		}
118
	}
119
120
	function non_admins_current_screen_check( $current_screen ) {
121
		self::$current_screen = $current_screen;
122
		if ( isset( $current_screen->id ) && 'toplevel_page_jetpack' == $current_screen->id ) {
123
			return null;
124
		}
125
126
		// If the user has dismissed the notice, and we're not currently on a Jetpack page,
127
		// then do not show the non-admin notice.
128
		if ( isset( $_COOKIE, $_COOKIE['jetpack_idc_dismiss_notice'] ) ) {
129
			remove_action( 'admin_notices', array( $this, 'display_non_admin_idc_notice' ) );
130
			remove_action( 'admin_enqueue_scripts', array( $this, 'enqueue_idc_notice_files' ) );
131
		}
132
	}
133
134
	function display_admin_bar_button() {
135
		global $wp_admin_bar;
136
137
		$href = is_admin()
138
			? add_query_arg( 'jetpack_idc_clear_confirmation', '1' )
139
			: add_query_arg( 'jetpack_idc_clear_confirmation', '1', admin_url() );
140
141
		$href = wp_nonce_url( $href, 'jetpack_idc_clear_confirmation' );
142
143
		$title = sprintf(
144
			'<span class="jp-idc-admin-bar">%s %s</span>',
145
			'<span class="dashicons dashicons-warning"></span>',
146
			esc_html__( 'Jetpack Safe Mode', 'jetpack' )
147
		);
148
149
		$menu = array(
150
			'id'     => 'jetpack-idc',
151
			'title'  => $title,
152
			'href'   => esc_url( $href ),
153
			'parent' => 'top-secondary',
154
		);
155
156
		if ( ! self::$is_safe_mode_confirmed ) {
157
			$menu['meta'] = array(
158
				'class' => 'hide',
159
			);
160
		}
161
162
		$wp_admin_bar->add_node( $menu );
163
	}
164
165
	static function prepare_url_for_display( $url ) {
166
		return untrailingslashit( Jetpack::normalize_url_protocol_agnostic( $url ) );
167
	}
168
169
	/**
170
	 * Clears all IDC specific options. This method is used on disconnect and reconnect.
171
	 */
172
	static function clear_all_idc_options() {
173
		// If the site is currently in IDC, let's also clear the VaultPress connection options.
174
		// We have to check if the site is in IDC, otherwise we'd be clearing the VaultPress
175
		// connection any time the Jetpack connection is cycled.
176
		if ( Jetpack::validate_sync_error_idc_option() ) {
177
			delete_option( 'vaultpress' );
178
			delete_option( 'vaultpress_auto_register' );
179
		}
180
181
		Jetpack_Options::delete_option(
182
			array(
183
				'sync_error_idc',
184
				'safe_mode_confirmed',
185
				'migrate_for_idc',
186
			)
187
		);
188
	}
189
190
	/**
191
	 * Does the current admin page have help tabs?
192
	 *
193
	 * @return bool
194
	 */
195
	function admin_page_has_help_tabs() {
196
		if ( ! function_exists( 'get_current_screen' ) ) {
197
			return false;
198
		}
199
200
		$current_screen = get_current_screen();
201
		$tabs           = $current_screen->get_help_tabs();
202
203
		return ! empty( $tabs );
204
	}
205
206
	function display_non_admin_idc_notice() {
207
		$classes = 'jp-idc-notice inline is-non-admin notice notice-warning';
208
		if ( isset( self::$current_screen ) && 'toplevel_page_jetpack' != self::$current_screen->id ) {
209
			$classes .= ' is-dismissible';
210
		}
211
212
		if ( $this->admin_page_has_help_tabs() ) {
213
			$classes .= ' has-help-tabs';
214
		}
215
		?>
216
217
		<div class="<?php echo $classes; ?>">
218
			<?php $this->render_notice_header(); ?>
219
			<div class="jp-idc-notice__content-header">
220
				<h3 class="jp-idc-notice__content-header__lead">
221
					<?php echo $this->get_non_admin_notice_text(); ?>
222
				</h3>
223
224
				<p class="jp-idc-notice__content-header__explanation">
225
					<?php echo $this->get_non_admin_contact_admin_text(); ?>
226
				</p>
227
			</div>
228
		</div>
229
		<?php
230
	}
231
232
	/**
233
	 * First "step" of the IDC mitigation. Will provide some messaging and two options/buttons.
234
	 * "Confirm Staging" - Dismiss the notice and continue on with our lives in staging mode.
235
	 * "Fix Jetpack Connection" - Will disconnect the site and start the mitigation...
236
	 */
237
	function display_idc_notice() {
238
		$classes = 'jp-idc-notice inline notice notice-warning';
239
		if ( $this->admin_page_has_help_tabs() ) {
240
			$classes .= ' has-help-tabs';
241
		}
242
		?>
243
		<div class="<?php echo $classes; ?>">
244
			<?php $this->render_notice_header(); ?>
245
			<?php $this->render_notice_first_step(); ?>
246
			<?php $this->render_notice_second_step(); ?>
247
		</div>
248
		<?php
249
	}
250
251
	function enqueue_admin_bar_css() {
252
		wp_enqueue_style(
253
			'jetpack-idc-admin-bar-css',
254
			plugins_url( 'css/jetpack-idc-admin-bar.css', JETPACK__PLUGIN_FILE ),
255
			array( 'dashicons' ),
256
			JETPACK__VERSION
257
		);
258
	}
259
260
	/**
261
	 * Enqueue scripts for the notice
262
	 */
263
	function enqueue_idc_notice_files() {
264
265
		wp_enqueue_script(
266
			'jetpack-idc-js',
267
			Assets::get_file_url_for_environment( '_inc/build/idc-notice.min.js', '_inc/idc-notice.js' ),
268
			array( 'jquery' ),
269
			JETPACK__VERSION,
270
			true
271
		);
272
273
		wp_localize_script(
274
			'jetpack-idc-js',
275
			'idcL10n',
276
			array(
277
				'apiRoot'         => esc_url_raw( rest_url() ),
278
				'nonce'           => wp_create_nonce( 'wp_rest' ),
279
				'tracksUserData'  => Jetpack_Tracks_Client::get_connected_user_tracks_identity(),
280
				'currentUrl'      => remove_query_arg( '_wpnonce', remove_query_arg( 'jetpack_idc_clear_confirmation' ) ),
281
				'tracksEventData' => array(
282
					'isAdmin'       => current_user_can( 'jetpack_disconnect' ),
283
					'currentScreen' => self::$current_screen ? self::$current_screen->id : false,
284
				),
285
			)
286
		);
287
288 View Code Duplication
		if ( ! wp_style_is( 'jetpack-dops-style' ) ) {
289
			wp_register_style(
290
				'jetpack-dops-style',
291
				plugins_url( '_inc/build/admin.css', JETPACK__PLUGIN_FILE ),
292
				array(),
293
				JETPACK__VERSION
294
			);
295
		}
296
297
		wp_enqueue_style(
298
			'jetpack-idc-css',
299
			plugins_url( 'css/jetpack-idc.css', JETPACK__PLUGIN_FILE ),
300
			array( 'jetpack-dops-style' ),
301
			JETPACK__VERSION
302
		);
303
304
		// Required for Tracks
305
		wp_enqueue_script(
306
			'jp-tracks',
307
			'//stats.wp.com/w.js',
308
			array(),
309
			gmdate( 'YW' ),
310
			true
311
		);
312
313
		wp_enqueue_script(
314
			'jp-tracks-functions',
315
			plugins_url( '_inc/lib/tracks/tracks-callables.js', JETPACK__PLUGIN_FILE ),
316
			array(),
317
			JETPACK__VERSION,
318
			false
319
		);
320
	}
321
322
	function render_notice_header() {
323
		?>
324
		<div class="jp-idc-notice__header">
325
			<div class="jp-idc-notice__header__emblem">
326
				<?php
327
				$jetpack_logo = new Jetpack_Logo();
328
				echo $jetpack_logo->get_jp_emblem();
329
				?>
330
			</div>
331
			<p class="jp-idc-notice__header__text">
332
				<?php esc_html_e( 'Jetpack Safe Mode', 'jetpack' ); ?>
333
			</p>
334
		</div>
335
336
		<div class="jp-idc-notice__separator"></div>
337
		<?php
338
	}
339
340
	/**
341
	 * Is a container for the error notices.
342
	 * Will be shown/controlled by jQuery in idc-notice.js
343
	 */
344
	function render_error_notice() {
345
		?>
346
		<div class="jp-idc-error__notice dops-notice is-error">
347
			<svg class="gridicon gridicons-notice dops-notice__icon" height="24" width="24" viewBox="0 0 24 24">
348
				<g>
349
					<path d="M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zm1 15h-2v-2h2v2zm0-4h-2l-.5-6h3l-.5 6z"></path>
350
				</g>
351
			</svg>
352
			<div class="dops-notice__content">
353
				<span class="dops-notice__text">
354
					<?php esc_html_e( 'Something went wrong:', 'jetpack' ); ?>
355
					<span class="jp-idc-error__desc"></span>
356
				</span>
357
				<a class="dops-notice__action" href="javascript:void(0);">
358
					<span id="jp-idc-error__action">
359
						<?php esc_html_e( 'Try Again', 'jetpack' ); ?>
360
					</span>
361
				</a>
362
			</div>
363
		</div>
364
		<?php
365
	}
366
367
	function render_notice_first_step() {
368
		?>
369
		<div class="jp-idc-notice__first-step">
370
			<div class="jp-idc-notice__content-header">
371
				<h3 class="jp-idc-notice__content-header__lead">
372
					<?php echo $this->get_first_step_header_lead(); ?>
373
				</h3>
374
375
				<p class="jp-idc-notice__content-header__explanation">
376
					<?php echo $this->get_first_step_header_explanation(); ?>
377
				</p>
378
			</div>
379
380
			<?php $this->render_error_notice(); ?>
381
382
			<div class="jp-idc-notice__actions">
383
				<div class="jp-idc-notice__action">
384
					<p class="jp-idc-notice__action__explanation">
385
						<?php echo $this->get_confirm_safe_mode_action_explanation(); ?>
386
					</p>
387
					<button id="jp-idc-confirm-safe-mode-action" class="dops-button">
388
						<?php echo $this->get_confirm_safe_mode_button_text(); ?>
389
					</button>
390
				</div>
391
392
				<div class="jp-idc-notice__action">
393
					<p class="jp-idc-notice__action__explanation">
394
						<?php echo $this->get_first_step_fix_connection_action_explanation(); ?>
395
					</p>
396
					<button id="jp-idc-fix-connection-action" class="dops-button">
397
						<?php echo $this->get_first_step_fix_connection_button_text(); ?>
398
					</button>
399
				</div>
400
			</div>
401
		</div>
402
		<?php
403
	}
404
405
	function render_notice_second_step() {
406
		?>
407
		<div class="jp-idc-notice__second-step">
408
			<div class="jp-idc-notice__content-header">
409
				<h3 class="jp-idc-notice__content-header__lead">
410
					<?php echo $this->get_second_step_header_lead(); ?>
411
				</h3>
412
			</div>
413
414
			<?php $this->render_error_notice(); ?>
415
416
			<div class="jp-idc-notice__actions">
417
				<div class="jp-idc-notice__action">
418
					<p class="jp-idc-notice__action__explanation">
419
						<?php echo $this->get_migrate_site_action_explanation(); ?>
420
					</p>
421
					<button id="jp-idc-migrate-action" class="dops-button">
422
						<?php echo $this->get_migrate_site_button_text(); ?>
423
					</button>
424
				</div>
425
426
				<div class="jp-idc-notice__action">
427
					<p class="jp-idc-notice__action__explanation">
428
						<?php echo $this->get_start_fresh_action_explanation(); ?>
429
					</p>
430
					<button id="jp-idc-reconnect-site-action" class="dops-button">
431
						<?php echo $this->get_start_fresh_button_text(); ?>
432
					</button>
433
				</div>
434
435
			</div>
436
437
			<p class="jp-idc-notice__unsure-prompt">
438
				<?php echo $this->get_unsure_prompt(); ?>
439
			</p>
440
		</div>
441
		<?php
442
	}
443
444
	function get_first_step_header_lead() {
445
		$html = wp_kses(
446
			sprintf(
447
				__(
448
					'Jetpack has been placed into <a href="%1$s">Safe mode</a> because we noticed this is an exact copy of <a href="%2$s">%3$s</a>.',
449
					'jetpack'
450
				),
451
				esc_url( self::get_safe_mod_doc_url() ),
452
				esc_url( self::$wpcom_home_url ),
453
				self::prepare_url_for_display( esc_url_raw( self::$wpcom_home_url ) )
454
			),
455
			array( 'a' => array( 'href' => array() ) )
456
		);
457
458
		/**
459
		 * Allows overriding of the default header text in the first step of the Safe Mode notice.
460
		 *
461
		 * @since 4.4.0
462
		 *
463
		 * @param string $html The HTML to be displayed
464
		 */
465
		return apply_filters( 'jetpack_idc_first_step_header_lead', $html );
466
	}
467
468 View Code Duplication
	function get_first_step_header_explanation() {
469
		$html = wp_kses(
470
			sprintf(
471
				__(
472
					'Please confirm Safe Mode or fix the Jetpack connection. Select one of the options below or <a href="%1$s">learn
473
					more about Safe Mode</a>.',
474
					'jetpack'
475
				),
476
				esc_url( self::get_safe_mod_doc_url() )
477
			),
478
			array( 'a' => array( 'href' => array() ) )
479
		);
480
481
		/**
482
		 * Allows overriding of the default header explanation text in the first step of the Safe Mode notice.
483
		 *
484
		 * @since 4.4.0
485
		 *
486
		 * @param string $html The HTML to be displayed
487
		 */
488
		return apply_filters( 'jetpack_idc_first_step_header_explanation', $html );
489
	}
490
491 View Code Duplication
	function get_confirm_safe_mode_action_explanation() {
492
		$html = wp_kses(
493
			sprintf(
494
				__(
495
					'Is this website a temporary duplicate of <a href="%1$s">%2$s</a> for the purposes
496
					of testing, staging or development? If so, we recommend keeping it in Safe Mode.',
497
					'jetpack'
498
				),
499
				esc_url( untrailingslashit( self::$wpcom_home_url ) ),
500
				self::prepare_url_for_display( esc_url( self::$wpcom_home_url ) )
501
			),
502
			array( 'a' => array( 'href' => array() ) )
503
		);
504
505
		/**
506
		 * Allows overriding of the default text used to explain the confirm safe mode action.
507
		 *
508
		 * @since 4.4.0
509
		 *
510
		 * @param string $html The HTML to be displayed
511
		 */
512
		return apply_filters( 'jetpack_idc_confirm_safe_mode_explanation', $html );
513
	}
514
515
	function get_confirm_safe_mode_button_text() {
516
		$string = esc_html__( 'Confirm Safe Mode', 'jetpack' );
517
518
		/**
519
		 * Allows overriding of the default text used for the confirm safe mode action button.
520
		 *
521
		 * @since 4.4.0
522
		 *
523
		 * @param string $string The string to be displayed
524
		 */
525
		return apply_filters( 'jetpack_idc_confirm_safe_mode_button_text', $string );
526
	}
527
528 View Code Duplication
	function get_first_step_fix_connection_action_explanation() {
529
		$html = wp_kses(
530
			sprintf(
531
				__(
532
					'If this is a separate and new website, or the new home of <a href="%1$s">%2$s</a>,
533
					we recommend turning Safe Mode off, and re-establishing your connection to WordPress.com.',
534
					'jetpack'
535
				),
536
				esc_url( untrailingslashit( self::$wpcom_home_url ) ),
537
				self::prepare_url_for_display( esc_url( self::$wpcom_home_url ) )
538
			),
539
			array( 'a' => array( 'href' => array() ) )
540
		);
541
542
		/**
543
		 * Allows overriding of the default text used to explain the fix Jetpack connection action.
544
		 *
545
		 * @since 4.4.0
546
		 *
547
		 * @param string $html The HTML to be displayed
548
		 */
549
		return apply_filters( 'jetpack_idc_first_fix_connection_explanation', $html );
550
	}
551
552
	function get_first_step_fix_connection_button_text() {
553
		$string = esc_html__( "Fix Jetpack's Connection", 'jetpack' );
554
555
		/**
556
		 * Allows overriding of the default text used for the fix Jetpack connection action button.
557
		 *
558
		 * @since 4.4.0
559
		 *
560
		 * @param string $string The string to be displayed
561
		 */
562
		return apply_filters( 'jetpack_idc_first_step_fix_connection_button_text', $string );
563
	}
564
565
	function get_second_step_header_lead() {
566
		$string = sprintf(
567
			esc_html__(
568
				'Is %1$s the new home of %2$s?',
569
				'jetpack'
570
			),
571
			untrailingslashit( Jetpack::normalize_url_protocol_agnostic( get_home_url() ) ),
572
			untrailingslashit( Jetpack::normalize_url_protocol_agnostic( esc_url_raw( self::$wpcom_home_url ) ) )
573
		);
574
575
		/**
576
		 * Allows overriding of the default header text in the second step of the Safe Mode notice.
577
		 *
578
		 * @since 4.4.0
579
		 *
580
		 * @param string $html The HTML to be displayed
581
		 */
582
		return apply_filters( 'jetpack_idc_second_step_header_lead', $string );
583
	}
584
585 View Code Duplication
	function get_migrate_site_action_explanation() {
586
		$html = wp_kses(
587
			sprintf(
588
				__(
589
					'Yes. <a href="%1$s">%2$s</a> is replacing <a href="%3$s">%4$s</a>. I would like to
590
					migrate my stats and subscribers from <a href="%3$s">%4$s</a> to <a href="%1$s">%2$s</a>.',
591
					'jetpack'
592
				),
593
				esc_url( get_home_url() ),
594
				self::prepare_url_for_display( get_home_url() ),
595
				esc_url( self::$wpcom_home_url ),
596
				untrailingslashit( Jetpack::normalize_url_protocol_agnostic( esc_url_raw( self::$wpcom_home_url ) ) )
597
			),
598
			array( 'a' => array( 'href' => array() ) )
599
		);
600
601
		/**
602
		 * Allows overriding of the default text for explaining the migrate site action.
603
		 *
604
		 * @since 4.4.0
605
		 *
606
		 * @param string $html The HTML to be displayed
607
		 */
608
		return apply_filters( 'jetpack_idc_migrate_site_explanation', $html );
609
	}
610
611
	function get_migrate_site_button_text() {
612
		$string = esc_html__( 'Migrate Stats &amp; Subscribers', 'jetpack' );
613
614
		/**
615
		 * Allows overriding of the default text used for the migrate site action button.
616
		 *
617
		 * @since 4.4.0
618
		 *
619
		 * @param string $string The string to be displayed
620
		 */
621
		return apply_filters( 'jetpack_idc_migrate_site_button_text', $string );
622
	}
623
624 View Code Duplication
	function get_start_fresh_action_explanation() {
625
		$html = wp_kses(
626
			sprintf(
627
				__(
628
					'No. <a href="%1$s">%2$s</a> is a new and different website that\'s separate from
629
					<a href="%3$s">%4$s</a>. It requires  a new connection to WordPress.com for new stats and subscribers.',
630
					'jetpack'
631
				),
632
				esc_url( get_home_url() ),
633
				self::prepare_url_for_display( get_home_url() ),
634
				esc_url( self::$wpcom_home_url ),
635
				untrailingslashit( Jetpack::normalize_url_protocol_agnostic( esc_url_raw( self::$wpcom_home_url ) ) )
636
			),
637
			array( 'a' => array( 'href' => array() ) )
638
		);
639
640
		/**
641
		 * Allows overriding of the default text for explaining the start fresh action.
642
		 *
643
		 * @since 4.4.0
644
		 *
645
		 * @param string $html The HTML to be displayed
646
		 */
647
		return apply_filters( 'jetpack_idc_start_fresh_explanation', $html );
648
	}
649
650
	function get_start_fresh_button_text() {
651
		$string = esc_html__( 'Start Fresh &amp; Create New Connection', 'jetpack' );
652
653
		/**
654
		 * Allows overriding of the default text used for the start fresh action button.
655
		 *
656
		 * @since 4.4.0
657
		 *
658
		 * @param string $string The string to be displayed
659
		 */
660
		return apply_filters( 'jetpack_idc_start_fresh_button_text', $string );
661
	}
662
663 View Code Duplication
	function get_unsure_prompt() {
664
		$html = wp_kses(
665
			sprintf(
666
				__(
667
					'Unsure what to do? <a href="%1$s">Read more about Jetpack Safe Mode</a>',
668
					'jetpack'
669
				),
670
				esc_url( self::get_safe_mod_doc_url() )
671
			),
672
			array( 'a' => array( 'href' => array() ) )
673
		);
674
675
		/**
676
		 * Allows overriding of the default text using in the "Unsure what to do?" prompt.
677
		 *
678
		 * @since 4.4.0
679
		 *
680
		 * @param string $html The HTML to be displayed
681
		 */
682
		return apply_filters( 'jetpack_idc_unsure_prompt', $html );
683
	}
684
685 View Code Duplication
	function get_non_admin_notice_text() {
686
		$html = wp_kses(
687
			sprintf(
688
				__(
689
					'Jetpack has been placed into Safe Mode. Learn more about <a href="%1$s">Safe Mode</a>.',
690
					'jetpack'
691
				),
692
				esc_url( self::get_safe_mod_doc_url() )
693
			),
694
			array( 'a' => array( 'href' => array() ) )
695
		);
696
697
		/**
698
		 * Allows overriding of the default text that is displayed to non-admin on the Jetpack admin page.
699
		 *
700
		 * @since 4.4.0
701
		 *
702
		 * @param string $html The HTML to be displayed
703
		 */
704
		return apply_filters( 'jetpack_idc_non_admin_notice_text', $html );
705
	}
706
707
	function get_non_admin_contact_admin_text() {
708
		$string = esc_html__( 'An administrator of this site can take Jetpack out of Safe Mode.', 'jetpack' );
709
710
		/**
711
		 * Allows overriding of the default text that is displayed to non-admins prompting them to contact an admin.
712
		 *
713
		 * @since 4.4.0
714
		 *
715
		 * @param string $string The string to be displayed
716
		 */
717
		return apply_filters( 'jetpack_idc_non_admin_contact_admin_text', $string );
718
	}
719
}
720
721
add_action( 'plugins_loaded', array( 'Jetpack_IDC', 'init' ) );
722