This commit is contained in:
proelements
2026-05-04 11:47:14 +03:00
parent b499583e5a
commit 872bc6fb57
375 changed files with 39949 additions and 9185 deletions
+40 -30
View File
@@ -3,7 +3,10 @@
namespace ElementorPro\Modules\Interactions;
use ElementorPro\Plugin;
use ElementorPro\Core\Utils as ProUtils;
use Elementor\Utils;
use Elementor\Modules\Interactions\Module as InteractionsModule;
use Elementor\Modules\Interactions\Presets;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
@@ -38,10 +41,13 @@ class Hooks {
}
private function replace_core_handlers() {
add_action( 'elementor/frontend/before_enqueue_scripts', [ $this, 'replace_frontend_handlers' ], 20 );
// Run after core's print_interactions_data (priority 1). If core enqueued its script
// it means the page has interactions — swap it for the pro script. If core didn't
// enqueue anything (no interactions), we skip too, preserving the load optimization.
add_action( 'wp_footer', [ $this, 'replace_frontend_handlers' ], 2 );
add_action( 'elementor/preview/enqueue_scripts', function() {
$core_module = Plugin::elementor()->modules_manager->get_modules( 'e-interactions' );
$core_module = Plugin::elementor()->modules_manager->get_modules( ProUtils::get_class_constant( InteractionsModule::class, 'MODULE_NAME', 'e-interactions' ) );
if ( $core_module && method_exists( $core_module, 'enqueue_preview_scripts' ) ) {
remove_action( 'elementor/preview/enqueue_scripts', [ $core_module, 'enqueue_preview_scripts' ] );
}
@@ -53,73 +59,77 @@ class Hooks {
}
public function register_frontend_scripts() {
$suffix = ( Utils::is_script_debug() || Utils::is_elementor_tests() ) ? '' : '.min';
wp_register_script(
'elementor-interactions-pro',
$this->get_js_assets_url( 'interactions-pro' ),
[ 'motion-js' ],
[
ProUtils::get_class_constant( InteractionsModule::class, 'HANDLE_MOTION_JS', 'motion-js' ),
ProUtils::get_class_constant( InteractionsModule::class, 'HANDLE_SHARED_UTILS', 'elementor-interactions-shared-utils' ),
],
ELEMENTOR_PRO_VERSION,
true
);
}
public function register_editor_scripts() {
$suffix = ( Utils::is_script_debug() || Utils::is_elementor_tests() ) ? '' : '.min';
wp_register_script(
'elementor-editor-interactions-pro',
$this->get_js_assets_url( 'editor-interactions-pro' ),
[ 'motion-js' ],
[
ProUtils::get_class_constant( InteractionsModule::class, 'HANDLE_MOTION_JS', 'motion-js' ),
ProUtils::get_class_constant( InteractionsModule::class, 'HANDLE_SHARED_UTILS', 'elementor-interactions-shared-utils' ),
],
ELEMENTOR_PRO_VERSION,
true
);
}
public function replace_frontend_handlers() {
wp_dequeue_script( 'elementor-interactions' );
wp_deregister_script( 'elementor-interactions' );
$handle_frontend = ProUtils::get_class_constant( InteractionsModule::class, 'HANDLE_FRONTEND', 'elementor-interactions' );
// Core only enqueues its script when the page has interactions.
// If it didn't enqueue, there's nothing to replace — skip to preserve the load optimization.
if ( ! wp_script_is( $handle_frontend, 'enqueued' ) ) {
return;
}
wp_dequeue_script( $handle_frontend );
wp_deregister_script( $handle_frontend );
wp_enqueue_script( 'elementor-interactions-pro' );
$config = $this->get_config();
wp_localize_script(
'elementor-interactions-pro',
'ElementorInteractionsConfig',
$config
ProUtils::get_class_constant( InteractionsModule::class, 'JS_CONFIG_OBJECT', 'ElementorInteractionsConfig' ),
$this->get_config()
);
}
public function replace_preview_handlers() {
wp_dequeue_script( 'elementor-editor-interactions' );
wp_deregister_script( 'elementor-editor-interactions' );
$handle_editor = ProUtils::get_class_constant( InteractionsModule::class, 'HANDLE_EDITOR', 'elementor-editor-interactions' );
wp_dequeue_script( $handle_editor );
wp_deregister_script( $handle_editor );
wp_enqueue_script( 'elementor-editor-interactions-pro' );
$config = $this->get_config();
wp_localize_script(
'elementor-editor-interactions-pro',
'ElementorInteractionsConfig',
$config
ProUtils::get_class_constant( InteractionsModule::class, 'JS_CONFIG_OBJECT', 'ElementorInteractionsConfig' ),
$this->get_config()
);
}
private function get_config() {
$interactions_module = Plugin::elementor()->modules_manager->get_modules( 'e-interactions' );
if ( $interactions_module && method_exists( $interactions_module, 'get_config' ) ) {
return $interactions_module->get_config();
if ( class_exists( 'Elementor\\Modules\\Interactions\\Module' ) ) {
$module = \Elementor\Modules\Interactions\Module::instance();
if ( $module && is_callable( [ $module, 'get_config' ] ) ) {
return $module->get_config();
}
}
return [
'constants' => [
'defaultDuration' => 300,
'defaultDelay' => 0,
'slideDistance' => 100,
'scaleStart' => 0,
'easing' => 'linear',
],
'animationOptions' => [],
'constants' => class_exists( Presets::class ) ? ( new Presets() )->defaults() : [],
'breakpoints' => [],
];
}
+21 -6
View File
@@ -4,20 +4,22 @@ namespace ElementorPro\Modules\Interactions;
use ElementorPro\Plugin;
use ElementorPro\Base\Module_Base;
use ElementorPro\Core\Utils as ProUtils;
use Elementor\Modules\AtomicWidgets\Module as AtomicWidgetsModule;
use Elementor\Modules\Interactions\Module as InteractionsModule;
use Elementor\Core\Experiments\Manager as ExperimentsManager;
use ElementorPro\License\API;
use ElementorPro\License\Admin;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
class Module extends Module_Base {
const MODULE_NAME = 'e-interactions';
const EXPERIMENT_NAME = 'e_pro_interactions';
public function get_name() {
return self::MODULE_NAME;
return ProUtils::get_class_constant( InteractionsModule::class, 'MODULE_NAME', 'e-interactions' );
}
public static function get_experimental_data(): array {
@@ -26,11 +28,23 @@ class Module extends Module_Base {
'title' => esc_html__( 'Pro Interactions', 'elementor-pro' ),
'description' => esc_html__( 'Enhanced interactions with replay support. Note: This feature requires both the "Atomic Widgets" and "Interactions" experiments to be enabled.', 'elementor-pro' ),
'hidden' => true,
'default' => ExperimentsManager::STATE_INACTIVE,
'default' => ExperimentsManager::STATE_ACTIVE,
'release_status' => ExperimentsManager::RELEASE_STATUS_DEV,
];
}
private function is_supported_by_current_license() {
if ( empty( \ElementorPro\License\Admin::get_license_key() ) ) {
return false;
}
if ( ! API::is_license_active() ) {
return false;
}
return API::is_licence_has_feature( 'pro-interactions', API::BC_VALIDATION_CALLBACK );
}
private function hooks() {
return new Hooks();
}
@@ -38,7 +52,7 @@ class Module extends Module_Base {
public function __construct() {
parent::__construct();
if ( ! $this->is_experiment_active() ) {
if ( ! $this->is_experiment_active() || ! $this->is_supported_by_current_license() ) {
return;
}
@@ -46,9 +60,10 @@ class Module extends Module_Base {
}
private function is_experiment_active(): bool {
return class_exists( 'Elementor\\Modules\\Interactions\\Module' )
return version_compare( ELEMENTOR_VERSION, '4.0', '>=' )
&& class_exists( 'Elementor\\Modules\\Interactions\\Module' )
&& Plugin::elementor()->experiments->is_feature_active( self::EXPERIMENT_NAME )
&& Plugin::elementor()->experiments->is_feature_active( AtomicWidgetsModule::EXPERIMENT_NAME )
&& Plugin::elementor()->experiments->is_feature_active( InteractionsModule::EXPERIMENT_NAME );
&& Plugin::elementor()->experiments->is_feature_active( ProUtils::get_class_constant( InteractionsModule::class, 'EXPERIMENT_NAME', 'e_interactions' ) );
}
}