DB
1 year ago
ActivationDatabaseHook.php
2 years ago
ActivationMultisite.php
7 years ago
ActivationNewSiteMultisite.php
7 years ago
ActivationRolesHook.php
7 years ago
ActivationSettingsHook.php
1 year ago
AutoUpdateHook.php
3 years ago
DeleteDatabaseHook.php
2 years ago
DeletionMultisite.php
5 years ago
DeletionMultisite.php
37 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Network activation |
| 4 | */ |
| 5 | |
| 6 | namespace AmeliaBooking\Infrastructure\WP\InstallActions; |
| 7 | |
| 8 | /** |
| 9 | * Class DeletionMultisite |
| 10 | * |
| 11 | * @package AmeliaBooking\Infrastructure\WP\InstallActions |
| 12 | */ |
| 13 | class DeletionMultisite |
| 14 | { |
| 15 | /** |
| 16 | * Delete the plugin tables for every sub-site separately |
| 17 | * @throws \AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException |
| 18 | */ |
| 19 | public static function delete() |
| 20 | { |
| 21 | global $wpdb; |
| 22 | |
| 23 | // Get current blog id |
| 24 | $oldSite = $wpdb->blogid; |
| 25 | // Get all blog ids |
| 26 | $siteIds = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs"); |
| 27 | |
| 28 | foreach ($siteIds as $siteId) { |
| 29 | switch_to_blog($siteId); |
| 30 | // Delete database tables if exists |
| 31 | DeleteDatabaseHook::delete(); |
| 32 | } |
| 33 | // Returns to current blog |
| 34 | switch_to_blog($oldSite); |
| 35 | } |
| 36 | } |
| 37 |