| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FireBox |
| 4 | - * @version 3.1.13 Free | |
| 4 | + * @version 2.1.14 Free | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <info@fireplugins.com> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | - * @copyright Copyright © 2026 FirePlugins All Rights Reserved | |
| 8 | + * @copyright Copyright © 2024 FirePlugins All Rights Reserved | |
| 9 | 9 | * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | namespace FireBox\Core\Admin; |
| @@ -38,117 +38,19 @@ | ||
| 38 | 38 | public function init() |
| 39 | 39 | { |
| 40 | 40 | register_activation_hook(FBOX_PLUGIN_BASE_FILE, [__CLASS__, 'activation']); |
| 41 | 41 | register_uninstall_hook(FBOX_PLUGIN_BASE_FILE, [__CLASS__, 'uninstall']); |
| 42 | - | |
| 43 | - if (!is_multisite()) | |
| 44 | - { | |
| 45 | - return; | |
| 46 | - } | |
| 47 | - | |
| 48 | - // A site added to the network needs the same install every other site got. | |
| 49 | - add_action('wp_initialize_site', [__CLASS__, 'onSiteInitialized'], 100, 1); | |
| 50 | - | |
| 51 | - // A site removed from the network takes its FireBox tables with it. | |
| 52 | - add_filter('wpmu_drop_tables', [__CLASS__, 'dropTables'], 10, 2); | |
| 53 | - | |
| 54 | - // Drains the remaining sites of a large network activation. | |
| 55 | - add_action('firebox_network_install', [__CLASS__, 'continueNetworkInstall']); | |
| 56 | 42 | } |
| 57 | 43 | |
| 58 | 44 | /** |
| 59 | 45 | * Runs on plugin activation |
| 60 | - * | |
| 61 | - * @param bool $network_wide Whether the plugin was network activated. | |
| 62 | - * | |
| 46 | + * | |
| 63 | 47 | * @return void |
| 64 | 48 | */ |
| 65 | - public static function activation($network_wide = false) | |
| 49 | + public static function activation() | |
| 66 | 50 | { |
| 67 | - if (is_multisite() && $network_wide) | |
| 68 | - { | |
| 69 | - SiteInstaller::installNetwork(); | |
| 70 | - } | |
| 71 | - else | |
| 72 | - { | |
| 73 | - SiteInstaller::installOnActivation(); | |
| 74 | - } | |
| 75 | - | |
| 76 | - // Redirect to the dashboard on first activation. Read by | |
| 77 | - // Admin::redirectAfterActivation(), which skips the network admin. | |
| 78 | - update_option('firebox_activation_redirect', true); | |
| 79 | - } | |
| 80 | - | |
| 81 | - /** | |
| 82 | - * Installs FireBox on a site that was just added to the network. | |
| 83 | - * | |
| 84 | - * @param \WP_Site $site | |
| 85 | - * | |
| 86 | - * @return void | |
| 87 | - */ | |
| 88 | - public static function onSiteInitialized($site) | |
| 89 | - { | |
| 90 | - if (!is_multisite() || !$site instanceof \WP_Site) | |
| 91 | - { | |
| 92 | - return; | |
| 93 | - } | |
| 94 | - | |
| 95 | - if (!self::isNetworkActive()) | |
| 96 | - { | |
| 97 | - return; | |
| 98 | - } | |
| 99 | - | |
| 100 | - switch_to_blog($site->blog_id); | |
| 101 | - SiteInstaller::install(); | |
| 102 | - restore_current_blog(); | |
| 103 | - } | |
| 104 | - | |
| 105 | - /** | |
| 106 | - * Adds the FireBox tables to the ones WordPress drops with a deleted site. | |
| 107 | - * | |
| 108 | - * WordPress calls this filter while switched to the site being deleted, so | |
| 109 | - * $wpdb->prefix is that site's prefix. | |
| 110 | - * | |
| 111 | - * @param array $tables | |
| 112 | - * @param int $blog_id | |
| 113 | - * | |
| 114 | - * @return array | |
| 115 | - */ | |
| 116 | - public static function dropTables($tables, $blog_id) | |
| 117 | - { | |
| 118 | - global $wpdb; | |
| 119 | - | |
| 120 | - foreach (self::$hook_data['tables'] as $table) | |
| 121 | - { | |
| 122 | - $tables[] = $wpdb->prefix . $table; | |
| 123 | - } | |
| 124 | - | |
| 125 | - return $tables; | |
| 126 | - } | |
| 127 | - | |
| 128 | - /** | |
| 129 | - * Installs the next batch of sites of a network activation. | |
| 130 | - * | |
| 131 | - * @return void | |
| 132 | - */ | |
| 133 | - public static function continueNetworkInstall() | |
| 134 | - { | |
| 135 | - SiteInstaller::installNetwork(); | |
| 136 | - } | |
| 137 | - | |
| 138 | - /** | |
| 139 | - * Whether FireBox is activated for the whole network. | |
| 140 | - * | |
| 141 | - * @return bool | |
| 142 | - */ | |
| 143 | - private static function isNetworkActive() | |
| 144 | - { | |
| 145 | - if (!function_exists('is_plugin_active_for_network')) | |
| 146 | - { | |
| 147 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; | |
| 148 | - } | |
| 149 | - | |
| 150 | - return is_plugin_active_for_network(FBOX_PLUGIN_BASENAME); | |
| 51 | + $pluginActivation = new PluginActivation(self::$hook_data); | |
| 52 | + $pluginActivation->start(); | |
| 151 | 53 | } |
| 152 | 54 | |
| 153 | 55 | /** |
| 154 | 56 | * Runs on plugin deactivation |