| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentForm\App\Modules\Payments\Migrations; |
| 4 |
|
| 5 |
if (!defined('ABSPATH')) { |
| 6 |
exit; // Exit if accessed directly. |
| 7 |
} |
| 8 |
|
| 9 |
class Migration |
| 10 |
{ |
| 11 |
public static function run($network_wide = false) |
| 12 |
{ |
| 13 |
global $wpdb; |
| 14 |
if ($network_wide) { |
| 15 |
// Retrieve all site IDs from this network (WordPress >= 4.6 provides easy to use functions for that). |
| 16 |
if (function_exists('get_sites') && function_exists('get_current_network_id')) { |
| 17 |
$site_ids = get_sites(array('fields' => 'ids', 'network_id' => get_current_network_id())); |
| 18 |
} else { |
| 19 |
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Multisite migration, direct query needed |
| 20 |
$site_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs WHERE site_id = $wpdb->siteid;"); |
| 21 |
} |
| 22 |
// Install the plugin for all these sites. |
| 23 |
foreach ($site_ids as $site_id) { |
| 24 |
switch_to_blog($site_id); |
| 25 |
self::migrate(); |
| 26 |
restore_current_blog(); |
| 27 |
} |
| 28 |
} else { |
| 29 |
self::migrate(); |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
public static function migrate() |
| 34 |
{ |
| 35 |
OrderItems::migrate(); |
| 36 |
Transactions::migrate(); |
| 37 |
OrderSubscriptions::migrate(); |
| 38 |
} |
| 39 |
} |
| 40 |
|