Go Live Update URLS - Version 3.1.1

Version Description

Download this release

Release Info

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

Code changes from version 3.1.0 to 3.1.1

Files changed (3) hide show
  1. go-live-update-urls.php +9 -8
  2. lib/GoLiveUpdateUrls.php +62 -35
  3. readme.txt +2 -2
go-live-update-urls.php CHANGED
@@ -5,21 +5,22 @@ 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: 3.1.0
9
  Text Domain: go-live-update-urls
10
  */
11
- define( 'GLUU_VERSION', "3.1.0" );
12
 
13
  define( 'GLUU_VIEWS_DIR', plugin_dir_path(__FILE__) . 'views/' );
14
  define( 'GLUU_URL_VIEWS_DIR', plugins_url('go-live-update-urls').'/views/' );
15
 
16
- require('lib/GoLiveUpdateUrls.php');
17
 
18
- #-- Translate
19
- add_action('plugins_loaded', 'gluu_translate' );
20
- function gluu_translate(){
21
  load_plugin_textdomain( 'go-live-update-urls', false, 'go-live-update-urls/languages' );
22
- }
23
 
 
24
 
25
- $GoLiveUpdateUrls = new GoLiveUpdateUrls();
 
 
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: 3.1.2
9
  Text Domain: go-live-update-urls
10
  */
11
+ define( 'GLUU_VERSION', "3.1.2" );
12
 
13
  define( 'GLUU_VIEWS_DIR', plugin_dir_path(__FILE__) . 'views/' );
14
  define( 'GLUU_URL_VIEWS_DIR', plugins_url('go-live-update-urls').'/views/' );
15
 
16
+ require( 'lib/GoLiveUpdateUrls.php' );
17
 
