config = $config; self::$instance->setup_config(); self::$instance->setup_actions(); } } } /** * Setup the class props based on the config array. */ public function setup_config() { $theme = wp_get_theme(); if ( is_child_theme() && is_object( $theme->parent() ) ) { $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'] : ( '
' . 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(); } /** * Setup the actions used for this page. */ public function setup_actions() { add_action( 'admin_menu', array( $this, 'register' ) ); /* activation notice */ add_action( 'load-themes.php', array( $this, 'activation_admin_notice' ) ); /* enqueue script and style for about page */ add_action( 'admin_enqueue_scripts', array( $this, 'style_and_scripts' ) ); /* ajax callback for dismissable required actions */ add_action( 'wp_ajax_ti_about_page_dismiss_required_action', array( $this, 'dismiss_required_action_callback' ) ); add_action( 'wp_ajax_nopriv_ti_about_page_dismiss_required_action', array( $this, 'dismiss_required_action_callback') ); } /** * Hide required tab if no actions present. * * @return bool Either hide the tab or not. */ public function hide_required( $value, $tab ) { if ( $tab != 'recommended_actions' ) { return $value; } $required = $this->get_required_actions(); if ( count( $required ) == 0 ) { return false; } else { return true; } } /** * Register the menu page under Appearance menu. */ function register() { if ( ! empty( $this->menu_name ) && ! empty( $this->page_name ) ) { $count = 0; $actions_count = $this->get_required_actions(); if ( ! empty( $actions_count ) ) { $count = count( $actions_count ); } $title = $count > 0 ? $this->page_name . '' . esc_html( $count ) . '' : $this->page_name; add_theme_page( $this->menu_name, $title, 'activate_plugins', $this->theme_slug . '-welcome', array( $this, 'about_page_render', ) ); } } /** * Adds an admin notice upon successful activation. */ public function activation_admin_notice() { global $pagenow; if ( is_admin() && ( 'themes.php' == $pagenow ) && isset( $_GET['activated'] ) ) { add_action( 'admin_notices', array( $this, 'welcome_admin_notice' ), 99 ); } } /** * Display an admin notice linking to the about page */ public function welcome_admin_notice() { if ( ! empty( $this->notification ) ) { echo '' . esc_html( $getting_started_item['text'] ). '
'; } if ( ! empty( $getting_started_item['button_link'] ) && ! empty( $getting_started_item['button_label'] ) ) { echo ''; $button_class = ''; if ( $getting_started_item['is_button'] ) { $button_class = 'button button-primary'; } $count = 0; $actions_count = $this->get_required_actions(); if ( ! empty( $actions_count ) ) { $count = count( $actions_count ); } if ( $getting_started_item['recommended_actions'] && isset( $count ) ) { if ( $count == 0 ) { echo ''; echo ''; } else { echo ''; $button_new_tab = '_self'; if ( isset( $getting_started_item['is_new_tab'] ) ) { if ( $getting_started_item['is_new_tab'] ) { $button_new_tab = '_blank'; } } echo '' .esc_html( $getting_started_item['button_label'] ) . ''; } } else { $button_new_tab = '_self'; if ( isset( $getting_started_item['is_new_tab'] ) ) { if ( $getting_started_item['is_new_tab'] ) { $button_new_tab = '_blank'; } } echo '' . esc_html( $getting_started_item['button_label'] ) . ''; } echo '
'; } echo '' . wp_kses_post( $action_value['description'] ) . '
'; } if ( ! empty( $action_value['plugin_slug'] ) ) { $active = $this->check_if_plugin_active( $action_value['plugin_slug'] ); $url = $this->create_action_link( $active['needs'], $action_value['plugin_slug'] ); $label = ''; switch ( $active['needs'] ) { case 'install': $class = 'install-now button'; if ( ! empty( $this->config['recommended_actions']['install_label'] ) ) { $label = $this->config['recommended_actions']['install_label']; } break; case 'activate': $class = 'activate-now button button-primary'; if ( ! empty( $this->config['recommended_actions']['activate_label'] ) ) { $label = $this->config['recommended_actions']['activate_label']; } break; case 'deactivate': $class = 'deactivate-now button'; if ( ! empty( $this->config['recommended_actions']['deactivate_label'] ) ) { $label = $this->config['recommended_actions']['deactivate_label']; } break; } ?> '; } } echo '' . esc_html( $support_step['text'] ) . '
'; } if ( ! empty( $support_step['button_link'] ) && ! empty( $support_step['button_label'] ) ) { echo ''; $button_class = ''; if ( $support_step['is_button'] ) { $button_class = 'button button-primary'; } $button_new_tab = '_self'; if ( isset( $support_step['is_new_tab'] ) ) { if ( $support_step['is_new_tab'] ) { $button_new_tab = '_blank'; } } echo '' . esc_html( $support_step['button_label'] ) . ''; echo '
'; } echo '| '; echo ' | ' . esc_html( $free_pro['free_theme_name'] ) . ' | '; echo '' . esc_html( $free_pro['pro_theme_name'] ) . ' | '; echo '||
|---|---|---|---|---|
';
if ( ! empty( $feature['title'] ) ) {
echo '' . wp_kses_post( $feature['title'] ) . ''; } if ( ! empty( $feature['description'] ) ) { echo '' . wp_kses_post( $feature['description'] ) . ' '; } echo ' | ';
}
if ( ! empty( $feature['is_in_lite'] ) && ( $feature['is_in_lite'] == 'true' ) ) {
echo ''; } else { echo ' | '; } if ( ! empty( $feature['is_in_pro'] ) && ( $feature['is_in_pro'] == 'true' ) ) { echo ' | '; } else { echo ' | '; } echo ' |
| '; echo ' | ' . wp_kses_post( $free_pro['get_pro_theme_label'] ) . ' | '; echo '|||