2

I can't seem to find such an option listed here:

http://codex.wordpress.org/XML-RPC_wp#wp.setOptions

Does it exist?

Thanks.

2

No, that option does not currently exist through XML-RPC. However, you can always create your own method in a plugin and hook it up to XML-RPC.


Update

There's an upcoming Google Summer of Code project that will be extending the XML-RPC interface to allow direct manipulation of themes, so I won't give away code to implement that here. But keep your ears and eyes open for when new code (core changes and/or plugins) start releasing this summer.

In the meantime, I will provide an alternative. The set of options that you can view and set through XML-RPC is filterable. Basically, you can tell the system to give you more information than it normally would.

What you can already get (bold options are read only ... you can't change them with wp.setOptions but you can retrieve them with wp.getOptions):

  • software_name
  • software_version
  • blog_url
  • content_width
  • time_zone
  • blog_title
  • blog_tagline
  • date_format
  • time_format
  • users_can_register
  • thumbnail_size_w
  • thumbnail_size_h
  • thumbnail_crop
  • medium_size_w
  • medium_size_h
  • large_size_w
  • large_size_h

This list (actually, an array with other settings), is passed through the xmlrpc_blog_options filter, which means you can add and remove to this list all you want. To enable the fetching of the current theme by wp.getOptions and the changing of the theme by wp.setOptions you'd use the following:

function allow_xmlrpc_theme_changes( $xmlrpcoptions ) {
    $xmlrpcoptions['active-theme'] = array(
        'desc'            => __( 'Active site theme' ),
        'readonly'        => false,
        'option'          => 'template'
    );

    $xmlrpcoptions['active-stylesheet'] = array(
        'desc'            => __( 'Active site stylesheet' ),
        'readonly'        => false,
        'option'          => 'stylesheet'
    );

    return $xmlrpcoptions
}

add_filter( 'xmlrpc_blog_options', 'allow_xmlrpc_theme_changes' );

This adds two fields that you can set: "active-theme" and "active-stylesheet".

Remember, you'll be setting these options the same way as you would using update_option(), so double check the codex before doing anything.

1

I've been interested in the same thing. I put together a plugin that extends XML-RPC to the wp_get_themes function and the switch_theme function. The plugin is on Github and I have a walkthrough on my blog.

  • 1
    Link only answer are discouraged. Answers should be as stand-alone as possible. – s_ha_dum Jan 27 '13 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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