base && ! Jetpack::is_plugin_active( 'akismet/akismet.php' ) ) { add_action( 'admin_enqueue_scripts', array( $this, 'jitm_enqueue_files' ) ); add_action( 'admin_notices', array( $this, 'akismet_msg' ) ); } elseif ( 'post' == $screen->base && ( isset( $_GET['message'] ) && 6 == $_GET['message'] ) && ! Jetpack::is_plugin_active( 'vaultpress/vaultpress.php' ) ) { add_action( 'admin_enqueue_scripts', array( $this, 'jitm_enqueue_files' ) ); add_action( 'edit_form_top', array( $this, 'backups_after_publish_msg' ) ); } elseif ( 'update-core' == $screen->base && ! Jetpack::is_plugin_active( 'vaultpress/vaultpress.php' ) ) { add_action( 'admin_enqueue_scripts', array( $this, 'jitm_enqueue_files' ) ); add_action( 'admin_notices', array( $this, 'backups_updates_msg' ) ); } } /* * Present Manage just in time activation msg on update-core.php * */ function manage_msg() { $normalized_site_url = Jetpack::build_raw_urls( get_home_url() ); ?>
stat( 'jitm', 'manage-viewed-' . JETPACK__VERSION ); $jetpack->do_stats( 'server_side' ); } /* * Present Photon just in time activation msg * */ function photon_msg() { ?> stat( 'jitm', 'photon-viewed-' . JETPACK__VERSION ); $jetpack->do_stats( 'server_side' ); } /** * Display Photon JITM template in Media Library after user uploads an image. * * @since 3.9.0 */ function photon_tmpl() { ?> response, $plugin_updates->no_update ); foreach ( $activated as $plugin ) { if ( isset( $plugin_updates[ $plugin ] ) ) { // There's at least one plugin set cleared for auto updates $plugin_can_auto_update = true; // We don't need to continue checking, it's ok to show JITM for this round. break; } } } if ( ! $manage_active && $plugin_auto_update_disabled && $plugin_can_auto_update && self::$auto_updates_allowed ) : ?> stat( 'jitm', 'manage-pi-viewed-' . JETPACK__VERSION ); $jetpack->do_stats( 'server_side' ); endif; // manage inactive } /** * Display message in editor prompting user to compose entry in WordPress.com. * * @since 3.8.2 */ function editor_msg() { global $typenow; if ( current_user_can( 'manage_options' ) ) { $normalized_site_url = Jetpack::build_raw_urls( get_home_url() ); $editor_dismissed = isset( self::$jetpack_hide_jitm['editor'] ); if ( ! $editor_dismissed ) : ?> stat( 'jitm', 'editor-viewed-' . JETPACK__VERSION ); $jetpack->do_stats( 'server_side' ); endif; // manage or editor inactive } } /** * Display message in editor prompting user to enable stats. * * @since 3.9.0 */ function stats_msg() { $stats_active = Jetpack::is_module_active( 'stats' ); $normalized_site_url = Jetpack::build_raw_urls( get_home_url() ); ?> stat( 'jitm', 'post-stats-viewed-' . JETPACK__VERSION ); $jetpack->do_stats( 'server_side' ); } /** * Display JITM in Updates screen prompting user to enable Backups. * * @since 3.9.5 */ function backups_updates_msg() { $normalized_site_url = Jetpack::build_raw_urls( get_home_url() ); $url = 'https://wordpress.com/plans/' . $normalized_site_url; $jitm_stats_url = Jetpack::build_stats_url( array( 'x_jetpack-jitm' => 'vaultpress' ) ); ?> stat( 'jitm', 'vaultpress-updates-viewed-' . JETPACK__VERSION ); $jetpack->do_stats( 'server_side' ); } /** * Display JITM in Comments screen prompting user to enable Akismet. * * @since 3.9.5 */ function akismet_msg() { $normalized_site_url = Jetpack::build_raw_urls( get_home_url() ); $url = 'https://wordpress.com/plans/' . $normalized_site_url; $jitm_stats_url = Jetpack::build_stats_url( array( 'x_jetpack-jitm' => 'akismet' ) ); ?> stat( 'jitm', 'akismet-viewed-' . JETPACK__VERSION ); $jetpack->do_stats( 'server_side' ); } /** * Display JITM after a post is published prompting user to enable Backups. * * @since 3.9.5 */ function backups_after_publish_msg() { $normalized_site_url = Jetpack::build_raw_urls( get_home_url() ); $url = 'https://wordpress.com/plans/' . $normalized_site_url; $jitm_stats_url = Jetpack::build_stats_url( array( 'x_jetpack-jitm' => 'vaultpress' ) ); ?> stat( 'jitm', 'vaultpress-publish-viewed-' . JETPACK__VERSION ); $jetpack->do_stats( 'server_side' ); } /* * Function to enqueue jitm css and js */ function jitm_enqueue_files( $hook ) { $wp_styles = new WP_Styles(); $min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; wp_enqueue_style( 'jetpack-jitm-css', plugins_url( "css/jetpack-admin-jitm{$min}.css", JETPACK__PLUGIN_FILE ), false, JETPACK__VERSION . '-201243242' ); $wp_styles->add_data( 'jetpack-jitm-css', 'rtl', true ); //Build stats url for tracking manage button $jitm_stats_url = Jetpack::build_stats_url( array( 'x_jetpack-jitm' => 'wordpresstools' ) ); // Enqueue javascript to handle jitm notice events wp_enqueue_script( 'jetpack-jitm-js', plugins_url( '_inc/jetpack-jitm.js', JETPACK__PLUGIN_FILE ), array( 'jquery' ), JETPACK__VERSION, true ); wp_localize_script( 'jetpack-jitm-js', 'jitmL10n', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'jitm_nonce' => wp_create_nonce( 'jetpack-jitm-nonce' ), 'photon_msgs' => array( 'success' => esc_html__( 'Success! Photon is now actively optimizing and serving your images for free.', 'jetpack' ), 'fail' => esc_html__( 'We are sorry but unfortunately Photon did not activate.', 'jetpack' ) ), 'manage_msgs' => array( 'success' => esc_html__( 'Success! WordPress.com tools are now active.', 'jetpack' ), 'fail' => esc_html__( 'We are sorry but unfortunately Manage did not activate.', 'jetpack' ) ), 'stats_msgs' => array( 'success' => esc_html__( 'Success! Stats are now active.', 'jetpack' ), 'fail' => esc_html__( 'We are sorry but unfortunately Stats did not activate.', 'jetpack' ) ), 'jitm_stats_url' => $jitm_stats_url ) ); } /** * Check if a JITM was dismissed or not. Currently, dismissing one JITM will dismiss all of them. * * @since 3.8.2 * * @return bool */ function is_jitm_dismissed() { if ( is_null( self::$jetpack_hide_jitm ) ) { // The option returns false when nothing was dismissed self::$jetpack_hide_jitm = Jetpack_Options::get_option( 'hide_jitm' ); } // so if it's not an array, it means no JITM was dismissed return is_array( self::$jetpack_hide_jitm ); } } /** * Filter to turn off all just in time messages * * @since 3.7.0 * * @param bool true Whether to show just in time messages. */ if ( apply_filters( 'jetpack_just_in_time_msgs', false ) ) { Jetpack_JITM::init(); }