Make WordPress Core

Changeset 36541


Ignore:
Timestamp:
02/16/2016 11:19:38 PM (9 years ago)
Author:
ocean90
Message:

Introduce a $parent_class parameter for _deprecated_constructor().

Use the parameter for the deprecated constructor warning in WP_Widget to provide an indication to which widget is using the PHP4 style constructor.

Props sebastian.pisula.
Fixes #33440.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-widget.php

    r35955 r36541  
    169169     */
    170170    public function WP_Widget( $id_base, $name, $widget_options = array(), $control_options = array() ) {
    171         _deprecated_constructor( 'WP_Widget', '4.3.0' );
     171        _deprecated_constructor( 'WP_Widget', '4.3.0', get_class( $this ) );
    172172        WP_Widget::__construct( $id_base, $name, $widget_options, $control_options );
    173173    }
  • trunk/src/wp-includes/functions.php

    r36500 r36541  
    36293629 *
    36303630 * @since 4.3.0
     3631 * @since 4.5.0 Added the `$parent_class` parameter.
     3632 *
    36313633 * @access private
    36323634 *
    3633  * @param string $class   The class containing the deprecated constructor.
    3634  * @param string $version The version of WordPress that deprecated the function.
    3635  */
    3636 function _deprecated_constructor( $class, $version ) {
     3635 * @param string $class        The class containing the deprecated constructor.
     3636 * @param string $version      The version of WordPress that deprecated the function.
     3637 * @param string $parent_class Optional. The parent class calling the deprecated constructor.
     3638 *                             Default empty string.
     3639 */
     3640function _deprecated_constructor( $class, $version, $parent_class = '' ) {
    36373641
    36383642    /**
     
    36403644     *
    36413645     * @since 4.3.0
    3642      *
    3643      * @param string $class   The class containing the deprecated constructor.
    3644      * @param string $version The version of WordPress that deprecated the function.
     3646     * @since 4.5.0 Added the `$parent_class` parameter.
     3647     *
     3648     * @param string $class        The class containing the deprecated constructor.
     3649     * @param string $version      The version of WordPress that deprecated the function.
     3650     * @param string $parent_class The parent class calling the deprecated constructor.
    36453651     */
    3646     do_action( 'deprecated_constructor_run', $class, $version );
     3652    do_action( 'deprecated_constructor_run', $class, $version, $parent_class );
    36473653
    36483654    /**
     
    36573663    if ( WP_DEBUG && apply_filters( 'deprecated_constructor_trigger_error', true ) ) {
    36583664        if ( function_exists( '__' ) ) {
    3659             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>' ) );
     3665            if ( ! empty( $parent_class ) ) {
     3666                /* translators: 1: PHP class name, 2: PHP parent class name, 3: version number, 4: __construct() method */
     3667                trigger_error( sprintf( __( 'The called constructor method for %1$s in %2$s is <strong>deprecated</strong> since version %3$s! Use %4$s instead.' ),
     3668                    $class, $parent_class, $version, '<pre>__construct()</pre>' ) );
     3669            } else {
     3670                /* translators: 1: PHP class name, 2: version number, 3: __construct() method */
     3671                trigger_error( sprintf( __( 'The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ),
     3672                    $class, $version, '<pre>__construct()</pre>' ) );
     3673            }
    36603674        } else {
    3661             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>' ) );
     3675            if ( ! empty( $parent_class ) ) {
     3676                trigger_error( sprintf( 'The called constructor method for %1$s in %2$s is <strong>deprecated</strong> since version %3$s! Use %4$s instead.',
     3677                    $class, $parent_class, $version, '<pre>__construct()</pre>' ) );
     3678            } else {
     3679                trigger_error( sprintf( 'The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.',
     3680                    $class, $version, '<pre>__construct()</pre>' ) );
     3681            }
    36623682        }
    36633683    }
Note: See TracChangeset for help on using the changeset viewer.