', '' ) . esc_html ( $message ) ); } } /** * Marks a function as deprecated and informs when it has been used. * * There is a hook monsterinsights_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. Based on the one in EDD core. * * 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. * * @since 6.0.0 * @access private * * @uses do_action() Calls 'monsterinsights_deprecated_function_run' and passes the function name, what to use instead, * and the version the function was deprecated in. * @uses apply_filters() Calls 'monsterinsights_deprecated_function_trigger_error' and expects boolean value of true to do * trigger or false to not trigger error. * * @param string $function The function that was called * @param string $version The version of WordPress that deprecated the function * @param array $backtrace Optional. Contains stack backtrace of deprecated function * @return void */ function _monsterinsights_deprecated_function( $function, $version, $backtrace = null ) { /** * Deprecated Function Action. * * Allow plugin run an action on the use of a * deprecated function. This could be used to * feed into an error logging program or file. * * @since 6.0.0 * * @param string $function The function that was called. * @param string $version The version of WordPress that deprecated the function. * @param array $backtrace Optional. Contains stack backtrace of deprecated function. */ do_action( 'deprecated_function_run', $function, $version, $backtrace ); /** * Filters whether to trigger an error for deprecated functions. * * @since 6.0.0 * * @param bool $trigger Whether to trigger the error for deprecated functions. Default true. */ if ( ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) || monsterinsights_is_debug_mode() ) { trigger_error( sprintf( esc_html__( '%1$s is %3$sdeprecated%4$s since MonsterInsights version %2$s.', 'google-analytics-for-wordpress' ), $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. } } /** * Marks something as deprecated. * * The current behavior is to trigger a user error if WP_DEBUG is true. * * @since 6.0.0 * @access private * * @uses apply_filters() Calls 'monsterinsights_deprecated_trigger_error' and expects boolean value of true to do * trigger or false to not trigger error. * * @param string $message Deprecation message shown. * @return void */ function _monsterinsights_deprecated( $message ) { /** * Deprecated Message Filter. * * Allow plugin to filter the deprecated message. * * @since 6.0.0 * * @param string $message Error message. */ do_action( 'monsterinsights_deprecated_run', $message ); $show_errors = current_user_can( 'manage_options' ); /** * Deprecated Error Trigger. * * Allow plugin to filter the output error trigger. * * @since 6.0.0 * * @param bool $show_errors Whether to show errors. */ $show_errors = apply_filters( 'monsterinsights_deprecated_trigger_error', $show_errors ); if ( ( WP_DEBUG && $show_errors ) || monsterinsights_is_debug_mode() ) { trigger_error( esc_html( $message ) ); } } /** * Start Deprecated Actions & Filters. * * These backwards compatibility fixes may be removed at any time. * Users/Developers are encouraged to update their code as soon as possible. */