-
Notifications
You must be signed in to change notification settings - Fork 4.6k
[Block Library - Post Excerpt]: Fix excerpt_more filter conflict and remove wordCount attribute
#33366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Size Change: +416 B (0%) Total Size: 1.07 MB
ℹ️ View Unchanged
|
|
I remember this was a problem with the latest posts block as well. How did that one sort it out in the end I wonder? Ideally this should be a layered approach:
To enable this flow it may be that we need to change more than the behavior of the editor. |
|
I'd appreciate some testing on thoughts for this one to make the right call for 5.8. cc @carolinan @aristath @scruffian @kjellr Removing the |
excerpt_more filter conflictexcerpt_more filter conflict and remove wordCount attribute
|
Will the theme be able to set these via theme.json? If yes, we can just forego the filters and allow themes to set excerpt length and read more in the theme.json and users to change it via UI. No need to respect the filter if the themes don't need it. This block afaik is for block themes, not for classic themes, right? |
|
Just to add some background info regarding:
There is a convention in core for this in /* translators: Maximum number of words used in a post excerpt. */
$excerpt_length = (int) _x( '55', 'excerpt_length' );It's intended for locales, but I wonder if any themes out there intercept this string. Anyway, if we build something for theme.json, let's keep this convention in mind. |
|
I'm convinced this is the right direction: removing the word-count attribute and sandboxing any server-rendered content. This block obviously has more rough edges, generally stemming from the frictions between the old and the new, but let's start by fixing proper failures (like the "inception" per #33309) and reduce the client-side feature set; that way, users of traditional themes can keep relying on excerpt hooks. There's also a bug in which the |
cb90afa to
fe3418a
Compare
Thinking some more, the fix may end up being more confusing than the original issue. So I decided not to touch this for now. On the other hand, I pushed 52aa854 to address a specific remark in #32473 (comment):
I think this is good to go. It definitely closes #33309 (by sandboxing RichText) and #33306 (by removing |
|
The failing E2E test stems from a recent merge to trunk and isn't related to this PR. Merging. |
…d remove `wordCount` attribute (#33366) * [Block Library - Post Excerpt]: Fix `excerpt_more` filter conflict * use Disabled component * add comments * Remove `wordCount` attribute * prioritize textContent * Post Excerpt: Don't output empty P tag when $more_text empty * Query Loop Patterns: Remove extinct wordCount attribute Co-authored-by: Miguel Fonseca <[email protected]>
…d remove `wordCount` attribute (#33366) * [Block Library - Post Excerpt]: Fix `excerpt_more` filter conflict * use Disabled component * add comments * Remove `wordCount` attribute * prioritize textContent * Post Excerpt: Don't output empty P tag when $more_text empty * Query Loop Patterns: Remove extinct wordCount attribute Co-authored-by: Miguel Fonseca <[email protected]>
…d remove `wordCount` attribute (#33366) * [Block Library - Post Excerpt]: Fix `excerpt_more` filter conflict * use Disabled component * add comments * Remove `wordCount` attribute * prioritize textContent * Post Excerpt: Don't output empty P tag when $more_text empty * Query Loop Patterns: Remove extinct wordCount attribute Co-authored-by: Miguel Fonseca <[email protected]>
Description
Fixes: #33309
Fixes: #32473
Fixes: #33306
There are a couple of issues in
Post Excerptblock that involve theexcerpt_lengthandexcerpt_morefilter. Withexcerpt_morefilter someone (usually a theme) can filter the string in the “more” link displayed after a trimmed excerpt. Both filters are called if a post has no explicit excerpt set inwp_trim_excerptfunction.Problems
The problems are:
Post Excerptblock when is not editable, uses therendered excerptfrom REST API which makes it impossible to know what and if something has been added. This makes thewordCountin editor and the displayed excerpt in editor inconsistent.Post Excerptis editable we create a preview excerpt from therendered content, which isn't the same as therendered excerpt.word countcontrol is currently displayed only if the excerpt has been produced from content and its value is used properly in the front-end but is inconsistent in the editor because of the above problem depending on whether the block is editable or not.inceptionproblems which might cause the editor to crash (Post Excerpt Block: Remove ability to load a post within the template editor to prevent inception/crashing #33309).What I've done so far
moreTextin the block, show block'smoreTextand override theme'sexcerpt_lengthfilter to return nothing. If we have not setmoreTextapply the filters if provided (conflicting filter issue).rendered excerpt, I've wrapped it in aDisabledcomponent in caseexcerpt_morefilter is used and applies a link (editor crash/inception issue).wordCountattribute altogether. This means that if a theme usesexcerpt_lengthfilter for posts with no excerpt, it will be used but you can't update it in javascript. This solves other inconsistencies described in aboveProblemssection in1 and 2.Testing instructions
twenty twenty one.excerpt_morefilter](Conflict with excerpt_more filter).