diff --git a/.changeset/large-insects-yell.md b/.changeset/large-insects-yell.md new file mode 100644 index 00000000..9f554143 --- /dev/null +++ b/.changeset/large-insects-yell.md @@ -0,0 +1,5 @@ +--- +"wptelegram": patch +--- + +Added filters for excerpt and content options diff --git a/plugins/wptelegram/src/modules/p2tg/PostData.php b/plugins/wptelegram/src/modules/p2tg/PostData.php index ab0841b0..adf4e9e3 100644 --- a/plugins/wptelegram/src/modules/p2tg/PostData.php +++ b/plugins/wptelegram/src/modules/p2tg/PostData.php @@ -181,17 +181,23 @@ public function get_field_value( $field, $options = [] ) { // Remove shortcodes. $excerpt = trim( strip_shortcodes( $excerpt ) ); - $value = Utils::prepare_content( - $excerpt, - [ - 'format_to' => $parse_mode, - 'id' => 'p2tg', - 'limit' => $excerpt_length, - 'limit_by' => 'words', - 'preserve_eol' => $preserve_eol, - ] + $excerpt_options = [ + 'format_to' => $parse_mode, + 'id' => 'p2tg', + 'limit' => $excerpt_length, + 'limit_by' => 'words', + 'preserve_eol' => $preserve_eol, + ]; + + $excerpt_options = apply_filters( + 'wptelegram_p2tg_post_data_prepare_excerpt_options', + $excerpt_options, + $this->post, + $options ); + $value = Utils::prepare_content( $excerpt, $excerpt_options ); + $plain_excerpt = apply_filters( 'wptelegram_p2tg_post_data_plain_excerpt', false, $value, $excerpt, $this->post, $options ); if ( $plain_excerpt ) { @@ -220,14 +226,15 @@ public function get_field_value( $field, $options = [] ) { // Remove shortcodes. $content = trim( strip_shortcodes( $content ) ); - $value = Utils::prepare_content( - $content, - [ - 'format_to' => $parse_mode, - 'id' => 'p2tg', - 'limit' => 0, - ] - ); + $content_options = [ + 'format_to' => $parse_mode, + 'id' => 'p2tg', + 'limit' => 0, + ]; + + $content_options = apply_filters( 'wptelegram_p2tg_post_data_prepare_content_options', $content_options, $this->post, $options ); + + $value = Utils::prepare_content( $content, $content_options ); break; case 'short_url':