Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

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

Does it exist?

Thanks.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer
    
A small example please –  Ashfame Apr 25 '11 at 14:57
    
Plenty of examples available if you search - here are 2: josephscott.org/archives/2008/11/… and franzone.com/2009/01/01/a-wordpress-plugin-hello-xml-rpc-world –  anu Apr 25 '11 at 16:20
    
I added an alternative example that uses a filter to expand the list of options available to existing requests. Creating a theme-specific XML-RPC method is a project currently being pursued by a GSoC student ... –  EAMann Apr 25 '11 at 16:54
    
Thanks both of you –  Ashfame Apr 25 '11 at 18:25
    
EAMann Great answer and congrats on being one of the GSCoC mentors. –  Chris_O Apr 26 '11 at 1:48

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.

share|improve this answer
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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