_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)
定义位置
相关方法
ms_deprecated_blogs_file_deprecated_function_deprecated_hookwp_delete_file_deprecated_argument
引入
2.5.0
弃用
-

deprecated_file: 当使用已弃用的文件时,触发弃用通知的函数。

将一个文件标记为过时的文件,并在它被使用时通知。

有一个钩子{@see ‘deprecated_file_included’}将被调用,可以用来获得回溯,直到哪个文件和函数包含了被弃用的文件。

目前的行为是,如果`WP_DEBUG’为真,则触发一个用户错误。

这个函数将被用于每个被弃用的文件。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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 <strong>deprecated</strong> 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 <strong>deprecated</strong> since version %2$s with no alternative available.' ),
$file,
$version
) . $message,
E_USER_DEPRECATED
);
}
} else {
if ( $replacement ) {
trigger_error(
sprintf(
'File %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.',
$file,
$version,
$replacement
) . $message,
E_USER_DEPRECATED
);
} else {
trigger_error(
sprintf(
'File %1$s is <strong>deprecated</strong> since version %2$s with no alternative available.',
$file,
$version
) . $message,
E_USER_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 <strong>deprecated</strong> 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 <strong>deprecated</strong> since version %2$s with no alternative available.' ), $file, $version ) . $message, E_USER_DEPRECATED ); } } else { if ( $replacement ) { trigger_error( sprintf( 'File %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $file, $version, $replacement ) . $message, E_USER_DEPRECATED ); } else { trigger_error( sprintf( 'File %1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $file, $version ) . $message, E_USER_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 <strong>deprecated</strong> 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 <strong>deprecated</strong> since version %2$s with no alternative available.' ),
						$file,
						$version
					) . $message,
					E_USER_DEPRECATED
				);
			}
		} else {
			if ( $replacement ) {
				trigger_error(
					sprintf(
						'File %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.',
						$file,
						$version,
						$replacement
					) . $message,
					E_USER_DEPRECATED
				);
			} else {
				trigger_error(
					sprintf(
						'File %1$s is <strong>deprecated</strong> since version %2$s with no alternative available.',
						$file,
						$version
					) . $message,
					E_USER_DEPRECATED
				);
			}
		}
	}
}

常见问题

FAQs
查看更多 >