These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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; |
||
0 ignored issues
–
show
|
|||
20 | |||
21 | /** |
||
22 | * Has safe mode been confirmed? |
||
23 | * @var bool |
||
24 | */ |
||
25 | static $is_safe_mode_confirmed; |
||
0 ignored issues
–
show
The visibility should be declared for property
$is_safe_mode_confirmed .
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using class A {
var $property;
}
the property is implicitly global. To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2. ![]() |
|||
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; |
||
0 ignored issues
–
show
The visibility should be declared for property
$current_screen .
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using class A {
var $property;
}
the property is implicitly global. To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2. ![]() |
|||
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 | plugins_url( '_inc/idc-notice.js', JETPACK__PLUGIN_FILE ), |
||
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 | wp_register_style( |
||
271 | 'jetpack-dops-style', |
||
272 | plugins_url( '_inc/build/admin.dops-style.css', JETPACK__PLUGIN_FILE ), |
||
273 | array(), |
||
274 | JETPACK__VERSION |
||
275 | ); |
||
276 | |||
277 | wp_enqueue_style( |
||
278 | 'jetpack-idc-css', |
||
279 | plugins_url( 'css/jetpack-idc.css', JETPACK__PLUGIN_FILE ), |
||
280 | array( 'jetpack-dops-style' ), |
||
281 | JETPACK__VERSION |
||
282 | ); |
||
283 | |||
284 | // Required for Tracks |
||
285 | wp_enqueue_script( |
||
286 | 'jp-tracks', |
||
287 | '//stats.wp.com/w.js', |
||
288 | array(), |
||
289 | gmdate( 'YW' ), |
||
290 | true |
||
291 | ); |
||
292 | |||
293 | wp_enqueue_script( |
||
294 | 'jp-tracks-functions', |
||
295 | plugins_url( '_inc/lib/tracks/tracks-callables.js', JETPACK__PLUGIN_FILE ), |
||
296 | array(), |
||
297 | JETPACK__VERSION, |
||
298 | false |
||
299 | ); |
||
300 | } |
||
301 | |||
302 | function render_notice_header() { ?> |
||
303 | <div class="jp-idc-notice__header"> |
||
304 | <div class="jp-idc-notice__header__emblem"> |
||
305 | <?php echo Jetpack::get_jp_emblem(); ?> |
||
306 | </div> |
||
307 | <p class="jp-idc-notice__header__text"> |
||
308 | <?php esc_html_e( 'Jetpack Safe Mode', 'jetpack' ); ?> |
||
309 | </p> |
||
310 | </div> |
||
311 | |||
312 | <div class="jp-idc-notice__separator"></div> |
||
313 | <?php } |
||
314 | |||
315 | /** |
||
316 | * Is a container for the error notices. |
||
317 | * Will be shown/controlled by jQuery in idc-notice.js |
||
318 | */ |
||
319 | function render_error_notice() { ?> |
||
320 | <div class="jp-idc-error__notice dops-notice is-error"> |
||
321 | <svg class="gridicon gridicons-notice dops-notice__icon" height="24" width="24" viewBox="0 0 24 24"> |
||
322 | <g> |
||
323 | <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> |
||
324 | </g> |
||
325 | </svg> |
||
326 | <div class="dops-notice__content"> |
||
327 | <span class="dops-notice__text"> |
||
328 | <?php esc_html_e( 'Something went wrong:', 'jetpack' ); ?> |
||
329 | <span class="jp-idc-error__desc"></span> |
||
330 | </span> |
||
331 | <a class="dops-notice__action" href="javascript:void(0);"> |
||
332 | <span id="jp-idc-error__action"> |
||
333 | <?php esc_html_e( 'Try Again', 'jetpack' ); ?> |
||
334 | </span> |
||
335 | </a> |
||
336 | </div> |
||
337 | </div> |
||
338 | <?php } |
||
339 | |||
340 | function render_notice_first_step() { ?> |
||
341 | <div class="jp-idc-notice__first-step"> |
||
342 | <div class="jp-idc-notice__content-header"> |
||
343 | <h3 class="jp-idc-notice__content-header__lead"> |
||
344 | <?php echo $this->get_first_step_header_lead(); ?> |
||
345 | </h3> |
||
346 | |||
347 | <p class="jp-idc-notice__content-header__explanation"> |
||
348 | <?php echo $this->get_first_step_header_explanation(); ?> |
||
349 | </p> |
||
350 | </div> |
||
351 | |||
352 | <?php $this->render_error_notice(); ?> |
||
353 | |||
354 | <div class="jp-idc-notice__actions"> |
||
355 | <div class="jp-idc-notice__action"> |
||
356 | <p class="jp-idc-notice__action__explanation"> |
||
357 | <?php echo $this->get_confirm_safe_mode_action_explanation(); ?> |
||
358 | </p> |
||
359 | <button id="jp-idc-confirm-safe-mode-action" class="dops-button"> |
||
360 | <?php echo $this->get_confirm_safe_mode_button_text(); ?> |
||
361 | </button> |
||
362 | </div> |
||
363 | |||
364 | <div class="jp-idc-notice__action"> |
||
365 | <p class="jp-idc-notice__action__explanation"> |
||
366 | <?php echo $this->get_first_step_fix_connection_action_explanation(); ?> |
||
367 | </p> |
||
368 | <button id="jp-idc-fix-connection-action" class="dops-button"> |
||
369 | <?php echo $this->get_first_step_fix_connection_button_text(); ?> |
||
370 | </button> |
||
371 | </div> |
||
372 | </div> |
||
373 | </div> |
||
374 | <?php } |
||
375 | |||
376 | function render_notice_second_step() { ?> |
||
377 | <div class="jp-idc-notice__second-step"> |
||
378 | <div class="jp-idc-notice__content-header"> |
||
379 | <h3 class="jp-idc-notice__content-header__lead"> |
||
380 | <?php echo $this->get_second_step_header_lead(); ?> |
||
381 | </h3> |
||
382 | </div> |
||
383 | |||
384 | <?php $this->render_error_notice(); ?> |
||
385 | |||
386 | <div class="jp-idc-notice__actions"> |
||
387 | <div class="jp-idc-notice__action"> |
||
388 | <p class="jp-idc-notice__action__explanation"> |
||
389 | <?php echo $this->get_migrate_site_action_explanation(); ?> |
||
390 | </p> |
||
391 | <button id="jp-idc-migrate-action" class="dops-button"> |
||
392 | <?php echo $this->get_migrate_site_button_text(); ?> |
||
393 | </button> |
||
394 | </div> |
||
395 | |||
396 | <div class="jp-idc-notice__action"> |
||
397 | <p class="jp-idc-notice__action__explanation"> |
||
398 | <?php echo $this->get_start_fresh_action_explanation(); ?> |
||
399 | </p> |
||
400 | <button id="jp-idc-reconnect-site-action" class="dops-button"> |
||
401 | <?php echo $this->get_start_fresh_button_text(); ?> |
||
402 | </button> |
||
403 | </div> |
||
404 | |||
405 | </div> |
||
406 | |||
407 | <p class="jp-idc-notice__unsure-prompt"> |
||
408 | <?php echo $this->get_unsure_prompt(); ?> |
||
409 | </p> |
||
410 | </div> |
||
411 | <?php } |
||
412 | |||
413 | View Code Duplication | function get_first_step_header_lead() { |
|
414 | $html = wp_kses( |
||
415 | sprintf( |
||
416 | __( |
||
417 | '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>.', |
||
418 | 'jetpack' |
||
419 | ), |
||
420 | esc_url( self::SAFE_MODE_DOC_LINK ), |
||
421 | esc_url( self::$wpcom_home_url ), |
||
422 | self::prepare_url_for_display( esc_url_raw( self::$wpcom_home_url ) ) |
||
423 | ), |
||
424 | array( 'a' => array( 'href' => array() ) ) |
||
425 | ); |
||
426 | |||
427 | /** |
||
428 | * Allows overriding of the default header text in the first step of the Safe Mode notice. |
||
429 | * |
||
430 | * @since 4.4.0 |
||
431 | * |
||
432 | * @param string $html The HTML to be displayed |
||
433 | */ |
||
434 | return apply_filters( 'jetpack_idc_first_step_header_lead', $html ); |
||
435 | } |
||
436 | |||
437 | View Code Duplication | function get_first_step_header_explanation() { |
|
438 | $html = wp_kses( |
||
439 | sprintf( |
||
440 | __( |
||
441 | 'Please confirm Safe Mode or fix the Jetpack connection. Select one of the options below or <a href="%1$s">learn |
||
442 | more about Safe Mode</a>.', |
||
443 | 'jetpack' |
||
444 | ), |
||
445 | esc_url( self::SAFE_MODE_DOC_LINK ) |
||
446 | ), |
||
447 | array( 'a' => array( 'href' => array() ) ) |
||
448 | ); |
||
449 | |||
450 | /** |
||
451 | * Allows overriding of the default header explanation text in the first step of the Safe Mode notice. |
||
452 | * |
||
453 | * @since 4.4.0 |
||
454 | * |
||
455 | * @param string $html The HTML to be displayed |
||
456 | */ |
||
457 | return apply_filters( 'jetpack_idc_first_step_header_explanation', $html ); |
||
458 | } |
||
459 | |||
460 | View Code Duplication | function get_confirm_safe_mode_action_explanation() { |
|
461 | $html = wp_kses( |
||
462 | sprintf( |
||
463 | __( |
||
464 | 'Is this website a temporary duplicate of <a href="%1$s">%2$s</a> for the purposes |
||
465 | of testing, staging or development? If so, we recommend keeping it in Safe Mode.', |
||
466 | 'jetpack' |
||
467 | ), |
||
468 | esc_url( untrailingslashit( self::$wpcom_home_url ) ), |
||
469 | self::prepare_url_for_display( esc_url( self::$wpcom_home_url ) ) |
||
470 | ), |
||
471 | array( 'a' => array( 'href' => array() ) ) |
||
472 | ); |
||
473 | |||
474 | /** |
||
475 | * Allows overriding of the default text used to explain the confirm safe mode action. |
||
476 | * |
||
477 | * @since 4.4.0 |
||
478 | * |
||
479 | * @param string $html The HTML to be displayed |
||
480 | */ |
||
481 | return apply_filters( 'jetpack_idc_confirm_safe_mode_explanation', $html ); |
||
482 | } |
||
483 | |||
484 | function get_confirm_safe_mode_button_text() { |
||
485 | $string = esc_html__( 'Confirm Safe Mode', 'jetpack' ); |
||
486 | |||
487 | /** |
||
488 | * Allows overriding of the default text used for the confirm safe mode action button. |
||
489 | * |
||
490 | * @since 4.4.0 |
||
491 | * |
||
492 | * @param string $string The string to be displayed |
||
493 | */ |
||
494 | return apply_filters( 'jetpack_idc_confirm_safe_mode_button_text', $string ); |
||
495 | } |
||
496 | |||
497 | View Code Duplication | function get_first_step_fix_connection_action_explanation() { |
|
498 | $html = wp_kses( |
||
499 | sprintf( |
||
500 | __( |
||
501 | 'If this is a separate and new website, or the new home of <a href="%1$s">%2$s</a>, |
||
502 | we recommend turning Safe Mode off, and re-establishing your connection to WordPress.com.', |
||
503 | 'jetpack' |
||
504 | ), |
||
505 | esc_url( untrailingslashit( self::$wpcom_home_url ) ), |
||
506 | self::prepare_url_for_display( esc_url( self::$wpcom_home_url ) ) |
||
507 | ), |
||
508 | array( 'a' => array( 'href' => array() ) ) |
||
509 | ); |
||
510 | |||
511 | /** |
||
512 | * Allows overriding of the default text used to explain the fix Jetpack connection action. |
||
513 | * |
||
514 | * @since 4.4.0 |
||
515 | * |
||
516 | * @param string $html The HTML to be displayed |
||
517 | */ |
||
518 | return apply_filters( 'jetpack_idc_first_fix_connection_explanation', $html ); |
||
519 | } |
||
520 | |||
521 | function get_first_step_fix_connection_button_text() { |
||
522 | $string = esc_html__( "Fix Jetpack's Connection", 'jetpack' ); |
||
523 | |||
524 | /** |
||
525 | * Allows overriding of the default text used for the fix Jetpack connection action button. |
||
526 | * |
||
527 | * @since 4.4.0 |
||
528 | * |
||
529 | * @param string $string The string to be displayed |
||
530 | */ |
||
531 | return apply_filters( 'jetpack_idc_first_step_fix_connection_button_text', $string ); |
||
532 | } |
||
533 | |||
534 | function get_second_step_header_lead() { |
||
535 | $string = sprintf( |
||
536 | esc_html__( |
||
537 | 'Is %1$s the new home of %2$s?', |
||
538 | 'jetpack' |
||
539 | ), |
||
540 | untrailingslashit( Jetpack::normalize_url_protocol_agnostic( get_home_url() ) ), |
||
541 | untrailingslashit( Jetpack::normalize_url_protocol_agnostic( esc_url_raw( self::$wpcom_home_url ) ) ) |
||
542 | ); |
||
543 | |||
544 | /** |
||
545 | * Allows overriding of the default header text in the second step of the Safe Mode notice. |
||
546 | * |
||
547 | * @since 4.4.0 |
||
548 | * |
||
549 | * @param string $html The HTML to be displayed |
||
550 | */ |
||
551 | return apply_filters( 'jetpack_idc_second_step_header_lead', $string ); |
||
552 | } |
||
553 | |||
554 | View Code Duplication | function get_migrate_site_action_explanation() { |
|
555 | $html = wp_kses( |
||
556 | sprintf( |
||
557 | __( |
||
558 | 'Yes. <a href="%1$s">%2$s</a> is replacing <a href="%3$s">%4$s</a>. I would like to |
||
559 | migrate my stats and subscribers from <a href="%3$s">%4$s</a> to <a href="%1$s">%2$s</a>.', |
||
560 | 'jetpack' |
||
561 | ), |
||
562 | esc_url( get_home_url() ), |
||
563 | self::prepare_url_for_display( get_home_url() ), |
||
564 | esc_url( self::$wpcom_home_url ), |
||
565 | untrailingslashit( Jetpack::normalize_url_protocol_agnostic( esc_url_raw( self::$wpcom_home_url ) ) ) |
||
566 | ), |
||
567 | array( 'a' => array( 'href' => array() ) ) |
||
568 | ); |
||
569 | |||
570 | /** |
||
571 | * Allows overriding of the default text for explaining the migrate site action. |
||
572 | * |
||
573 | * @since 4.4.0 |
||
574 | * |
||
575 | * @param string $html The HTML to be displayed |
||
576 | */ |
||
577 | return apply_filters( 'jetpack_idc_migrate_site_explanation', $html ); |
||
578 | } |
||
579 | |||
580 | function get_migrate_site_button_text() { |
||
581 | $string = esc_html__( 'Migrate stats & and Subscribers', 'jetpack' ); |
||
582 | |||
583 | /** |
||
584 | * Allows overriding of the default text used for the migrate site action button. |
||
585 | * |
||
586 | * @since 4.4.0 |
||
587 | * |
||
588 | * @param string $string The string to be displayed |
||
589 | */ |
||
590 | return apply_filters( 'jetpack_idc_migrate_site_button_text', $string ); |
||
591 | } |
||
592 | |||
593 | View Code Duplication | function get_start_fresh_action_explanation() { |
|
594 | $html = wp_kses( |
||
595 | sprintf( |
||
596 | __( |
||
597 | 'No. <a href="%1$s">%2$s</a> is a new and different website that\'s separate from |
||
598 | <a href="%3$s">%4$s</a>. It requires a new connection to WordPress.com for new stats and subscribers.', |
||
599 | 'jetpack' |
||
600 | ), |
||
601 | esc_url( get_home_url() ), |
||
602 | self::prepare_url_for_display( get_home_url() ), |
||
603 | esc_url( self::$wpcom_home_url ), |
||
604 | untrailingslashit( Jetpack::normalize_url_protocol_agnostic( esc_url_raw( self::$wpcom_home_url ) ) ) |
||
605 | ), |
||
606 | array( 'a' => array( 'href' => array() ) ) |
||
607 | ); |
||
608 | |||
609 | /** |
||
610 | * Allows overriding of the default text for explaining the start fresh action. |
||
611 | * |
||
612 | * @since 4.4.0 |
||
613 | * |
||
614 | * @param string $html The HTML to be displayed |
||
615 | */ |
||
616 | return apply_filters( 'jetpack_idc_start_fresh_explanation', $html ); |
||
617 | } |
||
618 | |||
619 | function get_start_fresh_button_text() { |
||
620 | $string = esc_html__( 'Start fresh & create new connection', 'jetpack' ); |
||
621 | |||
622 | /** |
||
623 | * Allows overriding of the default text used for the start fresh action button. |
||
624 | * |
||
625 | * @since 4.4.0 |
||
626 | * |
||
627 | * @param string $string The string to be displayed |
||
628 | */ |
||
629 | return apply_filters( 'jetpack_idc_start_fresh_button_text', $string ); |
||
630 | } |
||
631 | |||
632 | View Code Duplication | function get_unsure_prompt() { |
|
633 | $html = wp_kses( |
||
634 | sprintf( |
||
635 | __( |
||
636 | 'Unsure what to do? <a href="%1$s">Read more about Jetpack Safe Mode</a>', |
||
637 | 'jetpack' |
||
638 | ), |
||
639 | esc_url( self::SAFE_MODE_DOC_LINK ) |
||
640 | ), |
||
641 | array( 'a' => array( 'href' => array() ) ) |
||
642 | ); |
||
643 | |||
644 | /** |
||
645 | * Allows overriding of the default text using in the "Unsure what to do?" prompt. |
||
646 | * |
||
647 | * @since 4.4.0 |
||
648 | * |
||
649 | * @param string $html The HTML to be displayed |
||
650 | */ |
||
651 | return apply_filters( 'jetpack_idc_unsure_prompt', $html ); |
||
652 | } |
||
653 | |||
654 | View Code Duplication | function get_non_admin_notice_text() { |
|
655 | $html = wp_kses( |
||
656 | sprintf( |
||
657 | __( |
||
658 | 'Jetpack has been placed into Safe Mode. Learn more about <a href="%1$s">Safe Mode</a>.', |
||
659 | 'jetpack' |
||
660 | ), |
||
661 | esc_url( self::SAFE_MODE_DOC_LINK ) |
||
662 | ), |
||
663 | array( 'a' => array( 'href' => array() ) ) |
||
664 | ); |
||
665 | |||
666 | /** |
||
667 | * Allows overriding of the default text that is displayed to non-admin on the Jetpack admin page. |
||
668 | * |
||
669 | * @since 4.4.0 |
||
670 | * |
||
671 | * @param string $html The HTML to be displayed |
||
672 | */ |
||
673 | return apply_filters( 'jetpack_idc_non_admin_notice_text', $html ); |
||
674 | } |
||
675 | |||
676 | function get_non_admin_contact_admin_text() { |
||
677 | $string = esc_html__( 'An administrator of this site can take Jetpack out of Safe Mode.', 'jetpack' ); |
||
678 | |||
679 | /** |
||
680 | * Allows overriding of the default text that is displayed to non-admins prompting them to contact an admin. |
||
681 | * |
||
682 | * @since 4.4.0 |
||
683 | * |
||
684 | * @param string $string The string to be displayed |
||
685 | */ |
||
686 | return apply_filters( 'jetpack_idc_non_admin_contact_admin_text', $string ); |
||
687 | } |
||
688 | } |
||
689 | |||
690 | Jetpack_IDC::init(); |
||
691 |
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.