[wp-hackers] api.wordpress.org/themes ?

Mike Schinkel mikeschinkel at gmail.com
Mon Jan 12 07:50:35 GMT 2009


Looks like the API was coded with the plugins in mind and not the themes in

I've been working in similar areas recently albeit for plugins instead of
themes but what I've learned per those on this list is that the API was
designed more to meet the immediate needs for what was viewed as "internal"
functionality rather than architected with other use-cases in mind.

Anyway, I'm 99% sure you can get what you need short term by getting the
theme's slug using the API and then adding the slug to the end of this URL
to compose the URL for the HTML page for the theme:


>From there use file_get_contents() to grab the HTML and preg_match() to
extract the URL for the download file. Doing so violates several "best
practices" as per the W3C but it works and if for short term I'd say go for
it.  It's basically what I'm doing for a related plugin.


-Mike Schinkel

 Mon, Jan 12, 2009 at 2:13 AM, Jason DeVelvis <sales at emailappeal.com> wrote:

> I'm trying to code a themes installer plugin, similar to the plugin
> installer in the core (I know, I know, it'll probably be in 2.8, but I want
> it now...) and I've got it to do everything except find the proper theme
> .zip file.
> The API returns a download URL like
> http://downloads.wordpress.org/theme/openair.zip which returns a 404...
> The
> actual extend download URL for openair is
> http://wordpress.org/extend/themes/download/openair.1.1.7.zip
> Any ideas why the API download URLs are invalid? Did I jump into the API
> too
> early :) Could it be easily fixed so my plugin works? Or is there something
> else going on in my code if the API is returning the wrong d/l links?
> Here's the serialized api info for this call:
> O:8:"stdClass":13:{s:4:"name";s:7:"OpenAir";s:4:"slug";s:7:"openair";s:7:"ve
> rsion";N;s:6:"author";N;s:8:"requires";N;s:6:"tested";N;s:6:"rating";d:32;s:
> 11:"num_ratings";i:25;s:10:"downloaded";N;s:12:"last_updated";s:10:"2009-01-
> 07";s:8:"homepage";N;s:13:"download_link";s:48:"
> http://downloads.wordpress.o
> rg/theme/openair.zip";s:4:"tags";a:6:{s:19:"threaded-comments-1";s:17:"threa
> ded-comments";s:15:"right-sidebar-2";s:13:"right-sidebar";s:13:"fixed-width-
> 1";s:11:"fixed-width";s:5:"white";s:5:"white";s:4:"blue";s:4:"blue";s:13:"tw
> o-columns-1";s:11:"two-columns";}}
> Note, that api info is obtained with this line of code:
> $api = themes_api('theme_information', array('slug' => $theme, 'fields' =>
> array('sections' => false) ) ); //Save on a bit of bandwidth.
> (where $theme = the slug I retrieved earlier in the process, which is
> 'openair')
> Coincidentally, there is no version # passed with the api call either.
> Could
> be the same problem?
> Any help would be tremendous!
> Thanks,
> Jason

More information about the wp-hackers mailing list