theme_name = $theme->parent()->get( 'Name' ); $this->theme = $theme->parent(); } else { $this->theme_name = $theme->get( 'Name' ); $this->theme = $theme->parent(); } $this->theme_version = $theme->get( 'Version' ); $this->theme_slug = $theme->get_template(); $this->menu_name = sprintf( esc_html__( '%s', 'aytias' ), $this->theme_name ); $this->page_name = sprintf( esc_html__( '%s', 'aytias' ), $this->theme_name ); $this->page_slug = $this->theme_slug . '-welcome'; if ( current_user_can( 'manage_options' ) ) { add_action( 'admin_menu', array( $this, 'add_menu' ) ); add_action( 'admin_bar_menu', array( $this, 'add_bar_menu' ), 999 ); } add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); add_action( 'admin_init', array( $this, 'redirect' ) ); } /** * Add theme dashboard page. * * @since 1.0.0 */ public function add_menu() { add_theme_page( $this->menu_name, $this->page_name, 'manage_options', $this->page_slug, array( $this, 'render_main_page') ); } /** * Add link in menu bar * * @since 1.0.0 */ public function add_bar_menu() { global $wp_admin_bar; if ( ! is_super_admin() || ! is_admin_bar_showing() ) { return; } $wp_admin_bar->add_menu( array( 'parent' => 'site-name', 'id' => $this->page_slug, 'title' => $this->theme_name, 'href' => admin_url( "admin.php?page=$this->page_slug" ) ) ); } /** * Dashboard Page * * @since 1.0.0 */ public function render_main_page() { ?>

theme_name ); ?> - theme_version ); ?>

{$method}(); } else { printf( esc_html__( '%s() method does not exist.', 'aytias' ), $method ); } ?>
get_tgmpa_url(); $tgmpa_complete = $tgmpa->is_tgmpa_complete(); } ?>

get_tgmpa_url(); $tgmpa_complete = $tgmpa->is_tgmpa_complete(); $plugins = $tgmpa->plugins; ?>

page_slug", "appearance_page_$this->page_slug", ); if ( in_array( $hook, $valid_pages, true ) ) { wp_enqueue_media(); wp_enqueue_style( "aytias-dashboard-style", get_template_directory_uri() . '/inc/dashboard/css/style.css', array(), $this->theme_version ); wp_enqueue_script( "aytias-dashboard-script", get_template_directory_uri() . '/inc/dashboard/js/script.js', array( 'jquery' ), $this->theme_version, true ); $localize_script = array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'ajax-nonce' ), 'domain' => get_home_url( '/' ) ); wp_localize_script( "aytias-dashboard-script", 'UNFOLDDASHBOARD', $localize_script ); } } /** * Redirect to dashboard page after theme activation. * * @since 1.0.0 */ public function redirect() { global $pagenow; if ( is_admin() && isset( $_GET['activated'] ) && 'themes.php' === $pagenow ) { wp_safe_redirect( admin_url( "themes.php?page=$this->page_slug" ) ); exit; } } } }