_deprecated_file
函数
_deprecated_file ( $file, $version, $replacement = '', $message = '' )
- 参数
-
-
(string)
$file
The file that was included.- Required: 是
-
(string)
$version
The version of WordPress that deprecated the file.- Required: 是
-
(string)
$replacement
Optional. The file that should have been included based on ABSPATH. Default empty.- Required: 否
- Default: (empty)
-
(string)
$message
Optional. A message regarding the change. Default empty.- Required: 否
- Default: (empty)
-
(string)
- 定义位置
-
-
wp-includes/functions.php
, line 5545
-
wp-includes/functions.php
- 引入
- 2.5.0
- 弃用
- –
Marks a file as deprecated and inform when it has been used.
There is a hook {@see ‘deprecated_file_included’} that will be called that can be used
to get the backtrace up to what file and function included the deprecated
file.
The current behavior is to trigger a user error if `WP_DEBUG` is true.
This function is to be used in every file that is deprecated.
function _deprecated_file( $file, $version, $replacement = '', $message = '' ) { /** * Fires when a deprecated file is called. * * @since 2.5.0 * * @param string $file The file that was called. * @param string $replacement The file that should have been included based on ABSPATH. * @param string $version The version of WordPress that deprecated the file. * @param string $message A message regarding the change. */ do_action( 'deprecated_file_included', $file, $replacement, $version, $message ); /** * Filters whether to trigger an error for deprecated files. * * @since 2.5.0 * * @param bool $trigger Whether to trigger the error for deprecated files. Default true. */ if ( WP_DEBUG && apply_filters( 'deprecated_file_trigger_error', true ) ) { $message = empty( $message ) ? '' : ' ' . $message; if ( function_exists( '__' ) ) { if ( $replacement ) { trigger_error( sprintf( /* translators: 1: PHP file name, 2: Version number, 3: Alternative file name. */ __( 'File %1$s is deprecated since version %2$s! Use %3$s instead.' ), $file, $version, $replacement ) . $message, E_USER_DEPRECATED ); } else { trigger_error( sprintf( /* translators: 1: PHP file name, 2: Version number. */ __( 'File %1$s is deprecated since version %2$s with no alternative available.' ), $file, $version ) . $message, E_USER_DEPRECATED ); } } else { if ( $replacement ) { trigger_error( sprintf( 'File %1$s is deprecated since version %2$s! Use %3$s instead.', $file, $version, $replacement ) . $message, E_USER_DEPRECATED ); } else { trigger_error( sprintf( 'File %1$s is deprecated since version %2$s with no alternative available.', $file, $version ) . $message, E_USER_DEPRECATED ); } } } }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。