返回介绍

_doing_it_wrong()

发布于 2017-09-11 13:21:41 字数 6944 浏览 944 评论 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.

_doing_it_wrong( string $function,  string $message,  string $version )

Mark something as being incorrectly called.


description

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

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


参数

$function

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

$message

(string) (Required) A message explaining what has been done incorrectly.

$version

(string) (Required) The version of WordPress where the message was added.


源代码

File: wp-includes/functions.php

function _doing_it_wrong( $function, $message, $version ) {

	/**
	 * Fires when the given function is being used incorrectly.
	 *
	 * @since 3.1.0
	 *
	 * @param string $function The function that was called.
	 * @param string $message  A message explaining what has been done incorrectly.
	 * @param string $version  The version of WordPress where the message was added.
	 */
	do_action( 'doing_it_wrong_run', $function, $message, $version );

	/**
	 * Filters whether to trigger an error for _doing_it_wrong() calls.
	 *
	 * @since 3.1.0
	 *
	 * @param bool $trigger Whether to trigger the error for _doing_it_wrong() calls. Default true.
	 */
	if ( WP_DEBUG && apply_filters( 'doing_it_wrong_trigger_error', true ) ) {
		if ( function_exists( '__' ) ) {
			if ( is_null( $version ) ) {
				$version = '';
			} else {
				/* translators: %s: version number */
				$version = sprintf( __( '(This message was added in version %s.)' ), $version );
			}
			/* translators: %s: Codex URL */
			$message .= ' ' . sprintf( __( 'Please see <a href="%s">Debugging in WordPress</a> for more information.' ),
				__( 'https://codex.wordpress.org/Debugging_in_WordPress' )
			);
			/* translators: Developer debugging message. 1: PHP function name, 2: Explanatory message, 3: Version information message */
			trigger_error( sprintf( __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s' ), $function, $message, $version ) );
		} else {
			if ( is_null( $version ) ) {
				$version = '';
			} else {
				$version = sprintf( '(This message was added in version %s.)', $version );
			}
			$message .= sprintf( ' Please see <a href="%s">Debugging in WordPress</a> for more information.',
				'https://codex.wordpress.org/Debugging_in_WordPress'
			);
			trigger_error( sprintf( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s', $function, $message, $version ) );
		}
	}
}

更新日志

Versiondescription
3.1.0Introduced.

相关函数

Uses

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

Used By

  • wp-includes/rest-api/endpoints/class-wp-rest-controller.php: WP_REST_Controller::register_routes()
  • wp-includes/functions.wp-scripts.php: wp_add_inline_script()
  • wp-includes/customize/class-wp-customize-partial.php: WP_Customize_Partial::render()
  • wp-includes/rest-api.php: register_rest_route()
  • wp-includes/query.php: is_embed()
  • wp-includes/date.php: WP_Date_Query::validate_date_values()
  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::remove_panel()
  • wp-admin/includes/template.php: convert_to_screen()
  • wp-includes/capabilities.php: map_meta_cap()
  • wp-includes/theme.php: add_theme_support()
  • wp-includes/pluggable.php: check_admin_referer()
  • wp-includes/pluggable.php: check_ajax_referer()
  • wp-includes/query.php: is_preview()
  • wp-includes/query.php: is_robots()
  • wp-includes/query.php: is_search()
  • wp-includes/query.php: is_single()
  • wp-includes/query.php: is_singular()
  • wp-includes/query.php: is_time()
  • wp-includes/query.php: is_trackback()
  • wp-includes/query.php: is_year()
  • wp-includes/query.php: is_404()
  • wp-includes/query.php: is_main_query()
  • wp-includes/query.php: is_home()
  • wp-includes/query.php: is_month()
  • wp-includes/query.php: is_page()
  • wp-includes/query.php: is_paged()
  • wp-includes/query.php: is_attachment()
  • wp-includes/query.php: is_author()
  • wp-includes/query.php: is_category()
  • wp-includes/query.php: is_tag()
  • wp-includes/query.php: is_tax()
  • wp-includes/query.php: is_date()
  • wp-includes/query.php: is_day()
  • wp-includes/query.php: is_feed()
  • wp-includes/query.php: is_comment_feed()
  • wp-includes/query.php: is_front_page()
  • wp-includes/query.php: is_archive()
  • wp-includes/query.php: is_post_type_archive()
  • wp-includes/functions.wp-scripts.php: wp_deregister_script()
  • wp-includes/taxonomy.php: register_taxonomy()
  • wp-includes/class-wp-admin-bar.php: WP_Admin_Bar::add_node()
  • wp-includes/functions.wp-styles.php: wp_add_inline_style()
  • wp-includes/shortcodes.php: do_shortcode_tag()
  • wp-includes/shortcodes.php: add_shortcode()
  • wp-includes/plugin.php: register_uninstall_hook()
  • wp-includes/post.php: wp_insert_post()
  • wp-includes/post.php: register_post_type()
  • wp-includes/wp-db.php: wpdb::_real_escape()
  • wp-includes/wp-db.php: wpdb::prepare()
  • wp-includes/widgets.php: register_sidebar()
  • Show 45 more used by Hide more used by

User Contributed Notes

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

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

发布评论

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