In my last post I mentioned how changes to the Theme API An API or Application Programming Interface is a software intermediary that allows programs to interact with each other and share data in limited, clearly defined ways. that are necessary for the new Theme Directory, are done. It turned out that it’s only half true. Since the API is just as much based on bbpress Free, open source software built on top of WordPress for easily creating forums on sites. https://bbpress.org. as the current Theme Directory is, the underlying data source for it has to be changed as well, to use the new WordPress site that is being built. All of these changes will not affect the output of the API however, so let me go over the few things that we added recently, and that might be interesting for developers using the API.
The first step was a whitespace clean up, a chance to bring the code up to date with current WordPress coding standards A collection of PHP_CodeSniffer rules (sniffs) to validate code developed for WordPress. It ensures code quality and adherence to coding conventions, especially the official standards for WordPress Core., to make it easier to grok future changes to the file. After that, two fields were added for theme responses,
parent. Those fields are not included by default, so they have to be explicitly added to any request.
ratings are requested, it adds an array with the number of reviews for each rating level. For Twenty Ten, it looks like this:
public 'ratings' =>
1 => int 7
2 => int 0
3 => int 9
4 => int 31
5 => int 88
The Theme Directory uses that information to generate the broken down rating statistics.
To be able to display decently rich information about a theme’s parent theme, the
parent parameter was added. It will add an array with some information about the parent theme. Currently it has three rows, but if the need ever arises to add more information there, it’s possible to extend it to a full theme object without sacrificing backwards compatibility. For 2013 Green it looks like this:
public 'parent' =>
'slug' => string 'twentythirteen'
'name' => string 'Twenty Thirteen'
'homepage' => string 'https://wordpress.org/themes/twentythirteen'
For an example of all fields for a theme, you can use this poetic piece of code:
include ABSPATH . 'wp-admin/includes/theme.php';
$theme = themes_api( 'theme_information', array(
'slug' => 'twentyten',
'fields' => array(
'description' => true,
'sections' => true,
'rating' => true,
'ratings' => true,
'downloaded' => true,
'downloadlink' => true,
'last_updated' => true,
'tags' => true,
'template' => true,
'parent' => true,
'versions' => true,
'screenshot_url' => true,
var_dump( $theme );exit;