-
-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for infinite loops in post.excerpt in specific cases (#2972)
* test: Add test to confirm ticket #2041 * fix: Run excerpt_remove_blocks in Post::content() when called from Post::excerpt()
- Loading branch information
Showing
5 changed files
with
79 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
register_block_type('timber/test-block', [ | ||
'render_callback' => 'render_block_example', | ||
'api_version' => 3, | ||
'attributes' => [ | ||
'post_id' => [ | ||
'type' => 'integer', | ||
], | ||
], | ||
]); | ||
|
||
function render_block_example($attributes, $content = '', $wp_block = null) | ||
{ | ||
// get the dynamically set post ID from the block attributes. We do it this way because get_the_ID() doesn't work in the block context during phpUnit tests. | ||
return Timber::compile('block-template.twig', [ | ||
'post' => Timber::get_post($attributes['post_id']), | ||
'attributes' => $attributes, | ||
]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{{ post.excerpt({ | ||
words: 100, | ||
read_more: false | ||
}) | ||
}} | ||
<p>What is love</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters