PluginProbe
Elementor Website Builder – more than just a page builder / 3.31.2
Elementor Website Builder – more than just a page builder v3.31.2
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 +23 -203 4.2.0-beta13.31.2 View file →
@@ -3,32 +3,20 @@
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\Editor_One_Custom_Code_Menu;
10 -use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Custom_Elements_Menu;
11 -use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Fonts_Menu;
12 -use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Icons_Menu;
13 -use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Popups_Menu;
14 -use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Submissions_Menu;
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;
12 +use Elementor\Modules\Promotions\AdminMenuItems\Form_Submissions_Promotion_Item;
15 13 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;
14 +use Elementor\Modules\Promotions\AdminMenuItems\Popups_Promotion_Item;
18 15 use Elementor\Modules\Promotions\Pointers\Birthday;
19 -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 16 use Elementor\Widgets_Manager;
26 17 use Elementor\Utils;
27 18 use Elementor\Includes\EditorAssetsAPI;
28 -use Elementor\Plugin;
29 -use Elementor\Modules\EditorOne\Classes\Menu_Config;
30 -use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider;
31 19
32 20 if ( ! defined( 'ABSPATH' ) ) {
33 21 exit; // Exit if accessed directly.
34 22 }
@@ -53,15 +41,15 @@
53 41 add_action( 'admin_init', function () {
54 42 $this->handle_external_redirects();
55 43 } );
56 44
57 - add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) {
58 - $this->register_editor_one_menu_items( $menu_data_provider );
59 - } );
45 + add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) {
46 + $this->register_menu_items( $admin_menu );
47 + }, static::ADMIN_MENU_PRIORITY );
60 48
61 - if ( Utils::is_sale_time() ) {
62 - add_filter( 'add_menu_classes', [ $this, 'override_one_menu_upgrade_label_during_sale' ] );
63 - }
49 + add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) {
50 + $this->register_promotion_menu_item( $admin_menu );
51 + }, static::ADMIN_MENU_PROMOTIONS_PRIORITY );
64 52
65 53 add_action( 'elementor/widgets/register', function( Widgets_Manager $manager ) {
66 54 foreach ( Api::get_promotion_widgets() as $widget_data ) {
67 55 $manager->register( new Widgets\Pro_Widget_Promotion( [], [
@@ -74,24 +62,12 @@
74 62 if ( Birthday::should_display_notice() ) {
75 63 new Birthday();
76 64 }
77 65
78 - if ( Black_Friday::should_display_notice() ) {
79 - new Black_Friday();
80 - }
81 -
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 66 if ( Utils::has_pro() ) {
89 67 return;
90 68 }
91 69
92 - add_filter( 'elementor/editor/localize_settings', [ $this, 'add_editing_panel_sticky_promotion' ] );
93 -
94 70 add_action( 'elementor/controls/register', function ( Controls_Manager $controls_manager ) {
95 71 $controls_manager->register( new Controls\Promotion_Control() );
96 72 } );
97 73
@@ -96,63 +72,31 @@
96 72 } );
97 73
98 74 add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_react_data' ] );
99 75 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();
105 76 }
106 77
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 78 private function handle_external_redirects() {
117 - $page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
118 - if ( empty( $page ) ) {
79 + if ( empty( $_GET['page'] ) ) {
119 80 return;
120 81 }
121 82
122 - if ( 'go_elementor_pro' === $page ) {
123 - wp_redirect( Go_Pro_Promotion_Item::get_url() ); // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect
83 + if ( 'go_elementor_pro' === $_GET['page'] ) {
84 + wp_redirect( Go_Pro_Promotion_Item::get_url() );
124 85 die;
125 86 }
126 87 }
127 88
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;
136 - }
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;
89 + private function register_menu_items( Admin_Menu_Manager $admin_menu ) {
90 + $admin_menu->register( 'e-form-submissions', new Form_Submissions_Promotion_Item() );
91 + $admin_menu->register( 'elementor_custom_fonts', new Custom_Fonts_Promotion_Item() );
92 + $admin_menu->register( 'elementor_custom_icons', new Custom_Icons_Promotion_Item() );
93 + $admin_menu->register( 'elementor_custom_code', new Custom_Code_Promotion_Item() );
94 + $admin_menu->register( 'popup_templates', new Popups_Promotion_Item() );
146 95 }
147 96
148 - private function register_editor_one_menu_items( Menu_Data_Provider $menu_data_provider ) {
149 - $menu_data_provider->register_menu( new Editor_One_Custom_Elements_Menu() );
150 - $menu_data_provider->register_menu( new Editor_One_Submissions_Menu() );
151 - $menu_data_provider->register_menu( new Editor_One_Fonts_Menu() );
152 - $menu_data_provider->register_menu( new Editor_One_Icons_Menu() );
153 - $menu_data_provider->register_menu( new Editor_One_Custom_Code_Menu() );
154 - $menu_data_provider->register_menu( new Editor_One_Popups_Menu() );
97 + private function register_promotion_menu_item( Admin_Menu_Manager $admin_menu ) {
98 + $admin_menu->register( 'go_elementor_pro', new Go_Pro_Promotion_Item() );
155 99 }
156 100
157 101 public function enqueue_react_data(): void {
158 102 if ( ! current_user_can( 'manage_options' ) ) {
@@ -169,9 +113,8 @@
169 113 'react-dom',
170 114 'backbone-marionette',
171 115 'elementor-editor-modules',
172 116 'elementor-v2-ui',
173 - 'elementor-v2-icons',
174 117 ],
175 118 ELEMENTOR_VERSION,
176 119 true
177 120 );
@@ -218,129 +161,6 @@
218 161 EditorAssetsAPI::ASSETS_DATA_URL => 'https://assets.elementor.com/free-to-pro-upsell/v1/free-to-pro-upsell.json',
219 162 EditorAssetsAPI::ASSETS_DATA_TRANSIENT_KEY => '_elementor_free_to_pro_upsell',
220 163 EditorAssetsAPI::ASSETS_DATA_KEY => 'free-to-pro-upsell',
221 164 ];
222 - }
223 -
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 - public function add_v4_promotions_data( array $settings ): array {
235 - if ( ! current_user_can( 'manage_options' ) ) {
236 - return $settings;
237 - }
238 -
239 - $editor_assets_api = new EditorAssetsAPI( $this->get_v4_promotions_api_config() );
240 - $promotion_data = new PromotionData( $editor_assets_api );
241 -
242 - $settings['v4Promotions'] = $promotion_data->get_v4_promotions_data();
243 -
244 - return $settings;
245 - }
246 -
247 - private function get_v4_promotions_api_config(): array {
248 - return [
249 - EditorAssetsAPI::ASSETS_DATA_URL => 'https://assets.elementor.com/packages/v1/promotions.json',
250 - EditorAssetsAPI::ASSETS_DATA_TRANSIENT_KEY => '_elementor_v4_promotions',
251 - EditorAssetsAPI::ASSETS_DATA_KEY => 'promotions',
252 - ];
253 - }
254 -
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;
345 165 }
346 166 }