Go Live Update URLS - Version 5.0.1

Version Description

Download this release

Release Info

Developer Mat Lipe
Plugin Icon 128x128 Go Live Update URLS
Version 5.0.1
Comparing to
See all releases

Code changes from version 5.0.0 to 5.0.1

go-live-update-urls.php CHANGED
@@ -5,11 +5,11 @@ Plugin URI: https://matlipe.com/go-live-update-urls/
5
  Description: Updates all the URLs in the database to point to the new URL when making your site live or changing domains.
6
  Author: Mat Lipe
7
  Author URI: https://matlipe.com/
8
- Version: 5.0.0
9
  Text Domain: go-live-update-urls
10
  */
11
 
12
- define( 'GO_LIVE_UPDATE_URLS_VERSION', '5.0.0' );
13
 
14
  /** Deprecated to be removed 6/1/18 */
15
  require plugin_dir_path( __FILE__ ) . '/src/GoLiveUpdateUrls.php';
5
  Description: Updates all the URLs in the database to point to the new URL when making your site live or changing domains.
6
  Author: Mat Lipe
7
  Author URI: https://matlipe.com/
8
+ Version: 5.0.1
9
  Text Domain: go-live-update-urls
10
  */
11
 
12
+ define( 'GO_LIVE_UPDATE_URLS_VERSION', '5.0.1' );
13
 
14
  /** Deprecated to be removed 6/1/18 */
15
  require plugin_dir_path( __FILE__ ) . '/src/GoLiveUpdateUrls.php';
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: Mat Lipe
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=paypal%40matlipe%2ecom&lc=US&item_name=Go%20Live%20Update%20Urls&no_note=0&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest
4
  Tags: Go Live, Urls, Domain Changes
5
  Requires at least: 4.5.0
6
- Tested up to: 4.9.1
7
  Requires PHP: 5.2.4
8
- Stable tag: 5.0.0
9
 
10
  == Description ==
11
 
@@ -13,7 +13,7 @@ Goes through entire site and replaces all instances of an old url with a new one
13
 
14
  <strong>Check out <a href="https://matlipe.com/product/go-live-update-urls-pro/" target="_blank">Go Live Update Urls Pro</a> for more features including priority support, the ability to test a URL before running, updating of tables created by plugins, and so much more!</strong>
15
 
16
- <blockquote><a href="https://matlipe.com/product/go-live-update-urls-pro/" target="_blank">Pro version 2.0.3</a> just dropped with lots of great new stuff!</blockquote>
17
 
18
 
19
  <h4>Features</h4>
@@ -39,9 +39,12 @@ Goes through entire site and replaces all instances of an old url with a new one
39
  * Updates serialized data across any table.
40
  * Priority support.
41
  * Improved admin page.
42
- * Ability to test URL changes before running them. **NEW**
43
- * URL testing report is provided for peace of mind. **NEW**
44
- * Optionally fix common mistakes when entering a URL automatically. **NEW**
 
 
 
45
 
46
  <h4>Contribute</h4>
47
  Send pull requests via the <a href="https://github.com/lipemat/go-live-update-urls/">Github Repo</a>
@@ -108,59 +111,11 @@ If you wish to try to update tables mentioned as not safe anyway, you may make a
108
  * Remove misleading UI messages
109
  * Clears cache when finished
110
 
111
- = 2.4 =
112
- * Added multi-site support
113
- * Added an un-check all tables button
114
- * Enhanced Security
115
-
116
- = 2.3 =
117
- * Added Post Meta to Serialized Safe to coincide with Simple Links Version 2.0
118
-
119
- = 2.2 =
120
- * Added Gravity Forms Support to Serialized Safe
121
- * Added a filter for additional serialized safe tables
122
-
123
- = 2.0 =
124
- * Made updating the options table serialized safe *
125
- * Add extending ability of views and css *
126
- * Moved the Admin page to the Tools Section *
127
- * Improved the structure to allow for future changes *
128
-
129
- = 1.5 =
130
- * Added support for automatically keeping email addresses intact when switching to a subdomain like www
131
-
132
- = 1.3 =
133
- * Added support for adding subdomains like www
134
-
135
- = 1.2.1 =
136
- * Added support for other prefixes besides wp_
137
-
138
- = 1.2 =
139
- * Added the wp_options to the available tables to be updated and unchecked the table by default.
140
-
141
- = 1.1 =
142
- * Removed the wp-options table from the tables to be updated.
143
 
