Disabling Enzymes

Disabling Enzymes 2 for a single content
(from Nzymes)

It’s possible to disable Enzymes 2 for a single content by means of the following injections:

´{[ .disable-enzymes() ]} {[ defer(15) | .enable-enzymes() ]}´

The ´disable-enzymes´, and ´enable-enzymes´ custom fields could be:

NameValue
disable-enzymes
if ( is_plugin_active( 'enzymes/enzymes.php' ) ) {
  global $enzymes;
  remove_filter( 'the_content', array( $enzymes, 'metabolism' ), 10 );
  // unescape what Enzymes 2 was supposed to
  $this->new_content = str_replace( '{{[', '{[', $this->new_content );
}
enable-enzymes
if ( is_plugin_active( 'enzymes/enzymes.php' ) ) {
  global $enzymes;
  $this->add_filter( 'the_content', array( $enzymes, 'metabolism' ), 10 );
}
{[ defer(30) ]}

Notice that:

  • Enzymes 2 gets disabled only for the current content, thanks to the fact that it gets enabled again later. This is because I think it’s important to let Enzymes 2 do its job in other places as long as it stays active.
  • We absolutely need to call Nzymes ´->add_filter()´ instead of using the default ´add_filter()´ because the disabling is processed at priority ´9´ (or before, otherwise Enzymes 2 wold have run already) but, even if ´defer(15)´ makes the re-enabling run at priority ´15´ and even if the default ´10´ priority we set for Enzymes 2 should put it in the past, in reality the default ´add_filter()´ would add Enzymes 2 at the end of all the handlers for the current filter, thus causing ´apply_filters()´ to find it even if its priority is out of place.
  • You could improve those enzymes by passing the filter as an argument. Then you could improve that by making them accept a single filter or an array of filters. :-)

Actually, all of the above works very nicely, as outlined, on my local WordPress 4.1.1, but it doesn’t on my remote WordPress 4.1.1. The issue I get is that on the former (local-log), the content in the cell containing ´{{[´ is transcluded at priority 30, i.e. immediately before “canceling” the ´{[ defer(30) ]}´ injection. On the latter instead (remote-log), that content is transcluded at priority 15, thus it later interferes with the ´{[ defer(30) ]}´ injection at priority 30. One immediate “solution” is to change from 15 to 30 the deferred priority above.

However, the issue has revealed another bug, in another place. Given that I’m using Nzymes to highlight code in this document, I should have seen the need to properly escape code not only for HTML, but also for Nzymes. It’s important to understand that this bug is really parallel to the issue. In fact, it doesn’t make sense to generically escape all transclusions, otherwise we couldn’t achieve the dynamicity we can achieve with deferring.

I’m a bit sad to give up on finding the cause of the issue though.

Disabling Nzymes for a single content
(from Nzymes)

It’s possible to disable Nzymes for a single content by means of the following injection:

´{[ .disable-injections() ]}´

The ´disable-injections´ custom field could be:

NameValue
disable-injections
$this->continue_injecting = false;
{[ defer(30) ]}


Nzymes | WordPress Plugin

{[ defer(15) | 1.enable-enzymes() ]}