PluginProbe
Elementor Website Builder – more than just a page builder / 3.26.4
Elementor Website Builder – more than just a page builder v3.26.4
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 +24 -233 4.2.0-beta13.26.4 View file →
@@ -3,35 +3,22 @@
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;
18 -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;
14 +use Elementor\Modules\Promotions\AdminMenuItems\Popups_Promotion_Item;
25 15 use Elementor\Widgets_Manager;
26 16 use Elementor\Utils;
27 17 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 18
32 19 if ( ! defined( 'ABSPATH' ) ) {
33 - exit; // Exit if accessed directly.
20 + exit; // Exit if accessed directly
34 21 }
35 22
36 23 class Module extends Base_Module {
37 24
@@ -53,15 +40,15 @@
53 40 add_action( 'admin_init', function () {
54 41 $this->handle_external_redirects();
55 42 } );
56 43
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 - } );
44 + add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) {
45 + $this->register_menu_items( $admin_menu );
46 + }, static::ADMIN_MENU_PRIORITY );
60 47
61 - if ( Utils::is_sale_time() ) {
62 - add_filter( 'add_menu_classes', [ $this, 'override_one_menu_upgrade_label_during_sale' ] );
63 - }
48 + add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) {
49 + $this->register_promotion_menu_item( $admin_menu );
50 + }, static::ADMIN_MENU_PROMOTIONS_PRIORITY );
64 51
65 52 add_action( 'elementor/widgets/register', function( Widgets_Manager $manager ) {
66 53 foreach ( Api::get_promotion_widgets() as $widget_data ) {
67 54 $manager->register( new Widgets\Pro_Widget_Promotion( [], [
@@ -70,89 +57,40 @@
70 57 ] ) );
71 58 }
72 59 } );
73 60
74 - if ( Birthday::should_display_notice() ) {
75 - new Birthday();
76 - }
77 -
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 61 if ( Utils::has_pro() ) {
89 62 return;
90 63 }
91 64
92 - add_filter( 'elementor/editor/localize_settings', [ $this, 'add_editing_panel_sticky_promotion' ] );
93 -
94 65 add_action( 'elementor/controls/register', function ( Controls_Manager $controls_manager ) {
95 66 $controls_manager->register( new Controls\Promotion_Control() );
96 67 } );
97 68
98 69 add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_react_data' ] );
99 - 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 70 }
106 71
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 72 private function handle_external_redirects() {
117 - $page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
118 - if ( empty( $page ) ) {
73 + if ( empty( $_GET['page'] ) ) {
119 74 return;
120 75 }
121 76
122 - if ( 'go_elementor_pro' === $page ) {
123 - wp_redirect( Go_Pro_Promotion_Item::get_url() ); // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect
77 + if ( 'go_elementor_pro' === $_GET['page'] ) {
78 + wp_redirect( Go_Pro_Promotion_Item::get_url() );
124 79 die;
125 80 }
126 81 }
127 82
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;
83 + private function register_menu_items( Admin_Menu_Manager $admin_menu ) {
84 + $admin_menu->register( 'e-form-submissions', new Form_Submissions_Promotion_Item() );
85 + $admin_menu->register( 'elementor_custom_fonts', new Custom_Fonts_Promotion_Item() );
86 + $admin_menu->register( 'elementor_custom_icons', new Custom_Icons_Promotion_Item() );
87 + $admin_menu->register( 'elementor_custom_code', new Custom_Code_Promotion_Item() );
88 + $admin_menu->register( 'popup_templates', new Popups_Promotion_Item() );
146 89 }
147 90
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() );
91 + private function register_promotion_menu_item( Admin_Menu_Manager $admin_menu ) {
92 + $admin_menu->register( 'go_elementor_pro', new Go_Pro_Promotion_Item() );
155 93 }
156 94
157 95 public function enqueue_react_data(): void {
158 96 if ( ! current_user_can( 'manage_options' ) ) {
@@ -167,11 +105,8 @@
167 105 [
168 106 'react',
169 107 'react-dom',
170 108 'backbone-marionette',
171 - 'elementor-editor-modules',
172 - 'elementor-v2-ui',
173 - 'elementor-v2-icons',
174 109 ],
175 110 ELEMENTOR_VERSION,
176 111 true
177 112 );
@@ -184,29 +119,8 @@
184 119 $this->get_app_js_config()
185 120 );
186 121 }
187 122
188 - public function enqueue_editor_v4_alphachip(): void {
189 - if ( ! current_user_can( 'manage_options' ) ) {
190 - return;
191 - }
192 -
193 - $min_suffix = Utils::is_script_debug() ? '' : '.min';
194 -
195 - wp_enqueue_script(
196 - 'editor-v4-opt-in-alphachip',
197 - ELEMENTOR_ASSETS_URL . 'js/editor-v4-opt-in-alphachip' . $min_suffix . '.js',
198 - [
199 - 'react',
200 - 'react-dom',
201 - 'elementor-common',
202 - 'elementor-v2-ui',
203 - ],
204 - ELEMENTOR_VERSION,
205 - true
206 - );
207 - }
208 -
209 123 private function get_app_js_config(): array {
210 124 $editor_assets_api = new EditorAssetsAPI( $this->get_api_config() );
211 125 $promotion_data = new PromotionData( $editor_assets_api );
212 126
@@ -218,129 +132,6 @@
218 132 EditorAssetsAPI::ASSETS_DATA_URL => 'https://assets.elementor.com/free-to-pro-upsell/v1/free-to-pro-upsell.json',
219 133 EditorAssetsAPI::ASSETS_DATA_TRANSIENT_KEY => '_elementor_free_to_pro_upsell',
220 134 EditorAssetsAPI::ASSETS_DATA_KEY => 'free-to-pro-upsell',
221 135 ];
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 136 }
346 137 }