base, $allowed_pages)) { return; // Exit if not on an allowed page } global $current_user; $user_id = $current_user->ID; $theme_data = wp_get_theme(); if ( get_user_meta( $user_id, esc_html( $theme_data->get( 'TextDomain' ) ) . '_notice_ignore' ) ) { return; } // Retrieve the theme support data $plugin_data = get_theme_support('recommend-plugins'); $plugin_data = $plugin_data[0]; // Get the specific plugin data $plugin_pro_slug = isset($plugin_data['th-shop-mania-pro']['slug']) ? $plugin_data['th-shop-mania-pro']['slug'] : 'big-store-pro'; $plugin_pro_file = isset($plugin_data['th-shop-mania-pro']['init']) ? $plugin_data['th-shop-mania-pro']['init'] : 'big-store-pro/big-store-pro.php'; $plugin_companion_slug = isset($plugin_data['themehunk-customizer']['slug']) ? $plugin_data['themehunk-customizer']['slug'] : 'themehunk-customizer'; $plugin_companion_file = isset($plugin_data['themehunk-customizer']['active_filename']) ? $plugin_data['themehunk-customizer']['active_filename'] : 'themehunk-customizer/themehunk-customizer.php'; // Check if plugins are installed and activated $plugin_pro_exists = file_exists(WP_PLUGIN_DIR . '/' . $plugin_pro_file); $plugin_pro_installed = is_plugin_active($plugin_pro_file); $plugin_companion_exists = file_exists(WP_PLUGIN_DIR . '/' . $plugin_companion_file); $plugin_companion_installed = is_plugin_active($plugin_companion_file); if ((isset($_GET['page']) && $_GET['page'] == 'thunk_started' ) || ((!$plugin_pro_exists && !$plugin_companion_exists) ||($plugin_pro_exists && !$plugin_pro_installed) || (!$plugin_pro_exists && $plugin_companion_exists && !$plugin_companion_installed)) ) { if ($plugin_pro_exists) { // 'th-shop-mania-pro' is installed if ($plugin_pro_installed) { // Plugin is activated echo '

'.sprintf( esc_html__( 'Thank you for installing %1$s - Version %2$s', 'big-store' ), esc_html( $theme_data->Name ), esc_html( $theme_data->Version ) ).'

' . esc_html__('To take full advantage of all the features this theme has to offer, please install and activate the ', 'big-store') . 'ThemeHunk Customizer

'; } else { // Plugin is installed but not activated echo '

'.sprintf( esc_html__( 'Thank you for installing %1$s - Version %2$s', 'big-store' ), esc_html( $theme_data->Name ), esc_html( $theme_data->Version ) ).'

' . esc_html__('To take full advantage of all the features this theme has to offer, please install and activate the ', 'big-store') . 'Big Store Pro

'; } } else { // 'th-shop-mania-pro' is not installed, check 'hunk-companion' $plugin_companion_installed = is_plugin_active($plugin_companion_file); $plugin_companion_exists = file_exists(WP_PLUGIN_DIR . '/' . $plugin_companion_file); echo '

'.sprintf( esc_html__( 'Thank you for installing %1$s - Version %2$s', 'big-store' ), esc_html( $theme_data->Name ), esc_html( $theme_data->Version ) ).'

' . esc_html__('To take full advantage of all the features this theme has to offer, please install and activate the ', 'big-store') . 'ThemeHunk Customizer

'; if ($plugin_companion_exists) { if ($plugin_companion_installed) { echo ''; } else { echo ' '; } } else { echo ''; } echo '
'; } } } // add below line containg anchor a tag indise the banner wrapper if you want to use hide banner if clicks on banner close button permanently. // function big_store_install_custom_plugin($plugin_slug) { require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; $plugin_info = plugins_api('plugin_information', array('slug' => $plugin_slug)); if (is_wp_error($plugin_info)) { return $plugin_info->get_error_message(); } $upgrader = new Plugin_Upgrader(new Plugin_Installer_Skin(array( 'api' => $plugin_info, ))); $result = $upgrader->install($plugin_info->download_link); if (is_wp_error($result)) { return $result->get_error_message(); } return "success"; } // AJAX handler for installing and activating plugins add_action('wp_ajax_big_store_install_and_activate_callback', 'big_store_install_and_activate_callback'); // Callback function to install and activate plugin function big_store_install_and_activate_callback() { // Check nonce for security check_ajax_referer('thactivatenonce', 'security'); // Retrieve plugin slug from AJAX request $plugin_slug = isset($_POST['plugin_slug']) ? sanitize_text_field($_POST['plugin_slug']) : ''; if (empty($plugin_slug)) { wp_send_json_error(array('message' => 'Plugin slug is missing.')); return; } $plugin_file = WP_PLUGIN_DIR . '/' . $plugin_slug . '/' . $plugin_slug . '.php'; // Install the plugin if (!file_exists($plugin_file)) { // Start output buffering to capture the plugin installation output ob_start(); $status = big_store_install_custom_plugin($plugin_slug); // Get the buffered content $install_output = ob_get_clean(); if (is_wp_error($status)) { wp_send_json_error(array('message' => $status->get_error_message(), 'install_output' => $install_output)); return; } // Check if the plugin file exists after installation if (!file_exists($plugin_file)) { wp_send_json_error(array('message' => 'Plugin file does not exist after installation.', 'install_output' => $install_output)); return; } } // Activate the plugin if (!is_plugin_active($plugin_file)) { $status = activate_plugin($plugin_file); if (is_wp_error($status)) { wp_send_json_error(array('message' => $status->get_error_message())); return; } } return 'Plugin installed and activated successfully.'; } function big_store_admin_script($hook_suffix) { // Define the pages where the script should be enqueued $allowed_pages = array( 'index.php', 'themes.php', 'plugins.php', 'users.php', 'appearance_page_thunk_started' ); // Check if the current page is one of the allowed pages if (!in_array($hook_suffix, $allowed_pages)) { return; } // Enqueue styles and scripts only on the allowed pages wp_enqueue_style('big-store-admin-css', get_template_directory_uri() . '/lib/notification/css/admin.css', array(), BIG_STORE_THEME_VERSION, 'all'); wp_enqueue_script('big-store-notifyjs', get_template_directory_uri() . '/lib/notification/js/notify.js', array('jquery'), BIG_STORE_THEME_VERSION, true); // Pass AJAX URL to the script wp_localize_script('big-store-notifyjs', 'theme_data', array( 'ajax_url' => admin_url('admin-ajax.php'), 'security' => wp_create_nonce('thactivatenonce'), // Create nonce for security 'redirectUrl' => esc_url(admin_url('themes.php?page=one-click-demo-import')), 'redirectUrlPro' => esc_url(admin_url('themes.php?page=themehunk-site-library')) )); } add_action('admin_enqueue_scripts', 'big_store_admin_script'); // Hook the function to clear the cookie when the theme is switched to add_action('after_switch_theme', 'big_store_clear_notice_cookie'); ?>