public function getPledgeInfo()
 {
     if ($this->socialCampaign) {
         $data = SocialCampaignTaxonomy::parseSocialCampaign($this->socialCampaign);
         if (isset($data['pledge-info'])) {
             return $data['pledge-info'];
         }
     }
     return '';
 }
Ejemplo n.º 2
0
 private function getCampaignData($postId)
 {
     if ($this->cachedCampaignData !== null) {
         return $this->cachedCampaignData;
     }
     $campaign = SocialCampaignTaxonomy::getSocialCampaign($postId);
     if ($campaign) {
         $this->cachedCampaignData = SocialCampaignTaxonomy::parseSocialCampaign($campaign);
     } else {
         $this->cachedCampaignData = false;
     }
     return $this->cachedCampaignData;
 }
 /**
  * Create a "Social Share" post associated with the specified image, campaign, selected pledges.
  * Return the completed metadata.
  *
  * @param $imgUrl
  * @param $shareType
  * @param $parentId
  * @param $selectedPledgeIds
  * @return SharingMetaData
  */
 public static function createSocialShare($imgUrl, $shareType, $parentId, $selectedPledgeIds)
 {
     $shareData = new SharingMetaData();
     $shareData->pledgeText = PledgePostType::getSelectedPledgeText($selectedPledgeIds, $shareType == 'twitter');
     $shareData->title = get_bloginfo('name');
     $shareData->imageId = Utils::getAttachmentId($imgUrl);
     $shareData->shareType = $shareType;
     $campaign = SocialCampaignTaxonomy::getSocialCampaign($parentId);
     $postParams = ['post_type' => self::POST_TYPE, 'post_status' => 'publish'];
     if ($campaign) {
         $campaignData = SocialCampaignTaxonomy::parseSocialCampaign($campaign);
         $shareData->applyCampaignData($campaignData);
         $postParams['post_title'] = $campaign->slug;
     }
     $postParams['post_content'] = urlencode(serialize($shareData));
     $postId = wp_insert_post($postParams);
     $shareData->permalink = get_permalink($postId);
     // add these for reporting purposes.
     // share type is already saved in the content but this way we don't have to unserialize it
     update_post_meta($postId, 'client_ip', $_SERVER['REMOTE_ADDR']);
     update_post_meta($postId, 'share_type', $shareType);
     return $shareData;
 }