=')) { require_once( ENVO_PATH . '/includes/panel/classes/importers/class-helpers.php' ); require_once( ENVO_PATH . '/includes/panel/classes/class-install-demos.php' ); } // Disable Woo Wizard add_filter('woocommerce_enable_setup_wizard', '__return_false'); add_filter('woocommerce_show_admin_notice', '__return_false'); add_filter('woocommerce_prevent_automatic_wizard_redirect', '__return_false'); // Start things add_action('admin_init', array($this, 'init')); // Demos scripts add_action('admin_enqueue_scripts', array($this, 'scripts')); // Allows xml uploads add_filter('upload_mimes', array($this, 'allow_xml_uploads')); // Demos popup add_action('admin_footer', array($this, 'popup')); } /** * Register the AJAX methods * * @since 1.0.0 */ public function init() { // Demos popup ajax add_action('wp_ajax_envo_ajax_get_demo_data', array($this, 'ajax_demo_data')); add_action('wp_ajax_envo_ajax_required_plugins_activate', array($this, 'ajax_required_plugins_activate')); // Get data to import add_action('wp_ajax_envo_ajax_get_import_data', array($this, 'ajax_get_import_data')); // Import XML file add_action('wp_ajax_envo_ajax_import_xml', array($this, 'ajax_import_xml')); // Import customizer settings add_action('wp_ajax_envo_ajax_import_theme_settings', array($this, 'ajax_import_theme_settings')); // Import widgets add_action('wp_ajax_envo_ajax_import_widgets', array($this, 'ajax_import_widgets')); // Import widgets add_action('wp_ajax_envo_ajax_envo_activate_enwoo', array($this, 'ajax_activate_enwoo')); // After import add_action('wp_ajax_envo_after_import', array($this, 'ajax_after_import')); } /** * Load scripts * * @since 1.4.5 */ public static function scripts($hook_suffix) { if ('appearance_page_envothemes-panel-install-demos' == $hook_suffix) { // CSS wp_enqueue_style('envo-demos-style', plugins_url('/assets/css/demos.css', __FILE__)); // JS wp_enqueue_script('envo-demos-js', plugins_url('/assets/js/demos.js', __FILE__), array('jquery', 'wp-util', 'updates'), '1.0', true); wp_localize_script('envo-demos-js', 'envoDemos', array( 'ajaxurl' => admin_url('admin-ajax.php'), 'demo_data_nonce' => wp_create_nonce('get-demo-data'), 'envo_import_data_nonce' => wp_create_nonce('envo_import_data_nonce'), 'content_importing_error' => esc_html__('There was a problem during the importing process resulting in the following error from your server:', 'envothemes-demo-import'), 'button_activating' => esc_html__('Activating', 'envothemes-demo-import') . '…', 'button_active' => esc_html__('Active', 'envothemes-demo-import'), )); } //wp_enqueue_style('envo-notices', plugins_url('/assets/css/notify.css', __FILE__)); } /** * Allows xml uploads so we can import from server * * @since 1.0.0 */ public function allow_xml_uploads($mimes) { $mimes = array_merge($mimes, array( 'xml' => 'application/xml' )); return $mimes; } /** * Get demos data to add them in the Demo Import and Pro Demos plugins * * @since 1.4.5 */ public static function get_demos_data() { $theme = wp_get_theme(); $enwoo_data = array(); $data = array(); // Demos url $url = 'http://envothemes.com/wp-content/uploads/demo-import/' . $theme->template . '/'; if ('Envo Shop' == $theme->name || 'envo-shop' == $theme->template) { $data = array( $theme->template => array( 'demo_name' => $theme->name, 'categories' => array('WooCommerce'), 'xml_file' => $url . 'default/default-content.xml', 'theme_settings' => $url . 'default/default-customizer.dat', 'widgets_file' => $url . 'default/default-widgets.wie', 'screenshot' => $url . 'default/screenshot.png', 'home_title' => 'Home', 'blog_title' => 'Blog', 'posts_to_show' => '6', 'elementor_width' => '1400', 'is_shop' => true, 'woo_image_size' => '600', 'woo_thumb_size' => '300', 'woo_crop_width' => '1', 'woo_crop_height' => '1', 'required_plugins' => array( 'free' => array( array( 'slug' => 'elementor', 'init' => 'elementor/elementor.php', 'name' => 'Elementor', ), array( 'slug' => 'woocommerce', 'init' => 'woocommerce/woocommerce.php', 'name' => 'WooCommerce', ), array( 'slug' => 'envo-elementor-for-woocommerce', 'init' => 'envo-elementor-for-woocommerce/elementor-templates-widgets-woocommerce.php', 'name' => 'Elementor Templates and Widgets for WooCommerce', ), array( 'slug' => 'yith-woocommerce-wishlist', 'init' => 'yith-woocommerce-wishlist/init.php', 'name' => 'YITH WooCommerce Wishlist', ), array( 'slug' => 'yith-woocommerce-compare', 'init' => 'yith-woocommerce-compare/init.php', 'name' => 'YITH WooCommerce Compare', ), ), 'premium' => array( ), ), ), ); } elseif ('Envo Shopper' == $theme->name || 'envo-shopper' == $theme->template ||'Envo Online Store' == $theme->name || 'envo-online-store' == $theme->template || 'Envo Marketplace' == $theme->name || 'envo-marketplace' == $theme->template) { $data = array( $theme->template => array( 'demo_name' => $theme->name, 'categories' => array('WooCommerce'), 'xml_file' => $url . 'default/default-content.xml', 'theme_settings' => $url . 'default/default-customizer.dat', 'widgets_file' => $url . 'default/default-widgets.wie', 'screenshot' => $url . 'default/screenshot.png', 'home_title' => 'Home', 'blog_title' => 'Blog', 'posts_to_show' => '6', 'elementor_width' => '1140', 'is_shop' => true, 'woo_image_size' => '600', 'woo_thumb_size' => '300', 'woo_crop_width' => '2', 'woo_crop_height' => '3', 'required_plugins' => array( 'free' => array( array( 'slug' => 'elementor', 'init' => 'elementor/elementor.php', 'name' => 'Elementor', ), array( 'slug' => 'woocommerce', 'init' => 'woocommerce/woocommerce.php', 'name' => 'WooCommerce', ), array( 'slug' => 'envo-elementor-for-woocommerce', 'init' => 'envo-elementor-for-woocommerce/elementor-templates-widgets-woocommerce.php', 'name' => 'Elementor Templates and Widgets for WooCommerce', ), array( 'slug' => 'yith-woocommerce-wishlist', 'init' => 'yith-woocommerce-wishlist/init.php', 'name' => 'YITH WooCommerce Wishlist', ), array( 'slug' => 'yith-woocommerce-compare', 'init' => 'yith-woocommerce-compare/init.php', 'name' => 'YITH WooCommerce Compare', ), ), 'premium' => array( ), ), ), ); } elseif ('Envo eCommerce' == $theme->name || 'envo-ecommerce' == $theme->template || 'Envo Storefront' == $theme->name || 'envo-storefront' == $theme->template ) { $data = array( $theme->template => array( 'demo_name' => $theme->name, 'categories' => array('WooCommerce'), 'xml_file' => $url . 'default/default-content.xml', 'theme_settings' => $url . 'default/default-customizer.dat', 'widgets_file' => $url . 'default/default-widgets.wie', 'screenshot' => $url . 'default/screenshot.png', 'home_title' => 'Home', 'blog_title' => 'Blog', 'posts_to_show' => '6', 'elementor_width' => '1140', 'is_shop' => true, 'woo_image_size' => '600', 'woo_thumb_size' => '300', 'woo_crop_width' => '1', 'woo_crop_height' => '1', 'required_plugins' => array( 'free' => array( array( 'slug' => 'elementor', 'init' => 'elementor/elementor.php', 'name' => 'Elementor', ), array( 'slug' => 'woocommerce', 'init' => 'woocommerce/woocommerce.php', 'name' => 'WooCommerce', ), array( 'slug' => 'envo-elementor-for-woocommerce', 'init' => 'envo-elementor-for-woocommerce/elementor-templates-widgets-woocommerce.php', 'name' => 'Elementor Templates and Widgets for WooCommerce', ), ), 'premium' => array( ), ), ), ); } // Enwoo Demos url $enwoo_url = 'http://enwoo-wp.com/wp-content/uploads/demo-import/'; $enwoo_data = array( 'free-demo-1' => array( 'demo_name' => 'Enwoo Free Demo #1', 'categories' => array('WooCommerce', 'Elementor', 'Free'), 'xml_file' => $enwoo_url . 'free-1/content.xml', 'theme_settings' => $enwoo_url . 'free-1/customizer.dat', 'widgets_file' => $enwoo_url . 'free-1/widgets.wie', 'screenshot' => $enwoo_url . 'free-1/screenshot.jpg', 'home_title' => 'Home Free #1', 'blog_title' => 'Blog', 'posts_to_show' => '6', 'elementor_width' => '1140', 'is_shop' => true, 'woo_image_size' => '600', 'woo_thumb_size' => '300', 'woo_crop_width' => '2', 'woo_crop_height' => '3', 'required_plugins' => array( 'free' => array( array( 'slug' => 'envo-extra', 'init' => 'envo-extra/envo-extra.php', 'name' => 'Envo Extra', ), array( 'slug' => 'elementor', 'init' => 'elementor/elementor.php', 'name' => 'Elementor', ), array( 'slug' => 'woocommerce', 'init' => 'woocommerce/woocommerce.php', 'name' => 'WooCommerce', ), array( 'slug' => 'envo-elementor-for-woocommerce', 'init' => 'envo-elementor-for-woocommerce/elementor-templates-widgets-woocommerce.php', 'name' => 'Elementor Templates and Widgets for WooCommerce', ), ), 'recommended' => array( array( 'slug' => 'yith-woocommerce-wishlist', 'init' => 'yith-woocommerce-wishlist/init.php', 'name' => 'YITH WooCommerce Wishlist', ), array( 'slug' => 'yith-woocommerce-compare', 'init' => 'yith-woocommerce-compare/init.php', 'name' => 'YITH WooCommerce Compare', ), ), 'premium' => array(), ), 'required_theme' => 'Enwoo', ), 'free-demo-2' => array( 'demo_name' => 'Enwoo Free Demo #2', 'categories' => array('WooCommerce', 'Elementor', 'Free'), 'xml_file' => $enwoo_url . 'free-2/content.xml', 'theme_settings' => $enwoo_url . 'free-2/customizer.dat', 'widgets_file' => $enwoo_url . 'free-2/widgets.wie', 'screenshot' => $enwoo_url . 'free-2/screenshot.jpg', 'home_title' => 'Home Free #2', 'blog_title' => 'Blog', 'posts_to_show' => '6', 'elementor_width' => '1140', 'is_shop' => true, 'woo_image_size' => '600', 'woo_thumb_size' => '300', 'woo_crop_width' => '2', 'woo_crop_height' => '3', 'required_plugins' => array( 'free' => array( array( 'slug' => 'envo-extra', 'init' => 'envo-extra/envo-extra.php', 'name' => 'Envo Extra', ), array( 'slug' => 'elementor', 'init' => 'elementor/elementor.php', 'name' => 'Elementor', ), array( 'slug' => 'woocommerce', 'init' => 'woocommerce/woocommerce.php', 'name' => 'WooCommerce', ), array( 'slug' => 'envo-elementor-for-woocommerce', 'init' => 'envo-elementor-for-woocommerce/elementor-templates-widgets-woocommerce.php', 'name' => 'Elementor Templates and Widgets for WooCommerce', ), ), 'recommended' => array( array( 'slug' => 'yith-woocommerce-wishlist', 'init' => 'yith-woocommerce-wishlist/init.php', 'name' => 'YITH WooCommerce Wishlist', ), array( 'slug' => 'yith-woocommerce-compare', 'init' => 'yith-woocommerce-compare/init.php', 'name' => 'YITH WooCommerce Compare', ), ), 'premium' => array(), ), 'required_theme' => 'Enwoo', ), 'free-demo-3' => array( 'demo_name' => 'Enwoo Free Demo #3', 'categories' => array('WooCommerce', 'Elementor', 'Free'), 'xml_file' => $enwoo_url . 'free-3/content.xml', 'theme_settings' => $enwoo_url . 'free-3/customizer.dat', 'widgets_file' => $enwoo_url . 'free-3/widgets.wie', 'screenshot' => $enwoo_url . 'free-3/screenshot.jpg', 'home_title' => 'Home Free #3', 'blog_title' => 'Blog', 'posts_to_show' => '6', 'elementor_width' => '1140', 'is_shop' => true, 'woo_image_size' => '600', 'woo_thumb_size' => '300', 'woo_crop_width' => '2', 'woo_crop_height' => '3', 'required_plugins' => array( 'free' => array( array( 'slug' => 'envo-extra', 'init' => 'envo-extra/envo-extra.php', 'name' => 'Envo Extra', ), array( 'slug' => 'elementor', 'init' => 'elementor/elementor.php', 'name' => 'Elementor', ), array( 'slug' => 'woocommerce', 'init' => 'woocommerce/woocommerce.php', 'name' => 'WooCommerce', ), array( 'slug' => 'envo-elementor-for-woocommerce', 'init' => 'envo-elementor-for-woocommerce/elementor-templates-widgets-woocommerce.php', 'name' => 'Elementor Templates and Widgets for WooCommerce', ), ), 'recommended' => array(), 'premium' => array(), ), 'required_theme' => 'Enwoo', ), 'free-demo-4' => array( 'demo_name' => 'Enwoo Free Demo #4', 'categories' => array('WooCommerce', 'Elementor', 'Free', 'Business'), 'xml_file' => $enwoo_url . 'free-4/content.xml', 'theme_settings' => $enwoo_url . 'free-4/customizer.dat', 'widgets_file' => $enwoo_url . 'free-4/widgets.wie', 'screenshot' => $enwoo_url . 'free-4/screenshot.jpg', 'home_title' => 'Home Free #4', 'blog_title' => 'Blog', 'posts_to_show' => '6', 'elementor_width' => '1140', 'is_shop' => true, 'woo_image_size' => '600', 'woo_thumb_size' => '300', 'woo_crop_width' => '2', 'woo_crop_height' => '3', 'required_plugins' => array( 'free' => array( array( 'slug' => 'envo-extra', 'init' => 'envo-extra/envo-extra.php', 'name' => 'Envo Extra', ), array( 'slug' => 'elementor', 'init' => 'elementor/elementor.php', 'name' => 'Elementor', ), array( 'slug' => 'woocommerce', 'init' => 'woocommerce/woocommerce.php', 'name' => 'WooCommerce', ), array( 'slug' => 'envo-elementor-for-woocommerce', 'init' => 'envo-elementor-for-woocommerce/elementor-templates-widgets-woocommerce.php', 'name' => 'Elementor Templates and Widgets for WooCommerce', ), ), 'recommended' => array(), 'premium' => array(), ), 'required_theme' => 'Enwoo', ), 'free-demo-5' => array( 'demo_name' => 'Enwoo Free Demo #5', 'categories' => array('WooCommerce', 'Gutenberg', 'Free', 'Business'), 'xml_file' => $enwoo_url . 'free-5/content.xml', 'theme_settings' => $enwoo_url . 'free-5/customizer.dat', 'widgets_file' => $enwoo_url . 'free-5/widgets.wie', 'screenshot' => $enwoo_url . 'free-5/screenshot.jpg', 'home_title' => 'Home Free #5', 'blog_title' => 'Blog', 'posts_to_show' => '6', 'elementor_width' => '1140', 'is_shop' => true, 'woo_image_size' => '600', 'woo_thumb_size' => '300', 'woo_crop_width' => '2', 'woo_crop_height' => '3', 'required_plugins' => array( 'free' => array( array( 'slug' => 'envo-extra', 'init' => 'envo-extra/envo-extra.php', 'name' => 'Envo Extra', ), array( 'slug' => 'woocommerce', 'init' => 'woocommerce/woocommerce.php', 'name' => 'WooCommerce', ), ), 'recommended' => array(), 'premium' => array(), ), 'required_theme' => 'Enwoo', ), 'free-demo-6' => array( 'demo_name' => 'Enwoo Free Demo #6', 'categories' => array('Gutenberg', 'Free', 'Business'), 'xml_file' => $enwoo_url . 'free-6/content.xml', 'theme_settings' => $enwoo_url . 'free-6/customizer.dat', 'widgets_file' => $enwoo_url . 'free-6/widgets.wie', 'screenshot' => $enwoo_url . 'free-6/screenshot.jpg', 'home_title' => 'Home Free #6', 'blog_title' => 'Blog', 'posts_to_show' => '6', 'elementor_width' => '1140', 'is_shop' => true, 'woo_image_size' => '600', 'woo_thumb_size' => '300', 'woo_crop_width' => '2', 'woo_crop_height' => '3', 'required_plugins' => array( 'free' => array( array( 'slug' => 'envo-extra', 'init' => 'envo-extra/envo-extra.php', 'name' => 'Envo Extra', ), ), 'recommended' => array(), 'premium' => array(), ), 'required_theme' => 'Enwoo', ), 'free-demo-7' => array( 'demo_name' => 'Enwoo Free Demo #7', 'categories' => array('Elementor', 'Free', 'Business', 'WooCommerce'), 'xml_file' => $enwoo_url . 'free-7/content.xml', 'theme_settings' => $enwoo_url . 'free-7/customizer.dat', 'widgets_file' => $enwoo_url . 'free-7/widgets.wie', 'screenshot' => $enwoo_url . 'free-7/screenshot.jpg', 'home_title' => 'Home Free #7', 'blog_title' => 'Blog', 'posts_to_show' => '6', 'elementor_width' => '1140', 'is_shop' => true, 'woo_image_size' => '600', 'woo_thumb_size' => '300', 'woo_crop_width' => '2', 'woo_crop_height' => '3', 'required_plugins' => array( 'free' => array( array( 'slug' => 'envo-extra', 'init' => 'envo-extra/envo-extra.php', 'name' => 'Envo Extra', ), array( 'slug' => 'elementor', 'init' => 'elementor/elementor.php', 'name' => 'Elementor', ), array( 'slug' => 'envo-elementor-for-woocommerce', 'init' => 'envo-elementor-for-woocommerce/elementor-templates-widgets-woocommerce.php', 'name' => 'Elementor Templates and Widgets for WooCommerce', ), array( 'slug' => 'woocommerce', 'init' => 'woocommerce/woocommerce.php', 'name' => 'WooCommerce', ), ), 'recommended' => array(), 'premium' => array(), ), 'required_theme' => 'Enwoo', ), ); // combine the two arrays $data = array_merge($data, $enwoo_data); // Return return apply_filters('envo_demos_data', $data); } /** * Get the category list of all categories used in the predefined demo imports array. * * @since 1.4.5 */ public static function get_demo_all_categories($demo_imports) { $categories = array(); foreach ($demo_imports as $item) { if (!empty($item['categories']) && is_array($item['categories'])) { foreach ($item['categories'] as $category) { $categories[sanitize_key($category)] = $category; } } } if (empty($categories)) { return false; } return $categories; } /** * Return the concatenated string of demo import item categories. * These should be separated by comma and sanitized properly. * * @since 1.4.5 */ public static function get_demo_item_categories($item) { $sanitized_categories = array(); if (isset($item['categories'])) { foreach ($item['categories'] as $category) { $sanitized_categories[] = sanitize_key($category); } } if (!empty($sanitized_categories)) { return implode(',', $sanitized_categories); } return false; } /** * Demos popup * * @since 1.4.5 */ public static function popup() { global $pagenow; if (isset($_GET['page'])) { // Display on the demos pages if (( 'themes.php' == $pagenow && 'envothemes-panel-install-demos' == $_GET['page'])) { ?>
', '' ); ?>
', '');?>