Skip to content

Commit d9ec033

Browse files
committed
Merge branch 'master' into 2.x
# Conflicts: # composer.json # lib/Loader.php # lib/Post.php # tests/test-timber-post-content.php
2 parents 5c974f3 + 62d2817 commit d9ec033

3 files changed

Lines changed: 19 additions & 10 deletions

File tree

docs/v1/guides/performance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ The following cache modes are available:
4848

4949
## Cache _Parts_ of the Twig File and Data
5050

51-
This method implements the [Twig Cache Extension](https://github.com/asm89/twig-cache-extension). It adds the cache tag, for use in templates. Best shown by example:
51+
This method implements the [Twig Cache Extension](https://github.com/twigphp/twig-cache-extension). It adds the cache tag, for use in templates. Best shown by example:
5252

5353
```twig
5454
{% cache 'index/content' posts %}

lib/Post.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,9 +1431,9 @@ public function content( $page = 0, $len = -1 ) {
14311431
* @return string
14321432
*/
14331433
protected function content_handle_no_teaser_block( $content ) {
1434-
if ( strpos($content, 'noTeaser:true') !== false ) {
1435-
$arr = explode('<!--noteaser-->', $content);
1436-
return $arr[1];
1434+
if ( (strpos($content, 'noTeaser:true') !== false || strpos($content, '"noTeaser":true') !== false) && strpos($content, '<!-- /wp:more -->') !== false) {
1435+
$arr = explode('<!-- /wp:more -->', $content);
1436+
return trim($arr[1]);
14371437
}
14381438
return $content;
14391439
}

tests/test-timber-post-content.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,22 @@ function testGutenbergExcerptOption() {
6060
if ( $wp_version < 5.0 ) {
6161
$this->markTestSkipped('Only applies to Block editor which is avaialble in WP 5.x');
6262
}
63-
$content_1 = '<!-- wp:paragraph --><p>Here is the start to my post! This should not show when noTeaser:true</p><!-- /wp:paragraph -->
64-
<!-- wp:more {"noTeaser":true} --><!--more--><!--noteaser-->';
65-
$content_2 = '<!-- /wp:more --><!-- wp:paragraph --><p>WHEN noTeaser:true, ONLY this shows on the single page</p><!-- /wp:paragraph --><!-- wp:paragraph --><p>And this too!</p><!-- /wp:paragraph -->';
66-
$post_id = $this->factory->post->create(['post_content' => $content_1.$content_2 ]);
63+
$content_1 = '<!-- wp:paragraph -->
64+
<p>Heres the start to a thing</p>
65+
<!-- /wp:paragraph -->
66+
67+
<!-- wp:more {"noTeaser":true} -->
68+
<!--more-->
69+
<!--noteaser-->
70+
<!-- /wp:more -->
71+
72+
<!-- wp:paragraph -->
73+
<p>Heres the read more stuff that we shant see!</p>
74+
<!-- /wp:paragraph -->';
75+
$post_id = $this->factory->post->create(['post_content' => $content_1 ]);
6776
$post = Timber::get_post($post_id);
6877

69-
$this->assertEquals($content_2, $post->content());
78+
$this->assertEquals('<p>Heres the read more stuff that we shant see!</p>', trim($post->content()));
7079
}
7180

72-
}
81+
}

0 commit comments

Comments
 (0)