Created
May 5, 2016 09:05
-
-
Save shizhua/941f7f820a655559591a469b60bd9b57 to your computer and use it in GitHub Desktop.
"update notice" for self-hosted themes
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 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