Skip to content

Commit 4ea25a4

Browse files
committed
Fixed order of operations issue
1 parent 23951d2 commit 4ea25a4

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

network-subdomain-updater.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,21 @@
33
* @wordpress-plugin
44
* Plugin Name: Network Sub-Domain Updater
55
* Description: Update network (multisite) sub-domains after MySQL data import.
6-
* Version: 1.0.0
6+
* Version: 1.0.1
77
* Author: Daniel M. Hendricks
88
* Author URI: https://github.com/dmhendricks/wordpress-network-subdomain-updater-plugin/
99
* License: GPL-2.0
10-
* License URI: https://raw.githubusercontent.com/dmhendricks/wordpress-network-subdomain-updater-plugin/master/LICENSE
10+
* License URI: https://opensource.org/licenses/GPL-2.0
1111
*/
1212
namespace CloudVerve\NetworkSubdomainUpdater;
1313

1414
class SubdomainUpdate {
1515

16-
private $plugin_link;
16+
private $plugin_link = 'https://github.com/dmhendricks/wordpress-network-subdomain-updater-plugin';
1717

1818
function __construct() {
1919

20-
define( __NAMESPACE__ . '\VERSION', '1.0.0' );
21-
$this->plugin_link = 'https://github.com/dmhendricks/wordpress-network-subdomain-updater-plugin';
20+
define( __NAMESPACE__ . '\VERSION', '1.0.1' );
2221

2322
// If NETWORK_LOCAL_DOMAIN isn't defined, do nothing.
2423
if( ( !defined( 'NETWORK_LOCAL_DOMAIN' ) && !trim( NETWORK_LOCAL_DOMAIN ) ) || !defined( 'SITE_ID_CURRENT_SITE' ) ) return;
@@ -56,17 +55,6 @@ private function update_network_domain( &$wpdb, $current_domain, $new_domain ) {
5655

5756
$scheme = defined( 'NETWORK_LOCAL_DOMAIN_SCHEME' ) && NETWORK_LOCAL_DOMAIN_SCHEME ? strtolower( trim( NETWORK_LOCAL_DOMAIN_SCHEME ) ) : null;
5857

59-
// [wp_options] Update home and siteurl values
60-
$new_domain_url = rtrim( $this->set_url_scheme( $scheme, str_ireplace( $current_domain, $new_domain, network_site_url() ) ), '/' );
61-
update_option( 'home', $new_domain_url );
62-
update_option( 'siteurl', $new_domain_url );
63-
64-
// [wp_site.domain] Update current site domain
65-
$wpdb->update( $wpdb->site, [ 'domain' => $new_domain ], [ 'id' => SITE_ID_CURRENT_SITE ], [ '%s' ], [ '%d' ] );
66-
67-
// [wp_sitemeta.siteurl] Update siteurl value
68-
$wpdb->update( $wpdb->sitemeta, [ 'siteurl' => $new_domain ], [ 'site_id' => SITE_ID_CURRENT_SITE ], [ '%s' ], [ '%d' ] );
69-
7058
// [wp_blogs.domain] Update each site's domain
7159
$blogs = array();
7260
$sites = $wpdb->get_results( $wpdb->prepare( "SELECT blog_id, domain FROM $wpdb->blogs WHERE site_id = %d", SITE_ID_CURRENT_SITE ) );
@@ -83,6 +71,18 @@ private function update_network_domain( &$wpdb, $current_domain, $new_domain ) {
8371
update_blog_option( $blog_id, 'siteurl', $new_site_url );
8472
}
8573

74+
// [wp_options] Update home and siteurl values
75+
$new_domain_url = rtrim( $this->set_url_scheme( $scheme, str_ireplace( $current_domain, $new_domain, network_site_url() ) ), '/' );
76+
update_option( 'home', $new_domain_url );
77+
update_option( 'siteurl', $new_domain_url );
78+
79+
// [wp_site.domain] Update current site domain
80+
$wpdb->update( $wpdb->site, [ 'domain' => $new_domain ], [ 'id' => SITE_ID_CURRENT_SITE ], [ '%s' ], [ '%d' ] );
81+
82+
// [wp_sitemeta.siteurl] Update siteurl value
83+
$wpdb->update( $wpdb->sitemeta, [ 'siteurl' => $new_domain ], [ 'site_id' => SITE_ID_CURRENT_SITE ], [ '%s' ], [ '%d' ] );
84+
85+
8686
}
8787

8888
/**

0 commit comments

Comments
 (0)