config = $config; self::$instance->krystal_setup_config(); self::$instance->krystal_setup_actions(); } } /** * Setup the class props based on the config array. */ public function krystal_setup_config() { $theme = wp_get_theme(); if ( is_child_theme() ) { $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->notification = isset( $this->config['notification'] ) ? $this->config['notification'] : ( '

' . sprintf( 'Welcome! Thank you for choosing %1$s ! To take full advantage of this theme, please make sure you visit our %2$swelcome page%3$s.', $this->theme_name, '', '' ) . '

' . sprintf( 'Get started with %s', $this->theme_name ) . '

' ); } /** * Setup the actions used for this page. */ public function krystal_setup_actions() { /* activation notice */ add_action( 'load-themes.php', array( $this, 'krystal_activation_admin_notice' ) ); } /** * Adds an admin notice upon successful activation. */ public function krystal_activation_admin_notice() { global $pagenow; if ( is_admin() && ( 'themes.php' == $pagenow ) && isset( $_GET['activated'] ) ) { add_action( 'admin_notices', array( $this, 'krystal_about_page_welcome_admin_notice' ), 99 ); } } /** * Display an admin notice linking to the about page */ public function krystal_about_page_welcome_admin_notice() { if ( ! empty( $this->notification ) ) { echo '
'; echo wp_kses_post( $this->notification ); echo '
'; } } } } /** * Adding a About Krystal page */ add_action('admin_menu', 'krystal_add_menu'); function krystal_add_menu() { add_theme_page(__('About Krystal Theme','krystal'), __('About Krystal','krystal'),'manage_options', __('krystal-theme-info','krystal'), __('krystal_theme_info','krystal')); } /** * Callback */ function krystal_theme_info() { ?>