Attachments.php
2 days ago
Author.php
2 days ago
BeforeMoreContent.php
2 days ago
CommentCount.php
2 days ago
CommentsForPostLink.php
2 days ago
ContentExcerpt.php
2 days ago
DatePublishFormatted.php
2 days ago
Depth.php
2 days ago
DescriptivePostStatus.php
2 days ago
DiscussionStatus.php
2 days ago
Excerpt.php
2 days ago
ExcerptMissingMessage.php
2 days ago
ExcerptRaw.php
2 days ago
FeaturedImage.php
2 days ago
HasCommentStatus.php
2 days ago
IsPasswordProtected.php
2 days ago
IsSticky.php
2 days ago
LastModifiedAuthor.php
2 days ago
Meta.php
2 days ago
ModifiedDate.php
2 days ago
Order.php
2 days ago
PageTemplate.php
2 days ago
Path.php
2 days ago
Permalink.php
2 days ago
PingStatus.php
2 days ago
PostContent.php
2 days ago
PostDate.php
2 days ago
PostDateTimestamp.php
2 days ago
PostFormat.php
2 days ago
PostFormatIcon.php
2 days ago
PostFormatLabel.php
2 days ago
PostLink.php
2 days ago
PostParentId.php
2 days ago
PostReferences.php
2 days ago
PostStatus.php
2 days ago
PostStatusIcon.php
2 days ago
PostTerms.php
2 days ago
PostTermsOriginal.php
2 days ago
PostTitle.php
2 days ago
Property.php
2 days ago
ShortLink.php
2 days ago
Shortcodes.php
2 days ago
Slug.php
2 days ago
BeforeMoreContent.php
32 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Formatter\Post; |
| 6 | |
| 7 | use AC\Formatter; |
| 8 | use AC\Type\Value; |
| 9 | |
| 10 | class BeforeMoreContent implements Formatter |
| 11 | { |
| 12 | public function format(Value $value): Value |
| 13 | { |
| 14 | $post = get_post((int)$value->get_id()); |
| 15 | |
| 16 | if (! $post) { |
| 17 | return new Value(null); |
| 18 | } |
| 19 | |
| 20 | $content = ''; |
| 21 | |
| 22 | $extended = get_extended($post->post_content); |
| 23 | |
| 24 | if (! empty($extended['extended'])) { |
| 25 | $content = $extended['main']; |
| 26 | } |
| 27 | |
| 28 | return $value->with_value($content); |
| 29 | } |
| 30 | |
| 31 | } |
| 32 |