I’ve found my original function but it seems to be broken and I’ve no idea whats wrong:
function te_get_theme_information( $args ) {
$theme = "";
// Set the $request array
$request = array(
'body' => array(
'action' => 'theme_information',
'request' => serialize((object)$args)
)
);
// Generate a cache key that would hold the response for this request:
$key='te_theme_'.md5(serialize($request));
// Check transient. If it's there - use that, if not re fetch the theme
if ( false === ($theme = get_transient($key)) ) {
// Theme not found - we need to re-fetch it
$response = wp_remote_post('http://api.wordpress.org/themes/info/1.0/',$request);
if ( is_wp_error($response) )
return $response;
$theme = unserialize(wp_remote_retrieve_body($response));
if ( !is_object($theme) && !is_array($theme) )
return new WP_Error('theme_api_error', 'An unexpected error has occurred');
// Set transient for next time... keep it for 24 hours should be good
set_transient($key, $theme, 60*60*24);
}
return $theme;
}
Here’s the call to it:
$themeinfo = te_get_theme_information(array('slug' => $slug, 'ratings' => true));
If you have any idea of whats wrong with the above I’d be very grateful.
Thanks
Steven
Looks like I had already declared that function elsewhere in the theme.
Sorry!
Hi,
Just want to know if this function is working ? I also want to fetch number of active installs of theme on wordpress.org