PluginProbe
Elementor Website Builder – more than just a page builder / 3.31.4
Elementor Website Builder – more than just a page builder v3.31.4
4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 All 454 releases
← All changes | modules/atomic-opt-in/welcome-screen.php +16 -38 4.3.1 → 3.31.4 View file →
@@ -3,21 +3,17 @@
3 3 namespace Elementor\Modules\AtomicOptIn;
4 4
5 5 use Elementor\Core\Isolation\Elementor_Adapter;
6 6 use Elementor\Core\Isolation\Elementor_Adapter_Interface;
7 -use Elementor\Core\Utils\Assets_Config_Provider;
8 -use Elementor\Modules\AtomicWidgets\OptIn\Opt_In as Atomic_Widgets_Opt_In;
7 +use Elementor\Core\Utils\Isolation_Manager;
9 8 use Elementor\Modules\ElementorCounter\Module as Elementor_Counter;
10 -use Elementor\Core\Upgrade\Manager as Upgrade_Manager;
11 9 use Elementor\Utils;
12 10
13 11 class WelcomeScreen {
14 - const PACKAGE_NAME = 'v4-activation-modal';
15 -
16 12 private Elementor_Adapter_Interface $elementor_adapter;
17 13
18 14 public function __construct() {
19 - $this->elementor_adapter = new Elementor_Adapter();
15 + $this->elementor_adapter = Isolation_Manager::get_adapter( Elementor_Adapter::class );
20 16 }
21 17
22 18 public function init() {
23 19 add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'maybe_enqueue_welcome_popover' ] );
@@ -23,12 +19,8 @@
23 19 add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'maybe_enqueue_welcome_popover' ] );
24 20 }
25 21
26 22 public function maybe_enqueue_welcome_popover(): void {
27 - if ( ! $this->was_opt_in_clicked() ) {
28 - return;
29 - }
30 -
31 23 if ( $this->is_first_or_second_editor_visit() ) {
32 24 return;
33 25 }
34 26
@@ -35,22 +27,12 @@
35 27 if ( $this->has_welcome_popover_been_displayed() ) {
36 28 return;
37 29 }
38 30
39 - if ( Upgrade_Manager::is_new_installation() ) {
40 - return;
41 - }
42 -
43 - $this->register_package();
44 - wp_enqueue_script( 'elementor-v2-' . self::PACKAGE_NAME );
45 - wp_set_script_translations( 'elementor-v2-' . self::PACKAGE_NAME, 'elementor' );
31 + $this->enqueue_scripts();
46 32 $this->set_welcome_popover_as_displayed();
47 33 }
48 34
49 - private function was_opt_in_clicked(): bool {
50 - return (bool) get_option( Atomic_Widgets_Opt_In::OPT_IN_CLICKED_OPTION );
51 - }
52 -
53 35 private function is_first_or_second_editor_visit(): bool {
54 36 if ( ! $this->elementor_adapter ) {
55 37 return false;
56 38 }
@@ -66,31 +48,27 @@
66 48 private function set_welcome_popover_as_displayed(): void {
67 49 update_user_meta( $this->get_current_user_id(), Module::WELCOME_POPOVER_DISPLAYED_OPTION, true );
68 50 }
69 51
70 - private function register_package(): void {
52 + private function enqueue_scripts() {
71 53 $min_suffix = Utils::is_script_debug() ? '' : '.min';
72 - $package = self::PACKAGE_NAME;
73 54
74 - $assets_config_provider = ( new Assets_Config_Provider() )
75 - ->set_path_resolver( function ( $name ) {
76 - return ELEMENTOR_ASSETS_PATH . "js/packages/{$name}/{$name}.asset.php";
77 - } );
78 -
79 - $config = $assets_config_provider->load( $package )->get( $package );
80 -
81 - if ( ! $config ) {
82 - return;
83 - }
84 -
85 - wp_register_script(
86 - $config['handle'],
87 - ELEMENTOR_ASSETS_URL . "js/packages/{$package}/{$package}{$min_suffix}.js",
88 - $config['deps'],
55 + wp_enqueue_script(
56 + Module::MODULE_NAME . '-welcome',
57 + ELEMENTOR_ASSETS_URL . 'js/editor-v4-welcome-opt-in' . $min_suffix . '.js',
58 + [
59 + 'react',
60 + 'react-dom',
61 + 'elementor-common',
62 + 'elementor-v2-ui',
63 + ],
89 64 ELEMENTOR_VERSION,
90 65 true
91 66 );
67 +
68 + wp_set_script_translations( Module::MODULE_NAME . '-welcome', 'elementor' );
92 69 }
70 +
93 71
94 72 private function get_current_user_id(): int {
95 73 $current_user = wp_get_current_user();
96 74 return $current_user->ID ?? 0;