Make WordPress Core

Ticket #41125: 41125.diff

File 41125.diff, 2.9 KB (added by ohryan, 16 months ago)

Refresh

  • src/wp-includes/functions.php

    diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
    index 16a32dd7bf..1f5bbffd1d 100644
    a b function _deprecated_constructor( $class_name, $version, $parent_class = '' ) { 
    55955595
    55965596}
    55975597
     5598/**
     5599 * Marks a class as deprecated and informs when it has been used.
     5600 *
     5601 * There is a {@see 'deprecated_class_run'} hook that will be called that can be used
     5602 * to get the backtrace up to what file and function called the
     5603 * deprecated class.
     5604 *
     5605 * The current behavior is to trigger a user error if `WP_DEBUG` is true.
     5606 *
     5607 * This function is to be used in the class constructor for every deprecated class.
     5608 * See {@see _deprecated_constructor()} for deprecating PHP4 style constructors.
     5609 *
     5610 * @since 6.4.0
     5611 *
     5612 * @param string $class       The class being instantiated
     5613 * @param string $version     The version of WordPress that deprecated the class.
     5614 * @param string $replacement Optional. The class or function that should have been called.
     5615 *                            Default empty string.
     5616 */
     5617function _deprecated_class( $class, $version, $replacement = '' ) {
     5618
     5619        /**
     5620         * Fires when a deprecated class is called.
     5621         *
     5622         * @since 6.4.0
     5623         *
     5624         * @param string $class       The class being instantiated
     5625         * @param string $replacement The class or function that should have been called.
     5626         * @param string $version     The version of WordPress that deprecated the class.
     5627         */
     5628        do_action( 'deprecated_class_run', $class, $replacement, $version );
     5629
     5630        /**
     5631         * Filters whether to trigger an error for a deprecated class.
     5632         *
     5633         * @since 6.4.0
     5634         *
     5635         * @param bool $trigger Whether to trigger an error for a deprecated class. Default true.
     5636         */
     5637        if ( WP_DEBUG && apply_filters( 'deprecated_class_trigger_error', true ) ) {
     5638                if ( function_exists( '__' ) ) {
     5639                        if ( ! is_null( $replacement ) ) {
     5640                                /* translators: 1: PHP class name, 2: version number, 3: alternative clas or function name */
     5641                                trigger_error( sprintf( __('Class %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $class, $version, $replacement ), E_USER_DEPRECATED );
     5642                        } else {
     5643                                /* translators: 1: PHP class name, 2: version number */
     5644                                trigger_error( sprintf( __('Class %1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $class, $version ), E_USER_DEPRECATED );
     5645                        }
     5646                } else {
     5647                        if ( ! is_null( $replacement ) ) {
     5648                                trigger_error( sprintf( 'Class %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $class, $version, $replacement ), E_USER_DEPRECATED );
     5649                        } else {
     5650                                trigger_error( sprintf( 'Class %1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $class, $version ), E_USER_DEPRECATED );
     5651                        }
     5652                }
     5653        }
     5654}
     5655
    55985656/**
    55995657 * Marks a file as deprecated and inform when it has been used.
    56005658 *