'ikreate-demo-importer', 'name' => 'Ikreate Demo Importer', 'source' => 'https://ikreatethemes.com/ikreate-demo-importer.zip' ); /** * @var Businessroy_Demo_Importer * * @since 1.0.0 */ private $plugin = null; /** * Redirect. * * @param $url * * @since 1.0.0 * */ private static function businessroy_redirect( $url ) { if ( headers_sent() ) { echo ""; } else { wp_redirect( $url ); } exit(); } /** * Constructor for the Welcome Screen */ public function __construct() { /** Useful Variables */ $theme = wp_get_theme(); $this->theme_name = $theme->Name; $this->theme_version = $theme->Version; /** Define Tabs Sections */ $this->tab_sections = array( 'getting_started' => 'Getting Started', 'recommended_plugins' => 'Recommended Plugins', 'support' => 'Support', 'free_vs_pro' => 'Free Vs Pro' ); /** List of Recommended Free Plugins **/ $this->free_plugins = array( 'elementor' => array( 'name' => 'Elementor Page Builder', 'slug' => 'elementor', 'filename' => 'elementor', 'thumb_path' => 'https://ps.w.org/elementor/assets/icon-256x256.gif' ), 'contact-form-7' => array( 'name' => 'Contact Form 7', 'slug' => 'contact-form-7', 'filename' => 'contact-form-7', 'thumb_path' => 'https://ps.w.org/contact-form-7/assets/icon.svg' ), 'menu-icons' => array( 'name' => 'Menu Icons', 'slug' => 'menu-icons', 'filename' => 'menu-icons', 'thumb_path' => 'https://ps.w.org/menu-icons/assets/icon-128x128.png' ), 'loco-translate' => array( 'name' => 'Loco Translate', 'slug' => 'loco-translate', 'filename' => 'loco-translate', 'thumb_path' => 'https://ps.w.org/loco-translate/assets/icon-256x256.png' ), 'hash-form' => array( 'name' => 'Hash Form(Drag & Drop)', 'slug' => 'hash-form', 'filename' => 'hash-form', 'thumb_path' => 'https://ps.w.org/hash-form/assets/icon-256x256.gif' ), 'cookie-law-info' => array( 'name' => 'CookieYes(GDPR/CCPA)', 'slug' => 'cookie-law-info', 'filename' => 'cookie-law-info', 'thumb_path' => 'https://plugins.svn.wordpress.org/cookie-law-info/assets/icon-256x256.png' ) ); /* Create a Welcome Page */ add_action('admin_menu', array($this, 'welcome_register_menu')); /* Enqueue Styles & Scripts for Welcome Page */ add_action('admin_enqueue_scripts', array($this, 'welcome_styles_and_scripts')); /* Adds Footer Rating Text */ add_filter('admin_footer_text', array($this, 'admin_footer_text')); /* Hide Notice */ add_filter('wp_loaded', array($this, 'hide_admin_notice'), 10); /* Create a Welcome Page */ add_action('wp_loaded', array($this, 'admin_notice'), 20); add_action('after_switch_theme', array($this, 'erase_hide_notice')); add_action('wp_ajax_businessroy_activate_plugin', array($this, 'activate_plugin')); add_action( 'wp_ajax_thim_core_installer', array( $this, 'businessroy_ajax_install' ) ); add_action( 'businessroy_installer_step_start', array( $this, 'businessroy_prepare_installation' ) ); add_action( 'businessroy_installer_step_install', array( $this, 'businessroy_step_install' ) ); add_action( 'businessroy_installer_step_activate', array( $this, 'businessroy_step_activate' ) ); } /** Trigger Welcome Message Notification */ public function admin_notice($hook) { $hide_notice = get_option('businessroy_hide_notice'); if (!$hide_notice) { add_action('admin_notices', array($this, 'admin_notice_content')); } } /** Welcome Message Notification */ public function admin_notice_content() { $screen = get_current_screen(); if ('appearance_page_businessroy-welcome' === $screen->id || (isset($screen->parent_file) && 'plugins.php' === $screen->parent_file && 'update' === $screen->id) || 'theme-install' === $screen->id) { return; } $slug = $filename = 'elementor'; ?>

theme_name); ?>

<?php echo esc_attr__('Business Roy Demo', 'business-roy'); ?>

businessroy_setup_content(); ?>

theme_name); ?>

