Skip to content

Instantly share code, notes, and snippets.

@shizhua
Created May 5, 2016 09:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shizhua/941f7f820a655559591a469b60bd9b57 to your computer and use it in GitHub Desktop.
Save shizhua/941f7f820a655559591a469b60bd9b57 to your computer and use it in GitHub Desktop.
"update notice" for self-hosted themes
<?php
function pfun_update_notification ( $transient ) {
if ( empty( $transient->checked['pfun'] ) ) {
return $transient;
}
$url = 'http://ptheme.com/update.json';
//Send the request.
$result = wp_remote_get($url);
$code = wp_remote_retrieve_response_code($result);
$body = wp_remote_retrieve_body($result);
$data = json_decode( $body, true );
if ( ($code == 200) && !empty($body) ){
if( version_compare( $transient->checked['pfun'], $data['pfun']['new_version'], '<' ) )
$transient->response['pfun'] = (array) $data['pfun'];
}
return $transient;
}
add_filter ( 'pre_set_site_transient_update_themes', 'pfun_update_notification' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment