![]() Server : Apache/2.4.52 (Ubuntu) System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64 User : www-data ( 33) PHP Version : 8.1.2-1ubuntu2.21 Disable Function : NONE Directory : /var/www/famchicpd/wp-content/plugins/tastyc-plugin/admin/ |
<?php if ( ! class_exists( 'TastycThemeDashboard' ) ) { class TastycThemeDashboard { public $dashboard_slug = 'tastyc-theme-dashboard'; private static $_instance = null; /* Instance */ public static function instance() { if ( is_null( self::$_instance ) ) { self::$_instance = new self(); self::$_instance->init_theme_dashboard_enqueue(); self::$_instance->init_theme_dashboard_menu(); self::$_instance->init_theme_dashboard_content(); } return self::$_instance; } public function __construct() { } public function init_theme_dashboard_content() { } public function theme_dashboard_assets() { /* enqueue theme dashboard styles */ wp_enqueue_style( 'tastyc-theme-dashboard-style', tastyc_plugin_info()->dashboard_uri . 'assets/css/dashboard.css', [], tastyc_plugin_info()->version ); wp_enqueue_style( 'tastyc-theme-dashboard-webfonts', tastyc_plugin_info()->dashboard_uri . 'assets/css/webfonts.css', [], tastyc_plugin_info()->version ); /* enqueue theme dashboard scripts */ wp_enqueue_script( 'tastyc-theme-dashboard-scripts', tastyc_plugin_info()->dashboard_uri . 'assets/js/dashboard.js', [ 'jquery' ], tastyc_plugin_info()->version, true ); } public function init_theme_dashboard_enqueue() { add_action( 'admin_enqueue_scripts', array( $this, 'theme_dashboard_assets' ) ); } public function init_theme_dashboard_menu() { add_action( 'admin_menu', [ $this, 'theme_dashboard_menu' ] ); } public function theme_dashboard_menu() { $menu_position = 2; $menu_admin_capability = 'manage_options'; add_menu_page( esc_html__( 'Tastyc Panel', 'tastyc-plugin' ), esc_html__( 'Tastyc Panel', 'tastyc-plugin' ), $menu_admin_capability, $this->dashboard_slug, [ $this, 'theme_dashboard_general_render' ], 'dashicons-bslthemes', $menu_position ); $submenu_items = array(); $submenu_items[] = array( $this->dashboard_slug, esc_html__( 'Theme Dashboard', 'tastyc-plugin' ), esc_html__( 'Welcome', 'tastyc-plugin' ), $menu_admin_capability, 'tastyc-theme-dashboard', [ $this, 'theme_dashboard_general_render' ] ); $submenu_title = esc_html__( 'Activate', 'tastyc-plugin' ); if ( tastyc_plugin_info()->capability != 'normal' ) : $submenu_title = esc_html__( 'Status', 'tastyc-plugin' ); endif; $submenu_items[] = array( $this->dashboard_slug, $submenu_title, $submenu_title, $menu_admin_capability, 'tastyc-theme-activation', [ $this, 'theme_dashboard_activation_render' ] ); $submenu_items[] = array( $this->dashboard_slug, esc_html__( 'Plugins', 'tastyc-plugin' ), esc_html__( 'Plugins', 'tastyc-plugin' ), $menu_admin_capability, 'tastyc-theme-plugins', [ $this, 'theme_dashboard_plugins_render' ] ); $submenu_items[] = array( $this->dashboard_slug, esc_html__( 'Demo Content', 'tastyc-plugin' ), esc_html__( 'Demo Content', 'tastyc-plugin' ), $menu_admin_capability, 'tastyc-theme-demo', [ $this, 'theme_dashboard_demo_render' ] ); $submenu_items[] = array( $this->dashboard_slug, esc_html__( 'Help Center', 'tastyc-plugin' ), esc_html__( 'Help Center', 'tastyc-plugin' ), $menu_admin_capability, 'tastyc-theme-help', [ $this, 'theme_dashboard_help_render' ] ); $submenu_position = 0; foreach ( $submenu_items as $params ) { $submenu_position += 2; add_submenu_page( $params[0], $params[1], $params[2], $params[3], $params[4], $params[5], $submenu_position ); } } public function theme_dashboard_general_render() { $this->theme_dashboard_header(); $this->theme_dashboard_body( 'general' ); $this->theme_dashboard_footer(); } public function theme_dashboard_activation_render() { $this->theme_dashboard_header(); $this->theme_dashboard_body( 'activation' ); $this->theme_dashboard_footer(); } public function theme_dashboard_plugins_render() { $this->theme_dashboard_header(); $this->theme_dashboard_body( 'plugins' ); $this->theme_dashboard_footer(); } public function theme_dashboard_demo_render() { $this->theme_dashboard_header(); $this->theme_dashboard_body( 'demo' ); $this->theme_dashboard_footer(); } public function theme_dashboard_help_render() { $this->theme_dashboard_header(); $this->theme_dashboard_body( 'help' ); $this->theme_dashboard_footer(); } public function theme_dashboard_header() { global $submenu; $menu_items = ''; if ( isset( $submenu[ $this->dashboard_slug ] ) ) { $menu_items = $submenu[ $this->dashboard_slug ]; } if ( ! empty( $menu_items ) ) : ?> <div class="tastyc-dashboard"> <div class="tastyc-dashboard-header"> <div class="nav-tab-wrapper"> <?php foreach ( $menu_items as $item ): $class = isset( $_GET['page'] ) && $_GET['page'] == $item[2] ? ' nav-tab-active' : ''; ?> <a href="<?php echo esc_url( admin_url( 'admin.php?page=' . $item[2] ) ); ?>" class="nav-tab<?php echo esc_attr( $class ); ?>"> <?php echo esc_html( $item[0] ); ?> </a> <?php endforeach; ?> </div> </div> <div class="tastyc-dashboard-wrapper"> <?php endif; } public function theme_dashboard_body( $template ) { if ( tastyc_plugin_info()->capability == 'normal' && ( $template == 'plugins' || $template == 'demo' ) ) { require_once 'templates/dashboard-' . $template . '-normal.php'; } else { require_once 'templates/dashboard-' . $template . '.php'; } } public function theme_dashboard_footer() { ?> <div class="tastyc-dashboard-footer"> <div class="copyright"> <?php echo sprintf( __( '© %s %s. All rights reserved. ', 'tastyc-plugin' ), date('Y'), '<a href="https://bslthemes.com/" target="_blank">bslthemes</a>' ); ?> </div> </div> </div> </div> <?php } } function tastyc_theme_dashboard_init() { return TastycThemeDashboard::instance(); } tastyc_theme_dashboard_init(); }