Make WordPress Core


Ignore:
Timestamp:
08/25/2023 03:24:00 AM (13 months ago)
Author:
DrewAPicture
Message:

Introduce a _deprecated_class() function.

Similar to other function in the _deprecated_* series, _deprecated_class() comes with two new hooks: deprecated_class_run and deprecated_class_trigger_error.

Support has also been added for setting class deprecation expectations in tests.

Props jrf, wvega, ohryan.
See #41125.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/abstract-testcase.php

    r56421 r56467  
    569569        add_action( 'deprecated_function_run', array( $this, 'deprecated_function_run' ), 10, 3 );
    570570        add_action( 'deprecated_argument_run', array( $this, 'deprecated_function_run' ), 10, 3 );
     571        add_action( 'deprecated_class_run', array( $this, 'deprecated_function_run' ), 10, 3 );
    571572        add_action( 'deprecated_file_included', array( $this, 'deprecated_function_run' ), 10, 4 );
    572573        add_action( 'deprecated_hook_run', array( $this, 'deprecated_function_run' ), 10, 4 );
     
    575576        add_action( 'deprecated_function_trigger_error', '__return_false' );
    576577        add_action( 'deprecated_argument_trigger_error', '__return_false' );
     578        add_action( 'deprecated_class_trigger_error', '__return_false' );
    577579        add_action( 'deprecated_file_trigger_error', '__return_false' );
    578580        add_action( 'deprecated_hook_trigger_error', '__return_false' );
     
    741743                        $message = sprintf(
    742744                            'Function %1$s was called with an argument that is deprecated since version %2$s with no alternative available.',
     745                            $function_name,
     746                            $version
     747                        );
     748                    }
     749                    break;
     750
     751                case 'deprecated_class_run':
     752                    if ( $replacement ) {
     753                        $message = sprintf(
     754                            'Class %1$s is deprecated since version %2$s! Use %3$s instead.',
     755                            $function_name,
     756                            $version,
     757                            $replacement
     758                        );
     759                    } else {
     760                        $message = sprintf(
     761                            'Class %1$s is deprecated since version %2$s with no alternative available.',
    743762                            $function_name,
    744763                            $version
Note: See TracChangeset for help on using the changeset viewer.