PluginProbe
Elementor Website Builder – more than just a page builder / 3.26.3
Elementor Website Builder – more than just a page builder v3.26.3
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/floating-buttons/module.php +74 -38 4.1.23.26.3 View file →
@@ -2,28 +2,30 @@
2 2
3 3 namespace Elementor\Modules\FloatingButtons;
4 4
5 5 use Elementor\Controls_Manager;
6 +use Elementor\Core\Admin\Menu\Admin_Menu_Manager;
6 7 use Elementor\Core\Base\Document;
7 8 use Elementor\Core\Base\Module as BaseModule;
8 9 use Elementor\Core\Documents_Manager;
10 +use Elementor\Core\Experiments\Manager;
9 11 use Elementor\Modules\FloatingButtons\Base\Widget_Floating_Bars_Base;
12 +use Elementor\Modules\FloatingButtons\AdminMenuItems\Floating_Buttons_Empty_View_Menu_Item;
13 +use Elementor\Modules\FloatingButtons\AdminMenuItems\Floating_Buttons_Menu_Item;
10 14 use Elementor\Modules\FloatingButtons\Base\Widget_Contact_Button_Base;
11 -use Elementor\Modules\FloatingButtons\Classes\Action\Action_Handler;
12 15 use Elementor\Modules\FloatingButtons\Control\Hover_Animation_Floating_Buttons;
13 16 use Elementor\Modules\FloatingButtons\Documents\Floating_Buttons;
14 17 use Elementor\Plugin;
15 18 use Elementor\TemplateLibrary\Source_Local;
16 19 use Elementor\Utils as ElementorUtils;
17 -use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider;
18 -use Elementor\Modules\FloatingButtons\AdminMenuItems\Editor_One_Floating_Elements_Menu;
19 20
20 21 if ( ! defined( 'ABSPATH' ) ) {
21 - exit; // Exit if accessed directly.
22 + exit; // Exit if accessed directly
22 23 }
23 24
24 25 class Module extends BaseModule {
25 26
27 + const EXPERIMENT_NAME = 'floating-buttons';
26 28 const FLOATING_ELEMENTS_TYPE_META_KEY = '_elementor_floating_elements_type';
27 29 const ROUTER_OPTION_KEY = 'elementor_floating_buttons_router_version';
28 30 const META_CLICK_TRACKING = '_elementor_click_tracking';
29 31 const CLICK_TRACKING_NONCE = 'elementor-conversion-center-click';
@@ -45,10 +47,22 @@
45 47 'floating-bars' => esc_html__( 'Floating Bars', 'elementor' ),
46 48 ];
47 49 }
48 50
51 + // TODO: This is a hidden experiment which needs to remain enabled like this until 3.26 for pro compatibility.
52 + public static function get_experimental_data() {
53 + return [
54 + 'name' => self::EXPERIMENT_NAME,
55 + 'title' => esc_html__( 'Floating Buttons', 'elementor' ),
56 + 'hidden' => true,
57 + 'default' => Manager::STATE_ACTIVE,
58 + 'release_status' => Manager::RELEASE_STATUS_STABLE,
59 + 'mutable' => false,
60 + ];
61 + }
62 +
49 63 public function get_name(): string {
50 - return 'floating-buttons';
64 + return static::EXPERIMENT_NAME;
51 65 }
52 66
53 67 public function get_widgets(): array {
54 68
@@ -57,10 +71,17 @@
57 71 'Floating_Bars_Var_1',
58 72 ];
59 73 }
60 74
61 - private function register_editor_one_menu( Menu_Data_Provider $menu_data_provider ) {
62 - $menu_data_provider->register_menu( new Editor_One_Floating_Elements_Menu() );
75 + private function register_admin_menu_legacy( Admin_Menu_Manager $admin_menu ) {
76 + $menu_args = $this->get_contact_menu_args();
77 + $function = $menu_args['function'];
78 + if ( is_callable( $function ) ) {
79 + $admin_menu->register( $menu_args['menu_slug'], new Floating_Buttons_Empty_View_Menu_Item( $function ) );
80 + } else {
81 + $admin_menu->register( $menu_args['menu_slug'], new Floating_Buttons_Menu_Item() );
82 + };
83 +
63 84 }
64 85
65 86 public function __construct() {
66 87 parent::__construct();
@@ -92,16 +113,8 @@
92 113 $this->flush_permalinks_on_elementor_version_change();
93 114 }
94 115 });
95 116
96 - add_filter( 'elementor/editor-one/menu/elementor_post_types', function ( array $elementor_post_types ): array {
97 - $elementor_post_types[ static::CPT_FLOATING_BUTTONS ] = [
98 - 'menu_slug' => 'elementor-editor-templates',
99 - 'child_slug' => 'edit.php?post_type=e-floating-buttons',
100 - ];
101 - return $elementor_post_types;
102 - } );
103 -
104 117 add_action( 'wp_ajax_elementor_send_clicks', [ $this, 'handle_click_tracking' ] );
105 118 add_action( 'wp_ajax_nopriv_elementor_send_clicks', [ $this, 'handle_click_tracking' ] );
106 119
107 120 add_action( 'elementor/frontend/after_register_styles', [ $this, 'register_styles' ] );
@@ -152,11 +165,11 @@
152 165
153 166 return $is_top_bar_active;
154 167 }, 10, 2 );
155 168
156 - add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) {
157 - $this->register_editor_one_menu( $menu_data_provider );
158 - } );
169 + add_action( 'elementor/admin/menu/register', function( Admin_Menu_Manager $admin_menu ) {
170 + $this->register_admin_menu_legacy( $admin_menu );
171 + }, Source_Local::ADMIN_MENU_PRIORITY + 20 );
159 172
160 173 add_action( 'elementor/admin/localize_settings', function ( array $settings ) {
161 174 return $this->admin_localize_settings( $settings );
162 175 } );
@@ -171,14 +184,46 @@
171 184 return $cpts;
172 185 } );
173 186
174 187 add_action( 'admin_init', function () {
175 - $action = sanitize_text_field( filter_input( INPUT_GET, 'action' ) );
188 + $action = filter_input( INPUT_GET, 'action' );
189 + $menu_args = $this->get_contact_menu_args();
176 190
177 - if ( $action ) {
178 - $menu_args = $this->get_contact_menu_args();
179 - $action_handler = new Action_Handler( $action, $menu_args );
180 - $action_handler->process_action();
191 + switch ( $action ) {
192 + case 'remove_from_entire_site':
193 + $post = filter_input( INPUT_GET, 'post', FILTER_VALIDATE_INT );
194 + check_admin_referer( 'remove_from_entire_site_' . $post );
195 + delete_post_meta( $post, '_elementor_conditions' );
196 +
197 + wp_redirect( $menu_args['menu_slug'] );
198 + exit;
199 + case 'set_as_entire_site':
200 + $post = filter_input( INPUT_GET, 'post', FILTER_VALIDATE_INT );
201 + check_admin_referer( 'set_as_entire_site_' . $post );
202 +
203 + $posts = get_posts( [
204 + 'post_type' => static::CPT_FLOATING_BUTTONS,
205 + 'posts_per_page' => -1,
206 + 'post_status' => 'publish',
207 + 'fields' => 'ids',
208 + 'no_found_rows' => true,
209 + 'update_post_term_cache' => false,
210 + 'update_post_meta_cache' => false,
211 + 'meta_query' => Floating_Buttons::get_meta_query_for_floating_buttons(
212 + Floating_Buttons::get_floating_element_type( $post )
213 + ),
214 + ] );
215 +
216 + foreach ( $posts as $post_id ) {
217 + delete_post_meta( $post_id, '_elementor_conditions' );
218 + }
219 +
220 + update_post_meta( $post, '_elementor_conditions', [ 'include/general' ] );
221 +
222 + wp_redirect( $menu_args['menu_slug'] );
223 + exit;
224 + default:
225 + break;
181 226 }
182 227 } );
183 228
184 229 add_action( 'manage_' . static::CPT_FLOATING_BUTTONS . '_posts_columns', function( $posts_columns ) {
@@ -237,9 +282,9 @@
237 282 if ( ! isset( $posts_to_update[ $post_id ] ) ) {
238 283 $starting_clicks = (int) get_post_meta( $post_id, static::META_CLICK_TRACKING, true );
239 284 $posts_to_update[ $post_id ] = $starting_clicks ? $starting_clicks : 0;
240 285 }
241 - ++$posts_to_update[ $post_id ];
286 + $posts_to_update[ $post_id ] ++;
242 287 }
243 288
244 289 foreach ( $posts_to_update as $post_id => $clicks ) {
245 290 if ( self::CPT_FLOATING_BUTTONS !== get_post_type( $post_id ) ) {
@@ -347,10 +392,10 @@
347 392 if ( ! empty( $trashed_posts ) ) : ?>
348 393 <div class="e-trashed-items">
349 394 <?php
350 395 printf(
351 - /* translators: %1$s Link open tag, %2$s: Link close tag. */
352 - esc_html__( 'Or view %1$sTrashed Items%2$s', 'elementor' ),
396 + /* translators: %1$s Link open tag, %2$s: Link close tag. */
397 + esc_html__( 'Or view %1$sTrashed Items%1$s', 'elementor' ),
353 398 '<a href="' . esc_url( admin_url( 'edit.php?post_status=trash&post_type=' . self::CPT_FLOATING_BUTTONS ) ) . '">',
354 399 '</a>'
355 400 );
356 401 ?>
@@ -392,20 +437,10 @@
392 437 'labels' => $labels,
393 438 'public' => true,
394 439 'show_in_menu' => 'edit.php?post_type=elementor_library&tabs_group=library',
395 440 'show_in_nav_menus' => false,
396 - 'capabilities' => [
397 - 'edit_post' => 'manage_options',
398 - 'read_post' => 'manage_options',
399 - 'delete_post' => 'manage_options',
400 - 'edit_posts' => 'manage_options',
401 - 'edit_others_posts' => 'manage_options',
402 - 'publish_posts' => 'manage_options',
403 - 'read_private_posts' => 'manage_options',
404 - 'create_posts' => 'manage_options',
405 - ],
441 + 'capability_type' => 'page',
406 442 'taxonomies' => [ Source_Local::TAXONOMY_TYPE_SLUG ],
407 - 'show_in_rest' => true,
408 443 'supports' => [
409 444 'title',
410 445 'editor',
411 446 'comments',
@@ -447,8 +482,9 @@
447 482 'meta_value' => $document_type,
448 483 ] );
449 484
450 485 return $posts_query->post_count > 0;
486 +
451 487 }
452 488
453 489 private function get_contact_menu_args(): array {
454 490 if ( $this->has_contact_pages() ) {
@@ -548,9 +584,9 @@
548 584 );
549 585 }
550 586 }
551 587
552 - private function get_widgets_style_list(): array {
588 + private function get_widgets_style_list():array {
553 589 return [
554 590 'widget-floating-buttons' => self::WIDGET_HAS_CUSTOM_BREAKPOINTS, // TODO: Remove in v3.27.0 [ED-15717]
555 591 'widget-floating-bars-base' => self::WIDGET_HAS_CUSTOM_BREAKPOINTS,
556 592 'widget-floating-bars-var-2' => ! self::WIDGET_HAS_CUSTOM_BREAKPOINTS,