my_theme = wp_get_theme(); // Get theme data object. if ( 'Ascend' === $this->my_theme->get( 'Name' ) || 'ascend' === $this->my_theme->get( 'Template' ) ) { $this->theme_name = 'Ascend'; $this->theme_title = 'Ascend Theme'; } elseif ( 'Virtue' === $this->my_theme->get( 'Name' ) || 'virtue' === $this->my_theme->get( 'Template' ) ) { $this->theme_name = 'Virtue'; $this->theme_title = 'Virtue Theme'; } elseif ( 'Pinnacle' === $this->my_theme->get( 'Name' ) || 'pinnacle' === $this->my_theme->get( 'Template' ) ) { $this->theme_name = 'Pinnacle'; $this->theme_title = 'Pinnacle Theme'; } else { $this->theme_name = 'Not Kadence'; $this->theme_title = 'Not Kadence'; } if ( 'Not Kadence' !== $this->theme_name ) { add_action( 'admin_menu', array( $this, 'add_menu' ) ); add_action( 'tgmpa_register', array( $this, 'register_importer' ), 30 ); add_filter( 'plugin_action_links_virtue-toolkit/virtue_toolkit.php', array( $this, 'add_settings_link' ) ); } add_action( 'wp_ajax_kadence_import_plugin', array( $this, 'ajax_install_import_plugin' ), 10, 0 ); add_action( 'admin_init', array( $this, 'load_tgmpa_installer' ), 1 ); } } /** * Load Installer */ public function load_tgmpa_installer() { if ( class_exists( 'TGM_Plugin_Activation' ) ) { $this->tgmpa = isset( $GLOBALS['tgmpa'] ) ? $GLOBALS['tgmpa'] : TGM_Plugin_Activation::get_instance(); } } /** * Add option page menu */ public function add_menu() { $page = add_theme_page( __( 'Getting Started with: ', 'virtue-toolkit' ) . $this->theme_name, esc_html__( 'Getting Started', 'virtue-toolkit' ), 'manage_options', 'kadence_welcome_page', array( $this, 'config_page' ) ); add_action( 'admin_print_styles-' . $page, array( $this, 'css_scripts' ) ); } /** * Loads admin style sheets */ public function css_scripts() { wp_enqueue_style( 'toolkit-welcome-css', VIRTUE_TOOLKIT_URL . '/welcome/toolkit-welcome.css', array(), $this->version, 'all' ); wp_enqueue_script( 'toolkit-welcome-js', VIRTUE_TOOLKIT_URL . '/welcome/toolkit-welcome.js', array( 'jquery' ), $this->version, true ); wp_localize_script( 'toolkit-welcome-js', 'toolkit_welcome_params', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'wpnonce' => wp_create_nonce( 'install-plugin_kadence-importer' ), ) ); } /** * Loads config page */ public function config_page() { if ( 'Not Kadence' === $this->theme_name ) { ?>

' . esc_html( $this->theme_title ) . '' ); ?>

