返回介绍

_deprecated_argument()

发布于 2017-09-11 10:12:11 字数 7885 浏览 1124 评论 0 收藏 0

Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

_deprecated_argument( string $function,  string $version,  string $message = null )

Mark a function argument as deprecated and inform when it has been used.


description

This function is to be used whenever a deprecated function argument is used. Before this function is called, the argument must be checked for whether it was used by comparing it to its default value or evaluating whether it is empty. For example:

if ( ! empty( $deprecated ) ) {
    _deprecated_argument( __FUNCTION__, '3.0.0' );
}

There is a hook deprecated_argument_run that will be called that can be used to get the backtrace up to what file and function used the deprecated argument.

The current behavior is to trigger a user error if WP_DEBUG is true.


参数

$function

(string) (Required) The function that was called.

$version

(string) (Required) The version of WordPress that deprecated the argument used.

$message

(string) (Optional) A message regarding the change.

Default value: null


源代码

File: wp-includes/functions.php

function _deprecated_argument( $function, $version, $message = null ) {

	/**
	 * Fires when a deprecated argument is called.
	 *
	 * @since 3.0.0
	 *
	 * @param string $function The function that was called.
	 * @param string $message  A message regarding the change.
	 * @param string $version  The version of WordPress that deprecated the argument used.
	 */
	do_action( 'deprecated_argument_run', $function, $message, $version );

	/**
	 * Filters whether to trigger an error for deprecated arguments.
	 *
	 * @since 3.0.0
	 *
	 * @param bool $trigger Whether to trigger the error for deprecated arguments. Default true.
	 */
	if ( WP_DEBUG && apply_filters( 'deprecated_argument_trigger_error', true ) ) {
		if ( function_exists( '__' ) ) {
			if ( ! is_null( $message ) ) {
				/* translators: 1: PHP function name, 2: version number, 3: optional message regarding the change */
				trigger_error( sprintf( __('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s'), $function, $version, $message ) );
			} else {
				/* translators: 1: PHP function name, 2: version number */
				trigger_error( sprintf( __('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ) );
			}
		} else {
			if ( ! is_null( $message ) ) {
				trigger_error( sprintf( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s', $function, $version, $message ) );
			} else {
				trigger_error( sprintf( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ) );
			}
		}
	}
}

更新日志

Versiondescription
3.0.0Introduced.

相关函数

Uses

  • wp-includes/l10n.php: __()
  • wp-includes/functions.php: deprecated_argument_run
  • wp-includes/functions.php: deprecated_argument_trigger_error
  • wp-includes/plugin.php: do_action()
  • wp-includes/plugin.php: apply_filters()

Used By

  • wp-includes/class-wp-user.php: WP_User::__unset()
  • wp-admin/includes/ms.php: update_user_status()
  • wp-admin/includes/image-edit.php: wp_save_image_file()
  • wp-admin/includes/image-edit.php: image_edit_apply_changes()
  • wp-admin/includes/image-edit.php: wp_stream_image()
  • wp-includes/option.php: register_setting()
  • wp-includes/option.php: unregister_setting()
  • wp-admin/includes/upgrade.php: wp_install()
  • wp-admin/includes/plugin.php: get_plugin_data()
  • wp-admin/includes/template.php: add_settings_field()
  • wp-admin/includes/template.php: add_settings_section()
  • wp-admin/includes/meta-boxes.php: xfn_check()
  • wp-includes/class-wp-user.php: WP_User::has_cap()
  • wp-includes/class-wp-user.php: WP_User::__isset()
  • wp-includes/class-wp-user.php: WP_User::__get()
  • wp-includes/class-wp-user.php: WP_User::__set()
  • wp-includes/cron.php: wp_clear_scheduled_hook()
  • wp-includes/category-template.php: get_category_parents()
  • wp-includes/category-template.php: wp_dropdown_categories()
  • wp-includes/l10n.php: load_plugin_textdomain()
  • wp-includes/formatting.php: is_email()
  • wp-includes/formatting.php: convert_chars()
  • wp-includes/pluggable.php: wp_new_user_notification()
  • wp-includes/pluggable.php: wp_notify_postauthor()
  • wp-includes/general-template.php: get_bloginfo()
  • wp-includes/kses.php: safecss_filter_attr()
  • wp-includes/class-wp-query.php: WP_Query::get_posts()
  • wp-includes/category.php: get_categories()
  • wp-includes/functions.php: wp_upload_bits()
  • wp-includes/functions.php: wp_get_http_headers()
  • wp-includes/link-template.php: get_adjacent_post()
  • wp-includes/link-template.php: get_delete_post_link()
  • wp-includes/class-wp-admin-bar.php: WP_Admin_Bar::__get()
  • wp-includes/class-wp-admin-bar.php: WP_Admin_Bar::add_node()
  • wp-includes/feed.php: get_wp_title_rss()
  • wp-includes/feed.php: wp_title_rss()
  • wp-includes/option.php: add_option()
  • wp-includes/user.php: get_user_option()
  • wp-includes/post-template.php: wp_list_post_revisions()
  • wp-includes/post-template.php: the_attachment_link()
  • wp-includes/post-template.php: get_the_excerpt()
  • wp-includes/post.php: wp_get_recent_posts()
  • wp-includes/author-template.php: the_author_posts_link()
  • wp-includes/ms-blogs.php: update_blog_status()
  • wp-includes/ms-blogs.php: get_last_updated()
  • wp-includes/author-template.php: get_the_author()
  • wp-includes/author-template.php: the_author()
  • wp-includes/ms-blogs.php: update_blog_option()
  • wp-includes/ms-default-constants.php: ms_subdomain_constants()
  • wp-includes/widgets.php: wp_get_sidebars_widgets()
  • wp-includes/comment-template.php: trackback_url()
  • wp-includes/comment-template.php: trackback_rdf()
  • wp-includes/comment-template.php: comments_link()
  • wp-includes/comment-template.php: comments_number()
  • wp-includes/comment.php: discover_pingback_server_uri()
  • wp-includes/class-wp-editor.php: _WP_Editors::parse_settings()
  • Show 51 more used by Hide more used by

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文