/**
  * SPECIAL CASE: if the image-url changes, nuke the attachment
  *
  * @param $force force updates, ignoring local/modified/subscribed flags
  * @return boolean success
  */
 public function pull($force = false)
 {
     if (!$this->is_local() && $this->doc && $this->post && $this->doc->getProfileAlias() == 'image') {
         $enclosure = SdkWrapper::getImageEnclosure($this->doc);
         if (!isset($this->post_meta['pmp_image_url']) || $this->post_meta['pmp_image_url'] != $enclosure->href) {
             $this->pmp_debug("   ** refreshing attachment[{$this->post->ID}] guid[{$this->doc->attributes->guid}]");
             wp_delete_attachment($this->post->ID, true);
             $this->post = null;
             $this->post_meta = array();
         }
     }
     return parent::pull($force);
 }
예제 #2
0
 /**
  * Allow setting post-status
  *
  * @param $force force updates, ignoring local/modified/subscribed flags
  * @param $post_status optionally set a new post status after pulling
  * @return boolean success
  */
 public function pull($force = false, $post_status = null)
 {
     $this->attachment_force = $force;
     if (!parent::pull($force)) {
         return false;
     }
     // change status, if necessary
     if ($this->post && $post_status && $post_status != $this->post->post_status) {
         $data = array('ID' => $this->post->ID, 'post_status' => $post_status);
         $id_or_error = wp_update_post($data, true);
         if (is_wp_error($id_or_error)) {
             var_log("pull ERROR setting status for [{$this->doc->attributes->guid}] - {$id_or_error->get_error_message()}");
             return false;
         }
     }
     return true;
 }