^ 回到顶部
  • 人生没有定律,每个人都有自己的节奏
  • 本站wordpress建站教程均通过实践后发布,希望对你有帮助,如果有代码出错,请联系站长解决
  • 希望你的坚持,都是因为热爱,而不是因为不甘心
  • 8年wordpress建站经验,5星服务品质
  • 那些不愿意让你吃亏的人,才是真正值得你深交的人,也是值得你付出时间的人
  • 阿里云2核2g仅需86元/年

wordpress函数_doing_it_wrong()用法示例

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.

新用户2核2g仅需86元/年    领取1153套模板    免费cdn流量包    ¥3188礼包


描述

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 ) );
		}
	}
}

更新日志

Version 描述
3.1.0 Introduced.

相关函数

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


让小雨知道,这篇文章帮到了你
扫码关注微信公众号zs40086(微搜片)随时随地微信看片,抢先福利电影等你来

热门推荐

如有疑问,请前往问答中心反馈!

反馈