Skip to content

Instantly share code, notes, and snippets.

@prionkor
Created September 16, 2013 13:05
Show Gist options
  • Save prionkor/6580442 to your computer and use it in GitHub Desktop.
Save prionkor/6580442 to your computer and use it in GitHub Desktop.
Theme updater
theme updater add_action( 'init', 'kit_check_theme_update' );
function kit_check_theme_update(){
$versionInfo = 'http://kallzu.s3.amazonaws.com/_kallzu_wp_updates/ppl-ninja/meta.json';
$theme = $theme_data = is_child_theme() ? wp_get_theme()->parent() : wp_get_theme();
$themeDir = $theme->Template;
$updater = new ThemeUpdateChecker( $themeDir, $versionInfo );
$updater->addResultFilter( 'show_data' );
$updater->checkForUpdates();
}
function show_data($data){
log_it( $data );
}
if(!function_exists('log_it')){ // requires define( 'WP_DEBUG_LOG', true ); and Debug mode on
function log_it( $message ) {
if( WP_DEBUG === true ){
if( is_array( $message ) || is_object( $message ) ){
error_log( print_r( $message, true ) );
} else {
error_log( $message );
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment