id !== 'dashboard' && $current_screen->id !== 'themes') { return; } if (is_network_admin()) { return; } if (!current_user_can('manage_options')) { return; } $theme = wp_get_theme(); if (is_child_theme()) { $theme = wp_get_theme()->parent(); } $blockbooster_version = $theme->get('Version'); ?>

'Nonce verification failed.')); return; } $result = update_option('blockbooster_dismissed_custom_notice', 1); if ($result) { wp_send_json_success(); } else { wp_send_json_error(array('message' => 'Failed to update option')); } } add_action('wp_ajax_blockbooster_dismissble_notice', 'blockbooster_dismissble_notice'); // Hook into a custom action when the button is clicked add_action('wp_ajax_blockbooster_install_and_activate_plugins', 'blockbooster_install_and_activate_plugins'); add_action('wp_ajax_nopriv_blockbooster_install_and_activate_plugins', 'blockbooster_install_and_activate_plugins'); add_action('wp_ajax_blockbooster_rplugin_activation', 'blockbooster_rplugin_activation'); add_action('wp_ajax_nopriv_blockbooster_rplugin_activation', 'blockbooster_rplugin_activation'); // Function to install and activate the plugins function check_plugin_installed_status($pugin_slug, $plugin_file) { return file_exists(ABSPATH . 'wp-content/plugins/' . $pugin_slug . '/' . $plugin_file) ? true : false; } /* Check if plugin is activated */ function check_plugin_active_status($pugin_slug, $plugin_file) { return is_plugin_active($pugin_slug . '/' . $plugin_file) ? true : false; } require_once(ABSPATH . 'wp-admin/includes/plugin-install.php'); require_once(ABSPATH . 'wp-admin/includes/file.php'); require_once(ABSPATH . 'wp-admin/includes/misc.php'); require_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'); function blockbooster_install_and_activate_plugins() { if (!current_user_can('manage_options')) { return; } check_ajax_referer('blockbooster_welcome_nonce', 'nonce'); // Define the plugins to be installed and activated $recommended_plugins = array( array( 'slug' => 'cozy-addons', 'file' => 'cozy-addons.php', 'name' => 'Cozy Addons' ), array( 'slug' => 'advanced-import', 'file' => 'advanced-import.php', 'name' => 'Advanced Imporrt' ), array( 'slug' => 'cozy-essential-addons', 'file' => 'cozy-essential-addons.php', 'name' => 'Cozy Essential Addons' ), // Add more plugins here as needed ); // Include the necessary WordPress functions // Set up a transient to store the installation progress set_transient('install_and_activate_progress', array(), MINUTE_IN_SECONDS * 10); // Loop through each plugin foreach ($recommended_plugins as $plugin) { $plugin_slug = $plugin['slug']; $plugin_file = $plugin['file']; $plugin_name = $plugin['name']; // Check if the plugin is active if (is_plugin_active($plugin_slug . '/' . $plugin_file)) { update_install_and_activate_progress($plugin_name, 'Already Active'); continue; // Skip to the next plugin } // Check if the plugin is installed but not active if (is_blockbooster_plugin_installed($plugin_slug . '/' . $plugin_file)) { $activate = activate_plugin($plugin_slug . '/' . $plugin_file); if (is_wp_error($activate)) { update_install_and_activate_progress($plugin_name, 'Error'); continue; // Skip to the next plugin } update_install_and_activate_progress($plugin_name, 'Activated'); continue; // Skip to the next plugin } // Plugin is not installed or activated, proceed with installation update_install_and_activate_progress($plugin_name, 'Installing'); // Fetch plugin information $api = plugins_api('plugin_information', array( 'slug' => $plugin_slug, 'fields' => array('sections' => false), )); // Check if plugin information is fetched successfully if (is_wp_error($api)) { update_install_and_activate_progress($plugin_name, 'Error'); continue; // Skip to the next plugin } // Set up the plugin upgrader $upgrader = new Plugin_Upgrader(); $install = $upgrader->install($api->download_link); // Check if installation is successful if ($install) { // Activate the plugin $activate = activate_plugin($plugin_slug . '/' . $plugin_file); // Check if activation is successful if (is_wp_error($activate)) { update_install_and_activate_progress($plugin_name, 'Error'); continue; // Skip to the next plugin } update_install_and_activate_progress($plugin_name, 'Activated'); } else { update_install_and_activate_progress($plugin_name, 'Error'); } } // Delete the progress transient $redirect_url = admin_url('themes.php?page=advanced-import'); // Delete the progress transient delete_transient('install_and_activate_progress'); // Return JSON response wp_send_json_success(array('redirect_url' => $redirect_url)); } // Function to check if a plugin is installed but not active function is_blockbooster_plugin_installed($plugin_slug) { $plugins = get_plugins(); return isset($plugins[$plugin_slug]); } // Function to update the installation and activation progress function update_install_and_activate_progress($plugin_name, $status) { $progress = get_transient('install_and_activate_progress'); $progress[] = array( 'plugin' => $plugin_name, 'status' => $status, ); set_transient('install_and_activate_progress', $progress, MINUTE_IN_SECONDS * 10); } function blockbooster_dashboard_menu() { add_theme_page(esc_html__('About Blockbooster', 'blockbooster'), esc_html__('About Blockbooster', 'blockbooster'), 'edit_theme_options', 'about-blockbooster', 'blockbooster_theme_info_display'); } add_action('admin_menu', 'blockbooster_dashboard_menu'); function blockbooster_theme_info_display() { ?>

  • ' . esc_html__('Install and Activate', 'blockbooster') . ''; } ?>

  • ' . esc_html__('Install and Activate', 'blockbooster') . ''; } ?>

  • ' . esc_html__('Install and Activate', 'blockbooster') . ''; } ?>