
2020年最新版本WordPress本地环境搭建与安装教程
_deprecated_function ( $function, $version, $replacement = '' )
deprecated_function: 当使用一个已弃用的函数时,触发一个弃用通知的函数。
将一个函数标记为弃用的,并在它被使用时通知。
有一个钩子{@see ‘deprecated_function_run’}将被调用,可以用来获取回溯,直到哪个文件和函数调用了被弃用的函数。
目前的行为是,如果`WP_DEBUG’为真,就会触发一个用户错误。
这个函数将被用于每个被弃用的函数中。
function _deprecated_function( $function, $version, $replacement = '' ) { /** * Fires when a deprecated function is called. * * @since 2.5.0 * * @param string $function The function that was called. * @param string $replacement The function that should have been called. * @param string $version The version of WordPress that deprecated the function. */ do_action( 'deprecated_function_run', $function, $replacement, $version ); /** * Filters whether to trigger an error for deprecated functions. * * @since 2.5.0 * * @param bool $trigger Whether to trigger the error for deprecated functions. Default true. */ if ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) { if ( function_exists( '__' ) ) { if ( $replacement ) { trigger_error( sprintf( /* translators: 1: PHP function name, 2: Version number, 3: Alternative function name. */ __( 'Function %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ), $function, $version, $replacement ), E_USER_DEPRECATED ); } else { trigger_error( sprintf( /* translators: 1: PHP function name, 2: Version number. */ __( 'Function %1$s is <strong>deprecated</strong> since version %2$s with no alternative available.' ), $function, $version ), E_USER_DEPRECATED ); } } else { if ( $replacement ) { trigger_error( sprintf( 'Function %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $function, $version, $replacement ), E_USER_DEPRECATED ); } else { trigger_error( sprintf( 'Function %1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ), E_USER_DEPRECATED ); } } } }