t (browser console notice) or hard (use WordPress' native deprecation methods).
*
* @since 3.1.0
*
* @param string $entity - The Deprecated entity (the function/hook itself)
* @param string $version
* @param string $replacement Optional
* @param string $base_version Optional. Default is `null`
*
* @return bool|void
* @throws \Exception
*/
private function check_deprecation( $entity, $version, $replacement, $base_version = null ) {
if ( null === $base_version ) {
$base_version = $this->current_version;
}
$diff = $this->compare_version( $base_version, $version );
if ( false === $diff ) {
throw new \Exception( 'Invalid deprecation diff' );
}
$print_deprecated = false;
if ( defined( 'WP_DEBUG' ) && WP_DEBUG && $diff <= self::SOFT_VERSIONS_COUNT ) {
// Soft deprecated.
if ( ! isset( $this->soft_deprecated_notices[ $entity ] ) ) {
$this->soft_deprecated_notices[ $entity ] = [
$version,
$replacement,
];
}
if ( defined( 'ELEMENTOR_DEBUG' ) && ELEMENTOR_DEBUG ) {
$print_deprecated = true;
}
} else {
// Hard deprecated.
$print_deprecated = true;
}
return $print_deprecated;
}
/**
* Deprecated Function
*
* Handles the deprecation process for functions.
*
* @since 3.1.0
*
* @param string $function
* @param string $version
* @param string $replacement Optional. Default is ''
* @param string $base_version Optional. Default is `null`
* @throws \Exception
*/
public function deprecated_function( $function, $version, $replacement = '', $base_version = null ) {
$print_deprecated = $this->check_deprecation( $function, $version, $replacement, $base_version );
if ( $print_deprecated ) {
// PHPCS - We need to echo special characters because they can exist in function calls.
_deprecated_function( $function, esc_html( $version ), $replacement ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
/**
* Deprecated Hook
*
* Handles the deprecation process for hooks.
*
* @since 3.1.0
*
* @param string $hook
* @param string $version
* @param string $replacement Optional. Default is ''
* @param string $base_version Optional. Default is `null`
* @throws \Exception
*/
public function deprecated_hook( $hook, $version, $replacement = '', $base_version = null ) {
$print_deprecated = $this->check_deprecation( $hook, $version, $replacement, $base_version );
if ( $print_deprecated ) {
_deprecated_hook( esc_html( $hook ), esc_html( $version ), esc_html( $replacement ) );
}
}
/**
* Deprecated Argument
*
* Handles the deprecation process for function arguments.
*
* @since 3.1.0
*
* @param string $argument
* @param string $version
* @param string $replacement
* @param string $message
* @throws \Exception
*/
public function deprecated_argument( $argument, $version, $replacement = '', $message = '' ) {
$print_deprecated = $this->check_deprecation( $argument, $version, $replacement );
if ( $print_deprecated ) {
$message = empty( $message ) ? '' : ' ' . $message;
// These arguments are escaped because they are printed later, and are not escaped when printed.
$error_message_args = [ esc_html( $argument ), esc_html( $version ) ];
if ( $replacement ) {
/* translators: 1: Function argument, 2: Elementor version number, 3: Replacement argument name. */
$translation_string = esc_html__( 'The %1$s argument is deprecated since version %2$s! Use %3$s instead.', 'elementor' );
$error_message_args[] = $replacement;
} else {
/* translators: 1: Function argument, 2: Elementor version number. */
$translation_string = esc_html__( 'The %1$s argument is deprecated since version %2$s!', 'elementor' );
}
trigger_error(
vsprintf(
// PHPCS - $translation_string is already escaped above.
$translation_string, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
// PHPCS - $error_message_args is an array.
$error_message_args // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
) . esc_html( $message ),
E_USER_DEPRECATED
);
}
}
/**
* Do Deprecated Action
*
* A method used to run deprecated actions through Elementor's deprecation process.
*
* @since 3.1.0
*
* @param string $hook
* @param array $args
* @param string $version
* @param string $replacement
* @param null|string $base_version
*
* @throws \Exception
*/
public function do_deprecated_action( $hook, $args, $version, $replacement = '', $base_version = null ) {
if ( ! has_action( $hook ) ) {
return;
}
$this->deprecated_hook( $hook, $version, $replacement, $base_version );
do_action_ref_array( $hook, $args );
}
/**
* Apply Deprecated Filter
*
* A method used to run deprecated filters through Elementor's deprecation process.
*
* @since 3.2.0
*
* @param string $hook
* @param array $args
* @param string $version
* @param string $replacement
* @param null|string $base_version
*
* @return mixed
* @throws \Exception
*/
public function apply_deprecated_filter( $hook, $args, $version, $replacement = '', $base_version = null ) {
if ( ! has_action( $hook ) ) {
// `$args` should be an array, but in order to keep BC, we need to support non-array values.
if ( is_array( $args ) ) {
return $args[0] ?? null;
}
return $args;
}
// BC - See the comment above.
if ( ! is_array( $args ) ) {
$args = [ $args ];
}
// Avoid associative arrays.
$args = array_values( $args );
$this->deprecated_hook( $hook, $version, $replacement, $base_version );
return apply_filters_ref_array( $hook, $args );
}
}
Fatal error: Uncaught Error: Class 'Elementor\Modules\DevTools\Deprecation' not found in /home/arasetne/public_html/wp-content/plugins/elementor/modules/dev-tools/module.php:22
Stack trace:
#0 /home/arasetne/public_html/wp-content/plugins/elementor/core/base/module.php(85): Elementor\Modules\DevTools\Module->__construct()
#1 /home/arasetne/public_html/wp-content/plugins/elementor/core/modules-manager.php(64): Elementor\Core\Base\Module::instance()
#2 /home/arasetne/public_html/wp-content/plugins/elementor/includes/plugin.php(724): Elementor\Core\Modules_Manager->__construct()
#3 /home/arasetne/public_html/wp-content/plugins/elementor/includes/plugin.php(641): Elementor\Plugin->init_components()
#4 /home/arasetne/public_html/wp-includes/class-wp-hook.php(324): Elementor\Plugin->init('')
#5 /home/arasetne/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#6 /home/arasetne/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#7 /home/arasetne/public_html/wp-settings.php(695): d in /home/arasetne/public_html/wp-content/plugins/elementor/modules/dev-tools/module.php on line 22