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
ActivationMultisite.php
36 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Network activation |
| 4 | */ |
| 5 | |
| 6 | namespace AmeliaBooking\Infrastructure\WP\InstallActions; |
| 7 | |
| 8 | /** |
| 9 | * Class ActivationMultisite |
| 10 | * |
| 11 | * @package AmeliaBooking\Infrastructure\WP\InstallActions |
| 12 | */ |
| 13 | class ActivationMultisite |
| 14 | { |
| 15 | /** |
| 16 | * Activate the plugin for every sub-site separately |
| 17 | */ |
| 18 | public static function init() |
| 19 | { |
| 20 | global $wpdb; |
| 21 | |
| 22 | // Get current blog id |
| 23 | $oldSite = $wpdb->blogid; |
| 24 | // Get all blog ids |
| 25 | $siteIds = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs"); |
| 26 | |
| 27 | foreach ($siteIds as $siteId) { |
| 28 | switch_to_blog($siteId); |
| 29 | // Create database table if not exists |
| 30 | ActivationDatabaseHook::init(); |
| 31 | } |
| 32 | // Returns to current blog |
| 33 | switch_to_blog($oldSite); |
| 34 | } |
| 35 | } |
| 36 |