tab_sections; ?>
esc_html__('Installing Demo Importer Plugin', 'business-roy'), 'activating_text' => esc_html__('Activating Demo Importer Plugin', 'business-roy'), 'importer_page' => esc_html__('Go to Demo Importer Page', 'business-roy'), 'importer_url' => admin_url('themes.php?page=elementor'), 'error' => esc_html__('Error! Reload the page and try again.', 'business-roy'), ); wp_enqueue_style('businessroy-welcome', get_template_directory_uri() . '/inc/welcome/css/welcome.css', array()); wp_enqueue_script('businessroy-welcome', get_template_directory_uri() . '/inc/welcome/js/welcome.js', array('plugin-install', 'updates'), '', true); wp_localize_script('businessroy-welcome', 'importer_params', $importer_params); } } /* Check if plugin is installed */ public function check_plugin_installed_state($slug, $filename) { return file_exists(ABSPATH . 'wp-content/plugins/' . $slug . '/' . $filename . '.php') ? true : false; } /* Check if plugin is activated */ public function check_plugin_active_state($slug, $filename) { return is_plugin_active($slug . '/' . $filename . '.php') ? true : false; } /** Generate Url for the Plugin Button */ public function plugin_generate_url($status, $slug, $file_name) { switch ($status) { case 'install': return wp_nonce_url(add_query_arg(array( 'action' => 'install-plugin', 'plugin' => esc_attr($slug) ), network_admin_url('update.php')), 'install-plugin_' . esc_attr($slug)); break; case 'inactive': return add_query_arg(array( 'action' => 'deactivate', 'plugin' => rawurlencode(esc_attr($slug) . '/' . esc_attr($file_name) . '.php'), 'plugin_status' => 'all', 'paged' => '1', '_wpnonce' => wp_create_nonce('deactivate-plugin_' . esc_attr($slug) . '/' . esc_attr($file_name) . '.php'), ), network_admin_url('plugins.php')); break; case 'active': return add_query_arg(array( 'action' => 'activate', 'plugin' => rawurlencode(esc_attr($slug) . '/' . esc_attr($file_name) . '.php'), 'plugin_status' => 'all', 'paged' => '1', '_wpnonce' => wp_create_nonce('activate-plugin_' . esc_attr($slug) . '/' . esc_attr($file_name) . '.php'), ), network_admin_url('plugins.php')); break; } } /** Ajax Plugin Activation */ public function activate_plugin() { $slug = isset($_POST['slug']) ? $_POST['slug'] : ''; $file = isset($_POST['file']) ? $_POST['file'] : ''; $success = false; if (!empty($slug) && !empty($file)) { //patterns-plugin-activate //activate_plugin('patterns-kit/plugins.php'); $result = activate_plugin($slug . '/' . $file . '.php'); update_option('businessroy_hide_notice', true); if (!is_wp_error($result)) { $success = true; } } echo wp_json_encode(array('success' => $success)); die(); } /** Adds Footer Notes */ public function admin_footer_text($text) { $screen = get_current_screen(); if ('toplevel_page_businessroy-welcome' == $screen->id) { $text = sprintf(esc_html__('Please leave us a %s rating if you like our theme . A huge thank you from ikreate themes in advance!', 'business-roy'), '★★★★★'); } return $text; } public function erase_hide_notice() { delete_option('businessroy_hide_notice'); } private function businessroy_get_thim_core() { if ( $this->plugin === null ) { $plugin = new businessroy_Plugin(); $plugin->set_args( $this->package ); $this->plugin = $plugin; } return $this->plugin; } private function businessroy_get_link_step( $step = '' ) { return add_query_arg( array( 'step' => $step ) ); } public function businessroy_ajax_install() { $plugin = $this->businessroy_get_thim_core(); $result = $plugin->install(); if ( ! $result ) { wp_send_json_error( $plugin->get_messages() ); } wp_send_json_success( $plugin->get_messages() ); } private function businessroy_setup_content() { $thim_core = $this->businessroy_get_thim_core(); $status = $thim_core->get_status(); $step = isset( $_REQUEST['step'] ) ? $_REQUEST['step'] : 'start'; do_action( "businessroy_installer_step_$step" ); } /** * Prepare installation Thim Core. * * @since 1.0.0 */ public function businessroy_prepare_installation() { $thim_core = $this->businessroy_get_thim_core(); $status = $thim_core->get_status(); $step = ( $status == 'inactive' ) ? 'activate' : 'install'; $link = $this->businessroy_get_link_step( $step ); if ( $status == 'inactive' ) { $import_class = 'button button-primary'; $import_button_text = esc_html__('Activate Demo Importer Plugin', 'business-roy'); } elseif ( $status == 'active' ) { $import_class = 'button button-primary'; $import_button_text = esc_html__('Go to Demo Importer Page', 'business-roy'); $link = admin_url( '/themes.php?page=ikreate-demo-importer' ); } else { $import_class = 'thim-button-link button button-primary'; $import_button_text = esc_html__('Install Demo Importer Plugin', 'business-roy'); } ?> > businessroy_get_link_step( 'activate' ); $plugin = $this->businessroy_get_thim_core(); $status = $plugin->get_status(); if ( $status != 'not_installed' ) { self::businessroy_redirect( $link ); } $result = $plugin->install(); $messages = $plugin->get_messages(); $notice = $result ? 'success' : 'error'; ?> > businessroy_get_thim_core(); if ( $plugin->activate( true ) || $plugin->is_active() ) { $this->businessroy_redirect_dashboard(); return; } } /** * Reload to redirect to theme dashboard. * * @since 1.0.0 */ private function businessroy_redirect_dashboard() { $url = admin_url( 'themes.php?page=ikreate-demo-importer' ); self::businessroy_redirect( $url ); } } new businessroy_Welcome(); endif;