Skip to content

Instantly share code, notes, and snippets.

@barryhughes
Created March 30, 2015 22:28
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 barryhughes/8d5d078ca8f2864892a8 to your computer and use it in GitHub Desktop.
Save barryhughes/8d5d078ca8f2864892a8 to your computer and use it in GitHub Desktop.
/**
* Helper to undo the effects of the Tribe_Template_Factory::title_tag()
* filter (runs on wp_title).
*
* Since in current builds (3.9.x) the actual template object is anonymous
* it is not possible to cleanly unhook it with noodling in WP's global filter
* array, hence the approach taken here.
*/
class SingleEventTitleFilter {
static $title = '';
static function undo() {
add_filter( 'wp_title', array( __CLASS__, 'capture' ), 5 );
add_filter( 'wp_title', array( __CLASS__, 'restore' ), 50 );
}
static function capture( $title ) {
if ( is_singular( TribeEvents::POSTTYPE ) ) self::$title = $title;
return $title;
}
static function restore( $title ) {
if ( ! empty( self::$title ) ) return self::$title;
return $title;
}
}
SingleEventTitleFilter::undo();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment