Created
June 14, 2012 17:35
-
-
Save Rarst/2931653 to your computer and use it in GitHub Desktop.
Shuts up deprecated messages for specific functions
This file contains hidden or 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
<?php | |
Oh_Shuddup::on_load( array( 'get_theme_data' ) ); | |
/** | |
* Shuts up deprecated messages for specific functions. | |
*/ | |
class Oh_Shuddup { | |
static $functions; | |
/** | |
* @param array $functions to ignore | |
*/ | |
public static function on_load( $functions ) { | |
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { | |
self::$functions = $functions; | |
add_action( 'deprecated_function_run', array( __CLASS__, 'deprecated_function_run' ) ); | |
} | |
} | |
/** | |
* @param string $function name | |
*/ | |
public static function deprecated_function_run( $function ) { | |
if ( in_array( $function, self::$functions ) ) | |
add_filter( 'deprecated_function_trigger_error', array( __CLASS__, 'deprecated_function_trigger_error' ) ); | |
} | |
/** | |
* @return bool | |
*/ | |
public static function deprecated_function_trigger_error() { | |
remove_filter( __FUNCTION__, array( __CLASS__, __FUNCTION__ ) ); | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's you again