You've already forked wp-fedistream
fix: Prevent get_the_excerpt() from triggering the_content filter
All checks were successful
Create Release Package / build-release (push) Successful in 58s
All checks were successful
Create Release Package / build-release (push) Successful in 58s
- get_the_excerpt() internally calls the_content filter when generating auto-excerpts - When in shortcode context, now uses raw post_excerpt or wp_trim_words() instead - This was the remaining recursion path causing memory exhaustion Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -258,11 +258,23 @@ class TemplateLoader {
|
||||
// 2. We're at depth > 1 (nested data loading)
|
||||
$skip_content_filter = self::$shortcode_context_depth > 0 || self::$recursion_depth > 1;
|
||||
|
||||
// When skipping content filter, also use raw excerpt to avoid get_the_excerpt()
|
||||
// triggering the_content filter internally when generating auto-excerpts.
|
||||
if ( $skip_content_filter ) {
|
||||
$excerpt = $post->post_excerpt;
|
||||
if ( empty( $excerpt ) ) {
|
||||
// Generate a simple excerpt without triggering the_content filter.
|
||||
$excerpt = wp_trim_words( wp_strip_all_tags( $post->post_content ), 55, '…' );
|
||||
}
|
||||
} else {
|
||||
$excerpt = get_the_excerpt( $post );
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'id' => $post->ID,
|
||||
'title' => get_the_title( $post ),
|
||||
'content' => $skip_content_filter ? wp_kses_post( $post->post_content ) : apply_filters( 'the_content', $post->post_content ),
|
||||
'excerpt' => get_the_excerpt( $post ),
|
||||
'excerpt' => $excerpt,
|
||||
'permalink' => get_permalink( $post ),
|
||||
'thumbnail' => get_the_post_thumbnail_url( $post->ID, 'large' ),
|
||||
'date' => get_the_date( '', $post ),
|
||||
|
||||
Reference in New Issue
Block a user