| | 3331 | * Mark a constant as deprecated and inform when it has been used. |
| | 3332 | * |
| | 3333 | * There is a hook deprecated_constant_used that will be called that can be used |
| | 3334 | * to get the backtrace up to what file and function used the deprecated |
| | 3335 | * constant. |
| | 3336 | * |
| | 3337 | * The current behavior is to trigger a user error if WP_DEBUG is true. |
| | 3338 | * |
| | 3339 | * This function is to be used whenever a deprecated constant is used. |
| | 3340 | * |
| | 3341 | * @since 4.0.0 |
| | 3342 | * @access private |
| | 3343 | * |
| | 3344 | * @param string $constant The constant that was used. |
| | 3345 | * @param string $version The version of WordPress that deprecated the constant. |
| | 3346 | * @param string $message Optional. A message regarding the change. Default null. |
| | 3347 | */ |
| | 3348 | function _deprecated_constant( $constant, $version, $message = null ) { |
| | 3349 | |
| | 3350 | /** |
| | 3351 | * Fires when a deprecated constant is used. |
| | 3352 | * |
| | 3353 | * @since 4.0.0 |
| | 3354 | * |
| | 3355 | * @param string $constant The constant that was called. |
| | 3356 | * @param string $message A message regarding the change. |
| | 3357 | * @param string $version The version of WordPress that deprecated the constant used. |
| | 3358 | */ |
| | 3359 | do_action( 'deprecated_constant_used', $constant, $message, $version ); |
| | 3360 | |
| | 3361 | /** |
| | 3362 | * Filter whether to trigger an error for deprecated constants. |
| | 3363 | * |
| | 3364 | * @since 4.0.0 |
| | 3365 | * |
| | 3366 | * @param bool $trigger Whether to trigger the error for deprecated constants. Default true. |
| | 3367 | */ |
| | 3368 | if ( WP_DEBUG && apply_filters( 'deprecated_constant_trigger_error', true ) ) { |
| | 3369 | if ( function_exists( '__' ) ) { |
| | 3370 | if ( ! is_null( $message ) ) |
| | 3371 | trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! %3$s'), $constant, $version, $message ) ); |
| | 3372 | else |
| | 3373 | trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $constant, $version ) ); |
| | 3374 | } else { |
| | 3375 | if ( ! is_null( $message ) ) |
| | 3376 | trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! %3$s', $constant, $version, $message ) ); |
| | 3377 | else |
| | 3378 | trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $constant, $version ) ); |
| | 3379 | } |
| | 3380 | } |
| | 3381 | } |
| | 3382 | |
| | 3383 | /** |