/** * Enqueues the CSS and JS files needed for plugin UI * * @since 1.0.0 * @api Call this function before/in `admin_head`. * @param string $module_url URL to this module (directory). * @param string $body_class List of additional classes for the body tag. */ public static function load($module_url, $body_class = '') { self::$module_url = trailingslashit($module_url); self::$body_class = trim($body_class); add_filter('admin_body_class', array(__CLASS__, 'admin_body_class')); if (!did_action('admin_enqueue_scripts')) { add_action('admin_enqueue_scripts', array(__CLASS__, 'enqueue')); } else { self::enqueue(); } }
/** * Loads the Shared UI to on all admin pages * @param $current_page */ function load_shared_ui($current_page) { //If class method exists, load shared UI if (class_exists('WDEV_Plugin_Ui')) { if (method_exists('WDEV_Plugin_Ui', 'load')) { //Load Shared UI WDEV_Plugin_Ui::load(WP_SMUSH_URL . '/assets/shared-ui/', false); if ('media_page_wp-smush-bulk' != $current_page && 'gallery_page_wp-smush-nextgen-bulk' != $current_page) { //Don't add thhe WPMUD class to body to other admin pages remove_filter('admin_body_class', array('WDEV_Plugin_Ui', 'admin_body_class')); } } } }
/** * Renders the template header that is repeated on every page. * * @since 4.0.0 * @param string $page_title The page caption. */ protected function render_header($page_title) { $urls = $this->page_urls; $url_support = $urls->real_support_url; $url_dash = 'https://premium.wpmudev.org/hub/'; $url_logout = $urls->dashboard_url . '&clear_key=1'; if ($url_support == $urls->support_url) { $support_target = '_self'; } else { $support_target = '_blank'; } ?> <section id="header"> <div class="actions"> <?php if (WPMUDEV_CUSTOM_API_SERVER) { ?> <span class="flag"> <span class="tooltip-bottom" tooltip="<?php echo esc_attr(sprintf("Custom API Server:\n%s", WPMUDEV_CUSTOM_API_SERVER)); ?> "> <i class="wdv-icon wdv-icon-beaker"></i> </span> </span> <?php } ?> <a href="<?php echo esc_url($url_support); ?> " target="<?php echo esc_attr($support_target); ?> " class="button"> <?php esc_html_e('Get Support', 'wpmudev'); ?> </a> <a href="<?php echo esc_url($url_dash); ?> " target="_blank" class="button button-light"> <?php esc_html_e('The Hub', 'wpmudev'); ?> </a> <?php if (!defined('WPMUDEV_APIKEY') || WPMUDEV_APIKEY) { ?> <a href="<?php echo esc_url($url_logout); ?> " class="button button-light"> <?php esc_html_e('Logout', 'wpmudev'); ?> </a> <?php } ?> </div> <h1> <?php // @codingStandardsIgnoreStart: Title contains HTML, no escaping! echo $page_title; // @codingStandardsIgnoreEnd ?> </h1> </section> <dialog id="reload" title="<?php esc_attr_e('Almost there!', 'wpmudev'); ?> " class="small no-close"> <center> <p><span class="loading"></span></p> <p><?php _e('Hold on a moment while we finish that action and refresh the page...', 'wpmudev'); ?> </p> <p> </p> </center> <span class="the-hero"><i class="dev-icon dev-icon-devman"></i></span> </dialog> <?php $data = array(); if (!isset($_GET['wpmudev_msg'])) { $err = isset($_GET['failed']) ? intval($_GET['failed']) : false; $ok = isset($_GET['success']) ? intval($_GET['success']) : false; if ($ok && $ok >= time()) { $data[] = 'WDP.showSuccess()'; } elseif ($err && $err >= time()) { $data[] = 'WDP.showError()'; } } WDEV_Plugin_Ui::output($data); /** * Custom hook to display own notifications inside Dashboard. */ do_action('wpmudev_dashboard_notice'); }
/** * Choose a message to display and render it. * * This function is only called when those two conditions are true: * 1. We display the main WP Dashboard page * 2. Current user has access to the WPMUDEV Dashboard plugin * * @since 4.0.0 */ public function setup_message() { $msg = $this->choose_message(); if (!$msg) { return; } WDEV_Plugin_Ui::render_dev_notification(WPMUDEV_Dashboard::$site->plugin_url . 'shared-ui/', $msg); }