-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Adds the_excerpt
filter in the core/post-excerpt
block.
#67774
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -27,7 +27,8 @@ | |||
* wp_trim_words is used instead. | ||||
*/ | ||||
$excerpt_length = $attributes['excerptLength']; | ||||
$excerpt = get_the_excerpt( $block->context['postId'] ); | ||||
|
||||
$excerpt = apply_filters( 'the_excerpt', get_the_excerpt( $block->context['postId'] ) ); | ||||
Check warning on line 31 in packages/block-library/src/post-excerpt/index.php GitHub Actions / PHP coding standards
Check failure on line 31 in packages/block-library/src/post-excerpt/index.php GitHub Actions / PHP coding standards
|
||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @CoderAbhinav I think this will result in all the default filters being applied, so it'd be good to make everything still works correctly: I did some testing personally and couldn't see any issues. I think most of these filters like The change might also need a dev note, as some plugins might be working around the missing filter and reintroducing it could require plugins updating their code. As long as everything works, then this change seems fine (apart from Mamaduka's request change). There's precedence in that the post content block also does this and has done for a long time:
|
||||
if ( isset( $excerpt_length ) ) { | ||||
$excerpt = wp_trim_words( $excerpt, $excerpt_length ); | ||||
} | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function already has a filter -
get_the_excerpt
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Mamaduka, so in one of the issues #28214 it has been discussed already that, even though
get_the_excerpt()
function already uses theget_the_excerpt
filter, It would be good to havethe_excerpt
filter for backwards compatibility.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got it. The issue concerns the PHP filter. There's no need to update the JS code. For various reasons, the blocks don't mirror PHP filters in their React components.
P.S. I would recommend using reserved GitHub keywords to reference issues. It makes clear what you're trying to solve.