mirror of
https://github.com/Automattic/wordpress-activitypub
synced 2024-10-18 17:43:33 +00:00
fix excerpt length
This commit is contained in:
parent
3bbcc2cd5c
commit
4132fdb501
1 changed files with 17 additions and 7 deletions
|
@ -643,13 +643,23 @@ class Post extends Base {
|
|||
return null;
|
||||
}
|
||||
|
||||
return \wp_strip_all_tags(
|
||||
\html_entity_decode(
|
||||
\get_the_excerpt(
|
||||
$this->wp_object->ID
|
||||
)
|
||||
)
|
||||
);
|
||||
$content = \get_post_field( 'post_content', $this->wp_object->ID );
|
||||
$content = \html_entity_decode( $content );
|
||||
$content = \wp_strip_all_tags( $content );
|
||||
$content = \trim( $content );
|
||||
$content = \preg_replace( '/\R+/m', "\n\n", $content );
|
||||
|
||||
$excerpt_more = \apply_filters( 'activitypub_excerpt_more', '...' );
|
||||
$length = 500;
|
||||
$length = $length - strlen( $excerpt_more );
|
||||
|
||||
if ( \strlen( $content ) > $length ) {
|
||||
$content = \wordwrap( $content, $length, '</activitypub-summary>' );
|
||||
$content = \explode( '</activitypub-summary>', $content, 2 );
|
||||
$content = $content[0];
|
||||
}
|
||||
|
||||
return $content . $excerpt_more;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue