diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 1dce3aa161..33619fa458 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -3415,6 +3415,52 @@ function _deprecated_function( $function, $version, $replacement = null ) { } } +/** + * Marks a constructor as deprecated and informs when it has been used. + * + * Similar to _deprecated_function(), but with different strings. Used to + * remove PHP4 style constructors. + * + * The current behavior is to trigger a user error if WP_DEBUG is true. + * + * This function is to be used in every PHP4 style constructor method that is deprecated. + * + * @since 4.3.0 + * + * @access private + * + * @param string $class The class containing the deprecated constructor. + * @param string $version The version of WordPress that deprecated the function. + */ +function _deprecated_constructor( $class, $version ) { + + /** + * Fires when a deprecated constructor is called. + * + * @since 4.3.0 + * + * @param string $class The class containing the deprecated constructor. + * @param string $version The version of WordPress that deprecated the function. + */ + do_action( 'deprecated_constructor_run', $class, $version ); + + /** + * Filter whether to trigger an error for deprecated functions. + * + * @since 4.3.0 + * + * @param bool $trigger Whether to trigger the error for deprecated functions. Default true. + */ + if ( WP_DEBUG && apply_filters( 'deprecated_constructor_trigger_error', true ) ) { + if ( function_exists( '__' ) ) { + trigger_error( sprintf( __( 'The called constructor method for %1$s is deprecated since version %2$s! Use %3$s instead.' ), $class, $version, '
__construct()
' ) ); + } else { + trigger_error( sprintf( 'The called constructor method for %1$s is deprecated since version %2$s! Use %3$s instead.', $class, $version, '
__construct()
' ) ); + } + } + +} + /** * Mark a file as deprecated and inform when it has been used. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 95645556c8..679e53f040 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.3-alpha-32988'; +$wp_version = '4.3-alpha-32989'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.