Version Description
Download this release
Release Info
Developer | Mat Lipe |
Plugin | Go Live Update URLS |
Version | 2.5.0 |
Comparing to | |
See all releases |
Code changes from version 2.4.5 to 2.5.0
- go-live-update-urls.php +3 -1
- lib/GoLiveUpdateUrls.php +443 -335
- readme.txt +21 -12
- views/admin-tools-page.php +71 -49
go-live-update-urls.php
CHANGED
@@ -5,9 +5,11 @@ Plugin URI: http://matlipe.com/go-live-update-urls/
|
|
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.
|
9 |
*/
|
10 |
|
|
|
|
|
11 |
define( 'GLUU_VIEWS_DIR', plugin_dir_path(__FILE__) . 'views/' );
|
12 |
define( 'GLUU_URL_VIEWS_DIR', plugins_url('go-live-update-urls').'/views/' );
|
13 |
|
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.5.0
|
9 |
*/
|
10 |
|
11 |
+
define( 'GLUU_VERSION', "2.5.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 |
|
lib/GoLiveUpdateUrls.php
CHANGED
@@ -1,346 +1,454 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Methods for the Go Live Update Urls Plugin
|
|
|
4 |
* @author Mat Lipe
|
5 |
-
* @since
|
6 |
-
*
|
7 |
-
* @
|
8 |
-
*
|
9 |
-
* @TODO Cleanup the Names and formatting
|
10 |
*/
|
11 |
-
class GoLiveUpdateUrls{
|
12 |
-
var $oldurl = false;
|
13 |
-
var $newurl = false;
|
14 |
-
var $double_subdomain = false; //keep track if going to a subdomain
|
15 |
-
|
16 |
-
//Keys are table names, values are table columns
|
17 |
-
//set in self::__construct()
|
18 |
-
public $seralized_tables = array();
|
19 |
-
|
20 |
-
|
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(
|
38 |
-
$pf.'options' => 'option_value', //wordpres options
|
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 |
-
*
|
67 |
-
* @since 2.0
|
68 |
-
*/
|
69 |
-
function css(){
|
70 |
-
?><style type="text/css"><?php
|
71 |
-
include( $this->fileHyercy('go-live-update-urls.css') );
|
72 |
-
?></style><?php
|
73 |
-
|
74 |
-
}
|
75 |
-
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Menu Under Tools Menu
|
79 |
-
*
|
80 |
-
* @since 2.0
|
81 |
-
*/
|
82 |
-
function gluu_add_url_options(){
|
83 |
-
add_management_page("go-live-setting", "Go Live", "manage_options", basename(__FILE__), array( $this,"adminToolsPage") );
|
84 |
-
}
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Output the Admin Page for using this plugin
|
91 |
-
*
|
92 |
-
* @since 2.0
|
93 |
-
*
|
94 |
-
*/
|
95 |
-
function adminToolsPage(){
|
96 |
-
global $table_prefix;
|
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 |
-
|
109 |
-
if( $this->makeTheUpdates() ){
|
110 |
-
echo '<div id="message" class="updated fade"><p><strong>URLs have been updated.</p></strong></div>';
|
111 |
-
} else {
|
112 |
-
echo '<div class="error"><p><strong>You must fill out both boxes to make the update!</p></strong></div>';
|
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 |
-
|
121 |
-
|
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 |
-
}
|
133 |
-
return $theme_file;
|
134 |
-
|
135 |
-
}
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
/**
|
140 |
-
* Creates a list of checkboxes for each table
|
141 |
-
*
|
142 |
-
* @since 2.2
|
143 |
-
*
|
144 |
-
* @since 10.23.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 <= 9; $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 .')';
|
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)) ){
|
178 |
-
$output .= sprintf('<li><input name="%s" type="checkbox" value="%s" checked /> %s - <strong><em>Seralized Safe</strong></em></li>',$v->TABLE_NAME,$v->TABLE_NAME,$v->TABLE_NAME);
|
179 |
-
} else {
|
180 |
-
$output .= sprintf('<li><input name="%s" type="checkbox" value="%s" checked /> %s</li>',$v->TABLE_NAME,$v->TABLE_NAME,$v->TABLE_NAME);
|
181 |
-
}
|
182 |
-
}
|
183 |
-
|
184 |
-
$output .= '</ul>';
|
185 |
-
|
186 |
-
return apply_filters('gluu_table_checkboxes', $output, $tables );
|
187 |
-
|
188 |
-
|
189 |
-
}
|
190 |
|
191 |
-
|
192 |
-
* Updates the datbase
|
193 |
-
*
|
194 |
-
* @uses the oldurl and newurl set above
|
195 |
-
* @since 10.22.13
|
196 |
-
*
|
197 |
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
259 |
|
|
|
|
|
260 |
|
261 |
-
/**
|
262 |
-
* Goes through a table line by line and updates it
|
263 |
-
*
|
264 |
-
* @uses for tables which may contain seralized arrays
|
265 |
-
* @since 2.1
|
266 |
-
*
|
267 |
-
* @param string $table the table to go through
|
268 |
-
* @param string $column to column in the table to go through
|
269 |
-
*
|
270 |
-
* @since 2.26.14
|
271 |
-
*
|
272 |
-
*/
|
273 |
-
function UpdateSeralizedTable( $table, $column = false ){
|
274 |
-
global $wpdb;
|
275 |
-
$pk = $wpdb->get_results("SHOW KEYS FROM $table WHERE Key_name = 'PRIMARY'");
|
276 |
-
$primary_key_column = $pk[0]->Column_name;
|
277 |
-
|
278 |
-
//Get all the Seralized Rows and Replace them properly
|
279 |
-
$rows = $wpdb->get_results("SELECT $primary_key_column, $column FROM $table WHERE $column LIKE 'a:%' OR $column LIKE 'O:%'");
|
280 |
-
|
281 |
-
foreach( $rows as $row ){
|
282 |
-
if( !is_serialized($row->{$column}) ) continue;
|
283 |
-
|
284 |
-
if( strpos($row->{$column}, $this->oldurl) === false ) continue;
|
285 |
-
|
286 |
-
$data = @unserialize($row->{$column});
|
287 |
-
|
288 |
-
$clean = $this->replaceTree($data, $this->oldurl, $this->newurl);
|
289 |
-
//If we switch to a submain we have to run this again to remove the doubles
|
290 |
-
if( $this->double_subdomain ){
|
291 |
-
$clean = $this->replaceTree($clean, $this->double_subdomain, $this->newurl);
|
292 |
-
}
|
293 |
-
|
294 |
-
$clean = @serialize($clean);
|
295 |
-
|
296 |
-
$wpdb->query($wpdb->prepare( "UPDATE $table SET $column=%s WHERE $primary_key_column=%s", $clean, $row->{$primary_key_column} ) );
|
297 |
-
|
298 |
-
}
|
299 |
-
}
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
/**
|
304 |
-
* Replaces all the occurances of a string in a multi dementional array or Object
|
305 |
-
*
|
306 |
-
* @uses itself to call each level of the array
|
307 |
-
* @since 2.1
|
308 |
-
*
|
309 |
-
* @param array|object|string $data to change
|
310 |
-
* @param string $old the old string
|
311 |
-
* @param string $new the new string
|
312 |
-
* @param bool [optional] $changeKeys to replace string in keys as well - defaults to false
|
313 |
-
*
|
314 |
-
* @since 3.26.13
|
315 |
-
*
|
316 |
-
*/
|
317 |
-
function replaceTree( $data, $old, $new, $changeKeys = false ){
|
318 |
-
|
319 |
-
if( is_string($data) ){
|
320 |
-
return trim(str_replace( $old, $new, $data ));
|
321 |
-
}
|
322 |
-
|
323 |
-
if( !is_array( $data) && !is_object($data) ){
|
324 |
-
return $data;
|
325 |
-
}
|
326 |
-
|
327 |
-
|
328 |
-
foreach( $data as $key => $item ){
|
329 |
-
|
330 |
-
if( $changeKeys ){
|
331 |
-
$key = str_replace( $old, $new, $key );
|
332 |
-
}
|
333 |
-
|
334 |
-
if( is_array( $data) ){
|
335 |
-
$data[$key] = $this->replaceTree($item, $old, $new);
|
336 |
-
} else {
|
337 |
-
$data->{$key} = $this->replaceTree($item, $old, $new);
|
338 |
-
}
|
339 |
-
}
|
340 |
-
return $data;
|
341 |
-
}
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
|
346 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
* Methods for the Go Live Update Urls Plugin
|
4 |
+
*
|
5 |
* @author Mat Lipe
|
6 |
+
* @since 2.2
|
7 |
+
*
|
8 |
+
* @TODO split into mutliple classes and cleanup
|
9 |
+
* Once get some funding
|
|
|
10 |
*/
|
11 |
+
class GoLiveUpdateUrls {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
+
var $oldurl = false;
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
var $newurl = false;
|
16 |
+
|
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
|
31 |
+
*
|
32 |
+
* Tables to update, set during self::maybe_make_updates()
|
33 |
+
*
|
34 |
+
* @var array
|
35 |
+
*/
|
36 |
+
public $tables = array();
|
37 |
+
|
38 |
+
|
39 |
+
/**
|
40 |
+
* @since 2.2
|
41 |
+
*
|
42 |
+
* @since 10.22.13
|
43 |
+
*/
|
44 |
+
function __construct(){
|
45 |
+
global $wpdb;
|
46 |
+
$pf = $wpdb->prefix;
|
47 |
+
|
48 |
+
//If the Form has been submitted make the updates
|
49 |
+
if( !empty( $_POST[ 'gluu-submit' ] ) ){
|
50 |
+
add_action( 'init', array( $this, 'maybe_run_updates' ) );
|
51 |
+
}
|
52 |
+
|
53 |
+
|
54 |
+
add_action( 'admin_notices', array( $this, 'pro_notice' ) );
|
55 |
+
|
56 |
+
//Add the settings to the admin menu
|
57 |
+
add_action( 'admin_menu', array( $this, 'gluu_add_url_options' ) );
|
58 |
+
|
59 |
+
//Add the CSS
|
60 |
+
add_action( 'admin_head', array( $this, 'css' ) );
|
61 |
+
|
62 |
+
//default tables with seralized data
|
63 |
+
$this->seralized_tables = array(
|
64 |
+
$wpdb->options => 'option_value', //wordpres options
|
65 |
+
$wpdb->postmeta => 'meta_value', //post meta data - since 2.3.0
|
66 |
+
$pf . 'rg_form_meta' => 'display_meta', //gravity forms
|
67 |
+
$wpdb->usermeta => 'meta_value', //user meta since 2.5.0
|
68 |
+
$wpdb->commentmeta => 'meta_value', //comment meta since 2.5.0
|
69 |
+
$wpdb->sitemeta => 'meta_value' //site meta since 2.5.0
|
70 |
+
);
|
71 |
+
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
+
public function maybe_run_updates(){
|
76 |
+
|
77 |
+
check_admin_referer( plugin_basename( __FILE__ ), 'gluu-manage-options' );
|
78 |
+
|
79 |
+
if( !wp_verify_nonce( $_POST[ 'gluu-manage-options' ], plugin_basename( __FILE__ ) ) ){
|
80 |
+
wp_die( __('Ouch! That hurt! You should not be here!', 'gluu' ) );
|
81 |
+
}
|
82 |
+
|
83 |
+
$this->oldurl = trim( strip_tags( $_POST[ 'oldurl' ] ) );
|
84 |
+
$this->newurl = trim( strip_tags( $_POST[ 'newurl' ] ) );
|
85 |
+
|
86 |
+
$this->tables = $_POST;
|
87 |
+
|
88 |
+
do_action( 'gluu-before-make-update', $this );
|
89 |
+
|
90 |
+
if( $this->makeTheUpdates( $this->tables ) ){
|
91 |
+
add_action( 'admin_notices', array( $this, 'success' ) );
|
92 |
+
} else {
|
93 |
+
add_action( 'admin_notices', array( $this, 'epic_fail' ) );
|
94 |
+
}
|
95 |
+
|
96 |
+
}
|
97 |
+
|
98 |
+
|
99 |
+
public function success(){
|
100 |
+
?>
|
101 |
+
<div id="message" class="updated fade">
|
102 |
+
<p>
|
103 |
+
<strong><?php _e( 'URLs have been updated.', 'gluu' ); ?></strong>
|
104 |
+
</p>
|
105 |
+
</div>
|
106 |
+
<?php
|
107 |
+
}
|
108 |
+
|
109 |
+
|
110 |
+
public function epic_fail(){
|
111 |
+
?>
|
112 |
+
<div id="message" class="error fade">
|
113 |
+
<p>
|
114 |
+
<strong><?php _e( 'You must fill out both boxes to make the update!.', 'gluu' ); ?></strong>
|
115 |
+
</p>
|
116 |
+
</div>
|
117 |
+
<?php
|
118 |
+
|
119 |
+
}
|
120 |
+
|
121 |
+
|
122 |
+
public function pro_notice(){
|
123 |
+
|
124 |
+
if( class_exists( 'Gluu_Pro' ) ){
|
125 |
+
return;
|
126 |
+
}
|
127 |
+
?>
|
128 |
+
<div id="message" class="error">
|
129 |
+
<p>
|
130 |
+
<?php _e( 'Want a smarter, easier to use plugin with better support?', 'gluu' ); ?>
|
131 |
+
<br>
|
132 |
+
<a target="blank" href="http://matlipe.com/product/go-live-update-urls-pro/">
|
133 |
+
<?php _e( 'Go Pro!', 'gluu' ); ?>
|
134 |
+
</a>
|
135 |
+
</p>
|
136 |
+
</div>
|
137 |
+
<?php
|
138 |
+
}
|
139 |
+
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Retrieve filtered list of seralize safe database tables
|
143 |
+
*
|
144 |
+
* @since 2.4.0
|
145 |
+
*
|
146 |
+
* @filters apply_filters( 'gluu-seralized-tables', $this->seralized_tables ); - effects makeCheckBoxes as well
|
147 |
+
*
|
148 |
+
* @return array( %table_name% => %table_column% )
|
149 |
+
*/
|
150 |
+
function getSerializedTables(){
|
151 |
+
|
152 |
+
return $tables = apply_filters( 'gluu-seralized-tables', $this->seralized_tables );
|
153 |
+
}
|
154 |
+
|
155 |
+
|
156 |
+
/**
|
157 |
+
* For adding Css to the admin
|
158 |
+
*
|
159 |
+
* @since 2.0
|
160 |
+
*/
|
161 |
+
function css(){
|
162 |
+
?>
|
163 |
+
<style type="text/css"><?php
|
164 |
+
include( $this->fileHyercy( 'go-live-update-urls.css' ) );
|
165 |
+
?></style><?php
|
166 |
+
|
167 |
+
}
|
168 |
+
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Menu Under Tools Menu
|
172 |
+
*
|
173 |
+
* @since 2.0
|
174 |
+
*/
|
175 |
+
function gluu_add_url_options(){
|
176 |
+
add_management_page( "go-live-setting", "Go Live", "manage_options", basename( __FILE__ ), array(
|
177 |
+
$this,
|
178 |
+
"adminToolsPage"
|
179 |
+
) );
|
180 |
+
}
|
181 |
+
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Output the Admin Page for using this plugin
|
185 |
+
*
|
186 |
+
* @since 2.0
|
187 |
+
*
|
188 |
+
*/
|
189 |
+
function adminToolsPage(){
|
190 |
+
global $table_prefix;
|
191 |
+
|
192 |
+
$nonce = wp_nonce_field( plugin_basename( __FILE__ ), 'gluu-manage-options', true, false );
|
193 |
+
|
194 |
+
require( $this->fileHyercy( 'admin-tools-page.php' ) );
|
195 |
+
}
|
196 |
+
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Allows for Overwritting files in the child theme
|
200 |
+
*
|
201 |
+
* @since 2.0
|
202 |
+
*
|
203 |
+
* @since 10.22.13
|
204 |
+
*
|
205 |
+
* @param string $file the name of the file to overwrite
|
206 |
+
*/
|
207 |
+
function fileHyercy( $file ){
|
208 |
+
if( !$theme_file = locate_template( array( 'go-live-update-urls/' . $file ) ) ){
|
209 |
+
$theme_file = GLUU_VIEWS_DIR . $file;
|
210 |
+
}
|
211 |
+
|
212 |
+
return $theme_file;
|
213 |
+
|
214 |
+
}
|
215 |
+
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Creates a list of checkboxes for each table
|
219 |
+
*
|
220 |
+
* @since 2.2
|
221 |
+
*
|
222 |
+
* @since 10.23.13
|
223 |
+
* @uses by the view admin-tools-page.php
|
224 |
+
*
|
225 |
+
* @filter 'gluu_table_checkboxes' with 2 param
|
226 |
+
* * $output - the html formatted checkboxes
|
227 |
+
* * $tables - the complete tables object
|
228 |
+
*
|
229 |
+
*/
|
230 |
+
function makeCheckBoxes(){
|
231 |
+
|
232 |
+
$tables = self::get_all_tables();
|
233 |
+
|
234 |
+
$output = '<ul id="gluu-checkboxes">';
|
235 |
+
|
236 |
+
$seralized_tables = $this->getSerializedTables();
|
237 |
+
|
238 |
+
foreach( $tables as $v ){
|
239 |
+
if( in_array( $v->TABLE_NAME, array_keys( $seralized_tables ) ) ){
|
240 |
+
$output .= sprintf( '<li><input name="%s" type="checkbox" value="%s" checked /> %s - <strong><em>Seralized Safe</strong></em></li>', $v->TABLE_NAME, $v->TABLE_NAME, $v->TABLE_NAME );
|
241 |
+
} else {
|
242 |
+
$output .= sprintf( '<li><input name="%s" type="checkbox" value="%s" checked /> %s</li>', $v->TABLE_NAME, $v->TABLE_NAME, $v->TABLE_NAME );
|
243 |
+
}
|
244 |
+
}
|
245 |
+
|
246 |
+
$output .= '</ul>';
|
247 |
+
|
248 |
+
return apply_filters( 'gluu_table_checkboxes', $output, $tables );
|
249 |
+
|
250 |
+
|
251 |
+
}
|
252 |
+
|
253 |
+
|
254 |
+
/**
|
255 |
+
* get_all_tables
|
256 |
+
*
|
257 |
+
* Get a list of all database table for current install
|
258 |
+
* Includes custom and standard tables
|
259 |
+
*
|
260 |
+
* @static
|
261 |
+
*
|
262 |
+
* @return mixed
|
263 |
+
*/
|
264 |
+
public static function get_all_tables(){
|
265 |
+
global $wpdb;
|
266 |
+
|
267 |
+
$god_query = "SELECT TABLE_NAME FROM information_schema.TABLES where TABLE_SCHEMA='" . $wpdb->dbname . "' AND TABLE_NAME LIKE '" . $wpdb->prefix . "%'";
|
268 |
+
|
269 |
+
//Done this way because like wp_% will return all other tables as well such as wp_2
|
270 |
+
$not_like = null;
|
271 |
+
if( is_multisite() ){
|
272 |
+
if( $wpdb->blogid == 1 ){
|
273 |
+
for( $i = 1; $i <= 9; $i ++ ){
|
274 |
+
$not_like .= "'" . $wpdb->prefix . $i . "',";
|
275 |
+
}
|
276 |
+
$not_like = substr( $not_like, 0, - 1 );
|
277 |
+
$god_query .= ' AND SUBSTRING(TABLE_NAME,1,4) NOT IN (' . $not_like . ')';
|
278 |
+
}
|
279 |
+
}
|
280 |
+
|
281 |
+
return $wpdb->get_results( $god_query );
|
282 |
+
}
|
283 |
+
|
284 |
+
|
285 |
+
/**
|
286 |
+
* Updates the datbase
|
287 |
+
*
|
288 |
+
* @uses the oldurl and newurl set above
|
289 |
+
* @since 10.22.13
|
290 |
+
*
|
291 |
+
|
292 |
+
*/
|
293 |
+
function makeTheUpdates(){
|
294 |
+
|
295 |
+
//in case of large tables
|
296 |
+
@set_time_limit( 0 );
|
297 |
+
@ini_set( 'memory_limit', '256M' );
|
298 |
+
@ini_set( 'max_input_time', '-1' );
|
299 |
+
|
300 |
+
global $wpdb;
|
301 |
+
|
302 |
+
$oldurl = $this->oldurl;
|
303 |
+
$newurl = $this->newurl;
|
304 |
+
|
305 |
+
//If a box was empty
|
306 |
+
if( $oldurl == '' || $newurl == '' ){
|
307 |
+
return false;
|
308 |
+
}
|
309 |
+
|
310 |
+
// If the new domain is the old one with a new subdomain like www
|
311 |
+
if( strpos( $newurl, $oldurl ) !== false ){
|
312 |
+
list( $subdomain ) = explode( '.', $newurl );
|
313 |
+
$this->double_subdomain = $subdomain . '.' . $newurl; //Create a match to what the broken one will be
|
314 |
+
}
|
315 |
+
|
316 |
+
$seralized_tables = $this->getSerializedTables();
|
317 |
+
|
318 |
+
//Go throuch each table sent to be updated
|
319 |
+
foreach( $this->tables as $v => $i ){
|
320 |
+
|
321 |
+
//Send the options table through the seralized safe Update
|
322 |
+
if( in_array( $v, array_keys( $seralized_tables ) ) ){
|
323 |
+
//in case tables have multiple text columns
|
324 |
+
if( is_array( $seralized_tables[ $v ] ) ){
|
325 |
+
foreach( $seralized_tables[ $v ] as $column ){
|
326 |
+
$this->UpdateSeralizedTable( $v, $column );
|
327 |
+
}
|
328 |
+
} else {
|
329 |
+
$this->UpdateSeralizedTable( $v, $seralized_tables[ $v ] );
|
330 |
+
}
|
331 |
+
}
|
332 |
+
|
333 |
+
if( $v != 'submit' && $v != 'oldurl' && $v != 'newurl' ){
|
334 |
+
|
335 |
+
$god_query = "SELECT COLUMN_NAME FROM information_schema.COLUMNS where TABLE_SCHEMA='" . $wpdb->dbname . "' and TABLE_NAME='" . $v . "'";
|
336 |
+
$all = $wpdb->get_results( $god_query );
|
337 |
+
foreach( $all as $t ){
|
338 |
+
$update_query = "UPDATE " . $v . " SET " . $t->COLUMN_NAME . " = replace(" . $t->COLUMN_NAME . ", '" . $oldurl . "','" . $newurl . "')";
|
339 |
+
//Run the query
|
340 |
+
$wpdb->query( $update_query );
|
341 |
+
|
342 |
+
//Fix the dub dubs if this was the old domain with a new sub
|
343 |
+
if( $this->double_subdomain ){
|
344 |
+
$update_query = "UPDATE " . $v . " SET " . $t->COLUMN_NAME . " = replace(" . $t->COLUMN_NAME . ", '" . $this->double_subdomain . "','" . $newurl . "')";
|
345 |
+
//Run the query
|
346 |
+
$wpdb->query( $update_query );
|
347 |
+
|
348 |
+
//Fix the emails breaking by being appended the new subdomain
|
349 |
+
$update_query = "UPDATE " . $v . " SET " . $t->COLUMN_NAME . " = replace(" . $t->COLUMN_NAME . ", '@" . $newurl . "','@" . $oldurl . "')";
|
350 |
+
$wpdb->query( $update_query );
|
351 |
+
}
|
352 |
+
|
353 |
+
}
|
354 |
+
}
|
355 |
+
}
|
356 |
+
|
357 |
+
return true;
|
358 |
+
}
|
359 |
+
|
360 |
+
|
361 |
+
/**
|
362 |
+
* Goes through a table line by line and updates it
|
363 |
+
*
|
364 |
+
* @uses for tables which may contain seralized arrays
|
365 |
+
* @since 2.1
|
366 |
+
*
|
367 |
+
* @param string $table the table to go through
|
368 |
+
* @param string $column to column in the table to go through
|
369 |
+
*
|
370 |
+
*
|
371 |
+
*/
|
372 |
+
function UpdateSeralizedTable( $table, $column = false ){
|
373 |
+
global $wpdb;
|
374 |
+
$pk = $wpdb->get_results( "SHOW KEYS FROM $table WHERE Key_name = 'PRIMARY'" );
|
375 |
+
if( empty( $pk[ 0 ] ) ){
|
376 |
+
$pk = $wpdb->get_results( "SHOW KEYS FROM $table" );
|
377 |
+
if( empty( $pk[ 0 ] ) ){
|
378 |
+
//fail
|
379 |
+
return;
|
380 |
+
}
|
381 |
+
}
|
382 |
+
|
383 |
+
$primary_key_column = $pk[ 0 ]->Column_name;
|
384 |
+
|
385 |
+
//Get all the Seralized Rows and Replace them properly
|
386 |
+
$rows = $wpdb->get_results( "SELECT $primary_key_column, $column FROM $table WHERE $column LIKE 'a:%' OR $column LIKE 'O:%'" );
|
387 |
+
|
388 |
+
foreach( $rows as $row ){
|
389 |
+
if( !is_serialized( $row->{$column} ) ){
|
390 |
+
continue;
|
391 |
+
}
|
392 |
+
|
393 |
+
if( strpos( $row->{$column}, $this->oldurl ) === false ){
|
394 |
+
continue;
|
395 |
+
}
|
396 |
+
|
397 |
+
$data = @unserialize( $row->{$column} );
|
398 |
+
|
399 |
+
$clean = $this->replaceTree( $data, $this->oldurl, $this->newurl );
|
400 |
+
//If we switch to a submain we have to run this again to remove the doubles
|
401 |
+
if( $this->double_subdomain ){
|
402 |
+
$clean = $this->replaceTree( $clean, $this->double_subdomain, $this->newurl );
|
403 |
+
}
|
404 |
+
|
405 |
+
$clean = @serialize( $clean );
|
406 |
+
|
407 |
+
$wpdb->query( $wpdb->prepare( "UPDATE $table SET $column=%s WHERE $primary_key_column=%s", $clean, $row->{$primary_key_column} ) );
|
408 |
+
|
409 |
+
}
|
410 |
+
}
|
411 |
+
|
412 |
+
|
413 |
+
/**
|
414 |
+
* Replaces all the occurances of a string in a multi dementional array or Object
|
415 |
+
*
|
416 |
+
* @uses itself to call each level of the array
|
417 |
+
* @since 2.1
|
418 |
+
*
|
419 |
+
* @param array|object|string $data to change
|
420 |
+
* @param string $old the old string
|
421 |
+
* @param string $new the new string
|
422 |
+
* @param bool [optional] $changeKeys to replace string in keys as well - defaults to false
|
423 |
+
*
|
424 |
+
* @since 3.26.13
|
425 |
+
*
|
426 |
+
*/
|
427 |
+
function replaceTree( $data, $old, $new, $changeKeys = false ){
|
428 |
+
|
429 |
+
if( is_string( $data ) ){
|
430 |
+
return trim( str_replace( $old, $new, $data ) );
|
431 |
+
}
|
432 |
+
|
433 |
+
if( !is_array( $data ) && !is_object( $data ) ){
|
434 |
+
return $data;
|
435 |
+
}
|
436 |
+
|
437 |
+
foreach( $data as $key => $item ){
|
438 |
+
|
439 |
+
if( $changeKeys ){
|
440 |
+
$key = str_replace( $old, $new, $key );
|
441 |
+
}
|
442 |
+
|
443 |
+
if( is_array( $data ) ){
|
444 |
+
$data[ $key ] = $this->replaceTree( $item, $old, $new );
|
445 |
+
} else {
|
446 |
+
$data->{$key} = $this->replaceTree( $item, $old, $new );
|
447 |
+
}
|
448 |
+
}
|
449 |
|
450 |
+
return $data;
|
451 |
+
}
|
452 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
453 |
|
454 |
}
|
readme.txt
CHANGED
@@ -4,18 +4,23 @@ 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: 4.0.0
|
7 |
-
Stable tag: 2.
|
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
|
18 |
-
* Supports
|
19 |
* Very easy to use admin page - which may be found under Tools
|
20 |
|
21 |
Updates Entire Site including:
|
@@ -32,14 +37,18 @@ Updates Entire Site including:
|
|
32 |
|
33 |
The admin screen is extendable for developers familiar with using filters or template overrides.
|
34 |
|
35 |
-
|
36 |
|
|
|
|
|
37 |
|
38 |
== Installation ==
|
39 |
|
40 |
-
|
|
|
|
|
41 |
|
42 |
-
|
43 |
|
44 |
1. Upload the `go-live-upload-urls` folder to the `/wp-content/plugins/` directory
|
45 |
2. Activate the plugin through the 'Plugins' menu in WordPress
|
@@ -53,17 +62,17 @@ Under the Tools menu in the dashboard there will be a "Go Live" link.
|
|
53 |
|
54 |
= Why does updating the domain break some plugins? =
|
55 |
|
56 |
-
Some plugins will store the data in the database
|
57 |
|
58 |
= How do I know which tables I should not update? =
|
59 |
|
60 |
-
Most tables will be just fine to update. You may make a backup of your database, run this on all tables and if you run into trouble, restore your database, uncheck tables in sections, and rerun this until you find the culpurit. If you find a particular table gives you trouble, let me know and I will add it to the urgent list for
|
61 |
|
62 |
|
63 |
|
64 |
== Screenshots ==
|
65 |
|
66 |
-
1. Screenshot of a
|
67 |
|
68 |
== Changelog ==
|
69 |
|
@@ -73,14 +82,14 @@ Most tables will be just fine to update. You may make a backup of your database,
|
|
73 |
* Enhanced Security
|
74 |
|
75 |
= 2.3 =
|
76 |
-
* Added Post Meta to
|
77 |
|
78 |
= 2.2 =
|
79 |
-
* Added Gravity Forms Support to
|
80 |
-
* Added a filter for additional
|
81 |
|
82 |
= 2.0 =
|
83 |
-
* Made updating the options
|
84 |
* Add extending ability of views and css *
|
85 |
* Moved the Admin page to the Tools Section *
|
86 |
* Improved the structure to allow for future changes *
|
4 |
Tags: Go Live, Urls, Domain Changes
|
5 |
Requires at least: 3.1
|
6 |
Tested up to: 4.0.0
|
7 |
+
Stable tag: 2.5.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 |
+
<h3>Want a smarter, easier to use plugin with better support?</h3>
|
14 |
+
<strong><big><a href="http://matlipe.com/product/go-live-update-urls-pro/">Go Pro!</a></big></strong>
|
15 |
+
|
16 |
+
|
17 |
+
|
18 |
Works on both multisite and single site installs.
|
19 |
|
20 |
Some of the features this plugin offers:
|
21 |
|
22 |
* Database table by table selection in case of issues
|
23 |
+
* Supports serialized data in the options table
|
24 |
* Very easy to use admin page - which may be found under Tools
|
25 |
|
26 |
Updates Entire Site including:
|
37 |
|
38 |
The admin screen is extendable for developers familiar with using filters or template overrides.
|
39 |
|
40 |
+
Additional Serialized Safe tables may be adding using the 'gluu-seralized-tables' filter.
|
41 |
|
42 |
+
To contribute send pull requests:
|
43 |
+
https://github.com/lipemat/go-live-update-urls/
|
44 |
|
45 |
== Installation ==
|
46 |
|
47 |
+
Use the standard WordPress plugins search and installer.
|
48 |
+
Activate the plugin.
|
49 |
+
Use the plugin under the Tools menu in the WordPress admin
|
50 |
|
51 |
+
Manual Installation
|
52 |
|
53 |
1. Upload the `go-live-upload-urls` folder to the `/wp-content/plugins/` directory
|
54 |
2. Activate the plugin through the 'Plugins' menu in WordPress
|
62 |
|
63 |
= Why does updating the domain break some plugins? =
|
64 |
|
65 |
+
Some plugins will store the data in the database serialized which does not allow for easy updating of the data. You may uncheck tables used by such plugins to avoid breakage and then update the urls manually for those plugins. Currently the options, postmeta, and rg_form_meta table as serialization safe.
|
66 |
|
67 |
= How do I know which tables I should not update? =
|
68 |
|
69 |
+
Most tables will be just fine to update. You may make a backup of your database, run this on all tables and if you run into trouble, restore your database, uncheck tables in sections, and rerun this until you find the culpurit. If you find a particular table gives you trouble, let me know and I will add it to the urgent list for serialized safe updating.
|
70 |
|
71 |
|
72 |
|
73 |
== Screenshots ==
|
74 |
|
75 |
+
1. Screenshot of a typical settings page. Theverbiagee will change slightly depending on your database structure
|
76 |
|
77 |
== Changelog ==
|
78 |
|
82 |
* Enhanced Security
|
83 |
|
84 |
= 2.3 =
|
85 |
+
* Added Post Meta to Serialized Safe to coincide with Simple Links Version 2.0
|
86 |
|
87 |
= 2.2 =
|
88 |
+
* Added Gravity Forms Support to Serialized Safe
|
89 |
+
* Added a filter for additional serialized safe tables
|
90 |
|
91 |
= 2.0 =
|
92 |
+
* Made updating the options tableserialized safe *
|
93 |
* Add extending ability of views and css *
|
94 |
* Moved the Admin page to the Tools Section *
|
95 |
* Improved the structure to allow for future changes *
|
views/admin-tools-page.php
CHANGED
@@ -2,60 +2,82 @@
|
|
2 |
|
3 |
/**
|
4 |
* Main Admin screen view
|
5 |
-
*
|
6 |
* @author Mat Lipe
|
7 |
-
*
|
8 |
-
* @uses
|
9 |
*/
|
10 |
?>
|
11 |
|
12 |
<div id="gluu" class="wrap">
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
</div>
|
51 |
<script type="text/javascript">
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
</script>
|
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 |
+
<h2>Go Live Update Urls</h2>
|
14 |
+
|
15 |
+
<h4><?php _e( 'This will replace all occurrences "in the entire database" of the old URL with the New URL.', 'gluu' ); ?></h4>
|
16 |
+
|
17 |
+
<div class="updated fade">
|
18 |
+
<p>
|
19 |
+
<?php
|
20 |
+
$message = sprintf( __( "Please Uncheck any Tables which may contain serialized data. The only tables which are currently serialized data safe when using this plugin are %s", 'gluu' ), "(" . 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.", 'gluu' ); ?>
|
30 |
+
</em>
|
31 |
+
</strong>
|
32 |
+
|
33 |
+
|
34 |
+
<h4>
|
35 |
+
<?php
|
36 |
+
echo apply_filters( 'gluu-uncheck-message', __( 'Uncheck any tables that you would not like to update.', 'gluu' ) );
|
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 |
+
echo $this->makeCheckBoxes();
|
48 |
+
}
|
49 |
+
?>
|
50 |
+
<table class="form-table">
|
51 |
+
<tr>
|
52 |
+
<th scope="row" style="width:150px;"><b>Old URL</b></th>
|
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;"><b>New URL</b></th>
|
59 |
+
<td>
|
60 |
+
<input name="newurl" type="text" id="newurl" value="" style="width:300px;"/>
|
61 |
+
</td>
|
62 |
+
</tr>
|
63 |
+
</table>
|
64 |
+
<p class="submit">
|
65 |
+
<?php submit_button( 'Make it Happen', 'primary', 'gluu-submit' ); ?>
|
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>
|