config = $config; self::$instance->setup_config(); self::$instance->setup_actions(); } } } /** * Setup theme information. */ public function setup_config() { $theme = wp_get_theme(); if ( is_child_theme() ) { if ( method_exists( $theme->parent(), 'get' ) ) { $this->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 = isset( $this->config['menu_name'] ) ? $this->config['menu_name'] : 'About ' . $this->theme_name; $this->page_name = isset( $this->config['page_name'] ) ? $this->config['page_name'] : 'About ' . $this->theme_name; $this->notification = isset( $this->config['notification'] ) ? $this->config['notification'] : ( apply_filters( 'tg_welcome_notice_filter', ( '
' . sprintf( 'Welcome! Thank you for choosing %1$s! To fully take advantage of the best our theme can offer please make sure you visit our %2$swelcome page%3$s.', $this->theme_name, '', '' ) . '
' . sprintf( 'Get started with %s', $this->theme_name ) . '
' ) ) ); $this->tabs = isset( $this->config['tabs'] ) ? $this->config['tabs'] : array(); } /** * Hooks. */ public function setup_actions() { add_action( 'admin_menu', array( $this, 'register' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) ); } /** * Add about page in admin. */ public function register() { if ( ! empty( $this->menu_name ) && ! empty( $this->page_name ) ) { $title = $this->page_name; add_theme_page( $this->menu_name, $title, 'activate_plugins', $this->theme_slug . '-about', array( $this, 'about_page_render', ) ); } } /** * Enqueue scripts. */ public function enqueue() { $current_screen = get_current_screen(); wp_enqueue_script( 'zakra-plugin-install-helper', ZAKRA_PARENT_INC_URI . '/admin/js/plugin-handle.js', array( 'jquery' ), ZAKRA_THEME_VERSION, true ); wp_localize_script( 'zakra-plugin-install-helper', 'zakra_plugin_helper', array( 'activating' => esc_html__( 'Activating ', 'zakra' ), ) ); if ( ! isset( $current_screen->id ) || ( 'appearance_page_' . $this->theme_slug . '-about' !== $current_screen->id ) ) { return; } wp_enqueue_style( 'zakra-about-page-css', get_template_directory_uri() . '/inc/admin/css/about-page.css', array(), ZAKRA_THEME_VERSION ); wp_enqueue_script( 'zakra-about-page-js', get_template_directory_uri() . '/inc/admin/js/about-page.js', array( 'jquery', 'jquery-ui-tabs', ), ZAKRA_THEME_VERSION, true ); wp_enqueue_script( 'updates' ); wp_localize_script( 'zakra-about-page-js', 'zakraAboutPageObject', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'template_directory' => get_template_directory_uri(), 'activating_string' => esc_html__( 'Activating', 'zakra' ), ) ); } /** * Render HTML contents for about page. */ public function about_page_render() { $this->render_header(); $this->render_tabs(); } /** * Render header part. */ private function render_header() { if ( ! empty( $this->config['welcome_title'] ) ) { $title = $this->config['welcome_title']; } if ( ! empty( $this->config['welcome_content'] ) ) { $content = $this->config['welcome_content']; } if ( empty( $title ) && empty( $content ) ) { return; } echo ''; if ( isset( $getting_started_item['install_button'] ) && true === $getting_started_item['install_button'] ) { ?>
' . esc_html( $support_item['text'] ) . '
'; } if ( ! empty( $support_item['button_link'] ) && ! empty( $support_item['button_label'] ) ) { echo ''; if ( isset( $support_item['install_button'] ) && true === $support_item['install_button'] ) { echo Zakra_Plugin_Install_Helper::instance()->get_button_html( $support_item['button_link'] ); // WPCS: XSS OK. } else { $this->display_button( $support_item ); } echo '
'; } echo '