Home / APIs / _deprecated_hook() – Marks a deprecated action or filter hook as deprecated and throws a notice.

You appear to be a bot. Output may be restricted

Description

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

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.

Usage

_deprecated_hook( $hook, $version, $replacement, $message );

Parameters

$hook
( string ) required – The hook that was used.
$version
( string ) required – The version of WordPress that deprecated the hook.
$replacement
( string ) optional – Optional. The hook that should have been used.
$message
( string ) optional – Optional. A message regarding the change.

Returns

void

Source

File name: wordpress/wp-includes/functions.php
Lines: 1 to 32 of 32

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

 View on GitHub View on Trac

Published: 13th March 2017 | Last updated: 13th March 2017

Information

Function name: _deprecated_hook
Plugin ref: WordPress
Version: 5.0.3
Sourcefile: wp-includes/functions.php
File ref: wp-includes/functions.php
API type: private
Deprecated?: No
API Letters: _,D,H

  • Plugins
  • Themes
  • Blocks
  • Shortcodes
  • APIs
  • Files
  • Hooks
  • Classes
  • Sites
  • Sitemap
  • Blog
WP-a2z Yoast SEO a2z
WordPress SEO a2z

Site:  wordpress-seo.wp-a2z.org
© Copyright WP-a2z 2017-2019. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins