_monsterinsights_deprecated_hook

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

Description

_monsterinsights_deprecated_hook( (string) $hook, (string) $version, (null) $message = null ); 

Use the 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.

Note, this is a copy of WordPress core's _deprecated_hook function, that we've copied into MonsterInsights so that we can use it on WordPress versions older than 6.0.0 (when it was introduced to core). If we ever bump our minimum WP version requirements above 6.0.0, we'll remove this function.

Parameters (3)

0. $hook (string)
The hook that was used.
1. $version (string)
The version of WordPress that deprecated the hook.
2. $message — Optional. (null) => null
A message regarding the change.

Usage

  1. if ( !function_exists( '_monsterinsights_deprecated_hook' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-analytics-for-wordpress-by-monsterinsights/includes/deprecated.php'; 
  3.  
  4. // The hook that was used. 
  5. $hook = ''; 
  6.  
  7. // The version of WordPress that deprecated the hook. 
  8. $version = ''; 
  9.  
  10. // Optional. A message regarding the change. 
  11. $message = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = _monsterinsights_deprecated_hook($hook, $version, $message); 
  15.  

Defined (1)

The function is defined in the following location(s).

/includes/deprecated.php  
  1. function _monsterinsights_deprecated_hook( $hook, $version, $message = null ) { 
  2. /** 
  3. * Fires when a deprecated hook is called. 
  4. * @since 6.0.0 
  5. * @param string $hook The hook that was called. 
  6. * @param string $version The version of MonsterInsights that deprecated the hook used. 
  7. * @param string $message A message regarding the change. 
  8. */ 
  9. do_action( 'deprecated_hook_run', $hook, $version, $message ); 
  10.  
  11. /** 
  12. * Filters whether to trigger deprecated hook errors. 
  13. * @since 6.0.0 
  14. * @param bool $trigger Whether to trigger deprecated hook errors. Requires 
  15. * `WP_DEBUG` to be defined true. 
  16. */ 
  17. if ( ( WP_DEBUG && apply_filters( 'deprecated_hook_trigger_error', true ) ) || monsterinsights_is_debug_mode() ) { 
  18. $message = empty( $message ) ? '' : ' ' . $message; 
  19. trigger_error( sprintf( esc_html__( '%1$s is %3$sdeprecated%4$s since MonsterInsights version %2$s!', 'google-analytics-for-wordpress' ), $hook, $version, '<strong>', '</strong>' ) . esc_html ( $message ) );