Go Live Update URLS - Version 1.2

Version Description

  • Added the wp_options to the available tables to be updated and unchecked the table by default.
Download this release

Release Info

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

Version 1.2

Files changed (3) hide show
  1. go-live-functions.php +44 -0
  2. go-live-update-urls.php +68 -0
  3. readme.txt +57 -0
go-live-functions.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ # creates a list of checked boxes for each table
4
+ function make_checked_boxes(){
5
+ global $wpdb;
6
+ $god_query = "SELECT TABLE_NAME FROM information_schema.TABLES where TABLE_SCHEMA='".$wpdb->dbname."'";
7
+
8
+ $all = $wpdb->get_results($god_query);
9
+ echo '<br>';
10
+ foreach($all as $v){
11
+ if($v->TABLE_NAME != 'wp_options'):
12
+ printf('<input name="%s" type="checkbox" value="%s" checked /> %s<br>',$v->TABLE_NAME,$v->TABLE_NAME,$v->TABLE_NAME);
13
+ else:
14
+ printf('<input name="%s" type="checkbox" value="%s" /> %s<br>',$v->TABLE_NAME,$v->TABLE_NAME,$v->TABLE_NAME);
15
+
16
+ endif;
17
+ }
18
+
19
+ }
20
+
21
+ #--------------- Updates the database ----------------------------------------
22
+
23
+ function make_the_updates($oldurl, $newurl){
24
+ global $wpdb;
25
+ foreach($_POST as $v => $i){
26
+ if($v != 'submit' && $v != 'oldurl' && $v != 'newurl'){
27
+ $god_query = "SELECT COLUMN_NAME FROM information_schema.COLUMNS where TABLE_SCHEMA='".$wpdb->dbname."' and TABLE_NAME='".$v."'";
28
+ $all = $wpdb->get_results($god_query);
29
+
30
+
31
+ foreach($all as $t){
32
+ $update_query = "UPDATE ".$v." SET ".$t->COLUMN_NAME." = replace(".$t->COLUMN_NAME.", '".$oldurl."','".$newurl."')";
33
+
34
+ $wpdb->query($update_query);
35
+ }
36
+
37
+ }
38
+
39
+ }
40
+
41
+ }
42
+
43
+
44
+ ?>
go-live-update-urls.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Go Live Update URLS
4
+ 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 channging domains.
6
+ Author: Mat Lipe
7
+ Author URI: http://lipeimagination/
8
+ Version: 1.2
9
+ */
10
+ /* Copyright 2011 Mat Lipe (mat@lipeimagination.info);
11
+
12
+ At Lipe Imagination We believe that information should be free.
13
+ Feel free to do whatever you want with this code as long as your do
14
+ not replicate the name of the Plugin or try to pass off something else
15
+ as an actual Lipe Imagination Script.
16
+
17
+ */
18
+
19
+
20
+
21
+ /* Functions for the options page */
22
+ function add_url_options(){
23
+ add_options_page("Go Live Setings", "Go Live", "manage_options", basename(__FILE__), "url_options_page");
24
+ }
25
+
26
+
27
+ function url_options_page(){
28
+ require('go-live-functions.php');
29
+
30
+ if( isset( $_POST['submit'] ) ){
31
+ $oldurl = $_POST['oldurl'];
32
+ $newurl = $_POST['newurl'];
33
+ make_the_updates($oldurl, $newurl);
34
+ // update_urls($update_links,$oldurl,$newurl);
35
+ echo '<div id="message" class="updated fade"><p><strong>URLs have been updated.</p></strong><p>You can now uninstall this plugin.</p></div>';
36
+ }
37
+ ?>
38
+ <div class="wrap">
39
+ <h2>Go Live Update Urls</h2>
40
+ <form method="post" action="options-general.php?page=<?php echo basename(__FILE__); ?>">
41
+ <p>This will replace all occurrences "in the entire database" of the old URL with the New URL. <br />Uncheck any tables that you would not like to update.</p>
42
+ <h4> THIS DOES NOT UPDATE THE WP_OPTIONS TABLE BY DEFAULT DUE TO WIDGET ISSUES. YOU MUST MANUALLY CHANGE YOUR SITES URL IN THE DASHBOARD'S GENERAL SETTINGS BEFORE RUNNING THIS PLUGIN! IF YOU MUST UPDATE THE WP_OPTIONS TABLE, RUN THIS PLUGIN THEN CLICK SAVE AT THE BOTTOM ON ALL YOUR WIDGETS, THEN RUN THIS PLUGIN WITH THE WP_OPTIONS BOX CHECKED.</h4>
43
+ Like any other database updating tool, you should always prefrom a backup before running.
44
+ <?php make_checked_boxes(); ?>
45
+ <table class="form-table">
46
+ <tr>
47
+ <th scope="row" style="width:150px;"><b>Old URL</b></th>
48
+ <td>
49
+ <input name="oldurl" type="text" id="oldurl" value="" style="width:300px;" />
50
+ </td>
51
+ </tr>
52
+ <tr>
53
+ <th scope="row" style="width:150px;"><b>New URL</b></th>
54
+ <td>
55
+ <input name="newurl" type="text" id="newurl" value="" style="width:300px;" />
56
+ </td>
57
+ </tr>
58
+ </table>
59
+ <p class="submit">
60
+ <input name="submit" value="Make it Happen" type="submit" />
61
+ </p>
62
+ </form>
63
+ <?php
64
+
65
+ } // end of the options_page function
66
+
67
+ add_action('admin_menu', 'add_url_options');
68
+ ?>
readme.txt ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Plugin Name ===
2
+ Contributors: Mat Lipe
3
+ Donate link: http://lipeimagination.info/contact/
4
+ Tags: Go Live, Urls, Domain Changes
5
+ Requires at least: 3.1
6
+ Tested up to: 3.3.1
7
+ Stable tag: 1.2
8
+
9
+ == Description ==
10
+
11
+ Goes through the entire database and replaces all instances of the test domain at Go Live time. Can also be used to replace all instances when changing domains.
12
+
13
+ Allows table by table selection for any issues with widgets/plugins and such.
14
+
15
+ Goes through the entire database and replaces all instances of the test domain at Go Live time. Can also be used to replace all instances when changing domains.
16
+
17
+ Allows table by table selection for any issues with widgets/plugins and such.
18
+
19
+
20
+
21
+ == Installation ==
22
+
23
+ This section describes how to install the plugin and get it working.
24
+
25
+ e.g.
26
+
27
+ 1. Upload the `go-live-upload-urls` folder to the `/wp-content/plugins/` directory
28
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
29
+
30
+
31
+ == Frequently Asked Questions ==
32
+
33
+ = Where do you use this plugin? =
34
+
35
+ Under the settings menu in the dashboard there will be a "Go Live" link.
36
+
37
+ = Why does this one uncheck the wp_options table by default? =
38
+
39
+ There are a few plugins out there that use certain values in the wp-options table which will break of they are changed manually in the database. Sometimes widgets will disappear. If you have some values that must be changed in the wp_options, I have found that you can prevent the disappearing widget problem by going through all of your widgets and clicking save on the bottom of them after you have changed the domain in general settings. You may then run the Update with the wp_options checked. This method is not fool proof, but it has worked on a few instances I have seen an actual need for updated the wp_options table manually.
40
+
41
+
42
+ == Changelog ==
43
+
44
+ = 1.2 =
45
+ * Added the wp_options to the available tables to be updated and unchecked the table by default.
46
+
47
+ = 1.1 =
48
+ * Removed the wp-options table from the tables to be updated.
49
+
50
+ == Upgrade Notice ==
51
+
52
+ = 1.2 =
53
+ This Version will add the wp_options to the available tables and uncheck the table by default.
54
+
55
+ = 1.1 =
56
+ This version will remove the wp_options from the available tables.
57
+