Skip to content

Build the post summary from the filtered content - #3877

Open
pfefferle wants to merge 11 commits into
trunkfrom
fix/summary-filters
Open

pfefferle wants to merge 11 commits into
trunkfrom
fix/summary-filters

Conversation

@pfefferle

@pfefferle pfefferle commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Proposed changes:

  • Without a manual excerpt, the summary was built from the raw post content, so it ignored everything plugins do in the_content. It is now built with get_the_excerpt(), with the global post set, so the content filters run and plugins see the excerpt path they already know.
  • Jetpack's paywall checks doing_filter( 'get_the_excerpt' ), so the summary stops at the paywall and the "Subscribe to continue reading" prompt is gone.
  • Core removes blocks that are not text (excerpt_remove_blocks()), so a search form no longer ends up as "SearchSearch".
  • The length is still ours. Core's word limit is lifted, so the 500 characters and [ap_excerpt length] work like before, also on sites that count characters instead of words (Chinese, Japanese). No theme read-more link is added.
  • Shortcodes and tags are stripped from core's excerpt, because core only strips shortcodes from excerpts it generates. A manual excerpt is used as written, and one with only whitespace counts as empty, like in core.
  • Mentions stay linked in the summary. get_the_excerpt() runs the_content, where the mention filter turns @user@host into a link with only @user as text, and the excerpt strips the link. So mentions are not linked while an excerpt is built: the excerpt keeps @user@host, and the summary links it like before. Theme excerpts on the website show the full handle now too.
  • Less code of our own: get_extended(), sanitize_post_field() and the whitespace regexes are gone.

Other information:

  • Have you written new tests for your changes, if applicable?

This follows #3876. Together they make sure the summary shows what a logged-out visitor sees.

What changes for the summary:

  • <!--more-->: the summary is the text above the tag, without […]. A post that starts with the tag has no summary. When the JSON is built on the post's own page (a remote server fetching the permalink), core ignores the tag, so the summary is the start of the whole post. The Create sent on publish has the teaser.
  • Posts split with <!--nextpage--> only use the first page, or the page of the request.
  • Line breaks are gone, core joins the words with spaces. Mastodon doesn't show them in the summary anyway.
  • Themes that hook get_the_excerpt can add to the summary. Twenty Ten and Twenty Eleven add "Continue reading" to manual excerpts.
  • The summary is texturized now (Don’t instead of Don't).

I think this is fine for a summary, and by following core we behave the way other plugins expect excerpts to work.

Testing instructions:

  • Add a the_content filter that removes part of a post.
  • Publish a post without an excerpt.
  • Check the post with Accept: application/activity+json: the summary does not contain the removed part.
  • With Jetpack's paywall block in a post, the summary stops at the paywall and has no subscribe prompt.

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Added - for new features
  • Changed - for changes in existing functionality
  • Deprecated - for soon-to-be removed features
  • Removed - for now removed features
  • Fixed - for any bug fixes
  • Security - in case of vulnerabilities

Message

Post summaries now respect plugins that change or hide parts of the post content.

@pfefferle

Copy link
Copy Markdown
Member Author

I changed the summary to use get_the_excerpt() instead of running the_content on our own.

What we get:

  • Plugins that hide content now see the excerpt path they already know. Jetpack's paywall checks doing_filter( 'get_the_excerpt' ) and adds its Paywall block to excerpt_allowed_blocks, so the summary stops at the paywall and the "Subscribe to continue reading" prompt is gone.
  • Core removes blocks that are not text (excerpt_remove_blocks()), so a search form no longer ends up as "SearchSearch".
  • Less code of our own: get_extended(), sanitize_post_field() and the whitespace regexes are gone.
  • The length is still ours. Core's word limit is lifted, so the 500 characters and [ap_excerpt length] work like before, also on sites that count characters instead of words (Chinese, Japanese).

What we have to accept:

  • <!--more-->: the summary is the text above the tag, without […]. A post that starts with the tag has no summary. When the JSON is built on the post's own page (a remote server fetching the permalink), core ignores the tag, so the summary is the start of the whole post. The Create sent on publish has the teaser.
  • Posts split with <!--nextpage--> only use the first page, or the page of the request.
  • Line breaks are gone, core joins the words with spaces. Mastodon doesn't show them in the summary anyway.
  • Themes that hook get_the_excerpt can add to the summary. Twenty Ten and Twenty Eleven add "Continue reading" to manual excerpts.
  • The summary is texturized now (Don’t instead of Don't).

I think this is fine for a summary, and by following core we behave the way other plugins expect excerpts to work. @jeherve what do you think?

@pfefferle
pfefferle requested a review from jeherve October 16, 2026 16:00
@github-actions github-actions Bot added the [Focus] Compatibility Ensuring the plugin plays well with other plugins label Oct 16, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working [Focus] Compatibility Ensuring the plugin plays well with other plugins [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant