static function init() { if (is_null(self::$instance)) { self::$instance = new Jetpack_JITM(); } return self::$instance; }
/** * Prepare actions according to screen and post type. * * @since 3.8.2 * * @param object $screen */ function prepare_jitms($screen) { global $pagenow; $post_type = $screen->post_type; self::$jetpack_hide_jitm = Jetpack_Options::get_option('hide_jitm'); $showphoton = empty(self::$jetpack_hide_jitm['photon']) ? 'show' : self::$jetpack_hide_jitm['photon']; $showmanage = empty(self::$jetpack_hide_jitm['manage']) ? 'show' : self::$jetpack_hide_jitm['manage']; $show_manage_pi = empty(self::$jetpack_hide_jitm['manage-pi']) ? 'show' : self::$jetpack_hide_jitm['manage-pi']; $show_editor = empty(self::$jetpack_hide_jitm['editor']) ? 'show' : self::$jetpack_hide_jitm['editor']; if ('media-new.php' == $pagenow && !Jetpack::is_module_active('photon') && 'hide' != $showphoton) { add_action('admin_enqueue_scripts', array($this, 'jitm_enqueue_files')); add_action('post-plupload-upload-ui', array($this, 'photon_msg')); } else { if ('update-core.php' == $pagenow && 'hide' != $showmanage) { add_action('admin_enqueue_scripts', array($this, 'jitm_enqueue_files')); add_action('admin_notices', array($this, 'manage_msg')); } elseif ('plugins.php' === $pagenow && isset($_GET['activate']) && 'true' === $_GET['activate'] && 'hide' != $show_manage_pi) { add_action('admin_enqueue_scripts', array($this, 'jitm_enqueue_files')); add_action('pre_current_active_plugins', array($this, 'manage_pi_msg')); } elseif ('post-new.php' === $pagenow && in_array($post_type, array('post', 'page')) && 'hide' != $show_editor) { add_action('admin_enqueue_scripts', array($this, 'jitm_enqueue_files')); add_action('admin_notices', array($this, 'editor_msg')); } } }
/** * 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); }