PluginProbe
Elementor Website Builder – more than just a page builder / 3.35.0-dev2
Elementor Website Builder – more than just a page builder v3.35.0-dev2
4.3.2 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 All 455 releases
← All changes | modules/promotions/module.php +29 -152 4.2.0-beta1 → 3.35.0-dev2 View file →
@@ -3,10 +3,13 @@
3 3 namespace Elementor\Modules\Promotions;
4 4
5 5 use Elementor\Api;
6 6 use Elementor\Controls_Manager;
7 +use Elementor\Core\Admin\Menu\Admin_Menu_Manager;
7 8 use Elementor\Core\Base\Module as Base_Module;
8 -use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager;
9 +use Elementor\Modules\Promotions\AdminMenuItems\Custom_Code_Promotion_Item;
10 +use Elementor\Modules\Promotions\AdminMenuItems\Custom_Fonts_Promotion_Item;
11 +use Elementor\Modules\Promotions\AdminMenuItems\Custom_Icons_Promotion_Item;
9 12 use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Custom_Code_Menu;
10 13 use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Custom_Elements_Menu;
11 14 use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Fonts_Menu;
12 15 use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Icons_Menu;
@@ -11,23 +14,17 @@
11 14 use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Fonts_Menu;
12 15 use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Icons_Menu;
13 16 use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Popups_Menu;
14 17 use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Submissions_Menu;
18 +use Elementor\Modules\Promotions\AdminMenuItems\Form_Submissions_Promotion_Item;
15 19 use Elementor\Modules\Promotions\AdminMenuItems\Go_Pro_Promotion_Item;
16 -use Elementor\Modules\Promotions\Controls\Atomic_Promotion_Control;
17 -use Elementor\Modules\Promotions\Conversion_Banner;
20 +use Elementor\Modules\Promotions\AdminMenuItems\Popups_Promotion_Item;
18 21 use Elementor\Modules\Promotions\Pointers\Birthday;
19 22 use Elementor\Modules\Promotions\Pointers\Black_Friday;
20 -use Elementor\Modules\Promotions\PropTypes\Promotion_Prop_Type;
21 -use Elementor\Modules\Promotions\Widgets\Ally_Dashboard_Widget;
22 -use Elementor\Modules\Promotions\Widgets\Atomic_Form_Widget_Promotion;
23 -use Elementor\Modules\Promotions\Widgets\Birthday_Easter_Egg_Promotion;
24 -use Elementor\Modules\Promotions\Widgets\Collection_Loop_Widget_Promotion;
25 23 use Elementor\Widgets_Manager;
26 24 use Elementor\Utils;
27 25 use Elementor\Includes\EditorAssetsAPI;
28 26 use Elementor\Plugin;
29 -use Elementor\Modules\EditorOne\Classes\Menu_Config;
30 27 use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider;
31 28
32 29 if ( ! defined( 'ABSPATH' ) ) {
33 30 exit; // Exit if accessed directly.
@@ -53,15 +50,19 @@
53 50 add_action( 'admin_init', function () {
54 51 $this->handle_external_redirects();
55 52 } );
56 53
54 + add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) {
55 + $this->register_menu_items( $admin_menu );
56 + }, static::ADMIN_MENU_PRIORITY );
57 +
57 58 add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) {
58 59 $this->register_editor_one_menu_items( $menu_data_provider );
59 60 } );
60 61
61 - if ( Utils::is_sale_time() ) {
62 - add_filter( 'add_menu_classes', [ $this, 'override_one_menu_upgrade_label_during_sale' ] );
63 - }
62 + add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) {
63 + $this->register_promotion_menu_item( $admin_menu );
64 + }, static::ADMIN_MENU_PROMOTIONS_PRIORITY );
64 65
65 66 add_action( 'elementor/widgets/register', function( Widgets_Manager $manager ) {
66 67 foreach ( Api::get_promotion_widgets() as $widget_data ) {
67 68 $manager->register( new Widgets\Pro_Widget_Promotion( [], [
@@ -78,20 +79,12 @@
78 79 if ( Black_Friday::should_display_notice() ) {
79 80 new Black_Friday();
80 81 }
81 82
82 - if ( Conversion_Banner::should_display_banner() ) {
83 - new Conversion_Banner();
84 - }
85 -
86 - add_filter( 'elementor/editor/localize_settings', [ $this, 'add_v4_promotions_data' ] );
87 -
88 83 if ( Utils::has_pro() ) {
89 84 return;
90 85 }
91 86
92 - add_filter( 'elementor/editor/localize_settings', [ $this, 'add_editing_panel_sticky_promotion' ] );
93 -
94 87 add_action( 'elementor/controls/register', function ( Controls_Manager $controls_manager ) {
95 88 $controls_manager->register( new Controls\Promotion_Control() );
96 89 } );
97 90
@@ -96,24 +89,11 @@
96 89 } );
97 90
98 91 add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_react_data' ] );
99 92 add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_editor_v4_alphachip' ] );
100 -
101 - // Add Ally promo
102 - Ally_Dashboard_Widget::init();
103 -
104 - $this->register_atomic_promotions();
93 + add_filter( 'elementor/editor/localize_settings', [ $this, 'add_v4_promotions_data' ] );
105 94 }
106 95
107 - /**
108 - * Get Ally Scanner URL
109 - *
110 - * @return string
111 - */
112 - public static function get_ally_external_scanner_url(): string {
113 - return apply_filters( 'elementor/ally_external_scanner_url', 'https://go.elementor.com/acc-checker-dashboard-plg' );
114 - }
115 -
116 96 private function handle_external_redirects() {
117 97 $page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
118 98 if ( empty( $page ) ) {
119 99 return;
@@ -124,26 +104,16 @@
124 104 die;
125 105 }
126 106 }
127 107
128 - public function override_one_menu_upgrade_label_during_sale( $menu ) {
129 - global $submenu;
130 -
131 - $parent_slug = Menu_Config::ELEMENTOR_HOME_MENU_SLUG;
132 - $upgrade_slug = 'elementor-one-upgrade';
133 -
134 - if ( empty( $submenu[ $parent_slug ] ) ) {
135 - return $menu;
108 + private function register_menu_items( Admin_Menu_Manager $admin_menu ) {
109 + if ( ! $this->is_editor_one_active() ) {
110 + $admin_menu->register( 'e-form-submissions', new Form_Submissions_Promotion_Item() );
111 + $admin_menu->register( 'elementor_custom_fonts', new Custom_Fonts_Promotion_Item() );
112 + $admin_menu->register( 'elementor_custom_icons', new Custom_Icons_Promotion_Item() );
113 + $admin_menu->register( 'elementor_custom_code', new Custom_Code_Promotion_Item() );
114 + $admin_menu->register( 'popup_templates', new Popups_Promotion_Item() );
136 115 }
137 -
138 - foreach ( $submenu[ $parent_slug ] as &$item ) {
139 - if ( isset( $item[2] ) && $upgrade_slug === $item[2] ) {
140 - $item[0] = esc_html__( 'Sale!', 'elementor' ) . '<br />' . esc_html__( 'Upgrade Now', 'elementor' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
141 - break;
142 - }
143 - }
144 -
145 - return $menu;
146 116 }
147 117
148 118 private function register_editor_one_menu_items( Menu_Data_Provider $menu_data_provider ) {
149 119 $menu_data_provider->register_menu( new Editor_One_Custom_Elements_Menu() );
@@ -153,8 +123,14 @@
153 123 $menu_data_provider->register_menu( new Editor_One_Custom_Code_Menu() );
154 124 $menu_data_provider->register_menu( new Editor_One_Popups_Menu() );
155 125 }
156 126
127 + private function register_promotion_menu_item( Admin_Menu_Manager $admin_menu ) {
128 + if ( ! $this->is_editor_one_active() ) {
129 + $admin_menu->register( 'go_elementor_pro', new Go_Pro_Promotion_Item() );
130 + }
131 + }
132 +
157 133 public function enqueue_react_data(): void {
158 134 if ( ! current_user_can( 'manage_options' ) ) {
159 135 return;
160 136 }
@@ -169,9 +145,8 @@
169 145 'react-dom',
170 146 'backbone-marionette',
171 147 'elementor-editor-modules',
172 148 'elementor-v2-ui',
173 - 'elementor-v2-icons',
174 149 ],
175 150 ELEMENTOR_VERSION,
176 151 true
177 152 );
@@ -220,18 +195,8 @@
220 195 EditorAssetsAPI::ASSETS_DATA_KEY => 'free-to-pro-upsell',
221 196 ];
222 197 }
223 198
224 - public function add_editing_panel_sticky_promotion( array $settings ): array {
225 - if ( ! Plugin::$instance->experiments->is_feature_active( 'e_panel_promotions' ) ) {
226 - return $settings;
227 - }
228 -
229 - $settings['editingPanelStickyPromotion'] = Filtered_Promotions_Manager::get_editor_panel_sticky_promotion();
230 -
231 - return $settings;
232 - }
233 -
234 199 public function add_v4_promotions_data( array $settings ): array {
235 200 if ( ! current_user_can( 'manage_options' ) ) {
236 201 return $settings;
237 202 }
@@ -251,96 +216,8 @@
251 216 EditorAssetsAPI::ASSETS_DATA_KEY => 'promotions',
252 217 ];
253 218 }
254 219
255 - private function is_atomic_widgets_active(): bool {
256 - return Plugin::$instance->experiments->is_feature_active( 'e_atomic_elements' );
257 - }
258 -
259 - private function get_atomic_promotion_configs(): array {
260 - return [
261 - [
262 - 'key' => 'attributes',
263 - 'label' => __( 'Attributes', 'elementor' ),
264 - 'section' => 'settings',
265 - 'priority' => 40,
266 - ],
267 - [
268 - 'key' => 'display-conditions',
269 - 'label' => __( 'Display Conditions', 'elementor' ),
270 - 'section' => 'settings',
271 - 'priority' => 50,
272 - ],
273 - ];
274 - }
275 -
276 - private function register_atomic_promotions(): void {
277 - add_action( 'elementor/init', function() {
278 - if ( ! $this->is_atomic_widgets_active() ) {
279 - return;
280 - }
281 -
282 - add_filter(
283 - 'elementor/atomic-widgets/props-schema',
284 - [ $this, 'inject_atomic_promotion_props' ]
285 - );
286 -
287 - foreach ( $this->get_atomic_promotion_configs() as $config ) {
288 - add_filter(
289 - 'elementor/atomic-widgets/controls',
290 - fn( array $controls, $element ) => $this->inject_atomic_promotion_control( $controls, $element, $config ),
291 - $config['priority'],
292 - 2
293 - );
294 - }
295 -
296 - ( new Birthday_Easter_Egg_Promotion() )->register();
297 - } );
298 -
299 - ( new Atomic_Form_Widget_Promotion() )->register();
300 - ( new Collection_Loop_Widget_Promotion() )->register();
301 - }
302 -
303 - public function inject_atomic_promotion_props( array $schema ): array {
304 - foreach ( $this->get_atomic_promotion_configs() as $config ) {
305 - $key = $config['key'];
306 -
307 - if ( isset( $schema[ $key ] ) ) {
308 - continue;
309 - }
310 -
311 - $schema[ $key ] = Promotion_Prop_Type::make( $key );
312 - }
313 -
314 - return $schema;
315 - }
316 -
317 - protected function inject_atomic_promotion_control( array $element_controls, $atomic_element, array $config ): array {
318 - $key = $config['key'];
319 - $schema = $atomic_element::get_props_schema();
320 -
321 - if ( ! array_key_exists( $key, $schema ) ) {
322 - return $element_controls;
323 - }
324 -
325 - foreach ( $element_controls as $item ) {
326 - if ( ! ( $item instanceof \Elementor\Modules\AtomicWidgets\Controls\Section ) ) {
327 - continue;
328 - }
329 -
330 - if ( $item->get_id() !== $config['section'] ) {
331 - continue;
332 - }
333 -
334 - $control = Atomic_Promotion_Control::make( $key )
335 - ->set_label( $config['label'] )
336 - ->set_meta( [
337 - 'topDivider' => true,
338 - ] );
339 -
340 - $item->add_item( $control );
341 - break;
342 - }
343 -
344 - return $element_controls;
220 + private function is_editor_one_active(): bool {
221 + return (bool) Plugin::instance()->modules_manager->get_modules( 'editor-one' );
345 222 }
346 223 }