-1

How would I update 500 different blogs hosted on separate hosting accounts and enable xml-rpc publishing?

We are writing a unified system for our clients who use a customized deployment of WP, allowing them to interact with their blogs from our site.

1
  • 4
    Please add some details, like are they hosted on same server and/or using same database. If you have any tools in place to manage them in bulk. And so on.
    – Rarst
    Aug 15, 2011 at 15:44

2 Answers 2

1

Short of logging into all the database servers remotely and updating the enable_xmlrpc option, you're looking at a lot of work.

But, I suspect you want XMLRPC to always be on. If that's the case, create an mu-plugins folder in wp-content. Create a php file (enable-xmlrpc.php or whatever you like, it doesn't matter), and drop this line in it:

<?php
add_filter( 'pre_option_enable_xmlrpc', '__return_true' );

XMLRPC will be enabled all the time for any site with that must use plugin.

You can probably automate uploading the file via FTP, just collect all the FTP info into some sort of structured file. Overly simple (and untested) Python ftplib example:

>>> import ftplib
>>> to_send = open('enable-xmlrpc.php', 'rb')
>>> # maybe use the csv module?
>>> with open('site_data.csv') as f:
...     for line in f:
...         host, user, pw = [i.strip() for i in line.strip().split(',')]
...         try:
...             s = ftplib.FTP(host, user, pw)
...             s.login()
...             # Switch to wp-content/mu-plugins
...             s.cwd('wp-content/mu-plugins')
...             # You probably need to change the following line, untested
...             s.storbinary('STOR enable-xmlrpc.php', to_send)
...         finally:
...             s.quit()
>>> to_send.close()
0

Untested but this should be it :

<?php

require 'wp-load.php';

$blogs = $wpdb->get_results("
    SELECT blog_id
    FROM {$wpdb->blogs}
    WHERE site_id = '{$wpdb->siteid}'
    AND spam = '0'
    AND deleted = '0'
    AND archived = '0'
    AND blog_id != 1
");

foreach ( $blogs as $blog ) {
    update_blog_option( $blog->blog_id, 'enable_xmlrpc', 1 );
}

Create a file in your WordPress root containing the above code and run it :)

2
  • This isn't a multiblog, 500 individual blogs. Aug 15, 2011 at 15:47
  • 3
    Answer what Rarst asked for. Basically, the option name stored in options table is enable_xmlrpc so you just have to change that value in the database for all of those blogs. Knowing your server setup, will help us give suggestions.
    – Ashfame
    Aug 15, 2011 at 17:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.