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.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 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
← All changes | modules/editor-app-bar/module.php +64 -0 4.1.43.35.0-dev4 View file →
@@ -15,8 +15,11 @@
15 15 const STYLES = [
16 16 'editor-v2-app-bar-overrides',
17 17 ];
18 18
19 + const POPUP_DISMISSED_OPTION = '_elementor_structure_popup_dismissed';
20 + const STRUCTURE_POPUP_TARGET_VERSION = '3.32.0';
21 +
19 22 public function get_name() {
20 23 return 'editor-app-bar';
21 24 }
22 25
@@ -28,8 +31,69 @@
28 31 add_filter( 'elementor/editor/templates', fn( $templates ) => $this->remove_templates( $templates ) );
29 32
30 33 add_action( 'elementor/editor/v2/scripts/enqueue', fn() => $this->dequeue_scripts() );
31 34 add_action( 'elementor/editor/v2/styles/enqueue', fn() => $this->dequeue_styles() );
35 +
36 + add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'maybe_enqueue_structure_popup' ] );
37 + add_action( 'elementor/ajax/register_actions', [ $this, 'register_ajax_actions' ] );
38 + }
39 +
40 + public function register_ajax_actions( $ajax ) {
41 + $ajax->register_ajax_action( 'structure_popup_dismiss', [ $this, 'ajax_dismiss_structure_popup' ] );
42 + }
43 +
44 + public function ajax_dismiss_structure_popup( $data ) {
45 + $user_id = get_current_user_id();
46 +
47 + if ( ! $user_id ) {
48 + throw new \Exception( 'User not authenticated' );
49 + }
50 +
51 + update_user_meta( $user_id, self::POPUP_DISMISSED_OPTION, true );
52 +
53 + return [
54 + 'success' => true,
55 + 'message' => 'Structure popup dismissed successfully',
56 + ];
57 + }
58 +
59 + public function maybe_enqueue_structure_popup(): void {
60 +
61 + if ( ! $this->should_show_structure_popup_for_current_user() ) {
62 + return;
63 + }
64 +
65 + wp_localize_script( 'elementor-editor', 'elementorShowInfotip', [ 'shouldShow' => '1' ] );
66 + }
67 +
68 + private function should_show_structure_popup_for_current_user(): bool {
69 + $user_id = get_current_user_id();
70 +
71 + if ( ! $user_id ) {
72 + return false;
73 + }
74 +
75 + if ( ! $this->is_existing_user_upgraded_to_target_version( self::STRUCTURE_POPUP_TARGET_VERSION ) ) {
76 + return false;
77 + }
78 +
79 + if ( get_user_meta( $user_id, self::POPUP_DISMISSED_OPTION, true ) ) {
80 + return false;
81 + }
82 +
83 + return true;
84 + }
85 +
86 + private function is_existing_user_upgraded_to_target_version( string $target_version ): bool {
87 +
88 + if ( version_compare( ELEMENTOR_VERSION, $target_version, '<' ) ) {
89 + return false;
90 + }
91 +
92 + $installs_history = \Elementor\Core\Upgrade\Manager::get_installs_history();
93 +
94 + return ! empty( $installs_history ) &&
95 + version_compare( array_key_first( $installs_history ), $target_version, '<' );
32 96 }
33 97
34 98 private function add_packages( $packages ) {
35 99 return array_merge( $packages, self::PACKAGES );