/** * Determine if current admin page is an admin * module page. * * @since 2.2.0 */ function themeblvd_is_admin_module() { global $pagenow; global $_GET; // Current page $current_page = $pagenow; if (isset($_GET['page'])) { $current_page .= sprintf('?page=%s', $_GET['page']); } // Get admin modules $modules = themeblvd_get_admin_modules(); return in_array($current_page, $modules); }
/** * Add items to admin menu bar. This needs to be here in general * functions because admin bar appears on frontend as well. * * @since 2.0.0 */ function themeblvd_admin_menu_bar() { global $wp_admin_bar; if (is_admin() || !method_exists($wp_admin_bar, 'add_node')) { return; } // Get all admin modules $modules = themeblvd_get_admin_modules(); if (!$modules) { return; } // Theme Options if (isset($modules['options']) && themeblvd_supports('admin', 'options') && current_user_can(themeblvd_admin_module_cap('options'))) { $wp_admin_bar->add_node(array('id' => 'tb_theme_options', 'title' => __('Theme Options', 'themeblvd'), 'parent' => 'site-name', 'href' => admin_url($modules['options']))); } // Sliders (if sliders plugin is installed) if (defined('TB_SLIDERS_PLUGIN_VERSION') && isset($modules['sliders'])) { if (themeblvd_supports('admin', 'sliders') && current_user_can(themeblvd_admin_module_cap('sliders'))) { $wp_admin_bar->add_node(array('id' => 'tb_sliders', 'title' => __('Sliders', 'themeblvd'), 'parent' => 'site-name', 'href' => admin_url($modules['sliders']))); } } // Builder (if layout builder plugin is installed) if (defined('TB_BUILDER_PLUGIN_VERSION') && isset($modules['builder'])) { if (themeblvd_supports('admin', 'builder') && current_user_can(themeblvd_admin_module_cap('builder'))) { $wp_admin_bar->add_node(array('id' => 'tb_builder', 'title' => __('Layout Builder', 'themeblvd'), 'parent' => 'site-name', 'href' => admin_url($modules['builder']))); } } // Sidebars (if sidebar plugin is installed) if (defined('TB_SIDEBARS_PLUGIN_VERSION') && isset($modules['sidebars'])) { if (themeblvd_supports('admin', 'sidebars') && current_user_can(themeblvd_admin_module_cap('sidebars'))) { $wp_admin_bar->add_node(array('id' => 'tb_sidebars', 'title' => __('Widget Areas', 'themeblvd'), 'parent' => 'site-name', 'href' => admin_url($modules['sidebars']))); } } }