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
|
|
|
function display_non_admin_idc_notice() { |
162
|
|
|
$classes = 'jp-idc-notice is-non-admin notice notice-warning'; |
163
|
|
|
if ( isset( self::$current_screen ) && 'toplevel_page_jetpack' != self::$current_screen->id ) { |
164
|
|
|
$classes .= ' is-dismissible'; |
165
|
|
|
} |
166
|
|
|
?> |
167
|
|
|
|
168
|
|
|
<div class="<?php echo $classes; ?>"> |
169
|
|
|
<?php $this->render_notice_header(); ?> |
170
|
|
|
<div class="jp-idc-notice__content-header"> |
171
|
|
|
<h3 class="jp-idc-notice__content-header__lead"> |
172
|
|
|
<?php echo $this->get_non_admin_notice_text(); ?> |
173
|
|
|
</h3> |
174
|
|
|
|
175
|
|
|
<p class="jp-idc-notice__content-header__explanation"> |
176
|
|
|
<?php echo $this->get_non_admin_contact_admin_text(); ?> |
177
|
|
|
</p> |
178
|
|
|
</div> |
179
|
|
|
</div> |
180
|
|
|
<?php } |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* First "step" of the IDC mitigation. Will provide some messaging and two options/buttons. |
184
|
|
|
* "Confirm Staging" - Dismiss the notice and continue on with our lives in staging mode. |
185
|
|
|
* "Fix Jetpack Connection" - Will disconnect the site and start the mitigation... |
186
|
|
|
*/ |
187
|
|
|
function display_idc_notice() { ?> |
188
|
|
|
<div class="jp-idc-notice notice notice-warning"> |
189
|
|
|
<?php $this->render_notice_header(); ?> |
190
|
|
|
<?php $this->render_notice_first_step(); ?> |
191
|
|
|
<?php $this->render_notice_second_step(); ?> |
192
|
|
|
</div> |
193
|
|
|
<?php } |
194
|
|
|
|
195
|
|
|
function enqueue_admin_bar_css() { |
196
|
|
|
wp_enqueue_style( |
197
|
|
|
'jetpack-idc-admin-bar-css', |
198
|
|
|
plugins_url( 'css/jetpack-idc-admin-bar.css', JETPACK__PLUGIN_FILE ), |
199
|
|
|
array( 'dashicons' ), |
200
|
|
|
JETPACK__VERSION |
201
|
|
|
); |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* Enqueue scripts for the notice |
206
|
|
|
*/ |
207
|
|
|
function enqueue_idc_notice_files() { |
208
|
|
|
|
209
|
|
|
wp_enqueue_script( |
210
|
|
|
'jetpack-idc-js', |
211
|
|
|
plugins_url( '_inc/idc-notice.js', JETPACK__PLUGIN_FILE ), |
212
|
|
|
array( 'jquery' ), |
213
|
|
|
JETPACK__VERSION, |
214
|
|
|
true |
215
|
|
|
); |
216
|
|
|
|
217
|
|
|
wp_localize_script( |
218
|
|
|
'jetpack-idc-js', |
219
|
|
|
'idcL10n', |
220
|
|
|
array( |
221
|
|
|
'apiRoot' => esc_url_raw( rest_url() ), |
222
|
|
|
'nonce' => wp_create_nonce( 'wp_rest' ), |
223
|
|
|
'tracksUserData' => Jetpack_Tracks_Client::get_connected_user_tracks_identity(), |
224
|
|
|
'currentUrl' => remove_query_arg( '_wpnonce', remove_query_arg( 'jetpack_idc_clear_confirmation' ) ) |
225
|
|
|
) |
226
|
|
|
); |
227
|
|
|
|
228
|
|
|
wp_register_style( |
229
|
|
|
'jetpack-dops-style', |
230
|
|
|
plugins_url( '_inc/build/admin.dops-style.css', JETPACK__PLUGIN_FILE ), |
231
|
|
|
array(), |
232
|
|
|
JETPACK__VERSION |
233
|
|
|
); |
234
|
|
|
|
235
|
|
|
wp_enqueue_style( |
236
|
|
|
'jetpack-idc-css', |
237
|
|
|
plugins_url( 'css/jetpack-idc.css', JETPACK__PLUGIN_FILE ), |
238
|
|
|
array( 'jetpack-dops-style' ), |
239
|
|
|
JETPACK__VERSION |
240
|
|
|
); |
241
|
|
|
|
242
|
|
|
// Required for Tracks |
243
|
|
|
wp_enqueue_script( |
244
|
|
|
'jp-tracks', |
245
|
|
|
'//stats.wp.com/w.js', |
246
|
|
|
array(), |
247
|
|
|
gmdate( 'YW' ), |
248
|
|
|
true |
249
|
|
|
); |
250
|
|
|
|
251
|
|
|
wp_enqueue_script( |
252
|
|
|
'jp-tracks-functions', |
253
|
|
|
plugins_url( '_inc/lib/tracks/tracks-callables.js', JETPACK__PLUGIN_FILE ), |
254
|
|
|
array(), |
255
|
|
|
JETPACK__VERSION, |
256
|
|
|
false |
257
|
|
|
); |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
function render_notice_header() { ?> |
261
|
|
|
<div class="jp-idc-notice__header"> |
262
|
|
|
<div class="jp-idc-notice__header__emblem"> |
263
|
|
|
<?php echo Jetpack::get_jp_emblem(); ?> |
264
|
|
|
</div> |
265
|
|
|
<p class="jp-idc-notice__header__text"> |
266
|
|
|
<?php esc_html_e( 'Jetpack Safe Mode', 'jetpack' ); ?> |
267
|
|
|
</p> |
268
|
|
|
</div> |
269
|
|
|
|
270
|
|
|
<div class="jp-idc-notice__separator"></div> |
271
|
|
|
<?php } |
272
|
|
|
|
273
|
|
|
function render_notice_first_step() { ?> |
274
|
|
|
<div class="jp-idc-notice__first-step"> |
275
|
|
|
<div class="jp-idc-notice__content-header"> |
276
|
|
|
<h3 class="jp-idc-notice__content-header__lead"> |
277
|
|
|
<?php echo $this->get_first_step_header_lead(); ?> |
278
|
|
|
</h3> |
279
|
|
|
|
280
|
|
|
<p class="jp-idc-notice__content-header__explanation"> |
281
|
|
|
<?php echo $this->get_first_step_header_explanation(); ?> |
282
|
|
|
</p> |
283
|
|
|
</div> |
284
|
|
|
|
285
|
|
|
<div class="jp-idc-notice__actions"> |
286
|
|
|
<div class="jp-idc-notice__action"> |
287
|
|
|
<p class="jp-idc-notice__action__explanation"> |
288
|
|
|
<?php echo $this->get_confirm_safe_mode_action_explanation(); ?> |
289
|
|
|
</p> |
290
|
|
|
<button id="jp-idc-confirm-safe-mode-action" class="dops-button"> |
291
|
|
|
<?php echo $this->get_confirm_safe_mode_button_text(); ?> |
292
|
|
|
</button> |
293
|
|
|
</div> |
294
|
|
|
|
295
|
|
|
<div class="jp-idc-notice__action"> |
296
|
|
|
<p class="jp-idc-notice__action__explanation"> |
297
|
|
|
<?php echo $this->get_first_step_fix_connection_action_explanation(); ?> |
298
|
|
|
</p> |
299
|
|
|
<button id="jp-idc-fix-connection-action" class="dops-button"> |
300
|
|
|
<?php echo $this->get_first_step_fix_connection_button_text(); ?> |
301
|
|
|
</button> |
302
|
|
|
</div> |
303
|
|
|
</div> |
304
|
|
|
</div> |
305
|
|
|
<?php } |
306
|
|
|
|
307
|
|
|
function render_notice_second_step() { ?> |
308
|
|
|
<div class="jp-idc-notice__second-step"> |
309
|
|
|
<div class="jp-idc-notice__content-header"> |
310
|
|
|
<h3 class="jp-idc-notice__content-header__lead"> |
311
|
|
|
<?php echo $this->get_second_step_header_lead(); ?> |
312
|
|
|
</h3> |
313
|
|
|
</div> |
314
|
|
|
|
315
|
|
|
<div class="jp-idc-notice__actions"> |
316
|
|
|
<div class="jp-idc-notice__action"> |
317
|
|
|
<p class="jp-idc-notice__action__explanation"> |
318
|
|
|
<?php echo $this->get_migrate_site_action_explanation(); ?> |
319
|
|
|
</p> |
320
|
|
|
<button id="jp-idc-migrate-action" class="dops-button"> |
321
|
|
|
<?php echo $this->get_migrate_site_button_text(); ?> |
322
|
|
|
</button> |
323
|
|
|
</div> |
324
|
|
|
|
325
|
|
|
<div class="jp-idc-notice__action"> |
326
|
|
|
<p class="jp-idc-notice__action__explanation"> |
327
|
|
|
<?php echo $this->get_start_fresh_action_explanation(); ?> |
328
|
|
|
</p> |
329
|
|
|
<button id="jp-idc-reconnect-site-action" class="dops-button"> |
330
|
|
|
<?php echo $this->get_start_fresh_button_text(); ?> |
331
|
|
|
</button> |
332
|
|
|
</div> |
333
|
|
|
|
334
|
|
|
</div> |
335
|
|
|
|
336
|
|
|
<p class="jp-idc-notice__unsure-prompt"> |
337
|
|
|
<?php echo $this->get_unsure_prompt(); ?> |
338
|
|
|
</p> |
339
|
|
|
</div> |
340
|
|
|
<?php } |
341
|
|
|
|
342
|
|
View Code Duplication |
function get_first_step_header_lead() { |
343
|
|
|
$html = wp_kses( |
344
|
|
|
sprintf( |
345
|
|
|
__( |
346
|
|
|
'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>.', |
347
|
|
|
'jetpack' |
348
|
|
|
), |
349
|
|
|
esc_url( self::SAFE_MODE_DOC_LINK ), |
350
|
|
|
esc_url( self::$wpcom_home_url ), |
351
|
|
|
self::prepare_url_for_display( esc_url_raw( self::$wpcom_home_url ) ) |
352
|
|
|
), |
353
|
|
|
array( 'a' => array( 'href' => array() ) ) |
354
|
|
|
); |
355
|
|
|
|
356
|
|
|
/** |
357
|
|
|
* Allows overriding of the default header text in the first step of the Safe Mode notice. |
358
|
|
|
* |
359
|
|
|
* @since 4.4.0 |
360
|
|
|
* |
361
|
|
|
* @param string $html The HTML to be displayed |
362
|
|
|
*/ |
363
|
|
|
return apply_filters( 'jetpack_idc_first_step_header_lead', $html ); |
364
|
|
|
} |
365
|
|
|
|
366
|
|
View Code Duplication |
function get_first_step_header_explanation() { |
367
|
|
|
$html = wp_kses( |
368
|
|
|
sprintf( |
369
|
|
|
__( |
370
|
|
|
'Please confirm Safe Mode or fix the Jetpack connection. Select one of the options below or <a href="%1$s">learn |
371
|
|
|
more about Safe Mode</a>.', |
372
|
|
|
'jetpack' |
373
|
|
|
), |
374
|
|
|
esc_url( self::SAFE_MODE_DOC_LINK ) |
375
|
|
|
), |
376
|
|
|
array( 'a' => array( 'href' => array() ) ) |
377
|
|
|
); |
378
|
|
|
|
379
|
|
|
/** |
380
|
|
|
* Allows overriding of the default header explanation text in the first step of the Safe Mode notice. |
381
|
|
|
* |
382
|
|
|
* @since 4.4.0 |
383
|
|
|
* |
384
|
|
|
* @param string $html The HTML to be displayed |
385
|
|
|
*/ |
386
|
|
|
return apply_filters( 'jetpack_idc_first_step_header_explanation', $html ); |
387
|
|
|
} |
388
|
|
|
|
389
|
|
View Code Duplication |
function get_confirm_safe_mode_action_explanation() { |
390
|
|
|
$html = wp_kses( |
391
|
|
|
sprintf( |
392
|
|
|
__( |
393
|
|
|
'Is this website a temporary duplicate of <a href="%1$s">%2$s</a> for the purposes |
394
|
|
|
of testing, staging or development? If so, we recommend keeping it in Safe Mode.', |
395
|
|
|
'jetpack' |
396
|
|
|
), |
397
|
|
|
esc_url( untrailingslashit( self::$wpcom_home_url ) ), |
398
|
|
|
self::prepare_url_for_display( esc_url( self::$wpcom_home_url ) ) |
399
|
|
|
), |
400
|
|
|
array( 'a' => array( 'href' => array() ) ) |
401
|
|
|
); |
402
|
|
|
|
403
|
|
|
/** |
404
|
|
|
* Allows overriding of the default text used to explain the confirm safe mode action. |
405
|
|
|
* |
406
|
|
|
* @since 4.4.0 |
407
|
|
|
* |
408
|
|
|
* @param string $html The HTML to be displayed |
409
|
|
|
*/ |
410
|
|
|
return apply_filters( 'jetpack_idc_confirm_safe_mode_explanation', $html ); |
411
|
|
|
} |
412
|
|
|
|
413
|
|
|
function get_confirm_safe_mode_button_text() { |
414
|
|
|
$string = esc_html__( 'Confirm Safe Mode', 'jetpack' ); |
415
|
|
|
|
416
|
|
|
/** |
417
|
|
|
* Allows overriding of the default text used for the confirm safe mode action button. |
418
|
|
|
* |
419
|
|
|
* @since 4.4.0 |
420
|
|
|
* |
421
|
|
|
* @param string $string The string to be displayed |
422
|
|
|
*/ |
423
|
|
|
return apply_filters( 'jetpack_idc_confirm_safe_mode_button_text', $string ); |
424
|
|
|
} |
425
|
|
|
|
426
|
|
View Code Duplication |
function get_first_step_fix_connection_action_explanation() { |
427
|
|
|
$html = wp_kses( |
428
|
|
|
sprintf( |
429
|
|
|
__( |
430
|
|
|
'If this is a separate and new website, or the new home of <a href="%1$s">%2$s</a>, |
431
|
|
|
we recommend turning Safe Mode off, and re-establishing your connection to WordPress.com.', |
432
|
|
|
'jetpack' |
433
|
|
|
), |
434
|
|
|
esc_url( untrailingslashit( self::$wpcom_home_url ) ), |
435
|
|
|
self::prepare_url_for_display( esc_url( self::$wpcom_home_url ) ) |
436
|
|
|
), |
437
|
|
|
array( 'a' => array( 'href' => array() ) ) |
438
|
|
|
); |
439
|
|
|
|
440
|
|
|
/** |
441
|
|
|
* Allows overriding of the default text used to explain the fix Jetpack connection action. |
442
|
|
|
* |
443
|
|
|
* @since 4.4.0 |
444
|
|
|
* |
445
|
|
|
* @param string $html The HTML to be displayed |
446
|
|
|
*/ |
447
|
|
|
return apply_filters( 'jetpack_idc_first_fix_connection_explanation', $html ); |
448
|
|
|
} |
449
|
|
|
|
450
|
|
|
function get_first_step_fix_connection_button_text() { |
451
|
|
|
$string = esc_html__( "Fix Jetpack's Connection", 'jetpack' ); |
452
|
|
|
|
453
|
|
|
/** |
454
|
|
|
* Allows overriding of the default text used for the fix Jetpack connection action button. |
455
|
|
|
* |
456
|
|
|
* @since 4.4.0 |
457
|
|
|
* |
458
|
|
|
* @param string $string The string to be displayed |
459
|
|
|
*/ |
460
|
|
|
return apply_filters( 'jetpack_idc_first_step_fix_connection_button_text', $string ); |
461
|
|
|
} |
462
|
|
|
|
463
|
|
|
function get_second_step_header_lead() { |
464
|
|
|
$string = sprintf( |
465
|
|
|
esc_html__( |
466
|
|
|
'Is %1$s the new home of %2$s?', |
467
|
|
|
'jetpack' |
468
|
|
|
), |
469
|
|
|
untrailingslashit( Jetpack::normalize_url_protocol_agnostic( get_home_url() ) ), |
470
|
|
|
untrailingslashit( Jetpack::normalize_url_protocol_agnostic( esc_url_raw( self::$wpcom_home_url ) ) ) |
471
|
|
|
); |
472
|
|
|
|
473
|
|
|
/** |
474
|
|
|
* Allows overriding of the default header text in the second step of the Safe Mode notice. |
475
|
|
|
* |
476
|
|
|
* @since 4.4.0 |
477
|
|
|
* |
478
|
|
|
* @param string $html The HTML to be displayed |
479
|
|
|
*/ |
480
|
|
|
return apply_filters( 'jetpack_idc_second_step_header_lead', $string ); |
481
|
|
|
} |
482
|
|
|
|
483
|
|
View Code Duplication |
function get_migrate_site_action_explanation() { |
484
|
|
|
$html = wp_kses( |
485
|
|
|
sprintf( |
486
|
|
|
__( |
487
|
|
|
'Yes. <a href="%1$s">%2$s</a> is replacing <a href="%3$s">%4$s</a>. I would like to |
488
|
|
|
migrate my stats and subscribers from <a href="%3$s">%4$s</a> to <a href="%1$s">%2$s</a>.', |
489
|
|
|
'jetpack' |
490
|
|
|
), |
491
|
|
|
esc_url( get_home_url() ), |
492
|
|
|
self::prepare_url_for_display( get_home_url() ), |
493
|
|
|
esc_url( self::$wpcom_home_url ), |
494
|
|
|
untrailingslashit( Jetpack::normalize_url_protocol_agnostic( esc_url_raw( self::$wpcom_home_url ) ) ) |
495
|
|
|
), |
496
|
|
|
array( 'a' => array( 'href' => array() ) ) |
497
|
|
|
); |
498
|
|
|
|
499
|
|
|
/** |
500
|
|
|
* Allows overriding of the default text for explaining the migrate site action. |
501
|
|
|
* |
502
|
|
|
* @since 4.4.0 |
503
|
|
|
* |
504
|
|
|
* @param string $html The HTML to be displayed |
505
|
|
|
*/ |
506
|
|
|
return apply_filters( 'jetpack_idc_migrate_site_explanation', $html ); |
507
|
|
|
} |
508
|
|
|
|
509
|
|
|
function get_migrate_site_button_text() { |
510
|
|
|
$string = esc_html__( 'Migrate stats & and Subscribers', 'jetpack' ); |
511
|
|
|
|
512
|
|
|
/** |
513
|
|
|
* Allows overriding of the default text used for the migrate site action button. |
514
|
|
|
* |
515
|
|
|
* @since 4.4.0 |
516
|
|
|
* |
517
|
|
|
* @param string $string The string to be displayed |
518
|
|
|
*/ |
519
|
|
|
return apply_filters( 'jetpack_idc_migrate_site_button_text', $string ); |
520
|
|
|
} |
521
|
|
|
|
522
|
|
View Code Duplication |
function get_start_fresh_action_explanation() { |
523
|
|
|
$html = wp_kses( |
524
|
|
|
sprintf( |
525
|
|
|
__( |
526
|
|
|
'No. <a href="%1$s">%2$s</a> is a new and different website that\'s separate from |
527
|
|
|
<a href="%3$s">%4$s</a>. It requires a new connection to WordPress.com for new stats and subscribers.', |
528
|
|
|
'jetpack' |
529
|
|
|
), |
530
|
|
|
esc_url( get_home_url() ), |
531
|
|
|
self::prepare_url_for_display( get_home_url() ), |
532
|
|
|
esc_url( self::$wpcom_home_url ), |
533
|
|
|
untrailingslashit( Jetpack::normalize_url_protocol_agnostic( esc_url_raw( self::$wpcom_home_url ) ) ) |
534
|
|
|
), |
535
|
|
|
array( 'a' => array( 'href' => array() ) ) |
536
|
|
|
); |
537
|
|
|
|
538
|
|
|
/** |
539
|
|
|
* Allows overriding of the default text for explaining the start fresh action. |
540
|
|
|
* |
541
|
|
|
* @since 4.4.0 |
542
|
|
|
* |
543
|
|
|
* @param string $html The HTML to be displayed |
544
|
|
|
*/ |
545
|
|
|
return apply_filters( 'jetpack_idc_start_fresh_explanation', $html ); |
546
|
|
|
} |
547
|
|
|
|
548
|
|
|
function get_start_fresh_button_text() { |
549
|
|
|
$string = esc_html__( 'Start fresh & create new connection', 'jetpack' ); |
550
|
|
|
|
551
|
|
|
/** |
552
|
|
|
* Allows overriding of the default text used for the start fresh action button. |
553
|
|
|
* |
554
|
|
|
* @since 4.4.0 |
555
|
|
|
* |
556
|
|
|
* @param string $string The string to be displayed |
557
|
|
|
*/ |
558
|
|
|
return apply_filters( 'jetpack_idc_start_fresh_button_text', $string ); |
559
|
|
|
} |
560
|
|
|
|
561
|
|
View Code Duplication |
function get_unsure_prompt() { |
562
|
|
|
$html = wp_kses( |
563
|
|
|
sprintf( |
564
|
|
|
__( |
565
|
|
|
'Unsure what to do? <a href="%1$s">Read more about Jetpack Safe Mode</a>', |
566
|
|
|
'jetpack' |
567
|
|
|
), |
568
|
|
|
esc_url( self::SAFE_MODE_DOC_LINK ) |
569
|
|
|
), |
570
|
|
|
array( 'a' => array( 'href' => array() ) ) |
571
|
|
|
); |
572
|
|
|
|
573
|
|
|
/** |
574
|
|
|
* Allows overriding of the default text using in the "Unsure what to do?" prompt. |
575
|
|
|
* |
576
|
|
|
* @since 4.4.0 |
577
|
|
|
* |
578
|
|
|
* @param string $html The HTML to be displayed |
579
|
|
|
*/ |
580
|
|
|
return apply_filters( 'jetpack_idc_unsure_prompt', $html ); |
581
|
|
|
} |
582
|
|
|
|
583
|
|
View Code Duplication |
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
|
|
|
* |
598
|
|
|
* @since 4.4.0 |
599
|
|
|
* |
600
|
|
|
* @param string $html The HTML to be displayed |
601
|
|
|
*/ |
602
|
|
|
return apply_filters( 'jetpack_idc_non_admin_notice_text', $html ); |
603
|
|
|
} |
604
|
|
|
|
605
|
|
|
function get_non_admin_contact_admin_text() { |
606
|
|
|
$string = esc_html__( 'An administrator of this site can take Jetpack out of Safe Mode.', 'jetpack' ); |
607
|
|
|
|
608
|
|
|
/** |
609
|
|
|
* Allows overriding of the default text that is displayed to non-admins prompting them to contact an admin. |
610
|
|
|
* |
611
|
|
|
* @since 4.4.0 |
612
|
|
|
* |
613
|
|
|
* @param string $string The string to be displayed |
614
|
|
|
*/ |
615
|
|
|
return apply_filters( 'jetpack_idc_non_admin_contact_admin_text', $string ); |
616
|
|
|
} |
617
|
|
|
} |
618
|
|
|
|
619
|
|
|
Jetpack_IDC::init(); |
620
|
|
|
|
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.