theme_name = $theme->Name; $this->theme_version = $theme->Version; /** Define Tabs Sections **/ $this->tab_sections = array( 'getting_started' => __('Getting Started', 'buzzstore'), 'recommended_plugins' => __('Recommended Plugins', 'buzzstore'), 'support' => __('Support', 'buzzstore'), 'free_vs_pro' => __('Free Vs Pro', 'buzzstore'), ); /** List of Recommended Free Plugins **/ $this->free_plugins = array( 'woocommerce' => array( 'name' => 'WooCommerce', 'slug' => 'woocommerce', 'filename' => 'woocommerce' ), 'wpforms-lite' => array( 'name' => 'Contact Form by WPForms', 'slug' => 'wpforms-lite', 'filename' => 'wpforms' ), 'contact-form-7' => array( 'name' => 'Contact Form 7', 'slug' => 'contact-form-7', 'filename' => 'contact-form-7' ), 'yith-woocommerce-quick-view' => array( 'name' => 'YITH WooCommerce Quick View', 'slug' => 'yith-woocommerce-quick-view', 'filename' => 'yith-woocommerce-quick-view' ), 'yith-woocommerce-compare' => array( 'name' => 'YITH WooCommerce Compare', 'slug' => 'yith-woocommerce-compare', 'filename' => 'yith-woocommerce-compare' ), 'yith-woocommerce-wishlist' => array( 'name' => 'YITH WooCommerce Wishlist', 'slug' => 'yith-woocommerce-wishlist', 'filename' => 'yith-woocommerce-wishlist' ) ); /** List of Recommended Pro Plugins **/ $this->pro_plugins = array(); /* Theme Activation Notice */ add_action( 'admin_notices', array( $this, 'buzzstore_activation_admin_notice' ) ); /* Create a Welcome Page */ add_action( 'admin_menu', array( $this, 'buzzstore_welcome_register_menu' ) ); /* Enqueue Styles & Scripts for Welcome Page */ add_action( 'admin_enqueue_scripts', array( $this, 'buzzstore_welcome_styles_and_scripts' ) ); add_action( 'wp_ajax_buzzstore_activate_plugin', array( $this, 'buzzstore_activate_plugin') ); } /** Welcome Message Notification on Theme Activation **/ public function buzzstore_activation_admin_notice() { global $pagenow; if( is_admin() && ('themes.php' == $pagenow) && (isset($_GET['activated'])) ) { ?>

tab_sections; ?>

theme_name, $this->theme_version ); ?>

esc_html__('Installing Importer Plugin', 'buzzstore'), 'activating_text' => esc_html__('Activating Importer Plugin', 'buzzstore'), 'importer_page' => esc_html__('Go to Importer Page >>', 'buzzstore'), 'importer_url' => admin_url('themes.php?page=pt-one-click-demo-import'), 'error' => esc_html__('Error! Reload the page and try again.', 'buzzstore'), ); wp_enqueue_style( 'buzzstore-welcome', get_template_directory_uri() . '/welcome/css/welcome.css' ); wp_enqueue_style( 'plugin-install' ); wp_enqueue_script( 'plugin-install' ); wp_enqueue_script( 'updates' ); wp_enqueue_script( 'buzzstore-welcome', get_template_directory_uri() . '/welcome/js/welcome.js', array(), '1.0' ); wp_localize_script( 'buzzstore-welcome', 'importer_params', $importer_params); } } // Check if plugin is installed public function buzzstore_check_installed_plugin( $slug, $filename ) { return file_exists( ABSPATH . 'wp-content/plugins/' . $slug . '/' . $filename . '.php' ) ? true : false; } // Check if plugin is activated public function buzzstore_check_plugin_active_state( $slug, $filename ) { return is_plugin_active( $slug . '/' . $filename . '.php' ) ? true : false; } /** Generate Url for the Plugin Button **/ public function buzzstore_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; } } public function buzzstore_activate_plugin(){ $slug = isset($_POST['slug']) ? sanitize_text_field( wp_unslash( $_POST['slug'] ) ) : ''; $file = isset($_POST['file']) ? sanitize_text_field( wp_unslash( $_POST['file'] ) ) : ''; $success = false; if( !empty($slug) && !empty($file)){ $result = activate_plugin( $slug.'/'.$file.'.php' ); if ( !is_wp_error( $result ) ) { $success = true; } } echo wp_json_encode(array('success'=>$success)); die(); } } new Buzzstore_Welcome(); endif;