_edd_deprecated_function( string $function, string $version, string $replacement = null, array $backtrace = null )
Marks a function as deprecated and informs when it has been used.
Description Description
There is a hook edd_deprecated_function_run that will be called that can be used to get the backtrace up to what file and function called the deprecated function.
The current behavior is to trigger a user error if WP_DEBUG is true.
This function is to be used in every function that is deprecated.
Parameters Parameters
- $function
-
(Required) The function that was called
- $version
-
(Required) The version of Easy Digital Downloads that deprecated the function
- $replacement
-
(Optional) The function that should have been called
Default value: null
- $backtrace
-
(Optional) Contains stack backtrace of deprecated function
Default value: null
Source Source
File: includes/misc-functions.php
function _edd_deprecated_function( $function, $version, $replacement = null, $backtrace = null ) { do_action( 'edd_deprecated_function_run', $function, $replacement, $version ); $show_errors = current_user_can( 'manage_options' ); // Allow plugin to filter the output error trigger if ( WP_DEBUG && apply_filters( 'edd_deprecated_function_trigger_error', $show_errors ) ) { if ( ! is_null( $replacement ) ) { trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Easy Digital Downloads version %2$s! Use %3$s instead.', 'easy-digital-downloads' ), $function, $version, $replacement ) ); trigger_error( print_r( $backtrace, 1 ) ); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. // Alternatively we could dump this to a file. } else { trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Easy Digital Downloads version %2$s with no alternative available.', 'easy-digital-downloads' ), $function, $version ) ); trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. // Alternatively we could dump this to a file. } } }