Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
DRI - the_excerpt within the_content
`the_content` filter is potentially applied to related posts as well. The related posts section uses `the_excerpt()` and `the_content` filter gets applied when there is no custom excerpt is set for the post.

Let's say that I show 3 related posts, 2 x has Enlighter block and 1 x doesn't doesn't have Enlighter block, then variable `$T->_hasContent` of the plugin is set to `false` and the plugin doesn't add the necessary resources, because that one related post doesn't have enlighter within it.

This code checks if the current content being processed is excerpt. If it's excerpt (related posts), then just return the content. If not, then do the actual fun stuff.

The reason why it was working on twentynineteen is that there wasn't any other post using `the_excerpt()` function on the theme. E.g. related posts
  • Loading branch information
willstocks authored Feb 27, 2019
commit 4a4a91f32dfb4ee5fd09899ae1a733f4d3314db8
6 changes: 5 additions & 1 deletion class/ContentProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ public function __construct($settingsUtil, $languageShortcodes){

// EnlighterJS Code detection
add_filter('the_content', function($content) use ($T){

if (in_array('get_the_excerpt', $GLOBALS['wp_current_filter']))
return $content;

// contains enlighterjs codeblocks ?
$T->_hasContent = (strpos($content, 'EnlighterJSRAW') !== false);

Expand Down Expand Up @@ -184,4 +188,4 @@ public function registerCompatibilityFilterTarget($name){
public function hasContent(){
return $this->_hasContent;
}
}
}