/**
  * Create a new instance of PluginUpdateUtility from its JSON-encoded representation.
  *
  * @param string $json
  * @return PluginUpdateUtility
  */
 public static function fromJson($json)
 {
     //Since update-related information is simply a subset of the full plugin info,
     //we can parse the update JSON as if it was a plugin info string, then copy over
     //the parts that we care about.
     $pluginInfo = PU_PluginInfo::fromJson($json);
     if ($pluginInfo != null) {
         return PluginUpdateUtility::fromPluginInfo($pluginInfo);
     } else {
         return null;
     }
 }
 /**
  * Retrieve the latest update (if any) from the configured API endpoint.
  *
  * @uses PluginUpdateEngineChecker::requestInfo()
  *
  * @return PluginUpdateUtility An instance of PluginUpdateUtility, or NULL when no updates are available.
  */
 function requestUpdate()
 {
     //For the sake of simplicity, this function just calls requestInfo()
     //and transforms the result accordingly.
     $pluginInfo = $this->requestInfo(array('pu_checking_for_updates' => '1'));
     if ($pluginInfo == null) {
         return null;
     }
     //admin display for if the update check reveals that there is a new version but the API key isn't valid.
     if (isset($pluginInfo->api_invalid)) {
         //we have json_error returned let's display a message
         $this->json_error = $pluginInfo;
         add_action('admin_notices', array(&$this, 'display_json_error'));
         return null;
     }
     if (isset($pluginInfo->new_install_key)) {
         update_option($this->pue_install_key, $pluginInfo->new_install_key);
     }
     //need to correct the download url so it contains the custom user data (i.e. api and any other paramaters)
     if (!empty($this->download_query)) {
         $pluginInfo->download_url = add_query_arg($this->download_query, $pluginInfo->download_url);
     }
     return PluginUpdateUtility::fromPluginInfo($pluginInfo);
 }