url ); if ( ! is_wp_error( $response ) && 200 === $response['response']['code'] ) { $response_body = wp_remote_retrieve_body( $response ); $arr = json_decode( $response_body, true ); if ( !isset( $arr['themes'][$this->themeName] ) ) return; return $arr; } return; } public function __construct() { if ( !is_admin() ) return; $themeData = wp_get_theme(get_template()); $this->version = $themeData->get( 'Version' ); $this->themeName = $themeData->get( 'Name' ); if ( !apply_filters( 'kkHideUpdateNotice', false ) ) { add_action( 'admin_notices', array($this, 'print_notice' )); } } public function print_notice() { if ( false === ( $setV = get_transient( 'kkRemoteVersion'.$this->themeName ) ) ) { // this code runs when there is no valid transient set $arr = $this->get_HTTP_data(); $remoteVer = $arr['themes'][$this->themeName]['ver']; $interval = isset( $arr['interval'] ) ? $arr['interval'] : $this->interval; $this->logUrl = isset( $arr['themes'][$this->themeName]['logurl'] ) ? esc_url( $arr['themes'][$this->themeName]['logurl'] ) : $this->logUrl; $this->themeId = isset( $arr['themes'][$this->themeName]['id'] ) ? esc_attr( $arr['themes'][$this->themeName]['id'] ) : $this->themeId; if ( $arr === NULL ) { $interval = 1200; } set_transient( 'kkRemoteVersion'.$this->themeName, $remoteVer, $interval ); if ( $this->logUrl !== NULL ) { set_transient( 'kkLogUrl'.$this->themeName, $this->logUrl, $interval ); } if ( $this->themeId !== NULL ) { set_transient( 'kkthemeId'.$this->themeName, $this->themeId, $interval ); } } else { $remoteVer = $setV; $this->logUrl = get_transient( 'kkLogUrl'.$this->themeName ); $this->themeId = get_transient( 'kkthemeId'.$this->themeName ); } // text strings in the code below should not be translatable. if ( version_compare( $remoteVer, $this->version, '>' ) ) { echo '
New version of your '. $this->themeName .' theme is available for download.
Installed version: '.$this->version.'
Available version: '.$remoteVer. ( !empty( $this->logUrl ) ? ' ( Changelog )' : '' ).'
Please,'. ( empty( $this->themeId ) ? ' login to your ThemeForest account' : 'go to the item\'s page' ) .' and download latest version. Don\'t forget to renew support if needed.