post_title, get_permalink($postId)); $ret->setLinkDescription(substr(strip_tags($post->post_content), 0, 160)); $ret->setHubs(self::$accountRepository->getAccount()->getHubs()); $meta = get_post_meta($postId, 'socialpublish', true); if ($meta !== false && $meta !== '') { $json = json_decode($meta, true); $ret->setIsPublished($json['published']); $ret->setMessage($json['message']); $ret->setHashTags($json['hashtags']); $hubs = array(); foreach ($json['hubs'] as $hub) { $hubs[] = new SocialpublishAccountHub($hub['type'], $hub['name']); } $ret->setHubs($hubs); } return $ret; } public function save(SocialpublishPost $post) { $hubs = array(); foreach ($post->getHubs() as $hub) { $hubs[] = array('type' => $hub->getType(), 'name' => $hub->getName()); } $o = array( 'title' => $post->getTitle(), 'link' => $post->getLink(), 'link_description' => $post->getLinkDescription(), 'message' => $post->getMessage(), 'hashtags' => $post->getHashTags(), 'published' => $post->isPublished(), 'hubs' => $hubs ); update_post_meta($post->getId(), 'socialpublish', json_encode($o)); } } ?>