| @@ -4,8 +4,9 @@ | ||
| 4 | 4 | |
| 5 | 5 | use Elementor\Api; |
| 6 | 6 | use Elementor\Controls_Manager; |
| 7 | 7 | use Elementor\Core\Base\Module as Base_Module; |
| 8 | +use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager; | |
| 8 | 9 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Custom_Code_Menu; |
| 9 | 10 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Custom_Elements_Menu; |
| 10 | 11 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Fonts_Menu; |
| 11 | 12 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Icons_Menu; |
| @@ -12,17 +13,20 @@ | ||
| 12 | 13 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Popups_Menu; |
| 13 | 14 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Submissions_Menu; |
| 14 | 15 | use Elementor\Modules\Promotions\AdminMenuItems\Go_Pro_Promotion_Item; |
| 15 | 16 | use Elementor\Modules\Promotions\Controls\Atomic_Promotion_Control; |
| 17 | +use Elementor\Modules\Promotions\Conversion_Banner; | |
| 16 | 18 | use Elementor\Modules\Promotions\Pointers\Birthday; |
| 17 | 19 | use Elementor\Modules\Promotions\Pointers\Black_Friday; |
| 18 | 20 | use Elementor\Modules\Promotions\PropTypes\Promotion_Prop_Type; |
| 19 | 21 | use Elementor\Modules\Promotions\Widgets\Ally_Dashboard_Widget; |
| 20 | 22 | use Elementor\Modules\Promotions\Widgets\Atomic_Form_Widget_Promotion; |
| 23 | +use Elementor\Modules\Promotions\Widgets\Birthday_Easter_Egg_Promotion; | |
| 21 | 24 | use Elementor\Widgets_Manager; |
| 22 | 25 | use Elementor\Utils; |
| 23 | 26 | use Elementor\Includes\EditorAssetsAPI; |
| 24 | 27 | use Elementor\Plugin; |
| 28 | +use Elementor\Modules\EditorOne\Classes\Menu_Config; | |
| 25 | 29 | use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider; |
| 26 | 30 | |
| 27 | 31 | if ( ! defined( 'ABSPATH' ) ) { |
| 28 | 32 | exit; // Exit if accessed directly. |
| @@ -52,8 +56,12 @@ | ||
| 52 | 56 | add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) { |
| 53 | 57 | $this->register_editor_one_menu_items( $menu_data_provider ); |
| 54 | 58 | } ); |
| 55 | 59 | |
| 60 | + if ( Utils::is_sale_time() ) { | |
| 61 | + add_filter( 'add_menu_classes', [ $this, 'override_one_menu_upgrade_label_during_sale' ] ); | |
| 62 | + } | |
| 63 | + | |
| 56 | 64 | add_action( 'elementor/widgets/register', function( Widgets_Manager $manager ) { |
| 57 | 65 | foreach ( Api::get_promotion_widgets() as $widget_data ) { |
| 58 | 66 | $manager->register( new Widgets\Pro_Widget_Promotion( [], [ |
| 59 | 67 | 'widget_name' => $widget_data['name'], |
| @@ -69,8 +77,12 @@ | ||
| 69 | 77 | if ( Black_Friday::should_display_notice() ) { |
| 70 | 78 | new Black_Friday(); |
| 71 | 79 | } |
| 72 | 80 | |
| 81 | + if ( Conversion_Banner::should_display_banner() ) { | |
| 82 | + new Conversion_Banner(); | |
| 83 | + } | |
| 84 | + | |
| 73 | 85 | add_filter( 'elementor/editor/localize_settings', [ $this, 'add_v4_promotions_data' ] ); |
| 74 | 86 | |
| 75 | 87 | if ( Utils::has_pro() ) { |
| 76 | 88 | return; |
| @@ -75,8 +87,10 @@ | ||
| 75 | 87 | if ( Utils::has_pro() ) { |
| 76 | 88 | return; |
| 77 | 89 | } |
| 78 | 90 | |
| 91 | + add_filter( 'elementor/editor/localize_settings', [ $this, 'add_editing_panel_sticky_promotion' ] ); | |
| 92 | + | |
| 79 | 93 | add_action( 'elementor/controls/register', function ( Controls_Manager $controls_manager ) { |
| 80 | 94 | $controls_manager->register( new Controls\Promotion_Control() ); |
| 81 | 95 | } ); |
| 82 | 96 | |
| @@ -109,8 +123,28 @@ | ||
| 109 | 123 | die; |
| 110 | 124 | } |
| 111 | 125 | } |
| 112 | 126 | |
| 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; | |
| 135 | + } | |
| 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 | + } | |
| 146 | + | |
| 113 | 147 | private function register_editor_one_menu_items( Menu_Data_Provider $menu_data_provider ) { |
| 114 | 148 | $menu_data_provider->register_menu( new Editor_One_Custom_Elements_Menu() ); |
| 115 | 149 | $menu_data_provider->register_menu( new Editor_One_Submissions_Menu() ); |
| 116 | 150 | $menu_data_provider->register_menu( new Editor_One_Fonts_Menu() ); |
| @@ -134,8 +168,9 @@ | ||
| 134 | 168 | 'react-dom', |
| 135 | 169 | 'backbone-marionette', |
| 136 | 170 | 'elementor-editor-modules', |
| 137 | 171 | 'elementor-v2-ui', |
| 172 | + 'elementor-v2-icons', | |
| 138 | 173 | ], |
| 139 | 174 | ELEMENTOR_VERSION, |
| 140 | 175 | true |
| 141 | 176 | ); |
| @@ -184,8 +219,18 @@ | ||
| 184 | 219 | EditorAssetsAPI::ASSETS_DATA_KEY => 'free-to-pro-upsell', |
| 185 | 220 | ]; |
| 186 | 221 | } |
| 187 | 222 | |
| 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 | + | |
| 188 | 233 | public function add_v4_promotions_data( array $settings ): array { |
| 189 | 234 | if ( ! current_user_can( 'manage_options' ) ) { |
| 190 | 235 | return $settings; |
| 191 | 236 | } |
| @@ -245,8 +290,10 @@ | ||
| 245 | 290 | $config['priority'], |
| 246 | 291 | 2 |
| 247 | 292 | ); |
| 248 | 293 | } |
| 294 | + | |
| 295 | + ( new Birthday_Easter_Egg_Promotion() )->register(); | |
| 249 | 296 | } ); |
| 250 | 297 | |
| 251 | 298 | ( new Atomic_Form_Widget_Promotion() )->register(); |
| 252 | 299 | } |