PluginProbe
Elementor Website Builder – more than just a page builder / 3.35.0-dev4
Elementor Website Builder – more than just a page builder v3.35.0-dev4
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 +14 -37 4.3.1 → 3.35.0-dev4 View file →
@@ -3,17 +3,12 @@
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;
9 7 use Elementor\Modules\ElementorCounter\Module as Elementor_Counter;
10 -use Elementor\Core\Upgrade\Manager as Upgrade_Manager;
11 8 use Elementor\Utils;
12 9
13 10 class WelcomeScreen {
14 - const PACKAGE_NAME = 'v4-activation-modal';
15 -
16 11 private Elementor_Adapter_Interface $elementor_adapter;
17 12
18 13 public function __construct() {
19 14 $this->elementor_adapter = new Elementor_Adapter();
@@ -23,12 +18,8 @@
23 18 add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'maybe_enqueue_welcome_popover' ] );
24 19 }
25 20
26 21 public function maybe_enqueue_welcome_popover(): void {
27 - if ( ! $this->was_opt_in_clicked() ) {
28 - return;
29 - }
30 -
31 22 if ( $this->is_first_or_second_editor_visit() ) {
32 23 return;
33 24 }
34 25
@@ -35,22 +26,12 @@
35 26 if ( $this->has_welcome_popover_been_displayed() ) {
36 27 return;
37 28 }
38 29
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' );
30 + $this->enqueue_scripts();
46 31 $this->set_welcome_popover_as_displayed();
47 32 }
48 33
49 - private function was_opt_in_clicked(): bool {
50 - return (bool) get_option( Atomic_Widgets_Opt_In::OPT_IN_CLICKED_OPTION );
51 - }
52 -
53 34 private function is_first_or_second_editor_visit(): bool {
54 35 if ( ! $this->elementor_adapter ) {
55 36 return false;
56 37 }
@@ -66,31 +47,27 @@
66 47 private function set_welcome_popover_as_displayed(): void {
67 48 update_user_meta( $this->get_current_user_id(), Module::WELCOME_POPOVER_DISPLAYED_OPTION, true );
68 49 }
69 50
70 - private function register_package(): void {
51 + private function enqueue_scripts() {
71 52 $min_suffix = Utils::is_script_debug() ? '' : '.min';
72 - $package = self::PACKAGE_NAME;
73 53
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'],
54 + wp_enqueue_script(
55 + Module::MODULE_NAME . '-welcome',
56 + ELEMENTOR_ASSETS_URL . 'js/editor-v4-welcome-opt-in' . $min_suffix . '.js',
57 + [
58 + 'react',
59 + 'react-dom',
60 + 'elementor-common',
61 + 'elementor-v2-ui',
62 + ],
89 63 ELEMENTOR_VERSION,
90 64 true
91 65 );
66 +
67 + wp_set_script_translations( Module::MODULE_NAME . '-welcome', 'elementor' );
92 68 }
69 +
93 70
94 71 private function get_current_user_id(): int {
95 72 $current_user = wp_get_current_user();
96 73 return $current_user->ID ?? 0;