Wednesday, May 6, 2009

WordPress: update_option ping_sites via PHP CLI

I really hate relying on other site's servers for anything. For obvious reasons, if their site is slow, well that means whatever functionality you're relying on will be slow as well.

In this latest case, technorati.com's blog update service was timing out 'causing our WordPress posts to take up to 2 minutes. Not fun! So, sorry technorati, we're replacing you with google's update services until you get your act together. :)

Now, why am I doing this via CLI? Well, I manage 300+ WordPress blogs, so with a bash wrapper, I can give this script the site and then it will connect and run an update_option and we're good to go!

Yay!


include '/mnt/www/wordpress/wp-config.php';
global $wpdb;
$pingsites = get_option('ping_sites');
$newpingsites = str_replace('http://rpc.technorati.com/rpc/ping','http://blogsearch.google.com/ping/RPC2',$pingsites);
$newpingsites = str_replace('http://rpc.icerocket.com:10080/','',$newpingsites);
echo $newpingsites . "\n";

echo "updating $argv[1]'s ping_sites\n";

update_option('ping_sites', $newpingsites);

}

No comments: