Skip to content

Instantly share code, notes, and snippets.

@davehewy
Created April 5, 2013 14:55
Show Gist options
  • Save davehewy/5319925 to your computer and use it in GitHub Desktop.
Save davehewy/5319925 to your computer and use it in GitHub Desktop.
<?php
/*
Include wordpress core
*/
require_once('wp_load.php');
/* Validate a url */
function validate_url($url)
{
if( filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_QUERY_REQUIRED ) )
{
return true;
}
else
{
return false;
}
}
if(count($argv) > 1)
{
if( $argv[1] && !empty($argv[1]) )
{
/* Validate the url */
if( validate_url($argv[1]) )
{
/* Update the WP default options */
update_option('siteurl', $argv[1]);
update_option('home', $argv[1]);
/* If multisite is enabled also update */
if( is_multisite() )
{
/* Fetch a list of all the blogs listed */
$blog_list = get_blog_list( 0, 'all' );
if( count($blog_list) )
{
foreach($blog_list as $blog)
{
update_blog_option($blog['id'], 'domain', $argv[1]);
}
}
}
/* Return ok */
fwrite(STDOUT, "OK!");
}
}
}
exit(0);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment