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