/** * Setup test prerequisites once */ public static function setUpBeforeClass() { parent::setUpBeforeClass(); // throw in a test itag, so we can cleanup later PmpSyncer::$ITAGS = array_unique(array_merge(PmpSyncer::$ITAGS, array(self::$_write_itag))); // must have pmp settings defined $settings = get_option('pmp_settings'); if (empty($settings['pmp_api_url']) || empty($settings['pmp_client_id']) || empty($settings['pmp_client_secret'])) { self::$_sdk_wrapper = false; } else { self::$_sdk_wrapper = new SDKWrapper(); self::$_pmp_story = self::$_sdk_wrapper->fetchDoc(self::$_pmp_story_guid); } }
/** * Indent an extra level on the debugger */ protected function pmp_debug($msg) { $msg = preg_replace('/ post /', 'attachment', " {$msg}"); parent::pmp_debug($msg); }
/** * Turn a post into a story-doc */ protected function set_doc_data() { parent::set_doc_data(); // story-specific fields if (!empty($this->post->post_excerpt)) { $this->doc->attributes->teaser = $this->post->post_excerpt; } if (!empty($this->post->post_content)) { $this->doc->attributes->description = pmp_sanitize_content($this->post->post_content, true); $this->doc->attributes->contentencoded = pmp_sanitize_content($this->post->post_content); $this->doc->attributes->wpcontent = apply_filters('the_content', $this->post->post_content); } $this->doc->links->profile = $this->get_profile_links('story'); $this->doc->links->alternate = array((object) array('href' => get_permalink($this->post->ID), 'type' => 'text/html')); // use the custom byline, if it exists - otherwise post author if (!empty($this->post_meta['pmp_byline'])) { $this->doc->attributes->byline = $this->post_meta['pmp_byline']; } else { $author = get_user_by('id', $this->post->post_author); if ($author && !empty($author->display_name)) { $this->doc->attributes->byline = $author->display_name; } } // tags! $tags = wp_get_post_tags($this->post->ID); if (!empty($tags)) { $this->doc->attributes->tags = array(); foreach ($tags as $tagObj) { $this->doc->attributes->tags[] = $tagObj->name; } } // items (push them first!) $this->doc->links->item = array(); foreach ($this->attachment_syncers as $syncer) { $success = $syncer->push(); if ($success) { $rels = array(); if (in_array($syncer->doc->getProfileAlias(), array('image', 'audio', 'video'))) { $rels[] = 'urn:collectiondoc:' . $syncer->doc->getProfileAlias(); } if ($syncer->doc->getProfileAlias() == 'image' && get_post_thumbnail_id($this->post->ID) == $syncer->post->ID) { $rels[] = 'urn:collectiondoc:image:featured'; } $this->doc->links->item[] = (object) array('href' => $syncer->doc->href, 'rels' => $rels); } } }