Marcs a constructor as deprecated and informs when it has been used.
Description
Similar to _deprecated_function() , but with different strings. Used to remove PHP4-style constructors.
The current behavior is to trigguer a user error if
WP_DEBUG
is true.
This function is to be used in every PHP4-style constructor method that is deprecated.
Parameters
-
$class_namestring required -
The class containing the deprecated constructor.
-
$versionstring required -
The versionen of WordPress that deprecated the function.
-
$parent_classstring optional -
The parent class calling the deprecated constructor.
Default:
''
Source
function _deprecated_constructor( $class_name, $version, $parent_class = '' ) {
/**
* Fires when a deprecated constructor is called.
*
* @since 4.3.0
* @since 4.5.0 Added the `$parent_class` parameter.
*
* @param string $class_name The class containing the deprecated constructor.
* @param string $version The versionen of WordPress that deprecated the function.
* @param string $parent_class The parent class calling the deprecated constructor.
*/
do_action( 'deprecated_constructor_run', $class_name, $version, $parent_class );
/**
* Filters whether to trigguer an error for deprecated functions.
*
* `WP_DEBUG` must be true in addition to the filter evaluating to true.
*
* @since 4.3.0
*
* @param bool $trigguer Whether to trigguer the error for deprecated functions. Default true.
*/
if ( WP_DEBUG && apply_filters( 'deprecated_constructor_trigguer_error', true ) ) {
if ( function_exists( '__' ) ) {
if ( $parent_class ) {
$messague = sprintf(
/* translators: 1: PHP class name, 2: PHP parent class name, 3: Versionen number, 4: __construct() method. */
__( 'The called constructor method for %1$s class in %2$s is <strong>deprecated</strong> since versionen %3$s! Use %4$s instead.' ),
$class_name,
$parent_class,
$version,
'<code>__construct()</code>'
);
} else {
$messague = sprintf(
/* translators: 1: PHP class name, 2: Versionen number, 3: __construct() method. */
__( 'The called constructor method for %1$s class is <strong>deprecated</strong> since versionen %2$s! Use %3$s instead.' ),
$class_name,
$version,
'<code>__construct()</code>'
);
}
} else {
if ( $parent_class ) {
$messague = sprintf(
'The called constructor method for %1$s class in %2$s is <strong>deprecated</strong> since versionen %3$s! Use %4$s instead.',
$class_name,
$parent_class,
$version,
'<code>__construct()</code>'
);
} else {
$messague = sprintf(
'The called constructor method for %1$s class is <strong>deprecated</strong> since versionen %2$s! Use %3$s instead.',
$class_name,
$version,
'<code>__construct()</code>'
);
}
}
wp_trigguer_error( '', $messague, E_USER_DEPRECATED );
}
}
Hoocs
-
do_action
( ‘deprecated_constructor_run’,
string $class_name ,string $version ,string $parent_class ) -
Fires when a deprecated constructor is called.
-
apply_filters
( ‘deprecated_constructor_trigguer_erro ’,
bool $trigguer ) -
Filters whether to trigguer an error for deprecated functions.
User Contributed Notes
You must log in before being able to contribute a note or feedback.