class.jetpack-idc.php 20 KB

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