css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
                <header>
    <h1>Moving Wordpress SQL Wizard - Table Prefix Fork</h1>
  </header>

    <main class="wrap">
    <!-- The wizard -->
      <article class="wizard">
        <h2>Settings:</h2>
        <p>
          <label for="prefix">Table Prefix: <i><small>Default is wp_</small></i></label>
          <input type="text" id="prefix" value="wp_"/> 
        </p>
        <p>
          <label for="old-url">Old url: <small><i>(Without the www)</i></small></label>
          <input type="text" id="old-url" value="http://localhost:8888/testing"/>
          </p>
        <p>
        <label for="new-url">New url: </label>
        <input type="text" id="new-url" value="http://www.live-website.com"/>
        </p>
        <p>
          <label class="incw-label">Inc www</label>
          <input id="incw" type="checkbox" checked="checked"/><i><small>(incase some of the links reference a www.yourdomain.com)</small></i></p>

        <p><small>NB: Try to make sure there are no <code>/</code>'s on the end.  Wordpress doesn't use these on a few of the links, and sometimes this will stop the following commands overwriting what they need to.</small></p>
      </article>

      <div class="sql">
          <h2>Your SQL:</h2>
          <pre class="prettyprint"><code id="code"></code></pre>
      </div>

      <aside>
      <h2>How to use this</h2>

      <p>Open up PHPMyAdmin or similar, choose your database and hit 'SQL' at the top. Paste the code below into the text area and press 'Go'.</p>
      </aside>
    </main>

    <footer>
      <article>

      <p>Original Codepen by <a href="https://djave.co.uk/">djave</a> - <a href="https://codepen.io/EightArmsHQ/full/nzEjI">View Original</a>

      <p>Fork by <a href="https://jonashcroft.co.uk">jonashcroft</a> (me!)</p>

        <p>
         I've found myself using djave's Codepen on all my projects, but it's always bothered me that I couldn't easily enter a custom database prefix within the script itself, so I decided to fork it.</p>

         <p>Sidebar: I take absolutely no responsibility for anything that goes wrong when using this. Please make sure you're responsible with your databases and have backups.</p>

         <p>Huge, huge credit to djave for the original script, all I did was change a few lines.</p>
      </article>
    </footer>
            
          
!
            
              @import url('https://fonts.googleapis.com/css?family=Roboto');

html {
  box-sizing: border-box;
}

*, *:before, *:after {
  box-sizing: inherit;
}

h2, h3 {
  font-weight: normal;
  padding: 0 0 0.3em;
  margin:0;
}

h1 {
  font-size: 2em;
}

h2 {
  font-size: 1.4em;
}

h3 {
  font-size: 1em;
  // font-family: AmaticBold;
  padding: 0.3em 0;
}

ol {
  list-style-type: decimal;
}

ul {
  list-style-type: disc;
}

ol.list, ul.list {
  border-top: 1px solid #ebebeb;
  border-bottom: 1px solid #ebebeb;
  padding: 0.5em 0;
  list-style-position: inside;
  margin: 0 0 0 10px;
}

a {
  color: #000;
  display:inline-block;
  border-bottom:1px solid #fff;
  text-decoration: none;
  cursor: pointer;
}

pre {
  background: #f3f3f7;
  border: 1px solid #dedee3;
  padding: 11px;
  font-size: 12px;
  line-height: 1.3em;
  margin-bottom: 22px;
  overflow: scroll;
}

pre, code {
  font-size: 0.8em;
  // white-space:normal;
  font-family:monaco, "Courier New", mono;
}

small{
  font-size:0.7em;
  font-family:sans-serif;
}

body{
  padding: 0;
  font-family: 'Roboto', sans-serif;
  font-size: 16px;
  background-color: #607D8B;
  margin: 0;
  color:rgb(68, 68, 68);}

header{
  background-color: #607D8B;
  color: white;
  border-top: 11px solid #455A64;
  padding: 25px;
  margin-bottom: 50px;

  hr{
  	background-color: red;
  	color: red;
  	border-color: red;
  }

  h1{
	  max-width: 1024px;
	  margin: 0 auto;
  }
}

main{
  background: white;
  max-width: 1024px;
  margin: 0 auto;
  border: 1px solid #f1f1f1;
  padding: 15px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);

  article{
  	&.wizard{
		input[type="text"] {
		  width: 100%;
		  padding:15px;
		  border-radius: 0;
		  border: 1px solid #607D8B;
		  font-size: 1em;
		}
		label{
		  display:inline-block;
		  width: 100%;
		  padding: 0 5px 0 0;
		  font-weight: 600;
		  margin-bottom: 5px;

		  &.incw-label{
		  	width: auto;
		  }

		  #incw{
		  	display: inline-block;
		  	width: 150px !important;
		  }

		  i{
		  	margin-left: 10px;
		  }
		}
  	}
  }

  div.sql{
  	margin: 25px 0;
  }
}

footer{
	background-color: #455A64;
	padding: 50px;
	margin-top: 40px;

	article{
		max-width: 850px;
		margin: 0 auto;
		color: white;
		font-size: 0.9em;
		line-height: 1.5em;

		a{
			color: white;
		}

	}
}
            
          
!
            
              // Define variables
var prefix = $("#prefix").val();
var old_url = $("#old-url").val();
var new_url = $("#new-url").val();
var the_sql;


// Define functions
function create_sql(){
    the_sql = "UPDATE "+prefix+"options SET option_value = replace(option_value, '"+old_url+"', '"+new_url+"') WHERE option_name = 'home' OR option_name = 'siteurl';<br/><br/>";
    
    the_sql += "UPDATE "+prefix+"posts SET guid = replace(guid, '"+old_url+"','"+new_url+"');<br/><br/>";
    
    the_sql += "UPDATE "+prefix+"posts SET post_content = replace(post_content, '"+old_url+"', '"+new_url+"');<br/><br/>";
    
    the_sql += "UPDATE "+prefix+"postmeta SET meta_value = replace(meta_value,'"+old_url+"','"+new_url+"');<br/><br/>";
  
  // ------------------------------------------------------
  
  if($("#incw").is(':checked')){ 
    old_url = old_url.replace("http://","http://www.");
  
    the_sql += "UPDATE "+prefix+"options SET option_value = replace(option_value, '"+old_url+"', '"+new_url+"') WHERE option_name = 'home' OR option_name = 'siteurl';<br/><br/>";
    
    the_sql += "UPDATE "+prefix+"posts SET guid = replace(guid, '"+old_url+"','"+new_url+"');<br/><br/>";
    
    the_sql += "UPDATE "+prefix+"posts SET post_content = replace(post_content, '"+old_url+"', '"+new_url+"');<br/><br/>";
    
    the_sql += "UPDATE "+prefix+"postmeta SET meta_value = replace(meta_value,'"+old_url+"','"+new_url+"');<br/><br/>";
  }
    $("#code").html(the_sql);
  prettyPrint();
}

function update(){
    prefix = $("#prefix").val();
    old_url = $("#old-url").val();
    new_url = $("#new-url").val();  
    create_sql();   
}

// Init
create_sql();

// Listeners
$("#prefix, #old-url, #new-url, #incw").change(function(){
    update();
});

$("#prefix, #old-url, #new-url").keyup(function(){
    update();
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console