theme_domain.'-demo_content_imported')) { add_option($this->theme_domain.'-demo_content_imported', false); } } } /** * Registers dashboard page to WordPress admin */ function add_theme_page() { $actions = $this->get_recommended_actions(true, false); $count = $actions['no_alerts']; if ($count > 0) { $update_label = sprintf(_n('%1$s action required', '%1$s actions required', $count, 'bootstrap-coach'), $count); $count = " " . number_format_i18n($count) . ""; $menu_title = sprintf(esc_html__('Bootstrap Coach %s', 'bootstrap-coach'), $count); } else { $menu_title = esc_html__('Bootstrap Coach', 'bootstrap-coach'); } add_theme_page( esc_html__('Bootstrap Coach', 'bootstrap-coach'), $menu_title, 'edit_theme_options', $this->theme_domain, array($this, 'theme_page_content') ); } /** * Enqueue scripts for admin dashboard only */ function admin_scripts($hook) { if ($hook === 'appearance_page_'.$this->theme_domain) { $theme_directory_url = get_template_directory_uri(); // Dashboard styles wp_enqueue_style( 'bootstrapthemes-dashboard-css', $theme_directory_url . '/inc/admin/dashboard.css' ); // Recommended scripts for plugin install wp_enqueue_style('plugin-install'); wp_enqueue_script('plugin-install'); wp_enqueue_script('updates'); add_thickbox(); } } /** * Admin Dashboard content */ function theme_page_content() { $theme_data = wp_get_theme(); // Check for current viewing tab $tab = null; if (isset($_GET['tab'])) { $tab = sanitize_text_field($_GET['tab']); } else { $tab = null; } // Get recommended actions $actions = $this->get_recommended_actions(true, false); ?>

theme_name, $theme_data->Version); ?>

theme_desc); ?>
TheBootStrap
Themes

render_tab_content_get_started(); } else if ($tab == 'demo_import') { $this->render_tab_content_demo_import(); } else if ($tab == 'free_pro') { $this->render_tab_content_free_pro(); } ?>
required_plugins_generator(); foreach ($generator as $plugin) { // Ignore Demo Import plugin on the "Get started" tab if ($plugin['slug'] !== 'tbthemes-demo-import') { echo '
'; echo '

'; echo esc_html($plugin['name']); echo '

'; echo '

' . $plugin['button_txt'] . '

'; echo '' . esc_html__('Details', 'bootstrap-coach') . ''; echo '
'; } } } /** * Content of the tab "Get started" */ function render_tab_content_get_started() { $actions = $this->get_recommended_actions(true, false); $current_action_link = admin_url('themes.php?page='.$this->theme_domain); ?>

theme_name); ?>

render_required_plugins_get_started(); ?>
required_plugins_generator(); foreach ($generator as $plugin) { echo '
'; echo '

'; printf( esc_html__( 'To import a Demo site, you must first install and activate the %1$s plugin.', 'bootstrap-coach' ), '' . $plugin['name'] . '' ); echo '

'; echo '

' . $plugin['button_txt'] . '

'; echo '
'; } } /** * Content of the tab "Demo Import" */ function render_tab_content_demo_import() { $actions = $this->get_recommended_actions(false, true); ?>
render_required_plugins_demo_import(); } else { do_action('bootstrapthemes_demo_import_tab'); } ?>
theme_name;?> theme_name;?> Pro

Unlimited Colors

Google Fonts

Footer Copyright

Custom Offer Section

Benefit Section

Drag & Drop

Customer Support

theme_name); ?>
' . $this->theme_name . '', '★★★★★' ); return $footer_text; } /** * Get array of plugins required by the theme */ function get_required_plugins() { $required_plugins = get_theme_support('required-plugins'); if (is_array($required_plugins) && isset($required_plugins[0])) { $required_plugins = $required_plugins[0]; } else { $required_plugins[] = array(); } foreach ($required_plugins as $plugin) { $plugin = wp_parse_args($plugin, array( 'slug' => '', 'name' => '', 'active_filename' => '', )); if (!$plugin['active_filename']) { $plugin['active_filename'] = $plugin['slug'] . '/' . $plugin['slug'] . '.php'; } } return $required_plugins; } /** * Get actions recommended by the theme * * @param $ignore_demo_plugin - whether the Demo Import plugin should * be ignored in the actions * @param $ignore_demo_message - whether the Demo Import message should * be ignored in the actions * @return array */ function get_recommended_actions( $ignore_demo_plugin = false, $ignore_demo_message = false ) { $actions = array(); $actions['no_alerts'] = 0; // Required plugins $actions['required_plugins'] = false; $required_plugins = $this->get_required_plugins(); if (!empty($required_plugins)) { foreach ($required_plugins as $plugin) { // Ignore Demo Import plugin if desired if (!($plugin['slug'] === 'tbthemes-demo-import' && $ignore_demo_plugin)) { if (!is_plugin_active($plugin['active_filename'])) { $actions['required_plugins'] = true; $actions['no_alerts']++; } } } } // Demo import message $actions['demo_import'] = false; if (!$ignore_demo_message) { if (empty(get_option($this->theme_domain.'-demo_content_imported'))) { $actions['demo_import'] = true; $actions['no_alerts']++; } } return $actions; } /** * Generator yielding necessary information for rendering required plugins */ function required_plugins_generator() { $required_plugins = $this->get_required_plugins(); foreach ($required_plugins as $plugin) { $install_status = is_dir(WP_PLUGIN_DIR . '/' . $plugin['slug']); if (!is_plugin_active($plugin['active_filename'])) { if (!$install_status) { $install_url = wp_nonce_url( add_query_arg( array( 'action' => 'install-plugin', 'plugin' => $plugin['slug'] ), network_admin_url('update.php') ), 'install-plugin_' . $plugin['slug'] ); $button_class = 'install-now button'; $button_txt = esc_html__('Install Now', 'bootstrap-coach'); } else { $install_url = add_query_arg(array( 'action' => 'activate', 'plugin' => rawurlencode($plugin['active_filename']), 'plugin_status' => 'all', 'paged' => '1', '_wpnonce' => wp_create_nonce('activate-plugin_' . $plugin['active_filename']), ), network_admin_url('plugins.php')); $button_class = 'activate-now button-primary'; $button_txt = esc_html__('Activate Now', 'bootstrap-coach'); } $detail_link = add_query_arg( array( 'tab' => 'plugin-information', 'plugin' => $plugin['slug'], 'TB_iframe' => 'true', 'width' => '772', 'height' => '349', ), network_admin_url('plugin-install.php') ); yield array( 'slug' => $plugin['slug'], 'name' => $plugin['name'], 'active_filename' => $plugin['active_filename'], 'install_url' => $install_url, 'detail_link' => $detail_link, 'button_class' => $button_class, 'button_txt' => $button_txt ); } } } /** * Dismiss recommended actions */ function admin_dismiss_actions() { if (isset($_GET['dismiss_action'])) { $action = sanitize_text_field($_GET['dismiss_action']); if ($action === 'demo_import') { update_option($this->theme_domain.'-demo_content_imported', true); $url = wp_unslash($_SERVER['REQUEST_URI']); $url = remove_query_arg('dismiss_action', $url); wp_redirect($url); die(); } } } } } Bootstrap_Coach_Admin_Dashboard::get_instance()->init();