From 768d190be0868e0c58899be54006e2b30ee48b90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 25 Nov 2023 10:37:54 +0100 Subject: [PATCH] move transofmrer function get_post_content_template to base class fix: make in_array comparison strict --- includes/transformer/class-base.php | 22 +++++++++++++++++++++- includes/transformer/class-post.php | 19 ------------------- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/includes/transformer/class-base.php b/includes/transformer/class-base.php index 27f4a67..14feed2 100644 --- a/includes/transformer/class-base.php +++ b/includes/transformer/class-base.php @@ -93,7 +93,7 @@ abstract class Base { * @return string post_type Post type name. */ final public function supports_post_type( $post_type ) { - return in_array( $post_type, $this->get_supported_post_types() ); + return in_array( $post_type, $this->get_supported_post_types(), true ); } /** @@ -163,6 +163,26 @@ abstract class Base { return $content; } + /** + * Gets the template to use to generate the content of the activitypub item. + * + * @return string The Template. + */ + protected function get_post_content_template() { + if ( 'excerpt' === \get_option( 'activitypub_post_content_type', 'content' ) ) { + return "[ap_excerpt]\n\n[ap_permalink type=\"html\"]"; + } + + if ( 'title' === \get_option( 'activitypub_post_content_type', 'content' ) ) { + return "[ap_title]\n\n[ap_permalink type=\"html\"]"; + } + + if ( 'content' === \get_option( 'activitypub_post_content_type', 'content' ) ) { + return "[ap_content]\n\n[ap_permalink type=\"html\"]\n\n[ap_hashtags]"; + } + + return \get_option( 'activitypub_custom_post_content', ACTIVITYPUB_CUSTOM_POST_CONTENT ); + } /** * Returns the ID of the Post. diff --git a/includes/transformer/class-post.php b/includes/transformer/class-post.php index e89adbb..70fbc47 100644 --- a/includes/transformer/class-post.php +++ b/includes/transformer/class-post.php @@ -107,24 +107,5 @@ class Post extends Base { return $object_type; } - /** - * Gets the template to use to generate the content of the activitypub item. - * - * @return string The Template. - */ - protected function get_post_content_template() { - if ( 'excerpt' === \get_option( 'activitypub_post_content_type', 'content' ) ) { - return "[ap_excerpt]\n\n[ap_permalink type=\"html\"]"; - } - if ( 'title' === \get_option( 'activitypub_post_content_type', 'content' ) ) { - return "[ap_title]\n\n[ap_permalink type=\"html\"]"; - } - - if ( 'content' === \get_option( 'activitypub_post_content_type', 'content' ) ) { - return "[ap_content]\n\n[ap_permalink type=\"html\"]\n\n[ap_hashtags]"; - } - - return \get_option( 'activitypub_custom_post_content', ACTIVITYPUB_CUSTOM_POST_CONTENT ); - } }