PluginProbe
Elementor Website Builder – more than just a page builder / 3.32.2
Elementor Website Builder – more than just a page builder v3.32.2
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/promotions/module.php +26 -206 4.2.0-dev23.32.2 View file →
@@ -3,31 +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\Collection_Loop_Widget_Promotion;
24 16 use Elementor\Widgets_Manager;
25 17 use Elementor\Utils;
26 18 use Elementor\Includes\EditorAssetsAPI;
27 -use Elementor\Plugin;
28 -use Elementor\Modules\EditorOne\Classes\Menu_Config;
29 -use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider;
30 19
31 20 if ( ! defined( 'ABSPATH' ) ) {
32 21 exit; // Exit if accessed directly.
33 22 }
@@ -38,9 +27,9 @@
38 27
39 28 const ADMIN_MENU_PROMOTIONS_PRIORITY = 120;
40 29
41 30 public static function is_active() {
42 - return ! Utils::has_pro() || ! Utils::is_license_active();
31 + return ! Utils::has_pro();
43 32 }
44 33
45 34 public function get_name() {
46 35 return 'promotions';
@@ -48,28 +37,19 @@
48 37
49 38 public function __construct() {
50 39 parent::__construct();
51 40
52 - add_filter( 'elementor/editor/localize_settings', [ $this, 'add_v4_promotions_data' ] );
53 -
54 - if ( Utils::has_pro() ) {
55 - add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_react_data' ] );
56 - $this->register_atomic_promotions();
57 -
58 - return;
59 - }
60 -
61 41 add_action( 'admin_init', function () {
62 42 $this->handle_external_redirects();
63 43 } );
64 44
65 - add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) {
66 - $this->register_editor_one_menu_items( $menu_data_provider );
67 - } );
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 );
68 48
69 - if ( Utils::is_sale_time() ) {
70 - add_filter( 'add_menu_classes', [ $this, 'override_one_menu_upgrade_label_during_sale' ] );
71 - }
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 );
72 52
73 53 add_action( 'elementor/widgets/register', function( Widgets_Manager $manager ) {
74 54 foreach ( Api::get_promotion_widgets() as $widget_data ) {
75 55 $manager->register( new Widgets\Pro_Widget_Promotion( [], [
@@ -82,18 +62,12 @@
82 62 if ( Birthday::should_display_notice() ) {
83 63 new Birthday();
84 64 }
85 65
86 - if ( Black_Friday::should_display_notice() ) {
87 - new Black_Friday();
66 + if ( Utils::has_pro() ) {
67 + return;
88 68 }
89 69
90 - if ( Conversion_Banner::should_display_banner() ) {
91 - new Conversion_Banner();
92 - }
93 -
94 - add_filter( 'elementor/editor/localize_settings', [ $this, 'add_editing_panel_sticky_promotion' ] );
95 -
96 70 add_action( 'elementor/controls/register', function ( Controls_Manager $controls_manager ) {
97 71 $controls_manager->register( new Controls\Promotion_Control() );
98 72 } );
99 73
@@ -98,63 +72,31 @@
98 72 } );
99 73
100 74 add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_react_data' ] );
101 75 add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_editor_v4_alphachip' ] );
102 -
103 - // Add Ally promo
104 - Ally_Dashboard_Widget::init();
105 -
106 - $this->register_atomic_promotions();
107 76 }
108 77
109 - /**
110 - * Get Ally Scanner URL
111 - *
112 - * @return string
113 - */
114 - public static function get_ally_external_scanner_url(): string {
115 - return apply_filters( 'elementor/ally_external_scanner_url', 'https://go.elementor.com/acc-checker-dashboard-plg' );
116 - }
117 -
118 78 private function handle_external_redirects() {
119 - $page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
120 - if ( empty( $page ) ) {
79 + if ( empty( $_GET['page'] ) ) {
121 80 return;
122 81 }
123 82
124 - if ( in_array( $page, [ 'go_elementor_pro', 'elementor-one-upgrade' ], true ) ) {
125 - 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() );
126 85 die;
127 86 }
128 87 }
129 88
130 - public function override_one_menu_upgrade_label_during_sale( $menu ) {
131 - global $submenu;
132 -
133 - $parent_slug = Menu_Config::ELEMENTOR_HOME_MENU_SLUG;
134 - $upgrade_slug = 'elementor-one-upgrade';
135 -
136 - if ( empty( $submenu[ $parent_slug ] ) ) {
137 - return $menu;
138 - }
139 -
140 - foreach ( $submenu[ $parent_slug ] as &$item ) {
141 - if ( isset( $item[2] ) && $upgrade_slug === $item[2] ) {
142 - $item[0] = esc_html__( 'Sale!', 'elementor' ) . '<br />' . esc_html__( 'Upgrade Now', 'elementor' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
143 - break;
144 - }
145 - }
146 -
147 - 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() );
148 95 }
149 96
150 - private function register_editor_one_menu_items( Menu_Data_Provider $menu_data_provider ) {
151 - $menu_data_provider->register_menu( new Editor_One_Custom_Elements_Menu() );
152 - $menu_data_provider->register_menu( new Editor_One_Submissions_Menu() );
153 - $menu_data_provider->register_menu( new Editor_One_Fonts_Menu() );
154 - $menu_data_provider->register_menu( new Editor_One_Icons_Menu() );
155 - $menu_data_provider->register_menu( new Editor_One_Custom_Code_Menu() );
156 - $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() );
157 99 }
158 100
159 101 public function enqueue_react_data(): void {
160 102 if ( ! current_user_can( 'manage_options' ) ) {
@@ -171,9 +113,8 @@
171 113 'react-dom',
172 114 'backbone-marionette',
173 115 'elementor-editor-modules',
174 116 'elementor-v2-ui',
175 - 'elementor-v2-icons',
176 117 ],
177 118 ELEMENTOR_VERSION,
178 119 true
179 120 );
@@ -220,127 +161,6 @@
220 161 EditorAssetsAPI::ASSETS_DATA_URL => 'https://assets.elementor.com/free-to-pro-upsell/v1/free-to-pro-upsell.json',
221 162 EditorAssetsAPI::ASSETS_DATA_TRANSIENT_KEY => '_elementor_free_to_pro_upsell',
222 163 EditorAssetsAPI::ASSETS_DATA_KEY => 'free-to-pro-upsell',
223 164 ];
224 - }
225 -
226 - public function add_editing_panel_sticky_promotion( array $settings ): array {
227 - if ( ! Plugin::$instance->experiments->is_feature_active( 'e_panel_promotions' ) ) {
228 - return $settings;
229 - }
230 -
231 - $settings['editingPanelStickyPromotion'] = Filtered_Promotions_Manager::get_editor_panel_sticky_promotion();
232 -
233 - return $settings;
234 - }
235 -
236 - public function add_v4_promotions_data( array $settings ): array {
237 - if ( ! current_user_can( 'manage_options' ) ) {
238 - return $settings;
239 - }
240 -
241 - $editor_assets_api = new EditorAssetsAPI( $this->get_v4_promotions_api_config() );
242 - $promotion_data = new PromotionData( $editor_assets_api );
243 -
244 - $settings['v4Promotions'] = $promotion_data->get_v4_promotions_data();
245 -
246 - return $settings;
247 - }
248 -
249 - private function get_v4_promotions_api_config(): array {
250 - return [
251 - EditorAssetsAPI::ASSETS_DATA_URL => 'https://assets.elementor.com/packages/v1/promotions.json',
252 - EditorAssetsAPI::ASSETS_DATA_TRANSIENT_KEY => '_elementor_v4_promotions',
253 - EditorAssetsAPI::ASSETS_DATA_KEY => 'promotions',
254 - ];
255 - }
256 -
257 - private function is_atomic_widgets_active(): bool {
258 - return Plugin::$instance->experiments->is_feature_active( 'e_atomic_elements' );
259 - }
260 -
261 - private function get_atomic_promotion_configs(): array {
262 - return [
263 - [
264 - 'key' => 'attributes',
265 - 'label' => __( 'Attributes', 'elementor' ),
266 - 'section' => 'settings',
267 - 'priority' => 40,
268 - ],
269 - [
270 - 'key' => 'display-conditions',
271 - 'label' => __( 'Display Conditions', 'elementor' ),
272 - 'section' => 'settings',
273 - 'priority' => 50,
274 - ],
275 - ];
276 - }
277 -
278 - private function register_atomic_promotions(): void {
279 - add_action( 'elementor/init', function() {
280 - if ( ! $this->is_atomic_widgets_active() ) {
281 - return;
282 - }
283 -
284 - add_filter(
285 - 'elementor/atomic-widgets/props-schema',
286 - [ $this, 'inject_atomic_promotion_props' ]
287 - );
288 -
289 - foreach ( $this->get_atomic_promotion_configs() as $config ) {
290 - add_filter(
291 - 'elementor/atomic-widgets/controls',
292 - fn( array $controls, $element ) => $this->inject_atomic_promotion_control( $controls, $element, $config ),
293 - $config['priority'],
294 - 2
295 - );
296 - }
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 }