Automattic /
jetpack
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 | * 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() ) { |
||
| 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 | return $this->enqueue_jitm( 'akismet' ); |
||
| 65 | } |
||
| 66 | |||
| 67 | if ( |
||
| 68 | 'post' == $screen->base |
||
| 69 | && ( isset( $_GET['message'] ) && 6 == $_GET['message'] ) |
||
| 70 | && ! Jetpack::is_plugin_active( 'vaultpress/vaultpress.php' ) |
||
| 71 | ) { |
||
| 72 | return $this->enqueue_jitm( 'backups_after_publish' ); |
||
| 73 | } |
||
| 74 | |||
| 75 | if ( 'update-core' == $screen->base && ! Jetpack::is_plugin_active( 'vaultpress/vaultpress.php' ) ) { |
||
| 76 | return $this->enqueue_jitm( 'backups_updates' ); |
||
| 77 | } |
||
| 78 | } |
||
| 79 | |||
| 80 | /* |
||
| 81 | * Checks to see if JITM has been dismissed, and, if not, enqueues it |
||
| 82 | * |
||
| 83 | */ |
||
| 84 | function enqueue_jitm( $jitm_slug ) |
||
| 85 | { |
||
| 86 | if( ! $jitm_slug ) { |
||
| 87 | return; |
||
| 88 | } |
||
| 89 | |||
| 90 | $hide_jitm = Jetpack_Options::get_option( 'hide_jitm' ); |
||
| 91 | // Don't show the JITM if it's been seen in the last 6 months or dismissed twice in the past. |
||
| 92 | if( is_array( $hide_jitm ) && |
||
| 93 | isset( $hide_jitm[ $jitm_slug ] ) && is_array( $hide_jitm[ $jitm_slug ] ) && |
||
| 94 | ( |
||
| 95 | strtotime( $hide_jitm[ $jitm_slug ]['last_dismissed'] ) < strtotime( '6 months ago' ) || |
||
| 96 | $hide_jitm[ $jitm_slug ]['dismiss_count'] >= 2 |
||
| 97 | ) |
||
| 98 | ) { |
||
| 99 | return; |
||
| 100 | } |
||
| 101 | |||
| 102 | add_action( 'admin_enqueue_scripts', array( $this, 'jitm_enqueue_files' ) ); |
||
| 103 | add_action( 'admin_notices', array( $this, $jitm_slug . '_msg' ) ); |
||
| 104 | } |
||
| 105 | |||
| 106 | /* |
||
| 107 | * Present Manage just in time activation msg on update-core.php |
||
| 108 | * |
||
| 109 | */ |
||
| 110 | function manage_msg() { |
||
| 111 | $normalized_site_url = Jetpack::build_raw_urls( get_home_url() ); |
||
| 112 | ?> |
||
| 113 | <div class="jp-jitm"> |
||
| 114 | <a href="#" data-module="manage" data-jitm="manage" class="dismiss"><span class="genericon genericon-close"></span></a> |
||
| 115 | |||
| 116 | <?php echo self::get_emblem(); ?> |
||
| 117 | |||
| 118 | <p class="msg"> |
||
| 119 | <?php esc_html_e( 'Reduce security risks with automated plugin updates.', 'jetpack' ); ?> |
||
| 120 | </p> |
||
| 121 | |||
| 122 | <p> |
||
| 123 | <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' ) ) { |
||
| 124 | echo 'hide'; |
||
| 125 | } ?>"><?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' ) ) { |
||
| 126 | echo 'hide'; |
||
| 127 | } ?>"><?php esc_html_e( 'Go to WordPress.com', 'jetpack' ); ?></a> |
||
| 128 | </p> |
||
| 129 | </div> |
||
| 130 | <?php |
||
| 131 | //jitm is being viewed, track it |
||
| 132 | $jetpack = Jetpack::init(); |
||
| 133 | $jetpack->stat( 'jitm', 'manage-viewed-' . JETPACK__VERSION ); |
||
| 134 | $jetpack->do_stats( 'server_side' ); |
||
| 135 | } |
||
| 136 | |||
| 137 | /* |
||
| 138 | * Present Photon just in time activation msg |
||
| 139 | * |
||
| 140 | */ |
||
| 141 | function photon_msg() { |
||
| 142 | ?> |
||
| 143 | <div class="jp-jitm"> |
||
| 144 | <a href="#" data-module="photon" data-jitm="photon" class="dismiss"><span class="genericon genericon-close"></span></a> |
||
| 145 | |||
| 146 | <?php echo self::get_emblem(); ?> |
||
| 147 | |||
| 148 | <p class="msg"> |
||
| 149 | <?php esc_html_e( 'Speed up your photos and save bandwidth costs by using a free content delivery network.', 'jetpack' ); ?> |
||
| 150 | </p> |
||
| 151 | |||
| 152 | <p> |
||
| 153 | <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> |
||
| 154 | </p> |
||
| 155 | </div> |
||
| 156 | <?php |
||
| 157 | //jitm is being viewed, track it |
||
| 158 | $jetpack = Jetpack::init(); |
||
| 159 | $jetpack->stat( 'jitm', 'photon-viewed-' . JETPACK__VERSION ); |
||
| 160 | $jetpack->do_stats( 'server_side' ); |
||
| 161 | } |
||
| 162 | |||
| 163 | /** |
||
| 164 | * Display Photon JITM template in Media Library after user uploads an image. |
||
| 165 | * |
||
| 166 | * @since 3.9.0 |
||
| 167 | */ |
||
| 168 | function photon_tmpl() { |
||
| 169 | ?> |
||
| 170 | <script id="tmpl-jitm-photon" type="text/html"> |
||
| 171 | <div class="jp-jitm" data-track="photon-modal"> |
||
| 172 | <a href="#" data-module="photon" class="dismiss"><span class="genericon genericon-close"></span></a> |
||
| 173 | |||
| 174 | <?php echo self::get_emblem(); ?> |
||
| 175 | |||
| 176 | <p class="msg"> |
||
| 177 | <?php esc_html_e( 'Let Jetpack deliver your images optimized and faster than ever.', 'jetpack' ); ?> |
||
| 178 | </p> |
||
| 179 | |||
| 180 | <p> |
||
| 181 | <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> |
||
| 182 | </p> |
||
| 183 | </div> |
||
| 184 | </script> |
||
| 185 | <?php |
||
| 186 | } |
||
| 187 | |||
| 188 | /** |
||
| 189 | * Display message prompting user to enable auto-updates in WordPress.com. |
||
| 190 | * |
||
| 191 | * @since 3.8.2 |
||
| 192 | */ |
||
| 193 | function manage_pi_msg() { |
||
| 194 | $normalized_site_url = Jetpack::build_raw_urls( get_home_url() ); |
||
| 195 | $manage_active = Jetpack::is_module_active( 'manage' ); |
||
| 196 | |||
| 197 | // Check if plugin has auto update already enabled in WordPress.com and don't show JITM in such case. |
||
| 198 | $active_before = get_option( 'jetpack_temp_active_plugins_before', array() ); |
||
| 199 | delete_option( 'jetpack_temp_active_plugins_before' ); |
||
| 200 | $active_now = get_option( 'active_plugins', array() ); |
||
| 201 | $activated = array_diff( $active_now, $active_before ); |
||
| 202 | $auto_update_plugin_list = Jetpack_Options::get_option( 'autoupdate_plugins', array() ); |
||
| 203 | $plugin_auto_update_disabled = false; |
||
| 204 | foreach ( $activated as $plugin ) { |
||
| 205 | if ( ! in_array( $plugin, $auto_update_plugin_list ) ) { |
||
| 206 | |||
| 207 | // Plugin doesn't have auto updates enabled in WordPress.com yet. |
||
| 208 | $plugin_auto_update_disabled = true; |
||
| 209 | |||
| 210 | // We don't need to continue checking, it's ok to show JITM for this plugin. |
||
| 211 | break; |
||
| 212 | } |
||
| 213 | } |
||
| 214 | |||
| 215 | // Check if the activated plugin is in the WordPress.org repository |
||
| 216 | $plugin_can_auto_update = false; |
||
| 217 | $plugin_updates = get_site_transient( 'update_plugins' ); |
||
| 218 | if ( false === $plugin_updates ) { |
||
| 219 | |||
| 220 | // If update_plugins doesn't exist, display message anyway |
||
| 221 | $plugin_can_auto_update = true; |
||
| 222 | } else { |
||
| 223 | $plugin_updates = array_merge( $plugin_updates->response, $plugin_updates->no_update ); |
||
| 224 | foreach ( $activated as $plugin ) { |
||
| 225 | if ( isset( $plugin_updates[ $plugin ] ) ) { |
||
| 226 | |||
| 227 | // There's at least one plugin set cleared for auto updates |
||
| 228 | $plugin_can_auto_update = true; |
||
| 229 | |||
| 230 | // We don't need to continue checking, it's ok to show JITM for this round. |
||
| 231 | break; |
||
| 232 | } |
||
| 233 | } |
||
| 234 | } |
||
| 235 | |||
| 236 | if ( ! $manage_active && $plugin_auto_update_disabled && $plugin_can_auto_update && self::$auto_updates_allowed ) : |
||
| 237 | ?> |
||
| 238 | <div class="jp-jitm"> |
||
| 239 | <a href="#" data-module="manage-pi" data-jitm="manage_pi" class="dismiss"><span class="genericon genericon-close"></span></a> |
||
| 240 | |||
| 241 | <?php echo self::get_emblem(); ?> |
||
| 242 | |||
| 243 | <?php if ( ! $manage_active ) : ?> |
||
| 244 | <p class="msg"> |
||
| 245 | <?php esc_html_e( 'Save time with automated plugin updates.', 'jetpack' ); ?> |
||
| 246 | </p> |
||
| 247 | <p> |
||
| 248 | <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> |
||
| 249 | </p> |
||
| 250 | <?php elseif ( $manage_active ) : ?> |
||
| 251 | <p> |
||
| 252 | <?php esc_html_e( 'Save time with auto updates on WordPress.com', 'jetpack' ); ?> |
||
| 253 | </p> |
||
| 254 | <?php endif; // manage inactive |
||
| 255 | ?> |
||
| 256 | <p class="show-after-enable <?php echo $manage_active ? '' : 'hide'; ?>"> |
||
| 257 | <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> |
||
| 258 | </p> |
||
| 259 | </div> |
||
| 260 | <?php |
||
| 261 | //jitm is being viewed, track it |
||
| 262 | $jetpack = Jetpack::init(); |
||
| 263 | $jetpack->stat( 'jitm', 'manage-pi-viewed-' . JETPACK__VERSION ); |
||
| 264 | $jetpack->do_stats( 'server_side' ); |
||
| 265 | endif; // manage inactive |
||
| 266 | } |
||
| 267 | |||
| 268 | /** |
||
| 269 | * Display message in editor prompting user to compose entry in WordPress.com. |
||
| 270 | * |
||
| 271 | * @since 3.8.2 |
||
| 272 | */ |
||
| 273 | function editor_msg() { |
||
| 274 | global $typenow; |
||
| 275 | if ( current_user_can( 'manage_options' ) ) { |
||
| 276 | $normalized_site_url = Jetpack::build_raw_urls( get_home_url() ); |
||
| 277 | $editor_dismissed = isset( self::$jetpack_hide_jitm['editor'] ); |
||
| 278 | if ( ! $editor_dismissed ) : |
||
| 279 | ?> |
||
| 280 | <div class="jp-jitm"> |
||
| 281 | <a href="#" data-module="editor" data-jitm="editor" class="dismiss"><span class="genericon genericon-close"></span></a> |
||
| 282 | <?php echo self::get_emblem(); ?> |
||
| 283 | <p class="msg"> |
||
| 284 | <?php esc_html_e( 'Try the brand new editor.', 'jetpack' ); ?> |
||
| 285 | </p> |
||
| 286 | <p> |
||
| 287 | <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> |
||
| 288 | </p> |
||
| 289 | </div> |
||
| 290 | <?php |
||
| 291 | //jitm is being viewed, track it |
||
| 292 | $jetpack = Jetpack::init(); |
||
| 293 | $jetpack->stat( 'jitm', 'editor-viewed-' . JETPACK__VERSION ); |
||
| 294 | $jetpack->do_stats( 'server_side' ); |
||
| 295 | endif; // manage or editor inactive |
||
| 296 | } |
||
| 297 | } |
||
| 298 | |||
| 299 | /** |
||
| 300 | * Display message in editor prompting user to enable stats. |
||
| 301 | * |
||
| 302 | * @since 3.9.0 |
||
| 303 | */ |
||
| 304 | function stats_msg() { |
||
| 305 | $stats_active = Jetpack::is_module_active( 'stats' ); |
||
| 306 | $normalized_site_url = Jetpack::build_raw_urls( get_home_url() ); |
||
| 307 | ?> |
||
| 308 | <div class="jp-jitm"> |
||
| 309 | <a href="#" data-module="stats" data-jitm="stats" class="dismiss"><span class="genericon genericon-close"></span></a> |
||
| 310 | <?php echo self::get_emblem(); ?> |
||
| 311 | <p class="msg"> |
||
| 312 | <?php esc_html_e( 'Track detailed stats on this post and the rest of your site.', 'jetpack' ); ?> |
||
| 313 | </p> |
||
| 314 | <?php if ( ! $stats_active ) : ?> |
||
| 315 | <p> |
||
| 316 | <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> |
||
| 317 | </p> |
||
| 318 | <?php endif; // stats inactive |
||
| 319 | ?> |
||
| 320 | <p class="show-after-enable <?php echo $stats_active ? '' : 'hide'; ?>"> |
||
| 321 | <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> |
||
| 322 | </p> |
||
| 323 | </div> |
||
| 324 | <?php |
||
| 325 | //jitm is being viewed, track it |
||
| 326 | $jetpack = Jetpack::init(); |
||
| 327 | $jetpack->stat( 'jitm', 'post-stats-viewed-' . JETPACK__VERSION ); |
||
| 328 | $jetpack->do_stats( 'server_side' ); |
||
| 329 | } |
||
| 330 | |||
| 331 | /** |
||
| 332 | * Display JITM in Updates screen prompting user to enable Backups. |
||
| 333 | * |
||
| 334 | * @since 3.9.5 |
||
| 335 | */ |
||
| 336 | View Code Duplication | function backups_updates_msg() { |
|
| 337 | $normalized_site_url = Jetpack::build_raw_urls( get_home_url() ); |
||
| 338 | $url = 'https://jetpack.com/redirect/?source=jitm-backup-updates&site=' . $normalized_site_url; |
||
| 339 | $jitm_stats_url = Jetpack::build_stats_url( array( 'x_jetpack-jitm' => 'vaultpress' ) ); |
||
| 340 | ?> |
||
| 341 | <div class="jp-jitm" data-track="vaultpress-updates" data-jitm="backups_updates" data-stats_url="<?php echo esc_url( $jitm_stats_url ); ?>"> |
||
| 342 | <a href="#" data-module="vaultpress" class="dismiss"><span class="genericon genericon-close"></span></a> |
||
| 343 | <?php echo self::get_emblem(); ?> |
||
| 344 | <p class="msg"> |
||
| 345 | <?php esc_html_e( 'Backups are recommended to protect your site before you make any changes.', 'jetpack' ); ?> |
||
| 346 | </p> |
||
| 347 | <p> |
||
| 348 | <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> |
||
| 349 | </p> |
||
| 350 | </div> |
||
| 351 | <?php |
||
| 352 | //jitm is being viewed, track it |
||
| 353 | $jetpack = Jetpack::init(); |
||
| 354 | $jetpack->stat( 'jitm', 'vaultpress-updates-viewed-' . JETPACK__VERSION ); |
||
| 355 | $jetpack->do_stats( 'server_side' ); |
||
| 356 | } |
||
| 357 | |||
| 358 | /** |
||
| 359 | * Display JITM in Comments screen prompting user to enable Akismet. |
||
| 360 | * |
||
| 361 | * @since 3.9.5 |
||
| 362 | */ |
||
| 363 | View Code Duplication | function akismet_msg() { |
|
| 364 | $normalized_site_url = Jetpack::build_raw_urls( get_home_url() ); |
||
| 365 | $url = 'https://jetpack.com/redirect/?source=jitm-akismet&site=' . $normalized_site_url; |
||
| 366 | $jitm_stats_url = Jetpack::build_stats_url( array( 'x_jetpack-jitm' => 'akismet' ) ); |
||
| 367 | ?> |
||
| 368 | <div class="jp-jitm" data-stats_url="<?php echo esc_url( $jitm_stats_url ); ?>"> |
||
| 369 | <a href="#" data-module="akismet" data-jitm="akismet" class="dismiss"><span class="genericon genericon-close"></span></a> |
||
| 370 | <?php echo self::get_emblem(); ?> |
||
| 371 | <p class="msg"> |
||
| 372 | <?php esc_html_e( "Spam affects your site's legitimacy, protect your site with Akismet.", 'jetpack' ); ?> |
||
| 373 | </p> |
||
| 374 | <p> |
||
| 375 | <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> |
||
| 376 | </p> |
||
| 377 | </div> |
||
| 378 | <?php |
||
| 379 | //jitm is being viewed, track it |
||
| 380 | $jetpack = Jetpack::init(); |
||
| 381 | $jetpack->stat( 'jitm', 'akismet-viewed-' . JETPACK__VERSION ); |
||
| 382 | $jetpack->do_stats( 'server_side' ); |
||
| 383 | } |
||
| 384 | |||
| 385 | /** |
||
| 386 | * Display JITM after a post is published prompting user to enable Backups. |
||
| 387 | * |
||
| 388 | * @since 3.9.5 |
||
| 389 | */ |
||
| 390 | View Code Duplication | function backups_after_publish_msg() { |
|
| 391 | $normalized_site_url = Jetpack::build_raw_urls( get_home_url() ); |
||
| 392 | $url = 'https://jetpack.com/redirect/?source=jitm-backup-publish&site=' . $normalized_site_url; |
||
| 393 | $jitm_stats_url = Jetpack::build_stats_url( array( 'x_jetpack-jitm' => 'vaultpress' ) ); |
||
| 394 | ?> |
||
| 395 | <div class="jp-jitm" data-track="vaultpress-publish" data-jitm="backups_after_publish" data-stats_url="<?php echo esc_url( $jitm_stats_url ); ?>"> |
||
| 396 | <a href="#" data-module="vaultpress" class="dismiss"><span class="genericon genericon-close"></span></a> |
||
| 397 | |||
| 398 | <?php echo self::get_emblem(); ?> |
||
| 399 | |||
| 400 | <p class="msg"> |
||
| 401 | <?php esc_html_e( "Great job! Now let's make sure your hard work is never lost, backup everything with VaultPress.", 'jetpack' ); ?> |
||
| 402 | </p> |
||
| 403 | <p> |
||
| 404 | <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> |
||
| 405 | </p> |
||
| 406 | </div> |
||
| 407 | <?php |
||
| 408 | //jitm is being viewed, track it |
||
| 409 | $jetpack = Jetpack::init(); |
||
| 410 | $jetpack->stat( 'jitm', 'vaultpress-publish-viewed-' . JETPACK__VERSION ); |
||
| 411 | $jetpack->do_stats( 'server_side' ); |
||
| 412 | } |
||
| 413 | |||
| 414 | /** |
||
| 415 | * Display a JITM style message for the media-new page. |
||
| 416 | * |
||
| 417 | * @since 4.5 |
||
| 418 | */ |
||
| 419 | function videopress_media_upload_warning_msg() { |
||
| 420 | $jitm_stats_url = Jetpack::build_stats_url( array( 'x_jetpack-jitm' => 'videopress' ) ); |
||
| 421 | |||
| 422 | $upload_url = add_query_arg( 'mode', 'grid', admin_url( 'upload.php' ) ); |
||
| 423 | $new_post_url = admin_url( 'post-new.php' ); |
||
| 424 | |||
| 425 | $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 ) ); |
||
| 426 | ?> |
||
| 427 | <div class="jp-jitm" data-track="videopress-upload-warning" data-stats_url="<?php echo esc_url( $jitm_stats_url ); ?>"> |
||
| 428 | <!-- <a href="#" data-module="videopress" class="dismiss"><span class="genericon genericon-close"></span></a>--> |
||
| 429 | |||
| 430 | <?php echo self::get_emblem(); ?> |
||
| 431 | |||
| 432 | <p class="msg"> |
||
| 433 | <?php echo $msg; ?> |
||
| 434 | </p> |
||
| 435 | <p> |
||
| 436 | <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> |
||
| 437 | </p> |
||
| 438 | </div> |
||
| 439 | <?php |
||
| 440 | } |
||
| 441 | |||
| 442 | /* |
||
| 443 | * Function to enqueue jitm css and js |
||
| 444 | */ |
||
| 445 | function jitm_enqueue_files( $hook ) { |
||
|
0 ignored issues
–
show
|
|||
| 446 | |||
| 447 | $wp_styles = new WP_Styles(); |
||
| 448 | $min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
||
| 449 | wp_enqueue_style( 'jetpack-jitm-css', plugins_url( "css/jetpack-admin-jitm{$min}.css", JETPACK__PLUGIN_FILE ), false, JETPACK__VERSION . '-201243242' ); |
||
| 450 | $wp_styles->add_data( 'jetpack-jitm-css', 'rtl', true ); |
||
| 451 | |||
| 452 | //Build stats url for tracking manage button |
||
| 453 | $jitm_stats_url = Jetpack::build_stats_url( array( 'x_jetpack-jitm' => 'wordpresstools' ) ); |
||
| 454 | |||
| 455 | // Enqueue javascript to handle jitm notice events |
||
| 456 | wp_enqueue_script( 'jetpack-jitm-js', plugins_url( '_inc/jetpack-jitm.js', JETPACK__PLUGIN_FILE ), |
||
| 457 | array( 'jquery' ), JETPACK__VERSION, true ); |
||
| 458 | wp_localize_script( |
||
| 459 | 'jetpack-jitm-js', |
||
| 460 | 'jitmL10n', |
||
| 461 | array( |
||
| 462 | 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
||
| 463 | 'jitm_nonce' => wp_create_nonce( 'jetpack-jitm-nonce' ), |
||
| 464 | 'photon_msgs' => array( |
||
| 465 | 'success' => esc_html__( 'Success! Photon is now actively optimizing and serving your images for free.', 'jetpack' ), |
||
| 466 | 'fail' => esc_html__( 'We are sorry but unfortunately Photon did not activate.', 'jetpack' ) |
||
| 467 | ), |
||
| 468 | 'manage_msgs' => array( |
||
| 469 | 'success' => esc_html__( 'Success! WordPress.com tools are now active.', 'jetpack' ), |
||
| 470 | 'fail' => esc_html__( 'We are sorry but unfortunately Manage did not activate.', 'jetpack' ) |
||
| 471 | ), |
||
| 472 | 'stats_msgs' => array( |
||
| 473 | 'success' => esc_html__( 'Success! Stats are now active.', 'jetpack' ), |
||
| 474 | 'fail' => esc_html__( 'We are sorry but unfortunately Stats did not activate.', 'jetpack' ) |
||
| 475 | ), |
||
| 476 | 'jitm_stats_url' => $jitm_stats_url |
||
| 477 | ) |
||
| 478 | ); |
||
| 479 | } |
||
| 480 | } |
||
| 481 | if ( |
||
| 482 | /** |
||
| 483 | * Filter to turn off all just in time messages |
||
| 484 | * |
||
| 485 | * @since 3.7.0 |
||
| 486 | * |
||
| 487 | * @param bool true Whether to show just in time messages. |
||
| 488 | */ |
||
| 489 | apply_filters( 'jetpack_just_in_time_msgs', false ) |
||
| 490 | ) { |
||
| 491 | Jetpack_JITM::init(); |
||
| 492 | } |
||
| 493 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.