Ejemplo n.º 1
0
 /**
  * Sync a single post (on creation or update)
  *
  * @todo if post should not be added, it's deleted (to account for unpublishing, etc). Make that more elegant.
  *
  * @param int $post_id
  * @return void
  */
 public function sync_post($post_id)
 {
     $post = new SP_Post(get_post($post_id));
     if ($post->should_be_indexed()) {
         $response = SP_API()->index_post($post);
         if (!$this->parse_error($response, array(200, 201))) {
             do_action('sp_debug', '[SP_Sync_Manager] Indexed Post', $response);
         } else {
             do_action('sp_debug', '[SP_Sync_Manager] Error Indexing Post', $response);
         }
     } else {
         # This is excessive, figure out a better way around it
         $this->delete_post($post_id);
     }
 }