Version Description
- Pass option value when flushing Elementor cache to prevent edge case conflicts.
- Improve counting of urls across subdomains.
- Improve counting of urls across serialized data.
- Support replacing non subdomain values which duplicate because the old URL exists within the new URL.
- Introduce
go-live-update-urls/database/after-counting
action. - Introduce
go-live-update-urls/database/before-counting
action
Download this release
Release Info
Developer | Mat Lipe |
Plugin | Go Live Update URLS |
Version | 6.2.2 |
Comparing to | |
See all releases |
Code changes from version 6.2.1 to 6.2.2
- go-live-update-urls.php +3 -3
- readme.txt +10 -2
- src/Core.php +23 -0
- src/Database.php +10 -25
- src/Updates.php +31 -7
go-live-update-urls.php
CHANGED
@@ -5,14 +5,14 @@
|
|
5 |
* Description: Updates all the URLs in the database to point to a new URL when making your site live or changing domains.
|
6 |
* Author: OnPoint Plugins
|
7 |
* Author URI: https://onpointplugins.com/
|
8 |
-
* Version: 6.2.
|
9 |
* Text Domain: go-live-update-urls
|
10 |
*
|
11 |
* @package go-live-update-urls
|
12 |
*/
|
13 |
|
14 |
-
define( 'GO_LIVE_UPDATE_URLS_VERSION', '6.2.
|
15 |
-
define( 'GO_LIVE_UPDATE_URLS_REQUIRED_PRO_VERSION', '6.2.
|
16 |
define( 'GO_LIVE_UPDATE_URLS_URL', plugin_dir_url( __FILE__ ) );
|
17 |
|
18 |
use Go_Live_Update_Urls\Admin;
|
5 |
* Description: Updates all the URLs in the database to point to a new URL when making your site live or changing domains.
|
6 |
* Author: OnPoint Plugins
|
7 |
* Author URI: https://onpointplugins.com/
|
8 |
+
* Version: 6.2.2
|
9 |
* Text Domain: go-live-update-urls
|
10 |
*
|
11 |
* @package go-live-update-urls
|
12 |
*/
|
13 |
|
14 |
+
define( 'GO_LIVE_UPDATE_URLS_VERSION', '6.2.2' );
|
15 |
+
define( 'GO_LIVE_UPDATE_URLS_REQUIRED_PRO_VERSION', '6.2.4' );
|
16 |
define( 'GO_LIVE_UPDATE_URLS_URL', plugin_dir_url( __FILE__ ) );
|
17 |
|
18 |
use Go_Live_Update_Urls\Admin;
|
readme.txt
CHANGED
@@ -3,9 +3,9 @@ Contributors: Mat Lipe, onpointplugins
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=paypal%40onpointplugins%2ecom&lc=US&item_name=Go%20Live%20Update%20Urls&no_note=0¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest
|
4 |
Tags: urls, launching, site changes, tools, domain, domains, domain changes, url changes
|
5 |
Requires at least: 4.8.0
|
6 |
-
Tested up to: 5.
|
7 |
Requires PHP: 5.6.0
|
8 |
-
Stable tag: 6.2.
|
9 |
|
10 |
== Description ==
|
11 |
|
@@ -102,6 +102,14 @@ If you wish to try to update tables mentioned as "not safe" anyway, you may make
|
|
102 |
3. Update prevented due to incomplete data entered.
|
103 |
|
104 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
= 6.2.1 =
|
106 |
* Automatically flush Elementor's CSS cache during updates.
|
107 |
* Update screenshots and captions.
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=paypal%40onpointplugins%2ecom&lc=US&item_name=Go%20Live%20Update%20Urls&no_note=0¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest
|
4 |
Tags: urls, launching, site changes, tools, domain, domains, domain changes, url changes
|
5 |
Requires at least: 4.8.0
|
6 |
+
Tested up to: 5.6.0
|
7 |
Requires PHP: 5.6.0
|
8 |
+
Stable tag: 6.2.2
|
9 |
|
10 |
== Description ==
|
11 |
|
102 |
3. Update prevented due to incomplete data entered.
|
103 |
|
104 |
== Changelog ==
|
105 |
+
= 6.2.2 =
|
106 |
+
* Pass option value when flushing Elementor cache to prevent edge case conflicts.
|
107 |
+
* Improve counting of urls across subdomains.
|
108 |
+
* Improve counting of urls across serialized data.
|
109 |
+
* Support replacing non subdomain values which duplicate because the old URL exists within the new URL.
|
110 |
+
* Introduce `go-live-update-urls/database/after-counting` action.
|
111 |
+
* Introduce `go-live-update-urls/database/before-counting` action
|
112 |
+
|
113 |
= 6.2.1 =
|
114 |
* Automatically flush Elementor's CSS cache during updates.
|
115 |
* Update screenshots and captions.
|
src/Core.php
CHANGED
@@ -21,10 +21,12 @@ class Core {
|
|
21 |
*/
|
22 |
protected function hook() {
|
23 |
add_action( 'go-live-update-urls/database/before-update', [ $this, 'raise_resource_limits' ], 0, 0 );
|
|
|
24 |
add_filter( 'go-live-update-urls/database/memory-limit_memory_limit', [
|
25 |
$this,
|
26 |
'raise_memory_limit',
|
27 |
], 0, 0 );
|
|
|
28 |
}
|
29 |
|
30 |
|
@@ -45,6 +47,27 @@ class Core {
|
|
45 |
}
|
46 |
|
47 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
/**
|
49 |
* Raise the memory limit while the Database runs.
|
50 |
* If the memory limit is higher than self::MEMORY_LIMIT
|
21 |
*/
|
22 |
protected function hook() {
|
23 |
add_action( 'go-live-update-urls/database/before-update', [ $this, 'raise_resource_limits' ], 0, 0 );
|
24 |
+
add_action( 'go-live-update-urls/database/after-update', [ $this, 'flush_caches' ] );
|
25 |
add_filter( 'go-live-update-urls/database/memory-limit_memory_limit', [
|
26 |
$this,
|
27 |
'raise_memory_limit',
|
28 |
], 0, 0 );
|
29 |
+
|
30 |
}
|
31 |
|
32 |
|
47 |
}
|
48 |
|
49 |
|
50 |
+
/**
|
51 |
+
* Flush any known caches which are affected by updating the database.
|
52 |
+
*
|
53 |
+
* 1. WP core object cache.
|
54 |
+
* 2. Elementor CSS cache.
|
55 |
+
*
|
56 |
+
* @ticket #7751
|
57 |
+
*
|
58 |
+
* @see \Elementor\Settings::update_css_print_method
|
59 |
+
*
|
60 |
+
* @since 6.2.1
|
61 |
+
*/
|
62 |
+
public function flush_caches() {
|
63 |
+
// Special flush CSS cache for Elementor #7751.
|
64 |
+
$method = get_option( 'elementor_css_print_method' );
|
65 |
+
do_action( 'update_option_elementor_css_print_method', $method, $method, 'elementor_css_print_method' );
|
66 |
+
|
67 |
+
wp_cache_flush();
|
68 |
+
}
|
69 |
+
|
70 |
+
|
71 |
/**
|
72 |
* Raise the memory limit while the Database runs.
|
73 |
* If the memory limit is higher than self::MEMORY_LIMIT
|
src/Database.php
CHANGED
@@ -177,11 +177,10 @@ class Database {
|
|
177 |
$counts[ $_table ] += $updates->update_table_columns( $_table );
|
178 |
}
|
179 |
|
180 |
-
$this
|
181 |
|
182 |
do_action( 'go-live-update-urls/database/after-update', $old_url, $new_url, $tables, $this );
|
183 |
-
|
184 |
-
return apply_filters( 'go-live-update-urls/database/updated/counts', $counts, $old_url, $new_url, $tables, $this );
|
185 |
}
|
186 |
|
187 |
|
@@ -198,6 +197,7 @@ class Database {
|
|
198 |
* @return int[]
|
199 |
*/
|
200 |
public function count_database_urls( $old_url, $new_url, array $tables ) {
|
|
|
201 |
$tables = apply_filters( 'go-live-update-urls/database/update-tables', $tables, $this );
|
202 |
|
203 |
$updates = Updates::factory( $old_url, $new_url, $tables );
|
@@ -206,7 +206,11 @@ class Database {
|
|
206 |
$counts[ $_table ] = $updates->count_table_urls( $_table );
|
207 |
}
|
208 |
|
209 |
-
|
|
|
|
|
|
|
|
|
210 |
}
|
211 |
|
212 |
|
@@ -252,27 +256,8 @@ class Database {
|
|
252 |
public function count_column_urls( $table, $column, $old_url ) {
|
253 |
global $wpdb;
|
254 |
|
255 |
-
$
|
256 |
-
|
257 |
-
return (int) $wpdb->get_var( $wpdb->prepare( $update_query, [ $old_url, $old_url ] ) );
|
258 |
-
}
|
259 |
-
|
260 |
|
261 |
-
|
262 |
-
* Flush any known caches which are affected by updating the database.
|
263 |
-
*
|
264 |
-
* 1. WP core object cache.
|
265 |
-
* 2. Elementor CSS cache.
|
266 |
-
*
|
267 |
-
* @ticket #7751
|
268 |
-
*
|
269 |
-
* @see \Elementor\Settings::update_css_print_method
|
270 |
-
*
|
271 |
-
* @since 6.2.1
|
272 |
-
*/
|
273 |
-
protected function flush_caches() {
|
274 |
-
wp_cache_flush();
|
275 |
-
// Special flush CSS cache for Elementor #7751.
|
276 |
-
do_action( 'update_option_elementor_css_print_method' );
|
277 |
}
|
278 |
}
|
177 |
$counts[ $_table ] += $updates->update_table_columns( $_table );
|
178 |
}
|
179 |
|
180 |
+
$counts = apply_filters( 'go-live-update-urls/database/updated/counts', $counts, $old_url, $new_url, $tables, $this );
|
181 |
|
182 |
do_action( 'go-live-update-urls/database/after-update', $old_url, $new_url, $tables, $this );
|
183 |
+
return $counts;
|
|
|
184 |
}
|
185 |
|
186 |
|
197 |
* @return int[]
|
198 |
*/
|
199 |
public function count_database_urls( $old_url, $new_url, array $tables ) {
|
200 |
+
do_action( 'go-live-update-urls/database/before-counting', $old_url, $new_url, $tables, $this );
|
201 |
$tables = apply_filters( 'go-live-update-urls/database/update-tables', $tables, $this );
|
202 |
|
203 |
$updates = Updates::factory( $old_url, $new_url, $tables );
|
206 |
$counts[ $_table ] = $updates->count_table_urls( $_table );
|
207 |
}
|
208 |
|
209 |
+
$counts = apply_filters( 'go-live-update-urls/database/counted/counts', $counts, $old_url, $new_url, $tables, $this );
|
210 |
+
|
211 |
+
do_action( 'go-live-update-urls/database/after-counting', $old_url, $new_url, $tables, $this );
|
212 |
+
|
213 |
+
return $counts;
|
214 |
}
|
215 |
|
216 |
|
256 |
public function count_column_urls( $table, $column, $old_url ) {
|
257 |
global $wpdb;
|
258 |
|
259 |
+
$query = "SELECT SUM( ROUND( ( LENGTH( `${column}` ) - LENGTH( REPLACE( `${column}`, %s, '' ) ) ) / LENGTH( %s ) ) ) from `${table}`";
|
|
|
|
|
|
|
|
|
260 |
|
261 |
+
return (int) $wpdb->get_var( $wpdb->prepare( $query, [ $old_url, $old_url ] ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
}
|
263 |
}
|
src/Updates.php
CHANGED
@@ -72,7 +72,7 @@ class Updates {
|
|
72 |
$this->update_email_addresses( $table, $column );
|
73 |
|
74 |
if ( null !== $doubled ) {
|
75 |
-
Database::instance()->update_column( $table, $column, $doubled, $this->new_url );
|
76 |
}
|
77 |
} );
|
78 |
|
@@ -88,11 +88,16 @@ class Updates {
|
|
88 |
* @return int
|
89 |
*/
|
90 |
public function count_table_urls( $table ) {
|
|
|
91 |
$columns = $this->get_table_columns( $table );
|
92 |
$count = 0;
|
93 |
-
array_walk( $columns, function ( $column ) use ( $table, &$count ) {
|
94 |
$count += (int) Database::instance()->count_column_urls( $table, $column, $this->old_url );
|
95 |
$count += (int) $this->count_column_urls_with_updaters( $table, $column );
|
|
|
|
|
|
|
|
|
96 |
} );
|
97 |
|
98 |
return $count;
|
@@ -191,10 +196,15 @@ class Updates {
|
|
191 |
$doubled = $this->get_doubled_up_subdomain();
|
192 |
if ( null !== $doubled ) {
|
193 |
$serialized = new Serialized( $doubled, $this->new_url );
|
194 |
-
$
|
|
|
|
|
|
|
195 |
// Remove an prepended subdomain like www. from email addresses.
|
196 |
$serialized = new Serialized( '@' . $this->new_url, '@' . $this->old_url );
|
197 |
-
$
|
|
|
|
|
198 |
}
|
199 |
|
200 |
return $counts;
|
@@ -214,9 +224,8 @@ class Updates {
|
|
214 |
* @return string|null
|
215 |
*/
|
216 |
public function get_doubled_up_subdomain() {
|
217 |
-
if (
|
218 |
-
|
219 |
-
return $subdomain . '.' . $this->new_url;
|
220 |
}
|
221 |
return null;
|
222 |
}
|
@@ -249,6 +258,21 @@ class Updates {
|
|
249 |
}
|
250 |
|
251 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
/**
|
253 |
* Construct the Updates class.
|
254 |
*
|
72 |
$this->update_email_addresses( $table, $column );
|
73 |
|
74 |
if ( null !== $doubled ) {
|
75 |
+
$count -= (int) Database::instance()->update_column( $table, $column, $doubled, $this->new_url );
|
76 |
}
|
77 |
} );
|
78 |
|
88 |
* @return int
|
89 |
*/
|
90 |
public function count_table_urls( $table ) {
|
91 |
+
$doubled = $this->get_doubled_up_subdomain();
|
92 |
$columns = $this->get_table_columns( $table );
|
93 |
$count = 0;
|
94 |
+
array_walk( $columns, function ( $column ) use ( $table, $doubled, &$count ) {
|
95 |
$count += (int) Database::instance()->count_column_urls( $table, $column, $this->old_url );
|
96 |
$count += (int) $this->count_column_urls_with_updaters( $table, $column );
|
97 |
+
|
98 |
+
if ( null !== $doubled ) {
|
99 |
+
$count -= (int) Database::instance()->count_column_urls( $table, $column, $this->new_url );
|
100 |
+
}
|
101 |
} );
|
102 |
|
103 |
return $count;
|
196 |
$doubled = $this->get_doubled_up_subdomain();
|
197 |
if ( null !== $doubled ) {
|
198 |
$serialized = new Serialized( $doubled, $this->new_url );
|
199 |
+
$counts = array_combine( array_keys( $counts ), array_map( function ( $value, $subtract ) {
|
200 |
+
return $value - $subtract;
|
201 |
+
}, $counts, $serialized->update_all_serialized_tables( $this->tables ) ) );
|
202 |
+
|
203 |
// Remove an prepended subdomain like www. from email addresses.
|
204 |
$serialized = new Serialized( '@' . $this->new_url, '@' . $this->old_url );
|
205 |
+
$counts = array_combine( array_keys( $counts ), array_map( function ( $value, $subtract ) {
|
206 |
+
return $value - $subtract;
|
207 |
+
}, $counts, $serialized->update_all_serialized_tables( $this->tables ) ) );
|
208 |
}
|
209 |
|
210 |
return $counts;
|
224 |
* @return string|null
|
225 |
*/
|
226 |
public function get_doubled_up_subdomain() {
|
227 |
+
if ( static::is_subdomain( $this->old_url, $this->new_url ) ) {
|
228 |
+
return str_replace( $this->old_url, $this->new_url, $this->new_url );
|
|
|
229 |
}
|
230 |
return null;
|
231 |
}
|
258 |
}
|
259 |
|
260 |
|
261 |
+
/**
|
262 |
+
* Is a new URL a subdomain of the old URL?
|
263 |
+
*
|
264 |
+
* @param string $old_url - Old URL.
|
265 |
+
* @param string $new_url - New URL.
|
266 |
+
*
|
267 |
+
* @since 6.2.4
|
268 |
+
*
|
269 |
+
* @return bool
|
270 |
+
*/
|
271 |
+
public static function is_subdomain( $old_url, $new_url ) {
|
272 |
+
return strpos( $new_url, $old_url ) !== false;
|
273 |
+
}
|
274 |
+
|
275 |
+
|
276 |
/**
|
277 |
* Construct the Updates class.
|
278 |
*
|