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'); ?>

'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') . ''; } ?>