/** * Class constructor */ public function __construct() { if (gd_is_mt() || gd_is_reseller() || !gd_has_used_wpem()) { return; } add_action('wp_dashboard_setup', array($this, 'init')); }
/** * Add a "Flush Cache" button the admin menu * @param WP_Admin_Bar $admin_bar * @return void */ public function admin_bar_menu($admin_bar) { global $gd_system_config; $config = $gd_system_config->get_config(); $gateway_url = isset($config['gateway_url']) ? $config['gateway_url'] : ''; // Only show to admin users if (!current_user_can('activate_plugins')) { return; } switch (true) { case gd_is_mt(): $top_menu_label = __('Media Temple', 'gd_system'); $top_menu_icon_class = 'media-temple'; break; case gd_is_reseller(): $top_menu_label = __('Managed WordPress', 'gd_system'); $top_menu_icon_class = 'admin-generic'; break; default: $top_menu_label = __('GoDaddy', 'gd_system'); $top_menu_icon_class = 'godaddy-alt'; break; } $admin_bar->add_menu(['id' => static::ADMIN_MENU_SLUG, 'title' => sprintf('<span class="ab-icon dashicons dashicons-%s"></span><span class="ab-label">%s</span>', $top_menu_icon_class, $top_menu_label)]); // Settings menu $admin_bar->add_menu(['parent' => static::ADMIN_MENU_SLUG, 'id' => static::ADMIN_MENU_SLUG . '-control-panel', 'title' => sprintf('%s<span class="dashicons dashicons-external"></span>', __('Account Settings', 'gd_system')), 'href' => str_replace('%pl_id%', defined('GD_RESELLER') ? GD_RESELLER : '', $gateway_url), 'meta' => array('target' => '_blank')]); // Flush cache menu $admin_bar->add_menu(['parent' => static::ADMIN_MENU_SLUG, 'id' => static::ADMIN_MENU_SLUG . '-flush-cache', 'title' => __('Flush Cache', 'gd_system'), 'href' => esc_url(add_query_arg(['GD_COMMAND' => 'FLUSH_CACHE', 'GD_NONCE' => wp_create_nonce('GD_FLUSH_CACHE')]))]); }
/** * Class constructor */ public function __construct() { add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts')); if (gd_is_mt() || gd_is_reseller()) { return; } /** * Filter the admin menu position * * Note: By default we will use a long decimal string to reduce the * chance of position conflicts with other menu items, see Codex. * * @return string */ $this->position = (string) apply_filters('gd_system_page_menu_position', $this->position); add_action('init', array($this, 'init')); add_action('admin_menu', array($this, 'register_menu_page')); add_action('admin_bar_menu', array($this, 'admin_bar_menu'), 110); add_filter('admin_body_class', array($this, 'admin_body_class')); }
/** * Check if this is a Reseller account * * @return bool */ function gd_is_reseller() { return defined('GD_RESELLER') && 1 !== GD_RESELLER && !gd_is_mt(); }