Created
March 30, 2015 22:28
-
-
Save barryhughes/8d5d078ca8f2864892a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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