workaround for special chars

This commit is contained in:
Matthias Pfefferle 2023-07-27 19:27:01 +02:00
parent be26a18214
commit 686dbd0f9f
2 changed files with 19 additions and 3 deletions

View file

@ -33,6 +33,19 @@ class Follower extends Actor {
return get_post_meta( $this->_id, 'activitypub_errors' );
}
/**
* Get the Summary.
*
* @return int The Summary.
*/
public function get_summary() {
if ( isset( $this->summary ) ) {
return $this->summary;
}
return '';
}
/**
* Getter for URL attribute.
*
@ -122,11 +135,11 @@ class Follower extends Actor {
$args = array(
'ID' => $this->get__id(),
'guid' => esc_url_raw( $this->get_id() ),
'post_title' => esc_html( $this->get_name() ),
'post_title' => wp_strip_all_tags( sanitize_text_field( $this->get_name() ) ),
'post_author' => 0,
'post_type' => Followers::POST_TYPE,
'post_name' => esc_url_raw( $this->get_id() ),
'post_excerpt' => $this->get_summary() ? esc_html( $this->get_summary() ) : '',
'post_excerpt' => sanitize_text_field( wp_kses( $this->get_summary(), 'user_description' ) ),
'post_status' => 'publish',
'meta_input' => $this->get_post_meta_input(),
);
@ -266,6 +279,8 @@ class Follower extends Actor {
$object = self::init_from_json( $actor_json );
$object->set__id( $post->ID );
$object->set_id( $post->guid );
$object->set_name( $post->post_title );
$object->set_summary( $post->post_excerpt );
$object->set_published( gmdate( 'Y-m-d H:i:s', strtotime( $post->post_published ) ) );
$object->set_updated( gmdate( 'Y-m-d H:i:s', strtotime( $post->post_modified ) ) );

View file

@ -40,7 +40,7 @@ class Test_Db_Activitypub_Followers extends WP_UnitTestCase {
'id' => 'https://user2.example.com',
'url' => 'https://user2.example.com',
'inbox' => 'https://user2.example.com/inbox',
'name' => 'user2',
'name' => 'úser2',
'preferredUsername' => 'user2',
),
);
@ -126,6 +126,7 @@ class Test_Db_Activitypub_Followers extends WP_UnitTestCase {
$follower2 = \Activitypub\Collection\Followers::get_follower( 2, 'https://user2.example.com' );
$this->assertEquals( 'https://user2.example.com', $follower2->get_url() );
$this->assertEquals( 'úser2', $follower2->get_name() );
}
public function test_delete_follower() {