Exemplo n.º 1
0
 /**
  * Check for the theme update.
  * Notify the user if there is an update available.
  */
 public static function notify()
 {
     $note = get_option('ib_update_notifier');
     if (!is_object($note)) {
         $note = new stdClass();
         $note->checked = 0;
         $note->version = 0;
         $note->error = 0;
     }
     if (!$note->checked || time() - $note->checked > 10800) {
         $response = wp_remote_get(self::$url);
         if (!is_wp_error($response)) {
             $response_xml = simplexml_load_string($response['body']);
             if ($response_xml) {
                 if (isset($response_xml->version)) {
                     $note->version = (string) $response_xml->version;
                 } else {
                     $note->version = 0;
                 }
                 $note->error = 0;
             } else {
                 $note->error = 1;
             }
         } else {
             $note->error = 1;
         }
         $note->checked = time();
         update_option('ib_update_notifier', $note);
     }
     if (1 == $note->error) {
         add_action('admin_notices', array(__CLASS__, 'server_error_notice'));
     }
     if (version_compare(self::$current_version, $note->version, '<')) {
         add_action('admin_notices', array(__CLASS__, 'update_notice'));
     }
     self::$note = $note;
 }
Exemplo n.º 2
0
 /**
  * Check incrediblebytes.com if there is a theme update available.
  */
 function educator_theme_updates_notifier()
 {
     if (1 == get_theme_mod('updates_notifier', 0)) {
         require_once get_template_directory() . '/include/ib-update-notifier.php';
         IB_Update_Notifier::init('http://update.incrediblebytes.com/ib-educator.xml', IB_THEME_VERSION, array('update' => __('<strong>An update to the theme is available!</strong> The version of installed theme is %s. The latest version is %s.', 'ib-educator'), 'server_error' => __('Could not check for the theme update.', 'ib-educator')));
     }
 }