Ejemplo n.º 1
0
 /**
  * The post's sha
  * Cached as post meta, or will make a live call if need be
  *
  * Returns String the sha1 hash
  */
 public function sha()
 {
     $sha = get_post_meta($this->id, '_sha', true);
     // If we've done a full export and we have no sha
     // then we should try a live check to see if it exists.
     if (!$sha && 'yes' === get_option('_wpghs_fully_exported')) {
         // @todo could we eliminate this by calling down the full tree and searching it
         $data = $this->api->fetch()->remote_contents($this);
         if (!is_wp_error($data)) {
             update_post_meta($this->id, '_sha', $data->sha);
             $sha = $data->sha;
         }
     }
     // if the sha still doesn't exist, then it's empty
     if (!$sha || is_wp_error($sha)) {
         $sha = '';
     }
     return $sha;
 }