Go Live Update URLS - Version 2.4.0

Version Description

Download this release

Release Info

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

Code changes from version 2.3.0 to 2.4.0

go-live-update-urls.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://lipeimagination.info/
5
  Description: This Plugin 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: http://matlipe.com/
8
- Version: 2.3.0
9
  */
10
 
11
  define( 'GLUU_VIEWS_DIR', plugin_dir_path(__FILE__) . 'views/' );
5
  Description: This Plugin 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: http://matlipe.com/
8
+ Version: 2.4.0
9
  */
10
 
11
  define( 'GLUU_VIEWS_DIR', plugin_dir_path(__FILE__) . 'views/' );
lib/GoLiveUpdateUrls.php CHANGED
@@ -4,7 +4,7 @@
4
  * @author Mat Lipe
5
  * @since 2.2
6
  *
7
- * @since 9.22.13
8
  *
9
  * @TODO Cleanup the Names and formatting
10
  */
@@ -21,16 +21,17 @@ class GoLiveUpdateUrls{
21
  /**
22
  * @since 2.2
23
  *
24
- * @since 9.22.13
25
  */
26
  function __construct(){
27
  global $wpdb;
28
- $pf = $wpdb->base_prefix;
29
  //Add the settings to the admin menu
30
  add_action('admin_menu', array( $this,'gluu_add_url_options') );
31
 
32
  //Add the CSS
33
  add_action( 'admin_head', array( $this,'css') );
 
34
 
35
  //default tables with seralized data
36
  $this->seralized_tables = array(
@@ -38,9 +39,28 @@ class GoLiveUpdateUrls{
38
  $pf.'postmeta' => 'meta_value', //post meta data - since 2.3.0
39
  $pf.'rg_form_meta' => 'display_meta' //gravity forms
40
  );
41
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  }
43
 
 
44
  /**
45
  * For adding Css to the admin
46
  *
@@ -77,6 +97,12 @@ class GoLiveUpdateUrls{
77
 
78
  //If the Form has been submitted make the updates
79
  if( isset( $_POST['gluu-submit'] ) ){
 
 
 
 
 
 
80
  $this->oldurl = trim( strip_tags( $_POST['oldurl'] ) );
81
  $this->newurl = trim( strip_tags( $_POST['newurl'] ) );
82
 
@@ -87,6 +113,8 @@ class GoLiveUpdateUrls{
87
  }
88
  }
89
 
 
 
90
  require( $this->fileHyercy('admin-tools-page.php') );
91
  }
92
 
@@ -94,11 +122,11 @@ class GoLiveUpdateUrls{
94
  /**
95
  * Allows for Overwritting files in the child theme
96
  * @since 2.0
97
- * @param string $file the name of the file to overwrite
98
  *
99
- * @param bool $url if the file is being used for a url
 
100
  */
101
- function fileHyercy( $file , $url = false){
102
  if ( !$theme_file = locate_template(array('go-live-update-urls/'.$file)) ) {
103
  $theme_file = GLUU_VIEWS_DIR . $file;
104
  }
@@ -112,22 +140,38 @@ class GoLiveUpdateUrls{
112
  * Creates a list of checkboxes for each table
113
  *
114
  * @since 2.2
 
 
115
  * @uses by the view admin-tools-page.php
116
  *
117
  * @filter 'gluu_table_checkboxes' with 2 param
118
  * * $output - the html formatted checkboxes
119
  * * $tables - the complete tables object
120
  *
121
- * @filter apply_filters( 'gluu-seralized-tables', $this->seralized_tables ); - effect teh make the updates as well
122
  */
123
  function makeCheckBoxes(){
124
  global $wpdb;
125
- $god_query = "SELECT TABLE_NAME FROM information_schema.TABLES where TABLE_SCHEMA='".$wpdb->dbname."'";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  $tables = $wpdb->get_results($god_query);
127
 
128
  $output = '<ul id="gluu-checkboxes">';
129
 
130
- $seralized_tables = apply_filters( 'gluu-seralized-tables', $this->seralized_tables );
131
 
132
  foreach($tables as $v){
133
  if(in_array( $v->TABLE_NAME, array_keys($seralized_tables)) ){
@@ -148,9 +192,9 @@ class GoLiveUpdateUrls{
148
  * Updates the datbase
149
  *
150
  * @uses the oldurl and newurl set above
151
- * @since 9.22.13
152
  *
153
- * @filters apply_filters( 'gluu-seralized-tables', $this->seralized_tables ); - effects makeCheckBoxes as well
154
  */
155
  function makeTheUpdates(){
156
 
@@ -175,7 +219,7 @@ function makeTheUpdates(){
175
  $this->double_subdomain = $subdomain . '.' . $newurl; //Create a match to what the broken one will be
176
  }
177
 
178
- $seralized_tables = apply_filters( 'gluu-seralized-tables', $this->seralized_tables );
179
 
180
 
181
  //Go throuch each table sent to be updated
4
  * @author Mat Lipe
5
  * @since 2.2
6
  *
7
+ * @since 10.22.13
8
  *
9
  * @TODO Cleanup the Names and formatting
10
  */
21
  /**
22
  * @since 2.2
23
  *
24
+ * @since 10.22.13
25
  */
26
  function __construct(){
27
  global $wpdb;
28
+ $pf = $wpdb->prefix;
29
  //Add the settings to the admin menu
30
  add_action('admin_menu', array( $this,'gluu_add_url_options') );
31
 
32
  //Add the CSS
33
  add_action( 'admin_head', array( $this,'css') );
34
+
35
 
36
  //default tables with seralized data
37
  $this->seralized_tables = array(
39
  $pf.'postmeta' => 'meta_value', //post meta data - since 2.3.0
40
  $pf.'rg_form_meta' => 'display_meta' //gravity forms
41
  );
42
+
43
+ }
44
+
45
+
46
+ /**
47
+ * Retrieve filtered list of seralize safe database tables
48
+ *
49
+ * @since 2.4.0
50
+ *
51
+ * @filters apply_filters( 'gluu-seralized-tables', $this->seralized_tables ); - effects makeCheckBoxes as well
52
+ *
53
+ * @return array( %table_name% => %table_column% )
54
+ */
55
+ function getSerializedTables(){
56
+ static $tables = false;
57
+ if( $tables ) return $tables;
58
+
59
+ return $tables = apply_filters( 'gluu-seralized-tables', $this->seralized_tables );
60
+
61
  }
62
 
63
+
64
  /**
65
  * For adding Css to the admin
66
  *
97
 
98
  //If the Form has been submitted make the updates
99
  if( isset( $_POST['gluu-submit'] ) ){
100
+
101
+ check_admin_referer(plugin_basename( __FILE__ ), 'gluu-manage-options');
102
+
103
+ if( !wp_verify_nonce($_POST[ 'gluu-manage-options' ], plugin_basename(__FILE__)) ){
104
+ wp_die('Ouch! That hurt! You should not be here!' );
105
+ }
106
  $this->oldurl = trim( strip_tags( $_POST['oldurl'] ) );
107
  $this->newurl = trim( strip_tags( $_POST['newurl'] ) );
108
 
113
  }
114
  }
115
 
116
+ $nonce = wp_nonce_field( plugin_basename( __FILE__ ), 'gluu-manage-options', true, false );
117
+
118
  require( $this->fileHyercy('admin-tools-page.php') );
119
  }
120
 
122
  /**
123
  * Allows for Overwritting files in the child theme
124
  * @since 2.0
 
125
  *
126
+ * @since 10.22.13
127
+ * @param string $file the name of the file to overwrite
128
  */
129
+ function fileHyercy( $file){
130
  if ( !$theme_file = locate_template(array('go-live-update-urls/'.$file)) ) {
131
  $theme_file = GLUU_VIEWS_DIR . $file;
132
  }
140
  * Creates a list of checkboxes for each table
141
  *
142
  * @since 2.2
143
+ *
144
+ * @since 10.22.13
145
  * @uses by the view admin-tools-page.php
146
  *
147
  * @filter 'gluu_table_checkboxes' with 2 param
148
  * * $output - the html formatted checkboxes
149
  * * $tables - the complete tables object
150
  *
 
151
  */
152
  function makeCheckBoxes(){
153
  global $wpdb;
154
+
155
+ $god_query = "SELECT TABLE_NAME FROM information_schema.TABLES where TABLE_SCHEMA='".$wpdb->dbname."' AND TABLE_NAME LIKE '".$wpdb->prefix."%'";
156
+
157
+
158
+ //Done this way because like wp_% will return all other tables as well such as wp_2
159
+ if( is_multisite() ){
160
+ if( $wpdb->blogid == 1 ){
161
+ for( $i = 1; $i <= 100; $i++ ){
162
+ $not_like .= "'".$wpdb->prefix.$i."',";
163
+ }
164
+ $not_like = substr($not_like, 0, -1);
165
+ $god_query .= ' AND SUBSTRING(TABLE_NAME,1,4) NOT IN ('. $not_like .') AND SUBSTRING(TABLE_NAME,1,5) NOT IN ('. $not_like .')';
166
+ }
167
+ }
168
+
169
+
170
  $tables = $wpdb->get_results($god_query);
171
 
172
  $output = '<ul id="gluu-checkboxes">';
173
 
174
+ $seralized_tables = $this->getSerializedTables();
175
 
176
  foreach($tables as $v){
177
  if(in_array( $v->TABLE_NAME, array_keys($seralized_tables)) ){
192
  * Updates the datbase
193
  *
194
  * @uses the oldurl and newurl set above
195
+ * @since 10.22.13
196
  *
197
+
198
  */
199
  function makeTheUpdates(){
200
 
219
  $this->double_subdomain = $subdomain . '.' . $newurl; //Create a match to what the broken one will be
220
  }
221
 
222
+ $seralized_tables = $this->getSerializedTables();
223
 
224
 
225
  //Go throuch each table sent to be updated
readme.txt CHANGED
@@ -4,12 +4,14 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=paypa
4
  Tags: Go Live, Urls, Domain Changes
5
  Requires at least: 3.1
6
  Tested up to: 3.6.1
7
- Stable tag: 2.3.0
8
 
9
  == Description ==
10
 
11
  Goes through entire site and replaces all instances of and old url with a new one. Used to change the domain of a site.
12
 
 
 
13
  Some of the features this plugin offers:
14
 
15
  * Database table by table selection in case of issues
@@ -64,6 +66,12 @@ Most tables will be just fine to update. You may make a backup of your database,
64
  1. Screenshot of a tyical settings page. The verbage will change slightly depending on your database structure
65
 
66
  == Changelog ==
 
 
 
 
 
 
67
  = 2.3 =
68
  * Added Post Meta to Seralized Safe to coincide with Simple Links Version 2.0
69
 
@@ -94,6 +102,10 @@ Most tables will be just fine to update. You may make a backup of your database,
94
 
95
  == Upgrade Notice ==
96
 
 
 
 
 
97
  = 1.5 -
98
  This Version will automatically keep email addresses intact when switch to a subdomain like www
99
 
4
  Tags: Go Live, Urls, Domain Changes
5
  Requires at least: 3.1
6
  Tested up to: 3.6.1
7
+ Stable tag: 2.4.0
8
 
9
  == Description ==
10
 
11
  Goes through entire site and replaces all instances of and old url with a new one. Used to change the domain of a site.
12
 
13
+ Works on both multisite and single site installs.
14
+
15
  Some of the features this plugin offers:
16
 
17
  * Database table by table selection in case of issues
66
  1. Screenshot of a tyical settings page. The verbage will change slightly depending on your database structure
67
 
68
  == Changelog ==
69
+
70
+ = 2.4 =
71
+ * Added multisite support
72
+ * Added an uncheck all tables button
73
+ * Enhanced Security
74
+
75
  = 2.3 =
76
  * Added Post Meta to Seralized Safe to coincide with Simple Links Version 2.0
77
 
102
 
103
  == Upgrade Notice ==
104
 
105
+ = 2.4 =
106
+ This Version works properly on mulitsite
107
+ Enhanced Security - you should probably update
108
+
109
  = 1.5 -
110
  This Version will automatically keep email addresses intact when switch to a subdomain like www
111
 
views/admin-tools-page.php CHANGED
@@ -1,3 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
1
  <div id="gluu" class="wrap">
2
  <?php screen_icon('options-general'); ?>
3
  <h2>Go Live Update Urls</h2>
@@ -5,11 +16,12 @@
5
  <h4> This will replace all occurrences "in the entire database" of the old URL with the New URL.
6
  <br />
7
  Uncheck any tables that you would not like to update. </h4>
8
- <div class="error fade"><h4> Please Uncheck any Tables which may contain seralized data. The only table which is currently seralized data safe when using this plugin is <?php echo $table_prefix; ?>options.</h4></div>
9
  <strong><em>Like any other database updating tool, you should always perfrom a backup before running.</em></strong>
10
- <br>
11
-
12
- <form method="post">
 
13
  <?php //Make the boxes to select tables
14
  echo $this->makeCheckBoxes();
15
  ?>
@@ -30,5 +42,20 @@
30
  <p class="submit">
31
  <?php submit_button('Make it Happen', 'primary', 'gluu-submit'); ?>
32
  </p>
 
 
 
 
33
  </form>
34
  </div>
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Main Admin screen view
5
+ *
6
+ * @author Mat Lipe
7
+ *
8
+ * @uses may be overridden in your theme by putting a copy of this file inside a go-live-update-urls folder
9
+ */
10
+ ?>
11
+
12
  <div id="gluu" class="wrap">
13
  <?php screen_icon('options-general'); ?>
14
  <h2>Go Live Update Urls</h2>
16
  <h4> This will replace all occurrences "in the entire database" of the old URL with the New URL.
17
  <br />
18
  Uncheck any tables that you would not like to update. </h4>
19
+ <div class="updated fade"><h4> Please Uncheck any Tables which may contain seralized data. The only tables which are currently seralized data safe when using this plugin is <?php echo implode(', ', array_keys( $this->getSerializedTables() )) ; ?>.</h4></div>
20
  <strong><em>Like any other database updating tool, you should always perfrom a backup before running.</em></strong>
21
+ <p>
22
+ <input type="button" class="button secondary" value="uncheck all" id="uncheck-button"/>
23
+ </p>
24
+ <form method="post" id="gluu-checkbox-form">
25
  <?php //Make the boxes to select tables
26
  echo $this->makeCheckBoxes();
27
  ?>
42
  <p class="submit">
43
  <?php submit_button('Make it Happen', 'primary', 'gluu-submit'); ?>
44
  </p>
45
+ <?php
46
+ echo $nonce;
47
+ ?>
48
+
49
  </form>
50
  </div>
51
+ <script type="text/javascript">
52
+ jQuery('#uncheck-button').click( function(){
53
+ if( jQuery(this).val() == 'uncheck all' ){
54
+ jQuery('#gluu-checkbox-form input[type="checkbox"]').attr('checked',false);
55
+ jQuery(this).val('check all');
56
+ } else {
57
+ jQuery('#gluu-checkbox-form input[type="checkbox"]').attr('checked',true);
58
+ jQuery(this).val('uncheck all');
59
+ }
60
+ });
61
+ </script>
views/go-live-update-urls.css CHANGED
@@ -1,3 +1,13 @@
 
 
 
 
 
 
 
 
 
 
1
  #gluu{
2
  background: black;
3
  padding: 25px;
1
+ /**
2
+ * Main Admin screen css
3
+ *
4
+ * @author Mat Lipe
5
+ *
6
+ * @uses may be overridden in your theme by putting a copy of this file inside a go-live-update-urls folder
7
+ */
8
+
9
+
10
+
11
  #gluu{
12
  background: black;
13
  padding: 25px;