function check_for_update($transient) { global $wp_filesystem; if (empty($transient->checked)) { return $transient; } $curr_theme = wp_get_theme(); $curr_ver = getbowtied_theme_version(); // die(); $url = $this->api_url; // $args = array("k" => $this->license_key, // "t" => $curr_theme->name, // "d" => get_site_url() // ); $args = array('method' => 'POST', 'timeout' => 30, 'body' => array("k" => $this->license_key, "t" => THEME_NAME, "d" => get_site_url())); // echo $url; // die(); $request = wp_remote_post($url, $args); // echo $url; if (is_wp_error($request)) { return $transient; } if ($request['response']['code'] == 200) { $data = json_decode($request['body']); if (!empty($data->error) && $data->error == 1) { update_option("getbowtied_" . THEME_SLUG . "_license_expired", 1); add_action('admin_notices', array(&$this, 'expired_notice')); } if (version_compare($curr_ver, $data->version, '<')) { $transient->response[$curr_theme->get_template()] = array("new_version" => $data->version, "package" => $data->download_url, "url" => 'http://www.getbowtied.com'); // add_action( 'admin_notices', array(&$this, 'update_notice') ); update_option("getbowtied_" . THEME_SLUG . "_remote_ver", $data->version); } else { // update_option("getbowtied_".THEME_SLUG."_update_available", 0); } } // $curr_theme = wp_get_theme(); // foreach ($purchased_themes AS $theme) // { // if ($curr_theme->name == $theme->theme_name) // { // if(version_compare($curr_theme->version, $theme->version, '<')); // { // $new_ver = $theme->version; // $url = $this->api_url.$this->api_user.'/'.$this->api_key.'/wp-download:'.$theme->item_id.'.json'; // $request = wp_remote_get( $url ); // if ( is_wp_error( $request ) ) // { // return $transient; // } // if ( $request['response']['code'] == 200 ) // { // $data = json_decode($request['body']); // $download_url = $data->{'wp-download'}->url; // $transient->response[$curr_theme->slug] = array( // "new_version" => $new_ver, // "package" => $download_url, // "url" => 'http://www.getbowtied.com' // ); // add_action( 'admin_notices', array(&$this, 'update_notice') ); // } // } // } // } // echo '<script type="text/javascript">console.log('.json_encode($transient).')</script>'; return $transient; }
$plugins_page = "getbowtied_theme_plugins"; $demos_page = "getbowtied_theme_demos"; $getbowtied_settings = Getbowtied_Admin_Pages::settings(); ?> <h1><?php echo getbowtied_theme_name(); ?> </h1> <p><strong><?php echo __("Version", "getbowtied"); ?> <?php echo getbowtied_theme_version(); ?> </strong> - <a href="<?php echo $getbowtied_settings['release_notes']; ?> " target="_blank"><?php echo __("View Release Notes", "getbowtied"); ?> </a></p> <div class="getbowtied-theme-badge" style="background-image:url(<?php echo $getbowtied_settings['theme_logo']; ?> )"></div>
function update_notice() { $remote_ver = get_option("getbowtied_" . THEME_SLUG . "_remote_ver") ? get_option("getbowtied_" . THEME_SLUG . "_remote_ver") : getbowtied_theme_version(); $local_ver = getbowtied_theme_version(); if (version_compare($local_ver, $remote_ver, '<')) { if (function_exists('wp_get_theme')) { $theme_name = '<strong>' . wp_get_theme(get_template()) . '</strong>'; } echo '<div class="error getbowtied_admin_notices"> <p>There is an update available for the ' . $theme_name . ' theme. <a href="' . admin_url() . 'update-core.php">Update now</a>.</p> </div>'; } }