| | 3419 | * Mark a constructor as deprecated and inform when it has been used. |
| | 3420 | * |
| | 3421 | * Similar to _deprecated_function , but with different strings. Used to |
| | 3422 | * remove PHP4 style constructors |
| | 3423 | * |
| | 3424 | * The current behavior is to trigger a user error if WP_DEBUG is true. |
| | 3425 | * |
| | 3426 | * This function is to be used in every PHP4 style constructor method that is deprecated. |
| | 3427 | * |
| | 3428 | * @since 4.3.0 |
| | 3429 | * @access private |
| | 3430 | * |
| | 3431 | * @param string $class The class containing the deprecated constructor. |
| | 3432 | * @param string $version The version of WordPress that deprecated the function. |
| | 3433 | */ |
| | 3434 | function _deprecated_constructor( $class, $version ) { |
| | 3435 | |
| | 3436 | /** |
| | 3437 | * Fires when a deprecated constructor is called. |
| | 3438 | * |
| | 3439 | * @since 4.3.0 |
| | 3440 | * |
| | 3441 | * @param string $class The class containing the deprecated constructor. |
| | 3442 | * @param string $version The version of WordPress that deprecated the function. |
| | 3443 | */ |
| | 3444 | do_action( 'deprecated_constructor_run', $class, $version ); |
| | 3445 | |
| | 3446 | /** |
| | 3447 | * Filter whether to trigger an error for deprecated functions. |
| | 3448 | * |
| | 3449 | * @since 4.3.0 |
| | 3450 | * |
| | 3451 | * @param bool $trigger Whether to trigger the error for deprecated functions. Default true. |
| | 3452 | */ |
| | 3453 | if ( WP_DEBUG && apply_filters( 'deprecated_constructor_trigger_error', true ) ) { |
| | 3454 | if ( function_exists( '__' ) ) { |
| | 3455 | trigger_error( sprintf( __('The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $class, $version, '<pre>__construct()</pre>' ) ); |
| | 3456 | } else { |
| | 3457 | trigger_error( sprintf( 'The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $class, $version, '<pre>__construct()</pre>' ) ); |
| | 3458 | } |
| | 3459 | } |
| | 3460 | |
| | 3461 | } |
| | 3462 | |
| | 3463 | /** |