Skip to content

Instantly share code, notes, and snippets.

@ericmann
Created December 18, 2012 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericmann/4331872 to your computer and use it in GitHub Desktop.
Save ericmann/4331872 to your computer and use it in GitHub Desktop.
<?php
class regions {
static function initialize()
{
// We need to process the_content as early as possible, to be sure that DOM tree identical to edited one
// Also, function accept 2 arguments, so when needed we can supply exact regions to apply
if ( !is_admin() ) { // We don't want to run this on the backend
if (true) { // until apply_filter use current()/next()
add_filter('the_content', array(self::instance(), 'content_split_join'), -99991, 2);
} else {
// Use split/join to proceed every piece independently
add_filter('the_content', array(self::instance(), 'content_split'), -99991, 2);
add_filter('the_content', array(self::instance(), 'content_join'), +99991);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment