| 4093 | * Mark a class as deprecated and inform when it has been used. |
| 4094 | * |
| 4095 | * There is a {@see 'hook deprecated_class_run'} that will be called that can be used |
| 4096 | * to get the backtrace up to what file and function called the deprecated |
| 4097 | * class. |
| 4098 | * |
| 4099 | * The current behavior is to trigger a user error if `WP_DEBUG` is true. |
| 4100 | * |
| 4101 | * This function is to be used in the class constructor for every class that is deprecated. |
| 4102 | * |
| 4103 | * @since 4.9.0 |
| 4104 | * @access private |
| 4105 | * |
| 4106 | * @param string $class The class being instantiated. |
| 4107 | * @param string $version The version of WordPress that deprecated the class. |
| 4108 | * @param string $replacement Optional. The class or function that should have been called. Default null. |
| 4109 | */ |
| 4110 | function _deprecated_class( $class, $version, $replacement = null ) { |
| 4111 | |
| 4112 | /** |
| 4113 | * Fires when a deprecated class is called. |
| 4114 | * |
| 4115 | * @since 4.9.0 |
| 4116 | * |
| 4117 | * @param string $class The class being instantiated. |
| 4118 | * @param string $replacement The class or function that should have been called. |
| 4119 | * @param string $version The version of WordPress that deprecated the class. |
| 4120 | */ |
| 4121 | do_action( 'deprecated_class_run', $function, $replacement, $version ); |
| 4122 | |
| 4123 | /** |
| 4124 | * Filters whether to trigger an error for deprecated classes. |
| 4125 | * |
| 4126 | * @since 4.9.0 |
| 4127 | * |
| 4128 | * @param bool $trigger Whether to trigger the error for deprecated classes. Default true. |
| 4129 | */ |
| 4130 | if ( WP_DEBUG && apply_filters( 'deprecated_class_trigger_error', true ) ) { |
| 4131 | if ( function_exists( '__' ) ) { |
| 4132 | if ( ! is_null( $replacement ) ) { |
| 4133 | /* translators: 1: PHP class name, 2: version number, 3: alternative clas or function name */ |
| 4134 | trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $function, $version, $replacement ), E_USER_DEPRECATED ); |
| 4135 | } else { |
| 4136 | /* translators: 1: PHP class name, 2: version number */ |
| 4137 | trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ), E_USER_DEPRECATED ); |
| 4138 | } |
| 4139 | } else { |
| 4140 | if ( ! is_null( $replacement ) ) { |
| 4141 | trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $function, $version, $replacement ), E_USER_DEPRECATED ); |
| 4142 | } else { |
| 4143 | trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ), E_USER_DEPRECATED ); |
| 4144 | } |
| 4145 | } |
| 4146 | } |
| 4147 | } |
| 4148 | |
| 4149 | /** |