1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Jetpack just in time messaging through out the admin |
5
|
|
|
* |
6
|
|
|
* @since 3.7.0 |
7
|
|
|
*/ |
8
|
|
|
class Jetpack_JITM { |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @var Jetpack_JITM |
12
|
|
|
**/ |
13
|
|
|
private static $instance = null; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Get user dismissed messages. |
17
|
|
|
* |
18
|
|
|
* @var array |
19
|
|
|
*/ |
20
|
|
|
private static $jetpack_hide_jitm = null; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Whether plugin auto updates are allowed in this WordPress installation or not. |
24
|
|
|
* |
25
|
|
|
* @var bool |
26
|
|
|
*/ |
27
|
|
|
private static $auto_updates_allowed = false; |
28
|
|
|
|
29
|
|
|
static function init() { |
30
|
|
|
if ( is_null( self::$instance ) ) { |
31
|
|
|
self::$instance = new Jetpack_JITM; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
return self::$instance; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
private function __construct() { |
38
|
|
|
if ( ! Jetpack::is_active() || self::is_jitm_dismissed() ) { |
39
|
|
|
return; |
40
|
|
|
} |
41
|
|
|
add_action( 'current_screen', array( $this, 'prepare_jitms' ) ); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
function get_emblem() |
45
|
|
|
{ |
46
|
|
|
return '<div class="jp-emblem">' . Jetpack::get_jp_emblem() . '</div>'; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Prepare actions according to screen and post type. |
51
|
|
|
* |
52
|
|
|
* @since 3.8.2 |
53
|
|
|
* |
54
|
|
|
* @uses Jetpack_Autoupdate::get_possible_failures() |
55
|
|
|
* |
56
|
|
|
* @param object $screen |
57
|
|
|
*/ |
58
|
|
|
function prepare_jitms( $screen ) { |
59
|
|
|
if ( ! current_user_can( 'jetpack_manage_modules' ) ) { |
60
|
|
|
return; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
if ( 'edit-comments' == $screen->base && ! Jetpack::is_plugin_active( 'akismet/akismet.php' ) ) { |
64
|
|
|
add_action( 'admin_enqueue_scripts', array( $this, 'jitm_enqueue_files' ) ); |
65
|
|
|
add_action( 'admin_notices', array( $this, 'akismet_msg' ) ); |
66
|
|
|
} |
67
|
|
|
elseif ( |
68
|
|
|
'post' == $screen->base |
69
|
|
|
&& ( isset( $_GET['message'] ) && 6 == $_GET['message'] ) |
70
|
|
|
&& ! Jetpack::is_plugin_active( 'vaultpress/vaultpress.php' ) |
71
|
|
|
) { |
72
|
|
|
add_action( 'admin_enqueue_scripts', array( $this, 'jitm_enqueue_files' ) ); |
73
|
|
|
add_action( 'edit_form_top', array( $this, 'backups_after_publish_msg' ) ); |
74
|
|
|
} |
75
|
|
|
elseif ( 'update-core' == $screen->base && ! Jetpack::is_plugin_active( 'vaultpress/vaultpress.php' ) ) { |
76
|
|
|
add_action( 'admin_enqueue_scripts', array( $this, 'jitm_enqueue_files' ) ); |
77
|
|
|
add_action( 'admin_notices', array( $this, 'backups_updates_msg' ) ); |
78
|
|
|
} |
79
|
|
|
elseif ( ! Jetpack::is_plugin_active( 'woocommerce-services/woocommerce-services.php' ) ) { |
80
|
|
|
$pages_to_display = array( |
81
|
|
|
'woocommerce_page_wc-settings', // WooCommerce > Settings |
82
|
|
|
'edit-shop_order', // WooCommerce > Orders |
83
|
|
|
'shop_order', // WooCommerce > Edit Order |
84
|
|
|
); |
85
|
|
|
|
86
|
|
|
if ( in_array( $screen->id, $pages_to_display ) ) { |
87
|
|
|
add_action( 'admin_enqueue_scripts', array( $this, 'jitm_enqueue_files' ) ); |
88
|
|
|
add_action( 'admin_notices', array( $this, 'woocommerce_services_msg' ) ); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/* |
94
|
|
|
* Present Manage just in time activation msg on update-core.php |
95
|
|
|
* |
96
|
|
|
*/ |
97
|
|
|
function manage_msg() { |
98
|
|
|
$normalized_site_url = Jetpack::build_raw_urls( get_home_url() ); |
99
|
|
|
?> |
100
|
|
|
<div class="jp-jitm"> |
101
|
|
|
<a href="#" data-module="manage" class="dismiss"><span class="genericon genericon-close"></span></a> |
102
|
|
|
|
103
|
|
|
<?php echo self::get_emblem(); ?> |
104
|
|
|
|
105
|
|
|
<p class="msg"> |
106
|
|
|
<?php esc_html_e( 'Reduce security risks with automated plugin updates.', 'jetpack' ); ?> |
107
|
|
|
</p> |
108
|
|
|
|
109
|
|
|
<p> |
110
|
|
|
<img class="j-spinner hide" src="<?php echo esc_url( includes_url( 'images/spinner-2x.gif' ) ); ?>" alt="<?php echo esc_attr__( 'Loading...', 'jetpack' ); ?>" /><a href="#" data-module="manage" class="activate button <?php if ( Jetpack::is_module_active( 'manage' ) ) { |
111
|
|
|
echo 'hide'; |
112
|
|
|
} ?>"><?php esc_html_e( 'Activate Now', 'jetpack' ); ?></a><a href="<?php echo esc_url( 'https://wordpress.com/plugins/' . $normalized_site_url ); ?>" target="_blank" title="<?php esc_attr_e( 'Go to WordPress.com to try these features', 'jetpack' ); ?>" id="jetpack-wordpressdotcom" class="button button-jetpack <?php if ( ! Jetpack::is_module_active( 'manage' ) ) { |
113
|
|
|
echo 'hide'; |
114
|
|
|
} ?>"><?php esc_html_e( 'Go to WordPress.com', 'jetpack' ); ?></a> |
115
|
|
|
</p> |
116
|
|
|
</div> |
117
|
|
|
<?php |
118
|
|
|
//jitm is being viewed, track it |
119
|
|
|
$jetpack = Jetpack::init(); |
120
|
|
|
$jetpack->stat( 'jitm', 'manage-viewed-' . JETPACK__VERSION ); |
121
|
|
|
$jetpack->do_stats( 'server_side' ); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/* |
125
|
|
|
* Present Photon just in time activation msg |
126
|
|
|
* |
127
|
|
|
*/ |
128
|
|
|
function photon_msg() { |
129
|
|
|
?> |
130
|
|
|
<div class="jp-jitm"> |
131
|
|
|
<a href="#" data-module="photon" class="dismiss"><span class="genericon genericon-close"></span></a> |
132
|
|
|
|
133
|
|
|
<?php echo self::get_emblem(); ?> |
134
|
|
|
|
135
|
|
|
<p class="msg"> |
136
|
|
|
<?php esc_html_e( 'Speed up your photos and save bandwidth costs by using a free content delivery network.', 'jetpack' ); ?> |
137
|
|
|
</p> |
138
|
|
|
|
139
|
|
|
<p> |
140
|
|
|
<img class="j-spinner hide" style="margin-top: 13px;" width="17" height="17" src="<?php echo esc_url( includes_url( 'images/spinner-2x.gif' ) ); ?>" alt="<?php echo esc_attr__( 'Loading...', 'jetpack' ); ?>" /><a href="#" data-module="photon" class="activate button button-jetpack"><?php esc_html_e( 'Activate Photon', 'jetpack' ); ?></a> |
141
|
|
|
</p> |
142
|
|
|
</div> |
143
|
|
|
<?php |
144
|
|
|
//jitm is being viewed, track it |
145
|
|
|
$jetpack = Jetpack::init(); |
146
|
|
|
$jetpack->stat( 'jitm', 'photon-viewed-' . JETPACK__VERSION ); |
147
|
|
|
$jetpack->do_stats( 'server_side' ); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* Display Photon JITM template in Media Library after user uploads an image. |
152
|
|
|
* |
153
|
|
|
* @since 3.9.0 |
154
|
|
|
*/ |
155
|
|
|
function photon_tmpl() { |
156
|
|
|
?> |
157
|
|
|
<script id="tmpl-jitm-photon" type="text/html"> |
158
|
|
|
<div class="jp-jitm" data-track="photon-modal"> |
159
|
|
|
<a href="#" data-module="photon" class="dismiss"><span class="genericon genericon-close"></span></a> |
160
|
|
|
|
161
|
|
|
<?php echo self::get_emblem(); ?> |
162
|
|
|
|
163
|
|
|
<p class="msg"> |
164
|
|
|
<?php esc_html_e( 'Let Jetpack deliver your images optimized and faster than ever.', 'jetpack' ); ?> |
165
|
|
|
</p> |
166
|
|
|
|
167
|
|
|
<p> |
168
|
|
|
<img class="j-spinner hide" style="margin-top: 13px;" width="17" height="17" src="<?php echo esc_url( includes_url( 'images/spinner-2x.gif' ) ); ?>" alt="<?php echo esc_attr__( 'Loading...', 'jetpack' ); ?>" /><a href="#" data-module="photon" class="activate button button-jetpack"><?php esc_html_e( 'Activate Photon', 'jetpack' ); ?></a> |
169
|
|
|
</p> |
170
|
|
|
</div> |
171
|
|
|
</script> |
172
|
|
|
<?php |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* Display message prompting user to enable auto-updates in WordPress.com. |
177
|
|
|
* |
178
|
|
|
* @since 3.8.2 |
179
|
|
|
*/ |
180
|
|
|
function manage_pi_msg() { |
181
|
|
|
$normalized_site_url = Jetpack::build_raw_urls( get_home_url() ); |
182
|
|
|
$manage_active = Jetpack::is_module_active( 'manage' ); |
183
|
|
|
|
184
|
|
|
// Check if plugin has auto update already enabled in WordPress.com and don't show JITM in such case. |
185
|
|
|
$active_before = get_option( 'jetpack_temp_active_plugins_before', array() ); |
186
|
|
|
delete_option( 'jetpack_temp_active_plugins_before' ); |
187
|
|
|
$active_now = get_option( 'active_plugins', array() ); |
188
|
|
|
$activated = array_diff( $active_now, $active_before ); |
189
|
|
|
$auto_update_plugin_list = Jetpack_Options::get_option( 'autoupdate_plugins', array() ); |
190
|
|
|
$plugin_auto_update_disabled = false; |
191
|
|
|
foreach ( $activated as $plugin ) { |
192
|
|
|
if ( ! in_array( $plugin, $auto_update_plugin_list ) ) { |
193
|
|
|
|
194
|
|
|
// Plugin doesn't have auto updates enabled in WordPress.com yet. |
195
|
|
|
$plugin_auto_update_disabled = true; |
196
|
|
|
|
197
|
|
|
// We don't need to continue checking, it's ok to show JITM for this plugin. |
198
|
|
|
break; |
199
|
|
|
} |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
// Check if the activated plugin is in the WordPress.org repository |
203
|
|
|
$plugin_can_auto_update = false; |
204
|
|
|
$plugin_updates = get_site_transient( 'update_plugins' ); |
205
|
|
|
if ( false === $plugin_updates ) { |
206
|
|
|
|
207
|
|
|
// If update_plugins doesn't exist, display message anyway |
208
|
|
|
$plugin_can_auto_update = true; |
209
|
|
|
} else { |
210
|
|
|
$plugin_updates = array_merge( $plugin_updates->response, $plugin_updates->no_update ); |
211
|
|
|
foreach ( $activated as $plugin ) { |
212
|
|
|
if ( isset( $plugin_updates[ $plugin ] ) ) { |
213
|
|
|
|
214
|
|
|
// There's at least one plugin set cleared for auto updates |
215
|
|
|
$plugin_can_auto_update = true; |
216
|
|
|
|
217
|
|
|
// We don't need to continue checking, it's ok to show JITM for this round. |
218
|
|
|
break; |
219
|
|
|
} |
220
|
|
|
} |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
if ( ! $manage_active && $plugin_auto_update_disabled && $plugin_can_auto_update && self::$auto_updates_allowed ) : |
224
|
|
|
?> |
225
|
|
|
<div class="jp-jitm"> |
226
|
|
|
<a href="#" data-module="manage-pi" class="dismiss"><span class="genericon genericon-close"></span></a> |
227
|
|
|
|
228
|
|
|
<?php echo self::get_emblem(); ?> |
229
|
|
|
|
230
|
|
|
<?php if ( ! $manage_active ) : ?> |
231
|
|
|
<p class="msg"> |
232
|
|
|
<?php esc_html_e( 'Save time with automated plugin updates.', 'jetpack' ); ?> |
233
|
|
|
</p> |
234
|
|
|
<p> |
235
|
|
|
<img class="j-spinner hide" src="<?php echo esc_url( includes_url( 'images/spinner-2x.gif' ) ); ?>" alt="<?php echo esc_attr__( 'Loading...', 'jetpack' ); ?>" /><a href="#" data-module="manage" data-module-success="<?php esc_attr_e( 'Success!', 'jetpack' ); ?>" class="activate button"><?php esc_html_e( 'Activate remote management', 'jetpack' ); ?></a> |
236
|
|
|
</p> |
237
|
|
|
<?php elseif ( $manage_active ) : ?> |
238
|
|
|
<p> |
239
|
|
|
<?php esc_html_e( 'Save time with auto updates on WordPress.com', 'jetpack' ); ?> |
240
|
|
|
</p> |
241
|
|
|
<?php endif; // manage inactive |
242
|
|
|
?> |
243
|
|
|
<p class="show-after-enable <?php echo $manage_active ? '' : 'hide'; ?>"> |
244
|
|
|
<a href="<?php echo esc_url( 'https://wordpress.com/plugins/' . $normalized_site_url ); ?>" target="_blank" title="<?php esc_attr_e( 'Go to WordPress.com to enable auto-updates for plugins', 'jetpack' ); ?>" data-module="manage-pi" class="button button-jetpack launch show-after-enable"><?php if ( ! $manage_active ) : ?><?php esc_html_e( 'Enable auto-updates on WordPress.com', 'jetpack' ); ?><?php elseif ( $manage_active ) : ?><?php esc_html_e( 'Enable auto-updates', 'jetpack' ); ?><?php endif; // manage inactive ?></a> |
245
|
|
|
</p> |
246
|
|
|
</div> |
247
|
|
|
<?php |
248
|
|
|
//jitm is being viewed, track it |
249
|
|
|
$jetpack = Jetpack::init(); |
250
|
|
|
$jetpack->stat( 'jitm', 'manage-pi-viewed-' . JETPACK__VERSION ); |
251
|
|
|
$jetpack->do_stats( 'server_side' ); |
252
|
|
|
endif; // manage inactive |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* Display message in editor prompting user to compose entry in WordPress.com. |
257
|
|
|
* |
258
|
|
|
* @since 3.8.2 |
259
|
|
|
*/ |
260
|
|
|
function editor_msg() { |
261
|
|
|
global $typenow; |
262
|
|
|
if ( current_user_can( 'manage_options' ) ) { |
263
|
|
|
$normalized_site_url = Jetpack::build_raw_urls( get_home_url() ); |
264
|
|
|
$editor_dismissed = isset( self::$jetpack_hide_jitm['editor'] ); |
265
|
|
|
if ( ! $editor_dismissed ) : |
266
|
|
|
?> |
267
|
|
|
<div class="jp-jitm"> |
268
|
|
|
<a href="#" data-module="editor" class="dismiss"><span class="genericon genericon-close"></span></a> |
269
|
|
|
<?php echo self::get_emblem(); ?> |
270
|
|
|
<p class="msg"> |
271
|
|
|
<?php esc_html_e( 'Try the brand new editor.', 'jetpack' ); ?> |
272
|
|
|
</p> |
273
|
|
|
<p> |
274
|
|
|
<a href="<?php echo esc_url( 'https://wordpress.com/' . $typenow . '/' . $normalized_site_url ); ?>" target="_blank" title="<?php esc_attr_e( 'Write on WordPress.com', 'jetpack' ); ?>" data-module="editor" class="button button-jetpack launch show-after-enable"><?php esc_html_e( 'Write on WordPress.com', 'jetpack' ); ?></a> |
275
|
|
|
</p> |
276
|
|
|
</div> |
277
|
|
|
<?php |
278
|
|
|
//jitm is being viewed, track it |
279
|
|
|
$jetpack = Jetpack::init(); |
280
|
|
|
$jetpack->stat( 'jitm', 'editor-viewed-' . JETPACK__VERSION ); |
281
|
|
|
$jetpack->do_stats( 'server_side' ); |
282
|
|
|
endif; // manage or editor inactive |
283
|
|
|
} |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
/** |
287
|
|
|
* Display message in editor prompting user to enable stats. |
288
|
|
|
* |
289
|
|
|
* @since 3.9.0 |
290
|
|
|
*/ |
291
|
|
|
function stats_msg() { |
292
|
|
|
$stats_active = Jetpack::is_module_active( 'stats' ); |
293
|
|
|
$normalized_site_url = Jetpack::build_raw_urls( get_home_url() ); |
294
|
|
|
?> |
295
|
|
|
<div class="jp-jitm"> |
296
|
|
|
<a href="#" data-module="stats" class="dismiss"><span class="genericon genericon-close"></span></a> |
297
|
|
|
<?php echo self::get_emblem(); ?> |
298
|
|
|
<p class="msg"> |
299
|
|
|
<?php esc_html_e( 'Track detailed stats on this post and the rest of your site.', 'jetpack' ); ?> |
300
|
|
|
</p> |
301
|
|
|
<?php if ( ! $stats_active ) : ?> |
302
|
|
|
<p> |
303
|
|
|
<img class="j-spinner hide" src="<?php echo esc_url( includes_url( 'images/spinner-2x.gif' ) ); ?>" alt="<?php echo esc_attr__( 'Loading...', 'jetpack' ); ?>" /><a href="#" data-module="stats" data-module-success="<?php esc_attr_e( 'Success! Jetpack Stats is now activated.', 'jetpack' ); ?>" class="activate button"><?php esc_html_e( 'Enable Jetpack Stats', 'jetpack' ); ?></a> |
304
|
|
|
</p> |
305
|
|
|
<?php endif; // stats inactive |
306
|
|
|
?> |
307
|
|
|
<p class="show-after-enable <?php echo $stats_active ? '' : 'hide'; ?>"> |
308
|
|
|
<a href="<?php echo esc_url( 'https://wordpress.com/stats/insights/' . $normalized_site_url ); ?>" target="_blank" title="<?php esc_attr_e( 'Go to WordPress.com', 'jetpack' ); ?>" data-module="stats" class="button button-jetpack launch show-after-enable"><?php esc_html_e( 'Go to WordPress.com', 'jetpack' ); ?></a> |
309
|
|
|
</p> |
310
|
|
|
</div> |
311
|
|
|
<?php |
312
|
|
|
//jitm is being viewed, track it |
313
|
|
|
$jetpack = Jetpack::init(); |
314
|
|
|
$jetpack->stat( 'jitm', 'post-stats-viewed-' . JETPACK__VERSION ); |
315
|
|
|
$jetpack->do_stats( 'server_side' ); |
316
|
|
|
} |
317
|
|
|
|
318
|
|
|
/** |
319
|
|
|
* Display JITM in Updates screen prompting user to enable Backups. |
320
|
|
|
* |
321
|
|
|
* @since 3.9.5 |
322
|
|
|
*/ |
323
|
|
View Code Duplication |
function backups_updates_msg() { |
324
|
|
|
$normalized_site_url = Jetpack::build_raw_urls( get_home_url() ); |
325
|
|
|
$url = 'https://jetpack.com/redirect/?source=jitm-backup-updates&site=' . $normalized_site_url; |
326
|
|
|
$jitm_stats_url = Jetpack::build_stats_url( array( 'x_jetpack-jitm' => 'vaultpress' ) ); |
327
|
|
|
?> |
328
|
|
|
<div class="jp-jitm" data-track="vaultpress-updates" data-stats_url="<?php echo esc_url( $jitm_stats_url ); ?>"> |
329
|
|
|
<a href="#" data-module="vaultpress" class="dismiss"><span class="genericon genericon-close"></span></a> |
330
|
|
|
<?php echo self::get_emblem(); ?> |
331
|
|
|
<p class="msg"> |
332
|
|
|
<?php esc_html_e( 'Backups are recommended to protect your site before you make any changes.', 'jetpack' ); ?> |
333
|
|
|
</p> |
334
|
|
|
<p> |
335
|
|
|
<a href="<?php echo esc_url( $url ); ?>" target="_blank" title="<?php esc_attr_e( 'Enable VaultPress Backups', 'jetpack' ); ?>" data-module="vaultpress" data-jptracks-name="nudge_click" data-jptracks-prop="jitm-vault" class="button button-jetpack launch jptracks"><?php esc_html_e( 'Enable VaultPress Backups', 'jetpack' ); ?></a> |
336
|
|
|
</p> |
337
|
|
|
</div> |
338
|
|
|
<?php |
339
|
|
|
//jitm is being viewed, track it |
340
|
|
|
$jetpack = Jetpack::init(); |
341
|
|
|
$jetpack->stat( 'jitm', 'vaultpress-updates-viewed-' . JETPACK__VERSION ); |
342
|
|
|
$jetpack->do_stats( 'server_side' ); |
343
|
|
|
} |
344
|
|
|
|
345
|
|
|
/** |
346
|
|
|
* Display JITM in Comments screen prompting user to enable Akismet. |
347
|
|
|
* |
348
|
|
|
* @since 3.9.5 |
349
|
|
|
*/ |
350
|
|
View Code Duplication |
function akismet_msg() { |
351
|
|
|
$normalized_site_url = Jetpack::build_raw_urls( get_home_url() ); |
352
|
|
|
$url = 'https://jetpack.com/redirect/?source=jitm-akismet&site=' . $normalized_site_url; |
353
|
|
|
$jitm_stats_url = Jetpack::build_stats_url( array( 'x_jetpack-jitm' => 'akismet' ) ); |
354
|
|
|
?> |
355
|
|
|
<div class="jp-jitm" data-stats_url="<?php echo esc_url( $jitm_stats_url ); ?>"> |
356
|
|
|
<a href="#" data-module="akismet" class="dismiss"><span class="genericon genericon-close"></span></a> |
357
|
|
|
<?php echo self::get_emblem(); ?> |
358
|
|
|
<p class="msg"> |
359
|
|
|
<?php esc_html_e( "Spam affects your site's legitimacy, protect your site with Akismet.", 'jetpack' ); ?> |
360
|
|
|
</p> |
361
|
|
|
<p> |
362
|
|
|
<a href="<?php echo esc_url( $url ); ?>" target="_blank" title="<?php esc_attr_e( 'Automate Spam Blocking', 'jetpack' ); ?>" data-module="akismet" data-jptracks-name="nudge_click" data-jptracks-prop="jitm-akismet" class="button button-jetpack launch jptracks"><?php esc_html_e( 'Automate Spam Blocking', 'jetpack' ); ?></a> |
363
|
|
|
</p> |
364
|
|
|
</div> |
365
|
|
|
<?php |
366
|
|
|
//jitm is being viewed, track it |
367
|
|
|
$jetpack = Jetpack::init(); |
368
|
|
|
$jetpack->stat( 'jitm', 'akismet-viewed-' . JETPACK__VERSION ); |
369
|
|
|
$jetpack->do_stats( 'server_side' ); |
370
|
|
|
} |
371
|
|
|
|
372
|
|
|
/** |
373
|
|
|
* Display JITM after a post is published prompting user to enable Backups. |
374
|
|
|
* |
375
|
|
|
* @since 3.9.5 |
376
|
|
|
*/ |
377
|
|
View Code Duplication |
function backups_after_publish_msg() { |
378
|
|
|
$normalized_site_url = Jetpack::build_raw_urls( get_home_url() ); |
379
|
|
|
$url = 'https://jetpack.com/redirect/?source=jitm-backup-publish&site=' . $normalized_site_url; |
380
|
|
|
$jitm_stats_url = Jetpack::build_stats_url( array( 'x_jetpack-jitm' => 'vaultpress' ) ); |
381
|
|
|
?> |
382
|
|
|
<div class="jp-jitm" data-track="vaultpress-publish" data-stats_url="<?php echo esc_url( $jitm_stats_url ); ?>"> |
383
|
|
|
<a href="#" data-module="vaultpress" class="dismiss"><span class="genericon genericon-close"></span></a> |
384
|
|
|
|
385
|
|
|
<?php echo self::get_emblem(); ?> |
386
|
|
|
|
387
|
|
|
<p class="msg"> |
388
|
|
|
<?php esc_html_e( "Great job! Now let's make sure your hard work is never lost, backup everything with VaultPress.", 'jetpack' ); ?> |
389
|
|
|
</p> |
390
|
|
|
<p> |
391
|
|
|
<a href="<?php echo esc_url( $url ); ?>" target="_blank" title="<?php esc_attr_e( 'Enable Backups', 'jetpack' ); ?>" data-module="vaultpress" data-jptracks-name="nudge_click" data-jptracks-prop="jitm-vault-post" class="button button-jetpack launch jptracks"><?php esc_html_e( 'Enable Backups', 'jetpack' ); ?></a> |
392
|
|
|
</p> |
393
|
|
|
</div> |
394
|
|
|
<?php |
395
|
|
|
//jitm is being viewed, track it |
396
|
|
|
$jetpack = Jetpack::init(); |
397
|
|
|
$jetpack->stat( 'jitm', 'vaultpress-publish-viewed-' . JETPACK__VERSION ); |
398
|
|
|
$jetpack->do_stats( 'server_side' ); |
399
|
|
|
} |
400
|
|
|
|
401
|
|
|
/** |
402
|
|
|
* Display a JITM style message for the media-new page. |
403
|
|
|
* |
404
|
|
|
* @since 4.5 |
405
|
|
|
*/ |
406
|
|
|
function videopress_media_upload_warning_msg() { |
407
|
|
|
$jitm_stats_url = Jetpack::build_stats_url( array( 'x_jetpack-jitm' => 'videopress' ) ); |
408
|
|
|
|
409
|
|
|
$upload_url = add_query_arg( 'mode', 'grid', admin_url( 'upload.php' ) ); |
410
|
|
|
$new_post_url = admin_url( 'post-new.php' ); |
411
|
|
|
|
412
|
|
|
$msg = sprintf( __( 'Only videos uploaded from within the <a href="%s">media library</a> or while creating a <a href="%s">new post</a> will be fully hosted by WordPress.com.', 'jetpack' ), esc_url( $upload_url ), esc_url( $new_post_url ) ); |
413
|
|
|
?> |
414
|
|
|
<div class="jp-jitm" data-track="videopress-upload-warning" data-stats_url="<?php echo esc_url( $jitm_stats_url ); ?>"> |
415
|
|
|
<!-- <a href="#" data-module="videopress" class="dismiss"><span class="genericon genericon-close"></span></a>--> |
416
|
|
|
|
417
|
|
|
<?php echo self::get_emblem(); ?> |
418
|
|
|
|
419
|
|
|
<p class="msg"> |
420
|
|
|
<?php echo $msg; ?> |
421
|
|
|
</p> |
422
|
|
|
<p> |
423
|
|
|
<a href="<?php echo esc_url( $upload_url ); ?>" title="<?php esc_attr_e( 'Upload a Video', 'jetpack' ); ?>" data-module="videopress" data-jptracks-name="nudge_click" data-jptracks-prop="jitm-videopress-upload" class="button button-jetpack launch jptracks"><?php esc_html_e( 'Upload a Video Now', 'jetpack' ); ?></a> |
424
|
|
|
</p> |
425
|
|
|
</div> |
426
|
|
|
<?php |
427
|
|
|
} |
428
|
|
|
|
429
|
|
|
/** |
430
|
|
|
* Display message prompting user to install WooCommerce Services. |
431
|
|
|
* |
432
|
|
|
* @since 4.6 |
433
|
|
|
*/ |
434
|
|
|
function woocommerce_services_msg() { |
435
|
|
|
if ( ! current_user_can( 'manage_woocommerce' ) || ! current_user_can( 'install_plugins' ) ) { |
436
|
|
|
return; |
437
|
|
|
} |
438
|
|
|
|
439
|
|
|
if ( isset( self::$jetpack_hide_jitm['woocommerce_services'] ) ) { |
440
|
|
|
return; |
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
if ( ! function_exists( 'wc_get_base_location' ) ) { |
444
|
|
|
return; |
445
|
|
|
} |
446
|
|
|
|
447
|
|
|
$base_location = wc_get_base_location(); |
448
|
|
|
|
449
|
|
|
switch ( $base_location['country'] ) { |
450
|
|
|
case 'US': |
451
|
|
|
$message = __( 'Try our new service for USPS shipping & label-printing.', 'jetpack' ); |
452
|
|
|
break; |
453
|
|
|
case 'CA': |
454
|
|
|
$message = __( 'Try our new Canada Post shipping service.', 'jetpack' ); |
455
|
|
|
break; |
456
|
|
|
default: |
457
|
|
|
return; |
458
|
|
|
} |
459
|
|
|
|
460
|
|
|
$install_url = wp_nonce_url( add_query_arg( array( 'wc-services-action' => 'install' ) ), 'wc-services-install' ); |
461
|
|
|
|
462
|
|
|
?> |
463
|
|
|
<div class="jp-jitm woo-jitm"> |
464
|
|
|
<a href="#" data-module="woocommerce_services" class="dismiss"><span class="genericon genericon-close"></span></a> |
465
|
|
|
<div class="jp-emblem"> |
466
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0" y="0" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve"> |
467
|
|
|
<path d="M18,8h-2V7c0-1.105-0.895-2-2-2H4C2.895,5,2,5.895,2,7v10h2c0,1.657,1.343,3,3,3s3-1.343,3-3h4c0,1.657,1.343,3,3,3s3-1.343,3-3h2v-5L18,8z M7,18.5c-0.828,0-1.5-0.672-1.5-1.5s0.672-1.5,1.5-1.5s1.5,0.672,1.5,1.5S7.828,18.5,7,18.5z M4,14V7h10v7H4z M17,18.5c-0.828,0-1.5-0.672-1.5-1.5s0.672-1.5,1.5-1.5s1.5,0.672,1.5,1.5S17.828,18.5,17,18.5z" /> |
468
|
|
|
</svg> |
469
|
|
|
</div> |
470
|
|
|
<p class="msg"> |
471
|
|
|
<?php echo esc_html( $message ); ?> |
472
|
|
|
</p> |
473
|
|
|
<p> |
474
|
|
|
<a href="<?php echo esc_url( $install_url ); ?>" title="<?php esc_attr_e( 'Install WooCommerce Services', 'jetpack' ); ?>" data-module="woocommerce_services" class="button button-jetpack launch show-after-enable"><?php esc_html_e( 'Install WooCommerce Services', 'jetpack' ); ?></a> |
475
|
|
|
</p> |
476
|
|
|
</div> |
477
|
|
|
<?php |
478
|
|
|
//jitm is being viewed, track it |
479
|
|
|
$jetpack = Jetpack::init(); |
480
|
|
|
$jetpack->stat( 'jitm', 'woocommerce_services-viewed-' . JETPACK__VERSION ); |
481
|
|
|
} |
482
|
|
|
|
483
|
|
|
/* |
484
|
|
|
* Function to enqueue jitm css and js |
485
|
|
|
*/ |
486
|
|
|
function jitm_enqueue_files( $hook ) { |
|
|
|
|
487
|
|
|
|
488
|
|
|
$wp_styles = new WP_Styles(); |
489
|
|
|
$min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
490
|
|
|
wp_enqueue_style( 'jetpack-jitm-css', plugins_url( "css/jetpack-admin-jitm{$min}.css", JETPACK__PLUGIN_FILE ), false, JETPACK__VERSION . '-201243242' ); |
491
|
|
|
$wp_styles->add_data( 'jetpack-jitm-css', 'rtl', true ); |
492
|
|
|
|
493
|
|
|
//Build stats url for tracking manage button |
494
|
|
|
$jitm_stats_url = Jetpack::build_stats_url( array( 'x_jetpack-jitm' => 'wordpresstools' ) ); |
495
|
|
|
|
496
|
|
|
// Enqueue javascript to handle jitm notice events |
497
|
|
|
wp_enqueue_script( 'jetpack-jitm-js', plugins_url( '_inc/jetpack-jitm.js', JETPACK__PLUGIN_FILE ), |
498
|
|
|
array( 'jquery' ), JETPACK__VERSION, true ); |
499
|
|
|
wp_localize_script( |
500
|
|
|
'jetpack-jitm-js', |
501
|
|
|
'jitmL10n', |
502
|
|
|
array( |
503
|
|
|
'ajaxurl' => admin_url( 'admin-ajax.php' ), |
504
|
|
|
'jitm_nonce' => wp_create_nonce( 'jetpack-jitm-nonce' ), |
505
|
|
|
'photon_msgs' => array( |
506
|
|
|
'success' => esc_html__( 'Success! Photon is now actively optimizing and serving your images for free.', 'jetpack' ), |
507
|
|
|
'fail' => esc_html__( 'We are sorry but unfortunately Photon did not activate.', 'jetpack' ) |
508
|
|
|
), |
509
|
|
|
'manage_msgs' => array( |
510
|
|
|
'success' => esc_html__( 'Success! WordPress.com tools are now active.', 'jetpack' ), |
511
|
|
|
'fail' => esc_html__( 'We are sorry but unfortunately Manage did not activate.', 'jetpack' ) |
512
|
|
|
), |
513
|
|
|
'stats_msgs' => array( |
514
|
|
|
'success' => esc_html__( 'Success! Stats are now active.', 'jetpack' ), |
515
|
|
|
'fail' => esc_html__( 'We are sorry but unfortunately Stats did not activate.', 'jetpack' ) |
516
|
|
|
), |
517
|
|
|
'jitm_stats_url' => $jitm_stats_url |
518
|
|
|
) |
519
|
|
|
); |
520
|
|
|
} |
521
|
|
|
|
522
|
|
|
/** |
523
|
|
|
* Check if a JITM was dismissed or not. Currently, dismissing one JITM will dismiss all of them. |
524
|
|
|
* |
525
|
|
|
* @since 3.8.2 |
526
|
|
|
* |
527
|
|
|
* @return bool |
528
|
|
|
*/ |
529
|
|
|
function is_jitm_dismissed() { |
530
|
|
|
if ( is_null( self::$jetpack_hide_jitm ) ) { |
531
|
|
|
|
532
|
|
|
// The option returns false when nothing was dismissed |
533
|
|
|
self::$jetpack_hide_jitm = Jetpack_Options::get_option( 'hide_jitm' ); |
|
|
|
|
534
|
|
|
} |
535
|
|
|
|
536
|
|
|
// so if it's not an array, it means no JITM was dismissed |
537
|
|
|
return is_array( self::$jetpack_hide_jitm ); |
538
|
|
|
} |
539
|
|
|
} |
540
|
|
|
if ( |
541
|
|
|
/** |
542
|
|
|
* Filter to turn off all just in time messages |
543
|
|
|
* |
544
|
|
|
* @since 3.7.0 |
545
|
|
|
* |
546
|
|
|
* @param bool true Whether to show just in time messages. |
547
|
|
|
*/ |
548
|
|
|
apply_filters( 'jetpack_just_in_time_msgs', false ) |
549
|
|
|
) { |
550
|
|
|
Jetpack_JITM::init(); |
551
|
|
|
} |
552
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.