PluginProbe
Elementor Website Builder – more than just a page builder / 3.35.0-dev4
Elementor Website Builder – more than just a page builder v3.35.0-dev4
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 +59 -62 4.1.0-dev23.35.0-dev4 View file →
@@ -3,9 +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;
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;
8 12 use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Custom_Code_Menu;
9 13 use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Custom_Elements_Menu;
10 14 use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Fonts_Menu;
11 15 use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Icons_Menu;
@@ -10,15 +14,13 @@
10 14 use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Fonts_Menu;
11 15 use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Icons_Menu;
12 16 use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Popups_Menu;
13 17 use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Submissions_Menu;
18 +use Elementor\Modules\Promotions\AdminMenuItems\Form_Submissions_Promotion_Item;
14 19 use Elementor\Modules\Promotions\AdminMenuItems\Go_Pro_Promotion_Item;
15 -use Elementor\Modules\Promotions\Controls\Atomic_Promotion_Control;
20 +use Elementor\Modules\Promotions\AdminMenuItems\Popups_Promotion_Item;
16 21 use Elementor\Modules\Promotions\Pointers\Birthday;
17 22 use Elementor\Modules\Promotions\Pointers\Black_Friday;
18 -use Elementor\Modules\Promotions\PropTypes\Promotion_Prop_Type;
19 -use Elementor\Modules\Promotions\Widgets\Ally_Dashboard_Widget;
20 -use Elementor\Modules\Promotions\Widgets\Atomic_Form_Widget_Promotion;
21 23 use Elementor\Widgets_Manager;
22 24 use Elementor\Utils;
23 25 use Elementor\Includes\EditorAssetsAPI;
24 26 use Elementor\Plugin;
@@ -48,12 +50,20 @@
48 50 add_action( 'admin_init', function () {
49 51 $this->handle_external_redirects();
50 52 } );
51 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 +
52 58 add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) {
53 59 $this->register_editor_one_menu_items( $menu_data_provider );
54 60 } );
55 61
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 );
65 +
56 66 add_action( 'elementor/widgets/register', function( Widgets_Manager $manager ) {
57 67 foreach ( Api::get_promotion_widgets() as $widget_data ) {
58 68 $manager->register( new Widgets\Pro_Widget_Promotion( [], [
59 69 'widget_name' => $widget_data['name'],
@@ -69,10 +79,8 @@
69 79 if ( Black_Friday::should_display_notice() ) {
70 80 new Black_Friday();
71 81 }
72 82
73 - add_filter( 'elementor/editor/localize_settings', [ $this, 'add_v4_promotions_data' ] );
74 -
75 83 if ( Utils::has_pro() ) {
76 84 return;
77 85 }
78 86
@@ -81,24 +89,13 @@
81 89 } );
82 90
83 91 add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_react_data' ] );
84 92 add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_editor_v4_alphachip' ] );
93 + add_filter( 'elementor/editor/localize_settings', [ $this, 'add_v4_promotions_data' ] );
85 94
86 - // Add Ally promo
87 - Ally_Dashboard_Widget::init();
88 -
89 - $this->register_atomic_promotions();
95 + $this->register_display_conditions_promo_hooks();
90 96 }
91 97
92 - /**
93 - * Get Ally Scanner URL
94 - *
95 - * @return string
96 - */
97 - public static function get_ally_external_scanner_url(): string {
98 - return apply_filters( 'elementor/ally_external_scanner_url', 'https://go.elementor.com/acc-checker-dashboard-plg' );
99 - }
100 -
101 98 private function handle_external_redirects() {
102 99 $page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
103 100 if ( empty( $page ) ) {
104 101 return;
@@ -109,8 +106,18 @@
109 106 die;
110 107 }
111 108 }
112 109
110 + private function register_menu_items( Admin_Menu_Manager $admin_menu ) {
111 + if ( ! $this->is_editor_one_active() ) {
112 + $admin_menu->register( 'e-form-submissions', new Form_Submissions_Promotion_Item() );
113 + $admin_menu->register( 'elementor_custom_fonts', new Custom_Fonts_Promotion_Item() );
114 + $admin_menu->register( 'elementor_custom_icons', new Custom_Icons_Promotion_Item() );
115 + $admin_menu->register( 'elementor_custom_code', new Custom_Code_Promotion_Item() );
116 + $admin_menu->register( 'popup_templates', new Popups_Promotion_Item() );
117 + }
118 + }
119 +
113 120 private function register_editor_one_menu_items( Menu_Data_Provider $menu_data_provider ) {
114 121 $menu_data_provider->register_menu( new Editor_One_Custom_Elements_Menu() );
115 122 $menu_data_provider->register_menu( new Editor_One_Submissions_Menu() );
116 123 $menu_data_provider->register_menu( new Editor_One_Fonts_Menu() );
@@ -118,8 +125,14 @@
118 125 $menu_data_provider->register_menu( new Editor_One_Custom_Code_Menu() );
119 126 $menu_data_provider->register_menu( new Editor_One_Popups_Menu() );
120 127 }
121 128
129 + private function register_promotion_menu_item( Admin_Menu_Manager $admin_menu ) {
130 + if ( ! $this->is_editor_one_active() ) {
131 + $admin_menu->register( 'go_elementor_pro', new Go_Pro_Promotion_Item() );
132 + }
133 + }
134 +
122 135 public function enqueue_react_data(): void {
123 136 if ( ! current_user_can( 'manage_options' ) ) {
124 137 return;
125 138 }
@@ -205,72 +218,56 @@
205 218 EditorAssetsAPI::ASSETS_DATA_KEY => 'promotions',
206 219 ];
207 220 }
208 221
222 + private function is_editor_one_active(): bool {
223 + return (bool) Plugin::instance()->modules_manager->get_modules( 'editor-one' );
224 + }
225 +
209 226 private function is_atomic_widgets_active(): bool {
210 227 return Plugin::$instance->experiments->is_feature_active( 'e_atomic_elements' );
211 228 }
212 229
213 - private function get_atomic_promotion_configs(): array {
214 - return [
215 - [
216 - 'key' => 'attributes',
217 - 'label' => __( 'Attributes', 'elementor' ),
218 - 'section' => 'settings',
219 - 'priority' => 40,
220 - ],
221 - [
222 - 'key' => 'display-conditions',
223 - 'label' => __( 'Display Conditions', 'elementor' ),
224 - 'section' => 'settings',
225 - 'priority' => 50,
226 - ],
227 - ];
228 - }
229 -
230 - private function register_atomic_promotions(): void {
230 + private function register_display_conditions_promo_hooks(): void {
231 231 add_action( 'elementor/init', function() {
232 232 if ( ! $this->is_atomic_widgets_active() ) {
233 233 return;
234 234 }
235 235
236 + require_once __DIR__ . '/prop-types/display-conditions-prop-type.php';
237 + require_once __DIR__ . '/controls/display-conditions-promotion-control.php';
238 +
236 239 add_filter(
237 240 'elementor/atomic-widgets/props-schema',
238 - [ $this, 'inject_atomic_promotion_props' ]
241 + [ $this, 'inject_display_conditions_promo_prop' ]
239 242 );
240 243
241 - foreach ( $this->get_atomic_promotion_configs() as $config ) {
242 - add_filter(
243 - 'elementor/atomic-widgets/controls',
244 - fn( array $controls, $element ) => $this->inject_atomic_promotion_control( $controls, $element, $config ),
245 - $config['priority'],
246 - 2
247 - );
248 - }
244 + add_filter(
245 + 'elementor/atomic-widgets/controls',
246 + [ $this, 'inject_display_conditions_promo_control' ],
247 + 50,
248 + 2
249 + );
249 250 } );
250 -
251 - ( new Atomic_Form_Widget_Promotion() )->register();
252 251 }
253 252
254 - public function inject_atomic_promotion_props( array $schema ): array {
255 - foreach ( $this->get_atomic_promotion_configs() as $config ) {
256 - $key = $config['key'];
253 + public function inject_display_conditions_promo_prop( array $schema ): array {
254 + $prop_key = PropTypes\Display_Conditions_Prop_Type::get_key();
257 255
258 - if ( isset( $schema[ $key ] ) ) {
259 - continue;
260 - }
256 + if ( isset( $schema[ $prop_key ] ) ) {
257 + return $schema;
258 + }
261 259
262 - $schema[ $key ] = Promotion_Prop_Type::make( $key );
263 - }
260 + $schema[ $prop_key ] = PropTypes\Display_Conditions_Prop_Type::make();
264 261
265 262 return $schema;
266 263 }
267 264
268 - protected function inject_atomic_promotion_control( array $element_controls, $atomic_element, array $config ): array {
269 - $key = $config['key'];
265 + public function inject_display_conditions_promo_control( array $element_controls, $atomic_element ): array {
266 + $prop_key = PropTypes\Display_Conditions_Prop_Type::get_key();
270 267 $schema = $atomic_element::get_props_schema();
271 268
272 - if ( ! array_key_exists( $key, $schema ) ) {
269 + if ( ! array_key_exists( $prop_key, $schema ) ) {
273 270 return $element_controls;
274 271 }
275 272
276 273 foreach ( $element_controls as $item ) {
@@ -277,14 +274,14 @@
277 274 if ( ! ( $item instanceof \Elementor\Modules\AtomicWidgets\Controls\Section ) ) {
278 275 continue;
279 276 }
280 277
281 - if ( $item->get_id() !== $config['section'] ) {
278 + if ( $item->get_id() !== 'settings' ) {
282 279 continue;
283 280 }
284 281
285 - $control = Atomic_Promotion_Control::make( $key )
286 - ->set_label( $config['label'] )
282 + $control = Controls\Display_Conditions_Promotion_Control::bind_to( $prop_key )
283 + ->set_label( __( 'Display Conditions', 'elementor' ) )
287 284 ->set_meta( [
288 285 'topDivider' => true,
289 286 ] );
290 287