Пример #1
0
 /**
  * Add post to the batch that is referenced through the post meta of
  * another post.
  *
  * Scope of this method has been extended to also include changing the ID
  * of the referenced post into using the GUID instead.
  *
  * @param Batch $batch
  * @param array $postmeta
  *
  * @return array
  */
 private function add_related_posts(Batch $batch, $postmeta)
 {
     // Check if this post meta key is in the array of post relationship keys.
     if (!in_array($postmeta['meta_key'], $batch->get_post_rel_keys())) {
         return $postmeta;
     }
     // Find post the current post holds a reference to.
     $post = $this->post_dao->find($postmeta['meta_value']);
     if (isset($post) && $post->get_id() !== null) {
         $this->add_post($batch, $post);
         /*
          * Change meta value to post GUID instead of post ID so we can later find
          * the reference on production.
          */
         $postmeta['meta_value'] = $post->get_guid();
     }
     return $postmeta;
 }