title( __('Deprecated', 'debug-bar') );
add_action( 'deprecated_function_run', array( &$this, 'deprecated_function_run' ), 10, 3 );
add_action( 'deprecated_file_included', array( &$this, 'deprecated_file_included' ), 10, 4 );
add_action( 'deprecated_argument_run', array( &$this, 'deprecated_argument_run' ), 10, 3 );
// Silence E_NOTICE for deprecated usage.
foreach ( array( 'function', 'file', 'argument' ) as $item )
add_filter( "deprecated_{$item}_trigger_error", '__return_false' );
}
function prerender() {
$this->set_visible(
count( $this->deprecated_functions )
|| count( $this->deprecated_files )
|| count( $this->deprecated_arguments )
);
}
function render() {
echo "
";
echo '
Total Functions:' . number_format( count( $this->deprecated_functions ) ) . "
\n";
echo '
Total Arguments:' . number_format( count( $this->deprecated_arguments ) ) . "
\n";
echo '
Total Files:' . number_format( count( $this->deprecated_files ) ) . "
\n";
if ( count( $this->deprecated_functions ) ) {
echo '
';
foreach ( $this->deprecated_functions as $location => $message_stack) {
list( $message, $stack) = $message_stack;
echo "- ";
echo str_replace(ABSPATH, '', $location) . ' - ' . strip_tags($message);
echo "
";
echo $stack;
echo " ";
}
echo '
';
}
if ( count( $this->deprecated_files ) ) {
echo '
';
foreach ( $this->deprecated_files as $location => $message_stack) {
list( $message, $stack) = $message_stack;
echo "- ";
echo str_replace(ABSPATH, '', $location) . ' - ' . strip_tags($message);
echo "
";
echo $stack;
echo " ";
}
echo '
';
}
if ( count( $this->deprecated_arguments ) ) {
echo '
';
foreach ( $this->deprecated_arguments as $location => $message_stack) {
list( $message, $stack) = $message_stack;
echo "- ";
echo str_replace(ABSPATH, '', $location) . ' - ' . strip_tags($message);
echo "
";
echo $stack;
echo " ";
}
echo '
';
}
echo "
";
}
function deprecated_function_run($function, $replacement, $version) {
$backtrace = debug_backtrace( false );
$bt = 4;
// Check if we're a hook callback.
if ( ! isset( $backtrace[4]['file'] ) && 'call_user_func_array' == $backtrace[5]['function'] ) {
$bt = 6;
}
$file = $backtrace[ $bt ]['file'];
$line = $backtrace[ $bt ]['line'];
if ( ! is_null($replacement) )
$message = sprintf( __('%1$s is deprecated since version %2$s! Use %3$s instead.', 'debug-bar'), $function, $version, $replacement );
else
$message = sprintf( __('%1$s is deprecated since version %2$s with no alternative available.', 'debug-bar'), $function, $version );
$this->deprecated_functions[$file.':'.$line] = array( $message, wp_debug_backtrace_summary( null, $bt ) );
}
function deprecated_file_included( $old_file, $replacement, $version, $message ) {
$backtrace = debug_backtrace( false );
$file = $backtrace[4]['file'];
$file_abs = str_replace(ABSPATH, '', $file);
$line = $backtrace[4]['line'];
$message = empty( $message ) ? '' : ' ' . $message;
if ( ! is_null( $replacement ) )
$message = sprintf( __('%1$s is deprecated since version %2$s! Use %3$s instead.', 'debug-bar'), $file_abs, $version, $replacement ) . $message;
else
$message = sprintf( __('%1$s is deprecated since version %2$s with no alternative available.', 'debug-bar'), $file_abs, $version ) . $message;
$this->deprecated_functions[$file.':'.$line] = array( $message, wp_debug_backtrace_summary( null, 4 ) );
}
function deprecated_argument_run( $function, $message, $version) {
$backtrace = debug_backtrace( false );
if ( $function === 'define()' ) {
$this->deprecated_functions[] = array( $message, '' );
return;
}
$bt = 4;
if ( ! isset( $backtrace[4]['file'] ) && 'call_user_func_array' == $backtrace[5]['function'] ) {
$bt = 6;
}
$file = $backtrace[ $bt ]['file'];
$line = $backtrace[ $bt ]['line'];
$this->deprecated_functions[$file.':'.$line] = array( $message, wp_debug_backtrace_summary( null, $bt ) );
}
}