Created
June 24, 2014 17:50
-
-
Save tollmanz/92baa8c1b249af880996 to your computer and use it in GitHub Desktop.
Getting info from .org repo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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