144
  == Upgrade Notice ==
 
 
 
145
  = 3.1 =
146
  Upgrade to support WP 4.4's term meta.
147
 
148
- = 2.4 =
149
- This Version works properly on mulit-site
150
- Enhanced Security - you should probably update
151
-
152
- = 1.5 -
153
- This Version will automatically keep email addresses intact when switch to a sub-domain like www
154
-
155
- = 1.3 =
156
- This Version will allow you to switch to www without having to run it twice
157
-
158
- = 1.2.1 =
159
- This Version will un-check your options table by default for the wp_options as well as other table prefixes.
160
-
161
- = 1.2 =
162
- This Version will add the wp_options to the available tables and uncheck the table by default.
163
-
164
- = 1.1 =
165
- This version will remove the wp_options from the available tables.
166
-
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=paypal%40matlipe%2ecom&lc=US&item_name=Go%20Live%20Update%20Urls&no_note=0&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest
4
  Tags: Go Live, Urls, Domain Changes
5
  Requires at least: 4.5.0
6
+ Tested up to: 4.9.4
7
  Requires PHP: 5.2.4
8
+ Stable tag: 5.0.1
9
 
10
  == Description ==
11
 
13
 
14
  <strong>Check out <a href="https://matlipe.com/product/go-live-update-urls-pro/" target="_blank">Go Live Update Urls Pro</a> for more features including priority support, the ability to test a URL before running, updating of tables created by plugins, and so much more!</strong>
15
 
16
+ <blockquote><a href="https://matlipe.com/product/go-live-update-urls-pro/" target="_blank">Pro version 2.2.0</a> just dropped with lots of great new stuff!</blockquote>
17
 
18
 
19
  <h4>Features</h4>
39
  * Updates serialized data across any table.
40
  * Priority support.
41
  * Improved admin page.
42
+ * Ability to test URL changes before running them.
43
+ * URL testing report is provided for peace of mind.
44
+ * Optionally fix common mistakes when entering a URL automatically.
45
+ * View and use history of your Site Address (URL).
46
+ * Predictive URLs automatically fill in the OLD URL and NEW URL.
47
+
48
 
49
  <h4>Contribute</h4>
50
  Send pull requests via the <a href="https://github.com/lipemat/go-live-update-urls/">Github Repo</a>
111
  * Remove misleading UI messages
112
  * Clears cache when finished
113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
 
115
  == Upgrade Notice ==
116
+ = 5.1.1 =
117
+ For full functionality of PRO version 2.2.0
118
+
119
  = 3.1 =
120
  Upgrade to support WP 4.4's term meta.
121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/Core.php CHANGED
@@ -14,6 +14,28 @@ class Go_Live_Update_Urls_Core {
14
 
15
  }
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  /**
18
  * Get a view file from the theme first then this plugin
19
  *
14
 
15
  }
16
 
17
+
18
+ /**
19
+ * Quick and dirty update of entire blog
20
+ *
21
+ * Mostly used for unit testing and future WP-CLI command
22
+ *
23
+ * @param string $old_url
24
+ * @param string $new_url
25
+ *
26
+ * @since 5.0.1
27
+ *
28
+ * @return bool
29
+ */
30
+ public function update( $old_url, $new_url ) {
31
+ $db = Go_Live_Update_Urls_Database::instance();
32
+ $tables = $db->get_all_table_names();
33
+
34
+ do_action( 'go-live-update-urls/core/before-update', $old_url, $new_url, $tables );
35
+
36
+ return $db->update_the_database( $old_url, $new_url, $tables );
37
+ }
38
+
39
  /**
40
  * Get a view file from the theme first then this plugin
41
  *
src/Database.php CHANGED
@@ -55,7 +55,7 @@ class Go_Live_Update_Urls_Database {
55
  */
56
  public function get_custom_plugin_tables() {
57
  $core_tables = $this->get_core_tables();
58
- $all_tables = wp_list_pluck( $this->get_all_tables(), 'TABLE_NAME' );
59
  $all_tables = array_flip( $all_tables );
60
  foreach ( $core_tables as $_table ) {
61
  unset( $all_tables[ $_table ] );
@@ -113,16 +113,15 @@ class Go_Live_Update_Urls_Database {
113
 
114
 
115
  /**
116
- * Get a list of all database table for current install
117
- * Includes custom and standard tables
118
  *
119
- * @static
120
  *
121
- * @return mixed
122
  */
123
- public function get_all_tables() {
124
  global $wpdb;
125
-
126
  $query = "SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA='" . $wpdb->dbname . "' AND TABLE_NAME LIKE '" . $wpdb->prefix . "%'";
127
 
128
  //Done this way because like wp_% will return all other tables as well such as wp_2
@@ -136,7 +135,25 @@ class Go_Live_Update_Urls_Database {
136
  $query .= ' AND SUBSTRING(TABLE_NAME,1,4) NOT IN (' . $not_like . ')';
137
  }
138
 
139
- return $wpdb->get_results( $query );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  }
141
 
142
 
@@ -149,6 +166,8 @@ class Go_Live_Update_Urls_Database {
149
  * @param string $new_url
150
  * @param array $tables
151
  *
 
 
152
  * @return bool
153
  */
154
  public function update_the_database( $old_url, $new_url, array $tables ) {
@@ -156,6 +175,7 @@ class Go_Live_Update_Urls_Database {
156
  $this->old_url = $old_url;
157
  $this->new_url = $new_url;
158
 
 
159
 
160
  @set_time_limit( 0 );
161
  @ini_set( 'memory_limit', '256M' );
@@ -172,8 +192,13 @@ class Go_Live_Update_Urls_Database {
172
  $serialized_tables = $this->get_serialized_tables();
173
  $tables = apply_filters( 'go-live-update-urls/database/update-tables', $tables, $this );
174
 
 
 
 
 
 
175
  //Go through each table sent to be updated
176
- foreach ( array_keys( $tables ) as $table ) {
177
  if ( isset( $serialized_tables[ $table ] ) ) {
178
  if ( is_array( $serialized_tables[ $table ] ) ) {
179
  foreach ( $serialized_tables[ $table ] as $column ) {
@@ -225,6 +250,8 @@ class Go_Live_Update_Urls_Database {
225
 
226
  wp_cache_flush();
227
 
 
 
228
  return true;
229
  }
230
 
55
  */
56
  public function get_custom_plugin_tables() {
57
  $core_tables = $this->get_core_tables();
58
+ $all_tables = $this->get_all_table_names();
59
  $all_tables = array_flip( $all_tables );
60
  foreach ( $core_tables as $_table ) {
61
  unset( $all_tables[ $_table ] );
113
 
114
 
115
  /**
116
+ * Get the names of every table in this blog
117
+ * If we are multisite, we also get the global tables
118
  *
119
+ * @since 5.0.1
120
  *
121
+ * @return array
122
  */
123
+ public function get_all_table_names() {
124
  global $wpdb;
 
125
  $query = "SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA='" . $wpdb->dbname . "' AND TABLE_NAME LIKE '" . $wpdb->prefix . "%'";
126
 
127
  //Done this way because like wp_% will return all other tables as well such as wp_2
135
  $query .= ' AND SUBSTRING(TABLE_NAME,1,4) NOT IN (' . $not_like . ')';
136
  }
137
 
138
+ return $wpdb->get_col( $query );
139
+ }
140
+
141
+
142
+ /**
143
+ * @deprecated 5.0.1
144
+ * @see Go_Live_Update_Urls_Database::get_all_table_names()
145
+ */
146
+ public function get_all_tables() {
147
+ $names = $this->get_all_table_names();
148
+ $tables = array();
149
+
150
+ foreach ( $names as $_name ) {
151
+ $tables[] = array(
152
+ 'TABLE_NAME' => $_name,
153
+ );
154
+ }
155
+
156
+ return $tables;
157
  }
158
 
159
 
166
  * @param string $new_url
167
  * @param array $tables
168
  *
169
+ * @todo split this functionality into its own OOP class
170
+ *
171
  * @return bool
172
  */
173
  public function update_the_database( $old_url, $new_url, array $tables ) {
175
  $this->old_url = $old_url;
176
  $this->new_url = $new_url;
177
 
178
+ do_action( 'go-live-update-urls/database/before-update', $old_url, $new_url, $tables, $this );
179
 
180
  @set_time_limit( 0 );
181
  @ini_set( 'memory_limit', '256M' );
192
  $serialized_tables = $this->get_serialized_tables();
193
  $tables = apply_filters( 'go-live-update-urls/database/update-tables', $tables, $this );
194
 
195
+ //backward compatibility for PRO 2.2.1-
196
+ if ( ! array_values( $tables ) === $tables ) {
197
+ $tables = (array) array_flip( $tables );
198
+ }
199
+
200
  //Go through each table sent to be updated
201
+ foreach ( (array) $tables as $table ) {
202
  if ( isset( $serialized_tables[ $table ] ) ) {
203
  if ( is_array( $serialized_tables[ $table ] ) ) {
204
  foreach ( $serialized_tables[ $table ] as $column ) {
250
 
251
  wp_cache_flush();
252
 
253
+ do_action( 'go-live-update-urls/database/after-update', $old_url, $new_url, $tables, $this );
254
+
255
  return true;
256
  }
257
 
src/GoLiveUpdateUrls.php CHANGED
@@ -14,12 +14,12 @@ class GoLiveUpdateUrls {
14
 
15
  /**
16
  * @deprecated 5.0.0 in favor of Go_Live_Update_Urls_Database::get_all_tables()
17
- * @see Go_Live_Update_Urls_Database::get_all_tables()
18
  */
19
  public static function get_all_tables() {
20
  _deprecated_function( 'GoLiveUpdateUrls::get_all_tables', '5.0.0', 'Go_Live_Update_Urls_Database::get_all_tables' );
21
 
22
- return Go_Live_Update_Urls_Database::instance()->get_all_tables();
23
  }
24
 
25
  //********** SINGLETON FUNCTIONS **********/
14
 
15
  /**
16
  * @deprecated 5.0.0 in favor of Go_Live_Update_Urls_Database::get_all_tables()
17
+ * @see Go_Live_Update_Urls_Database::get_all_table_names()
18
  */
19
  public static function get_all_tables() {
20
  _deprecated_function( 'GoLiveUpdateUrls::get_all_tables', '5.0.0', 'Go_Live_Update_Urls_Database::get_all_tables' );
21
 
22
+ return Go_Live_Update_Urls_Database::instance()->get_all_table_names();
23
  }
24
 
25
  //********** SINGLETON FUNCTIONS **********/
views/admin-tools-page.php CHANGED
@@ -140,6 +140,6 @@ $admin = Go_Live_Update_Urls_Admin_Page::instance();
140
  <?php
141
  }
142
  ?>
143
- <?php submit_button( __( 'Make It Happen', 'go-live-update-urls' ), 'primary', Go_Live_Update_Urls_Admin_Page::SUBMIT ); ?>
144
  </form>
145
  </div>
140
  <?php
141
  }
142
  ?>
143
+ <?php submit_button( __( 'Update URLs', 'go-live-update-urls' ), 'primary', Go_Live_Update_Urls_Admin_Page::SUBMIT ); ?>
144
  </form>
145
  </div>