Jetpack_IDC

This class will handle everything involved with fixing an Identity Crisis.

Defined (1)

The class is defined in the following location(s).

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