array( 'slug' => 'woocommerce', 'base' => 'woocommerce', 'plugin_check' => 'woocommerce/woocommerce.php', 'active_url' => admin_url( 'admin.php?page=wc-settings' ), 'action_title' => __( 'WooCommerce Settings', 'virtue-toolkit' ), 'name' => 'WooCommerce', 'desc' => 'WooCommerce is a free eCommerce plugin that allows you to sell anything, beautifully. Built to integrate seamlessly with WordPress.', 'image' => esc_url( VIRTUE_TOOLKIT_URL . 'welcome/images/woo_logo.jpg' ), 'author' => 'Automattic', 'redirect_url' => '', ), 'wpforms-lite' => array( 'slug' => 'wpforms-lite', 'base' => 'wpforms', 'plugin_check' => 'wpforms-lite/wpforms.php', 'active_url' => admin_url( 'admin.php?page=wc-settings' ), 'action_title' => __( 'WPForms Settings', 'virtue-toolkit' ), 'name' => 'Contact Form by WPForms', 'desc' => 'A Drag & Drop Form Builder for WordPress, you can manage multiple contact forms, customize the form a with builder tools.', 'image' => esc_url( VIRTUE_TOOLKIT_URL . 'welcome/images/wpforms_logo.jpg' ), 'author' => 'WPForms', 'redirect_url' => '', ), 'wordpress-seo' => array( 'slug' => 'wordpress-seo', 'base' => 'wp-seo', 'plugin_check' => 'wordpress-seo/wp-seo.php', 'active_url' => admin_url( 'admin.php?page=wpseo_dashboard' ), 'action_title' => __( 'Yoast SEO Settings', 'virtue-toolkit' ), 'name' => 'Yoast SEO', 'desc' => 'Improve your WordPress SEO: Write better content and have a fully optimized WordPress site using Yoast SEO plugin.', 'image' => esc_url( VIRTUE_TOOLKIT_URL . 'welcome/images/ws_logo.jpg' ), 'author' => 'Yoast', 'redirect_url' => '', ), ); $installed_plugins = get_plugins(); foreach ( $suggested as $plugin ) { if ( is_plugin_active( $plugin['plugin_check'] ) ) { $action = $plugin['active_url']; $action_title = $plugin['action_title']; $activated = esc_html__( 'Activated', 'virtue-toolkit' ); $activated_class = 'activated plugin-active'; $class = ''; $data_action = ''; $redirect_url = $plugin['redirect_url']; $install_link = ''; $activation_link = ''; } elseif ( isset( $installed_plugins[ $plugin['plugin_check'] ] ) ) { $data_action = 'activate'; $install_link = ''; $activate_nonce = wp_create_nonce( 'activate-plugin_' . $plugin['plugin_check'] ); $activation_link = self_admin_url( 'plugins.php?_wpnonce=' . $activate_nonce . '&action=activate&plugin=' . esc_attr( $plugin['slug'] ) . '%2F' . esc_attr( $plugin['base'] ) . '.php' ); $action_title = esc_html__( 'Activate', 'virtue-toolkit' ) . ' ' . $plugin['name']; $activated_class = 'activated plugin-installed'; $activated = esc_html__( 'Installed', 'virtue-toolkit' ); $class = 'kt-trigger-plugin-install'; $action = '#'; $redirect_url = $plugin['redirect_url']; } else { $install_link = wp_nonce_url( add_query_arg( array( 'action' => 'install-plugin', 'plugin' => $plugin['slug'], ), network_admin_url( 'update.php' ) ), 'install-plugin_' . $plugin['slug'] ); $redirect_url = $plugin['redirect_url']; $activate_nonce = wp_create_nonce( 'activate-plugin_' . $plugin['plugin_check'] ); $activation_link = self_admin_url( 'plugins.php?_wpnonce=' . $activate_nonce . '&action=activate&plugin=' . esc_attr( $plugin['slug'] ) . '%2F' . esc_attr( $plugin['base'] ) . '.php' ); $action = '#'; $action_title = esc_html__( 'Install', 'virtue-toolkit' ) . ' ' . $plugin['name']; $activated = esc_html__( 'Not Installed', 'virtue-toolkit' ); $activated_class = 'activated plugin-not-installed'; $class = 'kt-trigger-plugin-install'; $data_action = 'install'; } $output[ $plugin['slug'] ] = array( 'image' => $plugin['image'], 'name' => $plugin['name'], 'author' => $plugin['author'], 'desc' => $plugin['desc'], 'action' => $action, 'action_title' => $action_title, 'activated' => $activated, 'activated_cs' => $activated_class, 'data_action' => $data_action, 'install_link' => $install_link, 'activation_link' => $activation_link, 'redirect_url' => $redirect_url, 'class' => $class, ); } return $output; } /** * Get array of suggested page builders. */ public function suggested_builder_plugins() { $suggested = array( 'elementor' => array( 'slug' => 'elementor', 'base' => 'elementor', 'plugin_check' => 'elementor/elementor.php', 'active_url' => admin_url( 'admin.php?page=elementor' ), 'redirect_url' => admin_url( 'admin.php?page=elementor' ), 'name' => 'Elementor Page Builder', 'desc' => 'A free front-end page builder with tons of ready-made content you can easily use. Elementor offers very powerful features and can create an incredible range of designs while giving great mobile specific editing. A pro extension is available which adds even more features.', 'pros' => '
  • Fully functional as a free plugin
  • Good user base with lots of extensions
  • Tons of pre-built content
  • Mobile previews and responsive design controls.
  • ', 'cons' => '
  • For some it can be overwhelming to learn, certain elements can be confusing.
  • While you don\'t need the pro extension, you may get annoyed seeing things it can do or demos it can install that you would have to pay to use.
  • ', 'image' => VIRTUE_TOOLKIT_URL . 'welcome/images/toolkit_ele.jpg', 'author' => 'elementor.com', 'action_title' => __( 'Elementor Settings', 'virtue-toolkit' ), ), 'brizy' => array( 'slug' => 'brizy', 'base' => 'brizy', 'plugin_check' => 'brizy/brizy.php', 'active_url' => admin_url( 'admin.php?page=brizy-settings' ), 'redirect_url' => admin_url( 'admin.php?page=brizy-settings' ), 'name' => 'Brizy – Page Builder', 'desc' => 'A free front-end page builder that is lighting fast and intuitive to use. Brizy offers powerful features with an app like feel. The editor is very clutter-free with a lot of features not found in other builders. A pro extension is availible which adds even more features.', 'pros' => '
  • Fully functional as a free plugin
  • Very fast and for many intuitive to use.
  • Features only found with brizy, like global linked colors and fonts or 4k icons
  • ', 'cons' => '
  • Early in development and so does not have the following or backing of tons of users.
  • Very little documentation or tutorials so far.
  • No extensions for it.
  • Missing some features.
  • ', 'image' => VIRTUE_TOOLKIT_URL . 'welcome/images/toolkit_brizy.jpg', 'author' => 'brizy.co', 'action_title' => __( 'Brizy Settings', 'virtue-toolkit' ), ), 'siteorigin-panels' => array( 'slug' => 'siteorigin-panels', 'base' => 'siteorigin-panels', 'plugin_check' => 'siteorigin-panels/siteorigin-panels.php', 'active_url' => admin_url( 'options-general.php?page=siteorigin_panels' ), 'redirect_url' => admin_url( 'options-general.php?page=siteorigin_panels' ), 'name' => 'Page Builder by SiteOrigin', 'desc' => 'A Free drag and drop, page builder that simplifies building your website using tools that will feel familiar if you have worked in WordPress. While there is a "live editor" mode it does not really compete with the other page builders for real front-end editing. But the developers have plans to improve Gutenberg with it\'s features which could make Gutenberg much more useful.', 'pros' => '
  • Fully functional as a free plugin
  • Widely popular with tons of free add on widgets
  • Stable with years of solid development behind it.
  • ', 'cons' => '
  • Not as user friendly as front-end builders
  • Slower editing experience
  • Not a lot of new features being developed.
  • ', 'image' => VIRTUE_TOOLKIT_URL . 'welcome/images/toolkit_siteorigin.jpg', 'author' => 'SiteOrigin', 'action_title' => __( 'SiteOrigin Page Builder Settings', 'virtue-toolkit' ), ), ); $installed_plugins = get_plugins(); foreach ( $suggested as $plugin ) { if ( is_plugin_active( $plugin['plugin_check'] ) ) { $action = $plugin['active_url']; $action_title = $plugin['action_title']; $activated = esc_html__( 'Activated', 'virtue-toolkit' ); $activated_class = 'activated plugin-active'; $class = ''; $data_action = ''; $redirect_url = $plugin['redirect_url']; $install_link = ''; $activation_link = ''; } elseif ( isset( $installed_plugins[ $plugin['plugin_check'] ] ) ) { $data_action = 'activate'; $install_link = ''; $activate_nonce = wp_create_nonce( 'activate-plugin_' . $plugin['plugin_check'] ); $activation_link = self_admin_url( 'plugins.php?_wpnonce=' . $activate_nonce . '&action=activate&plugin=' . esc_attr( $plugin['slug'] ) . '%2F' . esc_attr( $plugin['slug'] ) . '.php' ); $action_title = esc_html__( 'Activate', 'virtue-toolkit' ) . ' ' . $plugin['name']; $activated_class = 'activated plugin-installed'; $activated = esc_html__( 'Installed', 'virtue-toolkit' ); $class = 'kt-trigger-plugin-install'; $action = '#'; $redirect_url = $plugin['redirect_url']; } else { $install_link = wp_nonce_url( add_query_arg( array( 'action' => 'install-plugin', 'plugin' => $plugin['slug'], ), network_admin_url( 'update.php' ) ), 'install-plugin_' . $plugin['slug'] ); $redirect_url = $plugin['redirect_url']; $activate_nonce = wp_create_nonce( 'activate-plugin_' . $plugin['plugin_check'] ); $activation_link = self_admin_url( 'plugins.php?_wpnonce=' . $activate_nonce . '&action=activate&plugin=' . esc_attr( $plugin['slug'] ) . '%2F' . esc_attr( $plugin['slug'] ) . '.php' ); $action = '#'; $action_title = esc_html__( 'Install', 'virtue-toolkit' ) . ' ' . $plugin['name']; $activated = esc_html__( 'Not Installed', 'virtue-toolkit' ); $activated_class = 'activated plugin-not-installed'; $class = 'kt-trigger-plugin-install'; $data_action = 'install'; } $output[ $plugin['slug'] ] = array( 'image' => $plugin['image'], 'name' => $plugin['name'], 'author' => $plugin['author'], 'desc' => $plugin['desc'], 'pros' => $plugin['pros'], 'cons' => $plugin['cons'], 'action' => $action, 'action_title' => $action_title, 'activated' => $activated, 'activated_cs' => $activated_class, 'data_action' => $data_action, 'install_link' => $install_link, 'activation_link' => $activation_link, 'redirect_url' => $redirect_url, 'class' => $class, ); } return $output; } /** * Register_importer */ public function register_importer() { $plugins = array(); $plugins[] = array( 'name' => 'Kadence Importer', 'slug' => 'kadence-importer', 'source' => 'http://download.kadencethemes.com/importer/kadence-importer.zip', 'required' => false, 'version' => '2.0.3', 'force_activation' => false, 'force_deactivation' => false, 'external_url' => '', ); $config = array( 'domain' => 'virtue-toolkit', // Text domain - likely want to be the same as your theme. 'default_path' => '', // Default absolute path to pre-packaged plugins 'parent_slug' => 'themes.php', // Parent menu slug. 'menu' => 'install-recommended-plugins', // Menu slug 'has_notices' => false, // Show admin notices or not 'is_automatic' => false, // Automatically activate plugins after installation or not 'message' => '', // Message to output right before the plugins table. 'strings' => array( 'page_title' => __( 'Install Recommended Plugins', 'virtue-toolkit' ), 'menu_title' => __( 'Theme Plugins', 'virtue-toolkit' ), 'installing' => __( 'Installing Plugin: %s', 'virtue-toolkit' ), // %1$s = plugin name 'oops' => __( 'Something went wrong with the plugin API.', 'virtue-toolkit' ), 'notice_can_install_required' => _n_noop( 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.', 'virtue-toolkit' ), // %1$s = plugin name(s) 'notice_can_install_recommended' => _n_noop( 'This theme comes packaged with the following premium plugin: %1$s. Plugin is not required, but suggested.', 'This theme comes packaged with the following premium plugins: %1$s. Plugins are not required, but suggested.', 'virtue-toolkit' ), // %1$s = plugin name(s) 'notice_cannot_install' => _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.', 'virtue-toolkit' ), // %1$s = plugin name(s) 'notice_can_activate_required' => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.' , 'virtue-toolkit'), // %1$s = plugin name(s) 'notice_can_activate_recommended' => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.' , 'virtue-toolkit'), // %1$s = plugin name(s) 'notice_cannot_activate' => _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.', 'virtue-toolkit' ), // %1$s = plugin name(s) 'notice_ask_to_update' => _n_noop( 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.' , 'virtue-toolkit'), // %1$s = plugin name(s) 'notice_cannot_update' => _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.' , 'virtue-toolkit'), // %1$s = plugin name(s) 'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins', 'virtue-toolkit' ), 'activate_link' => _n_noop( 'Activate installed plugin', 'Activate installed plugins', 'virtue-toolkit' ), 'return' => __( 'Return to recommended Plugins Installer', 'virtue-toolkit' ), 'plugin_activated' => __( 'Plugin activated successfully.', 'virtue-toolkit' ), 'complete' => __( 'All plugins installed and activated successfully. %s', 'virtue-toolkit' ), // %1$s = dashboard link 'nag_type' => 'updated' // Determines admin notice type - can only be 'updated' or 'error'. ), ); if( 'Not Kadence' !== $this->theme_name ) { tgmpa( $plugins, $config ); } } /** * add settings link */ public function add_settings_link( $links ) { $settings_link = '' . __( 'Settings', 'virtue-toolkit' ) . ''; array_push( $links, $settings_link ); return $links; } /** * Install Importer */ public function ajax_install_import_plugin() { if ( ! check_ajax_referer( 'install-plugin_kadence-importer', 'wpnonce' ) ) { exit( 0 ); } $tgmpa_url = $this->tgmpa->get_tgmpa_url(); $json = array( 'url' => admin_url( 'themes.php?page=install-recommended-plugins' ), 'plugin' => array( 'kadence-importer' ), 'tgmpa-page' => 'install-recommended-plugins', 'plugin_status' => 'all', '_wpnonce' => wp_create_nonce( 'bulk-plugins' ), 'action' => 'tgmpa-bulk-install', 'action2' => - 1, 'message' => esc_html__( 'Installing', 'virtue-toolkit' ), ); wp_send_json( $json ); } } } new Virtue_Toolkit_Welcome();