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_hook( string $hook, string $version, string $replacement = null, string $message = null )

Marks a deprecated action or filter hook as deprecated and throws a notice.


Description Description

Use the ‘deprecated_hook_run’ action to get the backtrace describing where the deprecated hook was called.

Default behavior is to trigger a user error if WP_DEBUG is true.

This function is called by the do_action_deprecated() and apply_filters_deprecated() functions, and so generally does not need to be called directly.


Parameters Parameters

$hook

(string) (Required) The hook that was used.

$version

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

$replacement

(string) (Optional) The hook that should have been used.

Default value: null

$message

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

Default value: null


Top ↑

Source Source

File: wp-includes/functions.php

4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
function _deprecated_hook( $hook, $version, $replacement = null, $message = null ) {
    /**
     * Fires when a deprecated hook is called.
     *
     * @since 4.6.0
     *
     * @param string $hook        The hook that was called.
     * @param string $replacement The hook that should be used as a replacement.
     * @param string $version     The version of WordPress that deprecated the argument used.
     * @param string $message     A message regarding the change.
     */
    do_action( 'deprecated_hook_run', $hook, $replacement, $version, $message );
 
    /**
     * Filters whether to trigger deprecated hook errors.
     *
     * @since 4.6.0
     *
     * @param bool $trigger Whether to trigger deprecated hook errors. Requires
     *                      `WP_DEBUG` to be defined true.
     */
    if ( WP_DEBUG && apply_filters( 'deprecated_hook_trigger_error', true ) ) {
        $message = empty( $message ) ? '' : ' ' . $message;
        if ( ! is_null( $replacement ) ) {
            /* translators: 1: WordPress hook name, 2: version number, 3: alternative hook name */
            trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ), $hook, $version, $replacement ) . $message );
        } else {
            /* translators: 1: WordPress hook name, 2: version number */
            trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.' ), $hook, $version ) . $message );
        }
    }
}

Top ↑

Changelog Changelog

Changelog
Version Description
4.6.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.