Skip to content

Instantly share code, notes, and snippets.

@Rarst
Created June 14, 2012 17:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rarst/2931653 to your computer and use it in GitHub Desktop.
Save Rarst/2931653 to your computer and use it in GitHub Desktop.
Shuts up deprecated messages for specific functions
<?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;
}
}
@lkraav
Copy link

lkraav commented Sep 18, 2013

It's you again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment