Version Description
- Restructure admin page to separate WP Core from custom tables
- Remove custom styles in admin
- Improved js structure
- Improved actions and filters
- Improved verbiage with admin
Download this release
Release Info
Developer | Mat Lipe |
Plugin | Go Live Update URLS |
Version | 4.0.0 |
Comparing to | |
See all releases |
Code changes from version 3.1.2 to 4.0.0
- go-live-update-urls.php +5 -4
- languages/go-live-update-urls.pot +60 -25
- readme.txt +9 -2
- resources/js/admin-page.js +26 -0
- {lib → src}/GoLiveUpdateUrls.php +161 -95
- views/admin-tools-page.php +69 -46
- views/go-live-update-urls.css +0 -46
go-live-update-urls.php
CHANGED
@@ -5,15 +5,15 @@ 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:
|
9 |
Text Domain: go-live-update-urls
|
10 |
*/
|
11 |
-
define( 'GLUU_VERSION', "
|
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( '
|
17 |
|
18 |
add_action('plugins_loaded', 'gluu_load' );
|
19 |
function gluu_load(){
|
@@ -21,6 +21,7 @@ function gluu_load(){
|
|
21 |
|
22 |
GoLiveUpdateUrls::init();
|
23 |
|
24 |
-
|
|
|
25 |
$GoLiveUpdateUrls = GoLiveUpdateUrls::get_instance();
|
26 |
}
|
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: 4.0.0
|
9 |
Text Domain: go-live-update-urls
|
10 |
*/
|
11 |
+
define( 'GLUU_VERSION', "4.0.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( 'src/GoLiveUpdateUrls.php' );
|
17 |
|
18 |
add_action('plugins_loaded', 'gluu_load' );
|
19 |
function gluu_load(){
|
21 |
|
22 |
GoLiveUpdateUrls::init();
|
23 |
|
24 |
+
//backward compatibility
|
25 |
+
global $GoLiveUpdateUrls;
|
26 |
$GoLiveUpdateUrls = GoLiveUpdateUrls::get_instance();
|
27 |
}
|
languages/go-live-update-urls.pot
CHANGED
@@ -3,14 +3,14 @@ msgid ""
|
|
3 |
msgstr ""
|
4 |
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
|
5 |
"Project-Id-Version: Go Live Update URLS\n"
|
6 |
-
"POT-Creation-Date:
|
7 |
-
"PO-Revision-Date:
|
8 |
"Last-Translator: \n"
|
9 |
"Language-Team: \n"
|
10 |
"MIME-Version: 1.0\n"
|
11 |
"Content-Type: text/plain; charset=UTF-8\n"
|
12 |
"Content-Transfer-Encoding: 8bit\n"
|
13 |
-
"X-Generator: Poedit 1.8.
|
14 |
"X-Poedit-Basepath: ..\n"
|
15 |
"X-Poedit-WPHeader: go-live-update-urls.php\n"
|
16 |
"X-Poedit-SourceCharset: UTF-8\n"
|
@@ -20,47 +20,82 @@ msgstr ""
|
|
20 |
"X-Poedit-SearchPath-0: .\n"
|
21 |
"X-Poedit-SearchPathExcluded-0: *.js\n"
|
22 |
|
23 |
-
#:
|
24 |
msgid "Ouch! That hurt! You should not be here!"
|
25 |
msgstr ""
|
26 |
|
27 |
-
#:
|
28 |
-
msgid "
|
29 |
msgstr ""
|
30 |
|
31 |
-
#:
|
32 |
msgid "You must fill out both boxes to make the update!."
|
33 |
msgstr ""
|
34 |
|
35 |
-
#:
|
36 |
-
msgid "
|
37 |
msgstr ""
|
38 |
|
39 |
-
#:
|
40 |
-
|
|
|
|
|
|
|
|
|
41 |
msgstr ""
|
42 |
|
43 |
-
#: views/admin-tools-page.php:
|
44 |
msgid ""
|
45 |
-
"
|
46 |
-
"
|
47 |
msgstr ""
|
48 |
|
49 |
-
#: views/admin-tools-page.php:
|
50 |
-
|
|
|
|
|
|
|
51 |
msgid ""
|
52 |
-
"
|
53 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
msgstr ""
|
55 |
|
56 |
-
#: views/admin-tools-page.php:
|
|
|
|
|
57 |
msgid ""
|
58 |
-
"
|
59 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
msgstr ""
|
61 |
|
62 |
-
#: views/admin-tools-page.php:
|
63 |
-
msgid "
|
64 |
msgstr ""
|
65 |
|
66 |
#. Plugin Name of the plugin/theme
|
@@ -73,8 +108,8 @@ msgstr ""
|
|
73 |
|
74 |
#. Description of the plugin/theme
|
75 |
msgid ""
|
76 |
-
"
|
77 |
-
"
|
78 |
msgstr ""
|
79 |
|
80 |
#. Author of the plugin/theme
|
3 |
msgstr ""
|
4 |
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
|
5 |
"Project-Id-Version: Go Live Update URLS\n"
|
6 |
+
"POT-Creation-Date: 2016-05-15 10:48-0400\n"
|
7 |
+
"PO-Revision-Date: 2016-05-15 10:47-0400\n"
|
8 |
"Last-Translator: \n"
|
9 |
"Language-Team: \n"
|
10 |
"MIME-Version: 1.0\n"
|
11 |
"Content-Type: text/plain; charset=UTF-8\n"
|
12 |
"Content-Transfer-Encoding: 8bit\n"
|
13 |
+
"X-Generator: Poedit 1.8.7\n"
|
14 |
"X-Poedit-Basepath: ..\n"
|
15 |
"X-Poedit-WPHeader: go-live-update-urls.php\n"
|
16 |
"X-Poedit-SourceCharset: UTF-8\n"
|
20 |
"X-Poedit-SearchPath-0: .\n"
|
21 |
"X-Poedit-SearchPathExcluded-0: *.js\n"
|
22 |
|
23 |
+
#: src/GoLiveUpdateUrls.php:51
|
24 |
msgid "Ouch! That hurt! You should not be here!"
|
25 |
msgstr ""
|
26 |
|
27 |
+
#: src/GoLiveUpdateUrls.php:74
|
28 |
+
msgid "The URLS in the checked tables have been updated."
|
29 |
msgstr ""
|
30 |
|
31 |
+
#: src/GoLiveUpdateUrls.php:85
|
32 |
msgid "You must fill out both boxes to make the update!."
|
33 |
msgstr ""
|
34 |
|
35 |
+
#: src/GoLiveUpdateUrls.php:203
|
36 |
+
msgid "Serialized Safe"
|
37 |
msgstr ""
|
38 |
|
39 |
+
#: views/admin-tools-page.php:17
|
40 |
+
#, php-format
|
41 |
+
msgctxt "{<strong>}"
|
42 |
+
msgid ""
|
43 |
+
"This will replace all occurrences %sin the entire database%s of the Old URL "
|
44 |
+
"with the New URL."
|
45 |
msgstr ""
|
46 |
|
47 |
+
#: views/admin-tools-page.php:22
|
48 |
msgid ""
|
49 |
+
"Like any other database updating tool, you should always perform a backup "
|
50 |
+
"before running."
|
51 |
msgstr ""
|
52 |
|
53 |
+
#: views/admin-tools-page.php:34
|
54 |
+
msgid "WordPress Core Tables"
|
55 |
+
msgstr ""
|
56 |
+
|
57 |
+
#: views/admin-tools-page.php:37
|
58 |
msgid ""
|
59 |
+
"These tables are safe to update with the basic version of this plugin (the "
|
60 |
+
"version you are currently using)."
|
61 |
+
msgstr ""
|
62 |
+
|
63 |
+
#: views/admin-tools-page.php:44 views/admin-tools-page.php:45
|
64 |
+
#: views/admin-tools-page.php:69
|
65 |
+
msgid "un-check all"
|
66 |
+
msgstr ""
|
67 |
+
|
68 |
+
#: views/admin-tools-page.php:46 views/admin-tools-page.php:68
|
69 |
+
#: views/admin-tools-page.php:70
|
70 |
+
msgid "check all"
|
71 |
+
msgstr ""
|
72 |
+
|
73 |
+
#: views/admin-tools-page.php:58
|
74 |
+
msgid "Tables Created By Plugins"
|
75 |
msgstr ""
|
76 |
|
77 |
+
#: views/admin-tools-page.php:61
|
78 |
+
#, php-format
|
79 |
+
msgctxt "{<br />}{<a>}{</a>}"
|
80 |
msgid ""
|
81 |
+
"These tables are probably NOT SAFE to update with the basic version of this "
|
82 |
+
"plugin. %sTo support tables created by plugins use the %sPro Version%s."
|
83 |
+
msgstr ""
|
84 |
+
|
85 |
+
#: views/admin-tools-page.php:82 views/admin-tools-page.php:85
|
86 |
+
msgid "Old URL"
|
87 |
+
msgstr ""
|
88 |
+
|
89 |
+
#: views/admin-tools-page.php:90 views/admin-tools-page.php:93
|
90 |
+
msgid "New URL"
|
91 |
+
msgstr ""
|
92 |
+
|
93 |
+
#: views/admin-tools-page.php:100
|
94 |
+
msgid "Only the checked tables will be updated."
|
95 |
msgstr ""
|
96 |
|
97 |
+
#: views/admin-tools-page.php:104
|
98 |
+
msgid "Make It Happen"
|
99 |
msgstr ""
|
100 |
|
101 |
#. Plugin Name of the plugin/theme
|
108 |
|
109 |
#. Description of the plugin/theme
|
110 |
msgid ""
|
111 |
+
"Updates all the URLs in the database to point to the new URL when making "
|
112 |
+
"your site live or changing domains."
|
113 |
msgstr ""
|
114 |
|
115 |
#. Author of the plugin/theme
|
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¤cy_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.
|
7 |
-
Stable tag:
|
8 |
|
9 |
== Description ==
|
10 |
|
@@ -73,6 +73,13 @@ Most tables will be just fine to update. You may make a backup of your database,
|
|
73 |
1. Screenshot of a typical settings page. The verbiage will change slightly depending on your database structure
|
74 |
|
75 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
= 3.1 =
|
77 |
* Add support for serialized term meta
|
78 |
|
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¤cy_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.2
|
7 |
+
Stable tag: 4.0.0
|
8 |
|
9 |
== Description ==
|
10 |
|
73 |
1. Screenshot of a typical settings page. The verbiage will change slightly depending on your database structure
|
74 |
|
75 |
== Changelog ==
|
76 |
+
= 4.0.0 =
|
77 |
+
* Restructure admin page to separate WP Core from custom tables
|
78 |
+
* Remove custom styles in admin
|
79 |
+
* Improved js structure
|
80 |
+
* Improved actions and filters
|
81 |
+
* Improved verbiage with admin
|
82 |
+
|
83 |
= 3.1 =
|
84 |
* Add support for serialized term meta
|
85 |
|
resources/js/admin-page.js
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function( $ ){
|
2 |
+
var go_live_update_urls = {
|
3 |
+
init : function(){
|
4 |
+
$( '.gluu-tables-button' ).click( this._un_check_tables );
|
5 |
+
},
|
6 |
+
|
7 |
+
_un_check_tables : function(){
|
8 |
+
var el = $( this );
|
9 |
+
if( el.hasClass( 'checked' ) ){
|
10 |
+
el.removeClass( 'checked' );
|
11 |
+
el.val( el.data( 'un-checked' ) );
|
12 |
+
$( '[data-list="' + el.data( 'list' ) +'"] .gluu-wp-core-table' ).attr( 'checked', false );
|
13 |
+
} else {
|
14 |
+
el.addClass( 'checked' );
|
15 |
+
el.val( el.data( 'checked' ) );
|
16 |
+
$( '[data-list="' + el.data( 'list' ) +'"] .gluu-wp-core-table' ).attr( 'checked', true );
|
17 |
+
}
|
18 |
+
}
|
19 |
+
};
|
20 |
+
|
21 |
+
$( function(){
|
22 |
+
go_live_update_urls.init();
|
23 |
+
} );
|
24 |
+
|
25 |
+
|
26 |
+
})( jQuery );
|
{lib → src}/GoLiveUpdateUrls.php
RENAMED
@@ -5,16 +5,16 @@
|
|
5 |
* @author Mat Lipe
|
6 |
* @since 2.2
|
7 |
*
|
8 |
-
* @TODO split into multiple classes and cleanup
|
9 |
-
* Once get some funding
|
10 |
*/
|
11 |
class GoLiveUpdateUrls {
|
|
|
|
|
12 |
|
13 |
-
|
14 |
|
15 |
-
|
16 |
|
17 |
-
|
18 |
|
19 |
/*
|
20 |
* serialized_tables
|
@@ -42,23 +42,19 @@ class GoLiveUpdateUrls {
|
|
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 |
|
51 |
public function maybe_run_updates(){
|
52 |
-
|
53 |
-
|
54 |
-
if( !wp_verify_nonce( $_POST[ 'gluu-manage-options' ], plugin_basename( __FILE__ ) ) ){
|
55 |
wp_die( __('Ouch! That hurt! You should not be here!', 'go-live-update-urls' ) );
|
56 |
}
|
57 |
|
58 |
$this->oldurl = trim( strip_tags( $_POST[ 'oldurl' ] ) );
|
59 |
$this->newurl = trim( strip_tags( $_POST[ 'newurl' ] ) );
|
60 |
|
61 |
-
$this->tables = $_POST;
|
62 |
|
63 |
do_action( 'gluu-before-make-update', $this );
|
64 |
|
@@ -75,7 +71,7 @@ class GoLiveUpdateUrls {
|
|
75 |
?>
|
76 |
<div id="message" class="updated fade">
|
77 |
<p>
|
78 |
-
<strong><?php _e( '
|
79 |
</p>
|
80 |
</div>
|
81 |
<?php
|
@@ -94,29 +90,6 @@ class GoLiveUpdateUrls {
|
|
94 |
}
|
95 |
|
96 |
|
97 |
-
public function pro_notice(){
|
98 |
-
if( class_exists( 'Gluu_Pro' ) ){
|
99 |
-
return;
|
100 |
-
}
|
101 |
-
|
102 |
-
$screen = get_current_screen();
|
103 |
-
if( "tools_page_GoLiveUpdateUrls" != $screen->id ){
|
104 |
-
return;
|
105 |
-
}
|
106 |
-
?>
|
107 |
-
<div id="message" class="notice updated">
|
108 |
-
<p>
|
109 |
-
<?php _e( 'Want a smarter, easier to use plugin with better support?', 'go-live-update-urls' ); ?>
|
110 |
-
<br>
|
111 |
-
<a target="blank" href="http://matlipe.com/product/go-live-update-urls-pro/">
|
112 |
-
<?php _e( 'Go Pro!', 'go-live-update-urls' ); ?>
|
113 |
-
</a>
|
114 |
-
</p>
|
115 |
-
</div>
|
116 |
-
<?php
|
117 |
-
}
|
118 |
-
|
119 |
-
|
120 |
/**
|
121 |
* Retrieve filtered list of serialized safe database tables
|
122 |
*
|
@@ -159,21 +132,7 @@ class GoLiveUpdateUrls {
|
|
159 |
return $tables;
|
160 |
}
|
161 |
|
162 |
-
|
163 |
-
/**
|
164 |
-
* For adding Css to the admin
|
165 |
-
*
|
166 |
-
* @since 2.0
|
167 |
-
*/
|
168 |
-
function css(){
|
169 |
-
?>
|
170 |
-
<style type="text/css"><?php
|
171 |
-
include( $this->fileHyercy( 'go-live-update-urls.css' ) );
|
172 |
-
?></style><?php
|
173 |
-
|
174 |
-
}
|
175 |
-
|
176 |
-
|
177 |
/**
|
178 |
* Menu Under Tools Menu
|
179 |
*
|
@@ -194,9 +153,8 @@ class GoLiveUpdateUrls {
|
|
194 |
*
|
195 |
*/
|
196 |
function adminToolsPage(){
|
197 |
-
global $table_prefix;
|
198 |
|
199 |
-
|
200 |
|
201 |
require( $this->fileHyercy( 'admin-tools-page.php' ) );
|
202 |
}
|
@@ -226,35 +184,95 @@ class GoLiveUpdateUrls {
|
|
226 |
*
|
227 |
* @since 2.2
|
228 |
*
|
229 |
-
* @
|
230 |
-
* @uses
|
|
|
231 |
*
|
232 |
-
* @
|
233 |
-
* * $output - the html formatted checkboxes
|
234 |
-
* * $tables - the complete tables object
|
235 |
*
|
236 |
*/
|
237 |
-
function makeCheckBoxes(){
|
238 |
-
|
239 |
-
$tables = self::get_all_tables();
|
240 |
|
241 |
-
$output = '<ul id="gluu-checkboxes">';
|
242 |
|
243 |
-
$
|
244 |
|
245 |
-
foreach( $tables as $
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
$output .= sprintf( '<li><input name="%s" type="checkbox" value="%s" checked /> %s</li>', $v->TABLE_NAME, $v->TABLE_NAME, $v->TABLE_NAME );
|
250 |
}
|
|
|
251 |
}
|
252 |
|
253 |
$output .= '</ul>';
|
254 |
|
255 |
-
return
|
|
|
|
|
|
|
256 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
}
|
259 |
|
260 |
|
@@ -298,14 +316,14 @@ class GoLiveUpdateUrls {
|
|
298 |
function makeTheUpdates(){
|
299 |
global $wpdb;
|
300 |
|
|
|
|
|
|
|
|
|
301 |
@set_time_limit( 0 );
|
302 |
@ini_set( 'memory_limit', '256M' );
|
303 |
@ini_set( 'max_input_time', '-1' );
|
304 |
|
305 |
-
if( empty( $this->oldurl ) || empty( $this->newurl ) ){
|
306 |
-
return false;
|
307 |
-
}
|
308 |
-
|
309 |
// If the new domain is the old one with a new sub-domain like www
|
310 |
if( strpos( $this->newurl, $this->oldurl ) !== false ){
|
311 |
list( $subdomain ) = explode( '.', $this->newurl );
|
@@ -326,29 +344,27 @@ class GoLiveUpdateUrls {
|
|
326 |
}
|
327 |
}
|
328 |
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
}
|
351 |
-
}
|
352 |
}
|
353 |
|
354 |
wp_cache_flush();
|
@@ -449,6 +465,56 @@ class GoLiveUpdateUrls {
|
|
449 |
return $data;
|
450 |
}
|
451 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
452 |
|
453 |
|
454 |
//********** SINGLETON FUNCTIONS **********/
|
5 |
* @author Mat Lipe
|
6 |
* @since 2.2
|
7 |
*
|
|
|
|
|
8 |
*/
|
9 |
class GoLiveUpdateUrls {
|
10 |
+
const NONCE = 'gluu-update-tables';
|
11 |
+
const TABLE_INPUT_NAME = 'gluu_table';
|
12 |
|
13 |
+
public $oldurl = false;
|
14 |
|
15 |
+
public $newurl = false;
|
16 |
|
17 |
+
public $double_subdomain = false; //keep track if going to a subdomain
|
18 |
|
19 |
/*
|
20 |
* serialized_tables
|
42 |
add_action( 'init', array( $this, 'maybe_run_updates' ) );
|
43 |
}
|
44 |
|
|
|
45 |
add_action( 'admin_menu', array( $this, 'gluu_add_url_options' ) );
|
|
|
46 |
}
|
47 |
|
48 |
|
49 |
public function maybe_run_updates(){
|
50 |
+
if( !wp_verify_nonce( $_POST[ self::NONCE ], self::NONCE ) ){
|
|
|
|
|
51 |
wp_die( __('Ouch! That hurt! You should not be here!', 'go-live-update-urls' ) );
|
52 |
}
|
53 |
|
54 |
$this->oldurl = trim( strip_tags( $_POST[ 'oldurl' ] ) );
|
55 |
$this->newurl = trim( strip_tags( $_POST[ 'newurl' ] ) );
|
56 |
|
57 |
+
$this->tables = $_POST[ self::TABLE_INPUT_NAME ];
|
58 |
|
59 |
do_action( 'gluu-before-make-update', $this );
|
60 |
|
71 |
?>
|
72 |
<div id="message" class="updated fade">
|
73 |
<p>
|
74 |
+
<strong><?php _e( 'The URLS in the checked tables have been updated.', 'go-live-update-urls' ); ?></strong>
|
75 |
</p>
|
76 |
</div>
|
77 |
<?php
|
90 |
}
|
91 |
|
92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
/**
|
94 |
* Retrieve filtered list of serialized safe database tables
|
95 |
*
|
132 |
return $tables;
|
133 |
}
|
134 |
|
135 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
/**
|
137 |
* Menu Under Tools Menu
|
138 |
*
|
153 |
*
|
154 |
*/
|
155 |
function adminToolsPage(){
|
|
|
156 |
|
157 |
+
wp_enqueue_script( 'gluu-admin-page', self::plugin_url( 'resources/js/admin-page.js'), array( 'jquery'), GLUU_VERSION );
|
158 |
|
159 |
require( $this->fileHyercy( 'admin-tools-page.php' ) );
|
160 |
}
|
184 |
*
|
185 |
* @since 2.2
|
186 |
*
|
187 |
+
* @param array $tables
|
188 |
+
* @param string $list - uses by js to separate lists
|
189 |
+
* @param bool $checked
|
190 |
*
|
191 |
+
* @return string;
|
|
|
|
|
192 |
*
|
193 |
*/
|
194 |
+
function makeCheckBoxes( $tables, $list, $checked = true ){
|
|
|
|
|
195 |
|
196 |
+
$output = '<ul id="gluu-checkboxes" data-list="' . $list . '">';
|
197 |
|
198 |
+
$serialized_tables = $this->getSerializedTables();
|
199 |
|
200 |
+
foreach( $tables as $_table ){
|
201 |
+
$output .= sprintf( '<li><input name="%s[%s]" type="checkbox" value="%s" class="gluu-wp-core-table" %s/> %s', self::TABLE_INPUT_NAME, $_table, $_table, checked( $checked, true, false), $_table );
|
202 |
+
if( in_array( $_table, array_keys( $serialized_tables ) ) ){
|
203 |
+
$output .= sprintf( ' - <strong><em>%s</strong></em>', __( 'Serialized Safe', 'go-live-update-urls' ) );
|
|
|
204 |
}
|
205 |
+
$output .= '</li>';
|
206 |
}
|
207 |
|
208 |
$output .= '</ul>';
|
209 |
|
210 |
+
return $output;
|
211 |
+
|
212 |
+
}
|
213 |
+
|
214 |
|
215 |
+
/**
|
216 |
+
* Get the list of tables that were not create by WP core
|
217 |
+
*
|
218 |
+
* @return array
|
219 |
+
*/
|
220 |
+
public function get_custom_plugin_tables(){
|
221 |
+
$core_tables = $this->get_core_tables();
|
222 |
+
$all_tables = wp_list_pluck( self::get_all_tables(), 'TABLE_NAME' );
|
223 |
+
$all_tables = array_flip( $all_tables );
|
224 |
+
foreach( $core_tables as $_table ){
|
225 |
+
unset( $all_tables[ $_table ] );
|
226 |
+
}
|
227 |
|
228 |
+
return apply_filters( 'go_live_update_urls_plugin_tables' , array_keys( $all_tables ) );
|
229 |
+
}
|
230 |
+
|
231 |
+
|
232 |
+
/**
|
233 |
+
* Get the list of WP core tables
|
234 |
+
*
|
235 |
+
* @since 4.0.0
|
236 |
+
*
|
237 |
+
* @return array
|
238 |
+
*/
|
239 |
+
public function get_core_tables(){
|
240 |
+
global $wpdb;
|
241 |
+
|
242 |
+
//Pre WP 4.4
|
243 |
+
if( !isset( $wpdb->termmeta ) ){
|
244 |
+
$wpdb->termmeta = false;
|
245 |
+
}
|
246 |
+
|
247 |
+
$tables = array(
|
248 |
+
$wpdb->posts,
|
249 |
+
$wpdb->comments,
|
250 |
+
$wpdb->links,
|
251 |
+
$wpdb->options,
|
252 |
+
$wpdb->postmeta,
|
253 |
+
$wpdb->terms,
|
254 |
+
$wpdb->term_taxonomy,
|
255 |
+
$wpdb->term_relationships,
|
256 |
+
$wpdb->termmeta,
|
257 |
+
$wpdb->commentmeta,
|
258 |
+
$wpdb->users,
|
259 |
+
$wpdb->usermeta,
|
260 |
+
);
|
261 |
+
|
262 |
+
if( isset( $wpdb->termmeta ) ){
|
263 |
+
$tables[] = $wpdb->termmeta;
|
264 |
+
}
|
265 |
+
if( is_multisite() ){
|
266 |
+
$tables[] = $wpdb->blogs;
|
267 |
+
$tables[] = $wpdb->signups;
|
268 |
+
$tables[] = $wpdb->site;
|
269 |
+
$tables[] = $wpdb->sitemeta;
|
270 |
+
$tables[] = $wpdb->sitecategories;
|
271 |
+
$tables[] = $wpdb->registration_log;
|
272 |
+
$tables[] = $wpdb->blog_versions;
|
273 |
+
}
|
274 |
+
|
275 |
+
return apply_filters( 'go_live_update_urls_core_tables', $tables );
|
276 |
}
|
277 |
|
278 |
|
316 |
function makeTheUpdates(){
|
317 |
global $wpdb;
|
318 |
|
319 |
+
if( empty( $this->oldurl ) || empty( $this->newurl ) ){
|
320 |
+
return false;
|
321 |
+
}
|
322 |
+
|
323 |
@set_time_limit( 0 );
|
324 |
@ini_set( 'memory_limit', '256M' );
|
325 |
@ini_set( 'max_input_time', '-1' );
|
326 |
|
|
|
|
|
|
|
|
|
327 |
// If the new domain is the old one with a new sub-domain like www
|
328 |
if( strpos( $this->newurl, $this->oldurl ) !== false ){
|
329 |
list( $subdomain ) = explode( '.', $this->newurl );
|
344 |
}
|
345 |
}
|
346 |
|
347 |
+
$column_query = "SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='" . $wpdb->dbname . "' AND TABLE_NAME='" . $table . "'";
|
348 |
+
$columns = $wpdb->get_col( $column_query );
|
349 |
+
|
350 |
+
foreach( $columns as $_column ){
|
351 |
+
$update_query = "UPDATE " . $table . " SET " . $_column . " = replace(" . $_column . ", %s, %s)";
|
352 |
+
$wpdb->query( $wpdb->prepare( $update_query, array( $this->oldurl, $this->newurl ) ) );
|
353 |
+
|
354 |
+
//Fix the dub dubs if this was the old domain with a new sub
|
355 |
+
if( $this->double_subdomain ){
|
356 |
+
$wpdb->query( $wpdb->prepare( $update_query, array(
|
357 |
+
$this->double_subdomain,
|
358 |
+
$this->newurl,
|
359 |
+
) ) );
|
360 |
+
//Fix the emails breaking by being appended the new subdomain
|
361 |
+
$wpdb->query( $wpdb->prepare( $update_query, array(
|
362 |
+
"@" . $this->newurl,
|
363 |
+
"@" . $this->oldurl,
|
364 |
+
) ) );
|
365 |
+
}
|
366 |
+
}
|
367 |
+
|
|
|
|
|
368 |
}
|
369 |
|
370 |
wp_cache_flush();
|
465 |
return $data;
|
466 |
}
|
467 |
|
468 |
+
/**************** static ****************************/
|
469 |
+
|
470 |
+
/**
|
471 |
+
* Used along with self::plugin_path() to return path to this plugins files
|
472 |
+
*
|
473 |
+
* @var string
|
474 |
+
*/
|
475 |
+
private static $plugin_path = false;
|
476 |
+
|
477 |
+
/**
|
478 |
+
* To keep track of this plugins root dir
|
479 |
+
* Used along with self::plugin_url() to return url to plugin files
|
480 |
+
*
|
481 |
+
* @var string
|
482 |
+
*/
|
483 |
+
private static $plugin_url;
|
484 |
+
|
485 |
+
|
486 |
+
/**
|
487 |
+
* Retrieve the path this plugins dir
|
488 |
+
*
|
489 |
+
* @param string [$append] - optional path file or name to add
|
490 |
+
*
|
491 |
+
* @return string
|
492 |
+
*/
|
493 |
+
public static function plugin_path( $append = '' ){
|
494 |
+
|
495 |
+
if( !self::$plugin_path ){
|
496 |
+
self::$plugin_path = trailingslashit( dirname( dirname( __FILE__ ) ) );
|
497 |
+
}
|
498 |
+
|
499 |
+
return self::$plugin_path . $append;
|
500 |
+
}
|
501 |
+
|
502 |
+
|
503 |
+
/**
|
504 |
+
* Retrieve the url this plugins dir
|
505 |
+
*
|
506 |
+
* @param string [$append] - optional path file or name to add
|
507 |
+
*
|
508 |
+
* @return string
|
509 |
+
*/
|
510 |
+
public static function plugin_url( $append = '' ){
|
511 |
+
|
512 |
+
if( !self::$plugin_url ){
|
513 |
+
self::$plugin_url = trailingslashit( plugins_url( basename( self::plugin_path() ), dirname( dirname( __FILE__ ) ) ) );
|
514 |
+
}
|
515 |
+
|
516 |
+
return self::$plugin_url . $append;
|
517 |
+
}
|
518 |
|
519 |
|
520 |
//********** SINGLETON FUNCTIONS **********/
|
views/admin-tools-page.php
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
* Main Admin screen view
|
5 |
*
|
@@ -7,77 +6,101 @@
|
|
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 |
<h2>Go Live Update Urls</h2>
|
14 |
|
15 |
-
<
|
16 |
-
|
17 |
-
|
18 |
-
<p>
|
19 |
-
<?php
|
20 |
-
$message = sprintf( __( "Please un-check any tables which may contain serialized data. The only tables which are currently serialized data safe when using this plugin are %s", 'go-live-update-urls' ), "(" . implode( ', ', array_keys( $this->getSerializedTables() ) ) . ")" );
|
21 |
-
|
22 |
-
echo apply_filters( 'gluu-top-message', $message, $this->getSerializedTables() );
|
23 |
-
?>
|
24 |
-
</p>
|
25 |
-
</div>
|
26 |
|
27 |
<strong>
|
28 |
<em style="color:red">
|
29 |
<?php _e( "Like any other database updating tool, you should always perform a backup before running.", 'go-live-update-urls' ); ?>
|
30 |
</em>
|
31 |
</strong>
|
|
|
32 |
|
33 |
-
|
34 |
-
<h4>
|
35 |
<?php
|
36 |
-
|
37 |
-
?>
|
38 |
-
</h4>
|
39 |
|
|
|
40 |
|
41 |
-
<p>
|
42 |
-
<input type="button" class="button secondary" value="uncheck all" id="uncheck-button"/>
|
43 |
-
</p>
|
44 |
-
<form method="post" id="gluu-checkbox-form">
|
45 |
-
<?php //Make the boxes to select tables
|
46 |
if( apply_filters( 'gluu-use-default_checkboxes', true ) ){
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
}
|
|
|
|
|
|
|
49 |
?>
|
|
|
50 |
<table class="form-table">
|
51 |
<tr>
|
52 |
-
<th scope="row" style="width:150px;"
|
|
|
|
|
53 |
<td>
|
54 |
-
<input name="oldurl" type="text" id="oldurl" value="" style="width:300px;"/>
|
55 |
</td>
|
56 |
</tr>
|
57 |
<tr>
|
58 |
-
<th scope="row" style="width:150px;"
|
|
|
|
|
59 |
<td>
|
60 |
-
<input name="newurl" type="text" id="newurl" value="" style="width:300px;"/>
|
61 |
</td>
|
62 |
</tr>
|
63 |
</table>
|
64 |
-
<p class="
|
65 |
-
|
|
|
|
|
|
|
|
|
66 |
</p>
|
67 |
-
<?php
|
68 |
-
echo $nonce;
|
69 |
-
?>
|
70 |
-
|
71 |
</form>
|
72 |
-
</div>
|
73 |
-
<script type="text/javascript">
|
74 |
-
jQuery( '#uncheck-button' ).click( function(){
|
75 |
-
if( jQuery( this ).val() == 'uncheck all' ){
|
76 |
-
jQuery( '#gluu-checkbox-form input[type="checkbox"]' ).attr( 'checked', false );
|
77 |
-
jQuery( this ).val( 'check all' );
|
78 |
-
} else {
|
79 |
-
jQuery( '#gluu-checkbox-form input[type="checkbox"]' ).attr( 'checked', true );
|
80 |
-
jQuery( this ).val( 'uncheck all' );
|
81 |
-
}
|
82 |
-
} );
|
83 |
-
</script>
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* Main Admin screen view
|
4 |
*
|
6 |
*
|
7 |
* @uses may be overridden in your theme by putting a copy of this file inside a go-live-update-urls folder
|
8 |
*/
|
|
|
9 |
|
10 |
+
$gluu = GoLiveUpdateUrls::get_instance();
|
11 |
+
|
12 |
+
?>
|
13 |
<div id="gluu" class="wrap">
|
14 |
<h2>Go Live Update Urls</h2>
|
15 |
|
16 |
+
<p class="description">
|
17 |
+
<?php printf( _x( 'This will replace all occurrences %sin the entire database%s of the Old URL with the New URL.', '{<strong>}', '{/strong}', 'go-live-update-urls' ), '<strong>', '</strong>' ); ?>
|
18 |
+
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
<strong>
|
21 |
<em style="color:red">
|
22 |
<?php _e( "Like any other database updating tool, you should always perform a backup before running.", 'go-live-update-urls' ); ?>
|
23 |
</em>
|
24 |
</strong>
|
25 |
+
<hr />
|
26 |
|
27 |
+
<form method="post" id="gluu-checkbox-form">
|
|
|
28 |
<?php
|
29 |
+
wp_nonce_field( GoLiveUpdateUrls::NONCE, GoLiveUpdateUrls::NONCE );
|
|
|
|
|
30 |
|
31 |
+
do_action( 'gluu_before_checkboxes', $gluu );
|
32 |
|
|
|
|
|
|
|
|
|
|
|
33 |
if( apply_filters( 'gluu-use-default_checkboxes', true ) ){
|
34 |
+
?>
|
35 |
+
<h2>
|
36 |
+
<?php _e( 'WordPress Core Tables', 'go-live-update-urls' ); ?>
|
37 |
+
</h2>
|
38 |
+
<p class="description">
|
39 |
+
<?php _e( 'These tables are safe to update with the basic version of this plugin (the version you are currently using).', 'go-live-update-urls' ); ?>
|
40 |
+
</p>
|
41 |
+
<p>
|
42 |
+
<input
|
43 |
+
type="button"
|
44 |
+
class="button-secondary checked gluu-tables-button"
|
45 |
+
data-list="wp-core"
|
46 |
+
value="<?php _e( 'un-check all', 'go-live-update-urls' ); ?>"
|
47 |
+
data-checked="<?php _e( 'un-check all', 'go-live-update-urls' ); ?>"
|
48 |
+
data-un-checked="<?php _e( 'check all', 'go-live-update-urls' ); ?>" />
|
49 |
+
</p>
|
50 |
+
<?php
|
51 |
+
echo $gluu->makeCheckBoxes( $gluu->get_core_tables(), "wp-core" );
|
52 |
+
?>
|
53 |
+
|
54 |
+
<hr />
|
55 |
+
|
56 |
+
<h2>
|
57 |
+
<?php _e( 'Tables Created By Plugins', 'go-live-update-urls' ); ?>
|
58 |
+
</h2>
|
59 |
+
<p class="description" style="color:red">
|
60 |
+
<strong><?php printf( _x( 'These tables are probably NOT SAFE to update with the basic version of this plugin. %sTo support tables created by plugins use the %sPro Version%s.', '{<br />}{<a>}{</a>}', 'go-live-update-urls' ), '<br />', '<a href="https://matlipe.com/product/go-live-update-urls-pro/" target="_blank">', '</a>' ); ?></strong>
|
61 |
+
</p>
|
62 |
+
<p>
|
63 |
+
<input
|
64 |
+
type="button"
|
65 |
+
class="button-secondary gluu-tables-button"
|
66 |
+
data-list="custom-plugins"
|
67 |
+
value="<?php _e( 'check all', 'go-live-update-urls' ); ?>"
|
68 |
+
data-checked="<?php _e( 'un-check all', 'go-live-update-urls' ); ?>"
|
69 |
+
data-un-checked="<?php _e( 'check all', 'go-live-update-urls' ); ?>" />
|
70 |
+
</p>
|
71 |
+
<?php
|
72 |
+
echo $gluu->makeCheckBoxes( $gluu->get_custom_plugin_tables(), "custom-plugins", false );
|
73 |
}
|
74 |
+
|
75 |
+
do_action( 'gluu_after_checkboxes', $gluu );
|
76 |
+
|
77 |
?>
|
78 |
+
<hr />
|
79 |
<table class="form-table">
|
80 |
<tr>
|
81 |
+
<th scope="row" style="width:150px;">
|
82 |
+
<b><?php _e( 'Old URL', 'go-live-update-urls' ); ?></b>
|
83 |
+
</th>
|
84 |
<td>
|
85 |
+
<input name="oldurl" type="text" id="oldurl" value="" style="width:300px;" title="<?php _e( 'Old URL', 'go-live-update-urls' ); ?>"/>
|
86 |
</td>
|
87 |
</tr>
|
88 |
<tr>
|
89 |
+
<th scope="row" style="width:150px;">
|
90 |
+
<b><?php _e( 'New URL', 'go-live-update-urls' ); ?></b>
|
91 |
+
</th>
|
92 |
<td>
|
93 |
+
<input name="newurl" type="text" id="newurl" value="" style="width:300px;" title="<?php _e( 'New URL', 'go-live-update-urls' ); ?>"/>
|
94 |
</td>
|
95 |
</tr>
|
96 |
</table>
|
97 |
+
<p class="description">
|
98 |
+
<strong>
|
99 |
+
<?php
|
100 |
+
echo apply_filters( 'gluu-uncheck-message', __( 'Only the checked tables will be updated.', 'go-live-update-urls' ) );
|
101 |
+
?>
|
102 |
+
</strong>
|
103 |
</p>
|
104 |
+
<?php submit_button( __( 'Make It Happen', 'go-live-update-urls' ), 'primary', 'gluu-submit' ); ?>
|
|
|
|
|
|
|
105 |
</form>
|
106 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
views/go-live-update-urls.css
DELETED
@@ -1,46 +0,0 @@
|
|
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;
|
14 |
-
width: 520px;
|
15 |
-
border-radius: 20px;
|
16 |
-
color: white;
|
17 |
-
-moz-box-shadow: 0 0 5px 5px #888;
|
18 |
-
-webkit-box-shadow: 0 0 5px 5px#888;
|
19 |
-
box-shadow: 0 0 5px 5px #888;
|
20 |
-
margin: 40px 0 0 40px;
|
21 |
-
}
|
22 |
-
|
23 |
-
#gluu .error{
|
24 |
-
color: #000000;
|
25 |
-
}
|
26 |
-
|
27 |
-
#gluu h2{
|
28 |
-
color: white;
|
29 |
-
text-shadow: blue 0 1px 0;
|
30 |
-
}
|
31 |
-
|
32 |
-
#gluu .form-table b{
|
33 |
-
font-size: 16px;
|
34 |
-
color: white;
|
35 |
-
text-shadow: blue 0 1px 0;
|
36 |
-
}
|
37 |
-
|
38 |
-
#gluu input[type="text"]{
|
39 |
-
font-weight: bold;
|
40 |
-
padding: 6px;
|
41 |
-
}
|
42 |
-
|
43 |
-
#gluu .updated{
|
44 |
-
color: black;
|
45 |
-
}
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|