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