[wp-xmlrpc] New XML-RPC methods: wp.getOptions & wp.setOptions
Joseph Scott
joseph at randomnetworks.com
Tue Jun 17 22:01:38 GMT 2008
Just committed to -trunk, wp.getOptions and wp.setOptions:
http://trac.wordpress.org/ticket/7123
The ticket has all the details, I'll copy some of the specifics,
along with some examples here:
wp.getOptions( blog_id, username, password, array )
wp.setOptions( blog_id, username, password, struct )
Both return data that looks like:
{
'option_name': {
'desc': 'Label Description Here',
'readonly': true,
'value': 123
}
}
The last parameter in wp.getOptions is optional, if it is not
included then you'll get all of the currently available options. If
you want just specific options, provide an array of option_name's and
you'll get just those back.
The wp.setOptions method will only update options that are not read
only. The last parameter is a just a set of key/value pairs. Here's
an example to change the blog title and tag line:
wp.setOptions( 1, 'my_admin_user', 'XXXXXXXX', {
blog_title: 'This Is My Totally Awesome Blog!',
blog_tagline: 'My Commentary On Life, The Universe, etc.'
} );
which would return:
{
blog_title: {
desc: 'Blog Title',
readonly: false,
value: 'This Is My Totally Awesome Blog!'
},
blog_tagline: {
desc: 'Blog Tagline',
readonly: false,
value: 'My Commentary On Life, The Universe, etc.'
}
}
If you try to change the value of an option that is read only, you
will NOT get an error. It will simply not change the value and
you'll get the same old/original value in the response data.
Here's the current list of available values:
// Read only options
'software_name' => array(
'desc' => __( 'Software Name' ),
'readonly' => true,
'value' => 'WordPress'
),
'software_version' => array(
'desc' => __( 'Software Version' ),
'readonly' => true,
'value' => $wp_version
),
'blog_url' => array(
'desc' => __( 'Blog URL' ),
'readonly' => true,
'option' => 'siteurl'
),
// Updatable options
'time_zone' => array(
'desc' => __( 'Time Zone' ),
'readonly' => false,
'option' => 'gmt_offset'
),
'blog_title' => array(
'desc' => __( 'Blog Title' ),
'readonly' => false,
'option' => 'blogname'
),
'blog_tagline' => array(
'desc' => __( 'Blog Tagline' ),
'readonly' => false,
'option' => 'blogdescription'
),
'date_format' => array(
'desc' => __( 'Date Format' ),
'readonly' => false,
'option' => 'date_format'
),
'time_format' => array(
'desc' => __( 'Time Format' ),
'readonly' => false,
'option' => 'time_format'
)
This list is rather small, with the only specific option in there
that people had been asking about a lot being the time zone. This
will be in the upcoming 2.6 release, so please test it out and let us
know what you think. Also, if you have other specific option type
data that you want exposed, now is the time to speak up.
--
Joseph Scott
joseph at randomnetworks.com
http://joseph.randomnetworks.com/
More information about the wp-xmlrpc
mailing list