Skip to content

Instantly share code, notes, and snippets.

@tollmanz
Created June 24, 2014 17:50
Show Gist options
  • Save tollmanz/92baa8c1b249af880996 to your computer and use it in GitHub Desktop.
Save tollmanz/92baa8c1b249af880996 to your computer and use it in GitHub Desktop.
Getting info from .org repo
<?php
function ttf_get_make_stats() {
// Make remote request to WP.org
$response = wp_remote_post(
'http://api.wordpress.org/themes/info/1.0/',
array(
'body' => array(
'action' => 'theme_information',
'request' => serialize( (object) array(
'slug' => 'make'
) )
)
)
);
if ( 200 === wp_remote_retrieve_response_code( $response ) ) {
$body = maybe_unserialize( wp_remote_retrieve_body( $response ) );
if ( isset( $body->download_link ) && isset( $body->downloaded ) ) {
update_option( 'make-info', array(
'download_link' => esc_url_raw( $body->download_link ),
'downloaded' => absint( $body->downloaded ),
) );
update_option( 'make-info-last-update', time() );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment