fixed "excerpt" in AS JSON
This commit is contained in:
parent
4e653f5f75
commit
1580b3d4b1
5 changed files with 61 additions and 20 deletions
|
@ -59,6 +59,10 @@ To implement:
|
|||
|
||||
Project maintained on github at [pfefferle/wordpress-activitypub](https://github.com/pfefferle/wordpress-activitypub).
|
||||
|
||||
### 0.1.1 ###
|
||||
|
||||
* fixed "excerpt" in AS JSON
|
||||
|
||||
### 0.1.0 ###
|
||||
|
||||
* added basic WebFinger support
|
||||
|
|
|
@ -22,14 +22,12 @@ class Activitypub_Post {
|
|||
public function to_array() {
|
||||
$post = $this->post;
|
||||
|
||||
setup_postdata( $post );
|
||||
|
||||
$array = array(
|
||||
'id' => get_permalink( $post ),
|
||||
'type' => $this->get_object_type(),
|
||||
'published' => date( 'Y-m-d\TH:i:s\Z', strtotime( $post->post_date ) ),
|
||||
'attributedTo' => get_author_posts_url( $post->post_author ),
|
||||
'summary' => apply_filters( 'the_excerpt', get_post_field( 'post_excerpt', $post->ID ) ),
|
||||
'summary' => apply_filters( 'the_excerpt', activitypub_get_the_excerpt( $post->ID, 400 ) ),
|
||||
'inReplyTo' => null,
|
||||
'content' => apply_filters( 'the_content', get_post_field( 'post_content', $post->ID ) ),
|
||||
'contentMap' => array(
|
||||
|
@ -41,8 +39,6 @@ class Activitypub_Post {
|
|||
'tag' => $this->get_tags(),
|
||||
);
|
||||
|
||||
wp_reset_postdata();
|
||||
|
||||
return apply_filters( 'activitypub_post', $array );
|
||||
}
|
||||
|
||||
|
|
|
@ -183,3 +183,40 @@ function activitypub_get_follower_inboxes( $user_id, $followers ) {
|
|||
|
||||
return array_unique( $inboxes );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the excerpt for a post for use outside of the loop.
|
||||
*
|
||||
* @param int|WP_Post $post ID or WP_Post object.
|
||||
* @param int Optional excerpt length.
|
||||
*
|
||||
* @return string The excerpt.
|
||||
*/
|
||||
function activitypub_get_the_excerpt( $post, $excerpt_length = 55 ) {
|
||||
|
||||
$excerpt = get_post_field( 'post_excerpt', $post );
|
||||
|
||||
if ( '' === $excerpt ) {
|
||||
|
||||
$content = get_post_field( 'post_content', $post );
|
||||
|
||||
// An empty string will make wp_trim_excerpt do stuff we do not want.
|
||||
if ( '' !== $content ) {
|
||||
|
||||
$excerpt = strip_shortcodes( $content );
|
||||
|
||||
/** This filter is documented in wp-includes/post-template.php */
|
||||
$excerpt = apply_filters( 'the_content', $excerpt );
|
||||
$excerpt = str_replace( ']]>', ']]>', $excerpt );
|
||||
|
||||
$excerpt_length = apply_filters( 'excerpt_length', $excerpt_length );
|
||||
|
||||
/** This filter is documented in wp-includes/formatting.php */
|
||||
$excerpt_more = apply_filters( 'excerpt_more', ' […]' );
|
||||
|
||||
$excerpt = wp_trim_words( $excerpt, $excerpt_length, $excerpt_more );
|
||||
}
|
||||
}
|
||||
|
||||
return apply_filters( 'the_excerpt', $excerpt );
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: ActivityPub 0.1.0\n"
|
||||
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/activitypub\n"
|
||||
"POT-Creation-Date: 2018-12-20 10:32:52+00:00\n"
|
||||
"POT-Creation-Date: 2018-12-20 18:09:57+00:00\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
|
|
@ -59,6 +59,10 @@ To implement:
|
|||
|
||||
Project maintained on github at [pfefferle/wordpress-activitypub](https://github.com/pfefferle/wordpress-activitypub).
|
||||
|
||||
= 0.1.1 =
|
||||
|
||||
* fixed "excerpt" in AS JSON
|
||||
|
||||
= 0.1.0 =
|
||||
|
||||
* added basic WebFinger support
|
||||
|
|
Loading…
Reference in a new issue