18
+ add_action('plugins_loaded', 'gluu_load' );
19
+ function gluu_load(){
 
20
  load_plugin_textdomain( 'go-live-update-urls', false, 'go-live-update-urls/languages' );
 
21
 
22
+ GoLiveUpdateUrls::init();
23
 
24
+ global $GoLiveUpdateUrls; //backward compatibility
25
+ $GoLiveUpdateUrls = GoLiveUpdateUrls::get_instance();
26
+ }
lib/GoLiveUpdateUrls.php CHANGED
@@ -17,14 +17,14 @@ class GoLiveUpdateUrls {
17
  var $double_subdomain = false; //keep track if going to a subdomain
18
 
19
  /*
20
- * seralized_tables
21
  *
22
  * keys are table names
23
  * values are table columns
24
  *
25
  * @var array
26
  */
27
- public $seralized_tables = array();
28
 
29
  /**
30
  * tables
@@ -36,46 +36,15 @@ class GoLiveUpdateUrls {
36
  public $tables = array();
37
 
38
 
39
- /**
40
- * @since 2.2
41
- *
42
- */
43
- function __construct(){
44
- global $wpdb;
45
-
46
  //If the Form has been submitted make the updates
47
  if( !empty( $_POST[ 'gluu-submit' ] ) ){
48
  add_action( 'init', array( $this, 'maybe_run_updates' ) );
49
  }
50
 
51
-
52
  add_action( 'admin_notices', array( $this, 'pro_notice' ) );
53
-
54
- //Add the settings to the admin menu
55
  add_action( 'admin_menu', array( $this, 'gluu_add_url_options' ) );
56
-
57
- //Add the CSS
58
  add_action( 'admin_head', array( $this, 'css' ) );
59
-
60
- //default tables with seralized data
61
- $this->seralized_tables = array(
62
- $wpdb->options => 'option_value', //WP options
63
- $wpdb->postmeta => 'meta_value', //post meta - since 2.3.0
64
- $wpdb->usermeta => 'meta_value', //user meta since 2.5.0
65
- $wpdb->commentmeta => 'meta_value', //comment meta since 2.5.0
66
- $wpdb->sitemeta => 'meta_value' //site meta since 2.5.0
67
- );
68
-
69
- //term meta since WP 4.4
70
- if( isset( $wpdb->termmeta ) ){
71
- $this->seralized_tables[ $wpdb->termmeta ] = 'meta_value';
72
- }
73
-
74
- //we are not going to update user meta if we are not on main blog
75
- if( is_multisite() && $wpdb->blogid != 1 ){
76
- unset( $this->seralized_tables[ $wpdb->usermeta ] );
77
- }
78
-
79
  }
80
 
81
 
@@ -158,8 +127,31 @@ class GoLiveUpdateUrls {
158
  * @return array( %table_name% => %table_column% )
159
  */
160
  function getSerializedTables(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  //@deprecated
162
- $tables = apply_filters( 'gluu-seralized-tables', $this->seralized_tables );
163
 
164
  //use this filter
165
  $tables = apply_filters( 'go-live-update-urls-serialized-tables', $tables );
@@ -458,4 +450,39 @@ class GoLiveUpdateUrls {
458
  }
459
 
460
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
461
  }
17
  var $double_subdomain = false; //keep track if going to a subdomain
18
 
19
  /*
20
+ * serialized_tables
21
  *
22
  * keys are table names
23
  * values are table columns
24
  *
25
  * @var array
26
  */
27
+ public $serialized_tables = array();
28
 
29
  /**
30
  * tables
36
  public $tables = array();
37
 
38
 
39
+ private function hooks(){
 
 
 
 
 
 
40
  //If the Form has been submitted make the updates
41
  if( !empty( $_POST[ 'gluu-submit' ] ) ){
42
  add_action( 'init', array( $this, 'maybe_run_updates' ) );
43
  }
44
 
 
45
  add_action( 'admin_notices', array( $this, 'pro_notice' ) );
 
 
46
  add_action( 'admin_menu', array( $this, 'gluu_add_url_options' ) );
 
 
47
  add_action( 'admin_head', array( $this, 'css' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  }
49
 
50
 
127
  * @return array( %table_name% => %table_column% )
128
  */
129
  function getSerializedTables(){
130
+ if( empty( $this->serialized_tables ) ){
131
+ global $wpdb;
132
+ //default tables with serialized data
133
+ $this->serialized_tables = array(
134
+ $wpdb->options => 'option_value', //WP options
135
+ $wpdb->postmeta => 'meta_value', //post meta - since 2.3.0
136
+ $wpdb->commentmeta => 'meta_value', //comment meta since 2.5.0
137
+ );
138
+
139
+ //term meta since WP 4.4
140
+ if( isset( $wpdb->termmeta ) ){
141
+ $this->serialized_tables[ $wpdb->termmeta ] = 'meta_value';
142
+ }
143
+
144
+ //we are not going to update user meta if we are not on main blog
145
+ if( is_multisite() ){
146
+ $this->serialized_tables[ $wpdb->sitemeta ] = 'meta_value';
147
+ if( 1 === (int) $wpdb->blogid ){
148
+ $this->serialized_tables[ $wpdb->usermeta ] = 'meta_value';
149
+ }
150
+ }
151
+ }
152
+
153
  //@deprecated
154
+ $tables = apply_filters( 'gluu-seralized-tables', $this->serialized_tables );
155
 
156
  //use this filter
157
  $tables = apply_filters( 'go-live-update-urls-serialized-tables', $tables );
450
  }
451
 
452
 
453
+
454
+ //********** SINGLETON FUNCTIONS **********/
455
+
456
+ /**
457
+ * Instance of this class for use as singleton
458
+ */
459
+ private static $instance;
460
+
461
+
462
+ /**
463
+ * Create the instance of the class
464
+ *
465
+ * @static
466
+ * @return void
467
+ */
468
+ public static function init(){
469
+ self::get_instance()->hooks();
470
+ }
471
+
472
+
473
+ /**
474
+ * Get (and instantiate, if necessary) the instance of the
475
+ * class
476
+ *
477
+ * @static
478
+ * @return self
479
+ */
480
+ public static function get_instance(){
481
+ if( !is_a( self::$instance, __CLASS__ ) ){
482
+ self::$instance = new self();
483
+ }
484
+
485
+ return self::$instance;
486
+ }
487
+
488
  }
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: Mat Lipe
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=paypal%40lipeimagination%2einfo&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: 3.1
6
- Tested up to: 4.4.1
7
- Stable tag: 3.1.0
8
 
9
  == Description ==
10
 
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=paypal%40lipeimagination%2einfo&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: 3.1
6
+ Tested up to: 4.5.0
7
+ Stable tag: 3.1.2
8
 
9
  == Description ==
10