esc_html__( 'Demo Installer', 'best-shop' ), 'slug' => 'gradient-starter-templates', 'required' => false, ), array( 'name' => esc_html__( 'Classic Widgets', 'best-shop' ), 'slug' => 'classic-widgets', 'required' => false, ), array( 'name' => esc_html__( 'WooCommerce', 'best-shop' ), 'slug' => 'woocommerce', 'required' => false, ), array( 'name' => esc_html__( 'Contact Form', 'best-shop' ), 'slug' => 'wpforms-lite', 'required' => false, ), array( 'name' => esc_html__('Wishlist', 'best-shop' ), 'slug' => 'yith-woocommerce-wishlist', 'required' => false, ), array( 'name' => esc_html__('Quick View', 'best-shop' ), 'slug' => 'yith-woocommerce-quick-view', 'required' => false, ), array( 'name' => esc_html__('Product Compare', 'best-shop' ), 'slug' => 'yith-woocommerce-compare', 'required' => false, ), ); /* * Array of configuration settings. Amend each line as needed. * * TGMPA will start providing localized text strings soon. If you already have translations of our standard * strings available, please help us make TGMPA even better by giving us access to these translations or by * sending in a pull-request with .po file(s) with the translations. * * Only uncomment the strings in the config array if you want to customize the strings. */ $config = array( 'id' => 'best-shop', // Unique ID for hashing notices for multiple instances of TGMPA. 'default_path' => '', // Default absolute path to bundled plugins. 'menu' => 'tgmpa-install-plugins', // Menu slug. 'has_notices' => true, // Show admin notices or not. 'dismissable' => true, // If false, a user cannot dismiss the nag message. 'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag. 'is_automatic' => false, // Automatically activate plugins after installation or not. 'message' => '', // Message to output right before the plugins table. ); tgmpa( $plugins, $config ); } /** * Include the TGM_Plugin_Activation class. * * Depending on your implementation, you may want to change the include call: * * Parent Theme: * require_once get_template_directory() . '/path/to/class-tgm-plugin-activation.php'; * * Child Theme: * require_once get_stylesheet_directory() . '/path/to/class-tgm-plugin-activation.php'; * * Plugin: * require_once dirname( __FILE__ ) . '/path/to/class-tgm-plugin-activation.php'; */ function best_shop_admin_enqueue_scripts(){ wp_enqueue_script( 'best-shop-admin-script', get_template_directory_uri() . '/js/admin.js', array( 'jquery' ), '', true ); wp_localize_script( 'best-shop-admin-script', 'best_shop_ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) ); } add_action( 'admin_enqueue_scripts', 'best_shop_admin_enqueue_scripts' ); add_action( 'wp_ajax_install_act_plugin', 'best_shop_admin_install_plugin' ); function best_shop_admin_install_plugin() { /** * Install Plugin. */ include_once ABSPATH . '/wp-admin/includes/file.php'; include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; if ( ! file_exists( WP_PLUGIN_DIR . '/gradient-starter-templates' ) ) { $api = plugins_api( 'plugin_information', array( 'slug' => sanitize_key( wp_unslash( 'gradient-starter-templates' ) ), 'fields' => array( 'sections' => false, ), ) ); $skin = new WP_Ajax_Upgrader_Skin(); $upgrader = new Plugin_Upgrader( $skin ); $result = $upgrader->install( $api->download_link ); } if ( ! file_exists( WP_PLUGIN_DIR . '/advanced-import' ) ) { $api = plugins_api( 'plugin_information', array( 'slug' => sanitize_key( wp_unslash( 'advanced-import' ) ), 'fields' => array( 'sections' => false, ), ) ); $skin = new WP_Ajax_Upgrader_Skin(); $upgrader = new Plugin_Upgrader( $skin ); $result = $upgrader->install( $api->download_link ); } // Activate plugin. if ( current_user_can( 'activate_plugin' ) ) { $result = activate_plugin( 'gradient-starter-templates/gradient-starter-templates.php' ); $result = activate_plugin( 'advanced-import/advanced-import.php' ); } }