| @@ -3,10 +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; |
| 8 | -use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager; | |
| 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; | |
| 9 | 12 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Custom_Code_Menu; |
| 10 | 13 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Custom_Elements_Menu; |
| 11 | 14 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Fonts_Menu; |
| 12 | 15 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Icons_Menu; |
| @@ -11,22 +14,19 @@ | ||
| 11 | 14 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Fonts_Menu; |
| 12 | 15 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Icons_Menu; |
| 13 | 16 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Popups_Menu; |
| 14 | 17 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Submissions_Menu; |
| 18 | +use Elementor\Modules\Promotions\AdminMenuItems\Form_Submissions_Promotion_Item; | |
| 15 | 19 | use Elementor\Modules\Promotions\AdminMenuItems\Go_Pro_Promotion_Item; |
| 20 | +use Elementor\Modules\Promotions\AdminMenuItems\Popups_Promotion_Item; | |
| 16 | 21 | use Elementor\Modules\Promotions\Controls\Atomic_Promotion_Control; |
| 17 | -use Elementor\Modules\Promotions\Conversion_Banner; | |
| 18 | 22 | use Elementor\Modules\Promotions\Pointers\Birthday; |
| 19 | 23 | use Elementor\Modules\Promotions\Pointers\Black_Friday; |
| 20 | 24 | 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 | 25 | use Elementor\Widgets_Manager; |
| 25 | 26 | use Elementor\Utils; |
| 26 | 27 | use Elementor\Includes\EditorAssetsAPI; |
| 27 | 28 | use Elementor\Plugin; |
| 28 | -use Elementor\Modules\EditorOne\Classes\Menu_Config; | |
| 29 | 29 | use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider; |
| 30 | 30 | |
| 31 | 31 | if ( ! defined( 'ABSPATH' ) ) { |
| 32 | 32 | exit; // Exit if accessed directly. |
| @@ -52,15 +52,19 @@ | ||
| 52 | 52 | add_action( 'admin_init', function () { |
| 53 | 53 | $this->handle_external_redirects(); |
| 54 | 54 | } ); |
| 55 | 55 | |
| 56 | + add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) { | |
| 57 | + $this->register_menu_items( $admin_menu ); | |
| 58 | + }, static::ADMIN_MENU_PRIORITY ); | |
| 59 | + | |
| 56 | 60 | add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) { |
| 57 | 61 | $this->register_editor_one_menu_items( $menu_data_provider ); |
| 58 | 62 | } ); |
| 59 | 63 | |
| 60 | - if ( Utils::is_sale_time() ) { | |
| 61 | - add_filter( 'add_menu_classes', [ $this, 'override_one_menu_upgrade_label_during_sale' ] ); | |
| 62 | - } | |
| 64 | + add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) { | |
| 65 | + $this->register_promotion_menu_item( $admin_menu ); | |
| 66 | + }, static::ADMIN_MENU_PROMOTIONS_PRIORITY ); | |
| 63 | 67 | |
| 64 | 68 | add_action( 'elementor/widgets/register', function( Widgets_Manager $manager ) { |
| 65 | 69 | foreach ( Api::get_promotion_widgets() as $widget_data ) { |
| 66 | 70 | $manager->register( new Widgets\Pro_Widget_Promotion( [], [ |
| @@ -77,20 +81,12 @@ | ||
| 77 | 81 | if ( Black_Friday::should_display_notice() ) { |
| 78 | 82 | new Black_Friday(); |
| 79 | 83 | } |
| 80 | 84 | |
| 81 | - if ( Conversion_Banner::should_display_banner() ) { | |
| 82 | - new Conversion_Banner(); | |
| 83 | - } | |
| 84 | - | |
| 85 | - add_filter( 'elementor/editor/localize_settings', [ $this, 'add_v4_promotions_data' ] ); | |
| 86 | - | |
| 87 | 85 | if ( Utils::has_pro() ) { |
| 88 | 86 | return; |
| 89 | 87 | } |
| 90 | 88 | |
| 91 | - add_filter( 'elementor/editor/localize_settings', [ $this, 'add_editing_panel_sticky_promotion' ] ); | |
| 92 | - | |
| 93 | 89 | add_action( 'elementor/controls/register', function ( Controls_Manager $controls_manager ) { |
| 94 | 90 | $controls_manager->register( new Controls\Promotion_Control() ); |
| 95 | 91 | } ); |
| 96 | 92 | |
| @@ -95,24 +91,13 @@ | ||
| 95 | 91 | } ); |
| 96 | 92 | |
| 97 | 93 | add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_react_data' ] ); |
| 98 | 94 | add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_editor_v4_alphachip' ] ); |
| 95 | + add_filter( 'elementor/editor/localize_settings', [ $this, 'add_v4_promotions_data' ] ); | |
| 99 | 96 | |
| 100 | - // Add Ally promo | |
| 101 | - Ally_Dashboard_Widget::init(); | |
| 102 | - | |
| 103 | 97 | $this->register_atomic_promotions(); |
| 104 | 98 | } |
| 105 | 99 | |
| 106 | - /** | |
| 107 | - * Get Ally Scanner URL | |
| 108 | - * | |
| 109 | - * @return string | |
| 110 | - */ | |
| 111 | - public static function get_ally_external_scanner_url(): string { | |
| 112 | - return apply_filters( 'elementor/ally_external_scanner_url', 'https://go.elementor.com/acc-checker-dashboard-plg' ); | |
| 113 | - } | |
| 114 | - | |
| 115 | 100 | private function handle_external_redirects() { |
| 116 | 101 | $page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); |
| 117 | 102 | if ( empty( $page ) ) { |
| 118 | 103 | return; |
| @@ -123,26 +108,16 @@ | ||
| 123 | 108 | die; |
| 124 | 109 | } |
| 125 | 110 | } |
| 126 | 111 | |
| 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; | |
| 112 | + private function register_menu_items( Admin_Menu_Manager $admin_menu ) { | |
| 113 | + if ( ! $this->is_editor_one_active() ) { | |
| 114 | + $admin_menu->register( 'e-form-submissions', new Form_Submissions_Promotion_Item() ); | |
| 115 | + $admin_menu->register( 'elementor_custom_fonts', new Custom_Fonts_Promotion_Item() ); | |
| 116 | + $admin_menu->register( 'elementor_custom_icons', new Custom_Icons_Promotion_Item() ); | |
| 117 | + $admin_menu->register( 'elementor_custom_code', new Custom_Code_Promotion_Item() ); | |
| 118 | + $admin_menu->register( 'popup_templates', new Popups_Promotion_Item() ); | |
| 135 | 119 | } |
| 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 | 120 | } |
| 146 | 121 | |
| 147 | 122 | private function register_editor_one_menu_items( Menu_Data_Provider $menu_data_provider ) { |
| 148 | 123 | $menu_data_provider->register_menu( new Editor_One_Custom_Elements_Menu() ); |
| @@ -152,8 +127,14 @@ | ||
| 152 | 127 | $menu_data_provider->register_menu( new Editor_One_Custom_Code_Menu() ); |
| 153 | 128 | $menu_data_provider->register_menu( new Editor_One_Popups_Menu() ); |
| 154 | 129 | } |
| 155 | 130 | |
| 131 | + private function register_promotion_menu_item( Admin_Menu_Manager $admin_menu ) { | |
| 132 | + if ( ! $this->is_editor_one_active() ) { | |
| 133 | + $admin_menu->register( 'go_elementor_pro', new Go_Pro_Promotion_Item() ); | |
| 134 | + } | |
| 135 | + } | |
| 136 | + | |
| 156 | 137 | public function enqueue_react_data(): void { |
| 157 | 138 | if ( ! current_user_can( 'manage_options' ) ) { |
| 158 | 139 | return; |
| 159 | 140 | } |
| @@ -168,9 +149,8 @@ | ||
| 168 | 149 | 'react-dom', |
| 169 | 150 | 'backbone-marionette', |
| 170 | 151 | 'elementor-editor-modules', |
| 171 | 152 | 'elementor-v2-ui', |
| 172 | - 'elementor-v2-icons', | |
| 173 | 153 | ], |
| 174 | 154 | ELEMENTOR_VERSION, |
| 175 | 155 | true |
| 176 | 156 | ); |
| @@ -219,18 +199,8 @@ | ||
| 219 | 199 | EditorAssetsAPI::ASSETS_DATA_KEY => 'free-to-pro-upsell', |
| 220 | 200 | ]; |
| 221 | 201 | } |
| 222 | 202 | |
| 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 | - | |
| 233 | 203 | public function add_v4_promotions_data( array $settings ): array { |
| 234 | 204 | if ( ! current_user_can( 'manage_options' ) ) { |
| 235 | 205 | return $settings; |
| 236 | 206 | } |
| @@ -250,8 +220,12 @@ | ||
| 250 | 220 | EditorAssetsAPI::ASSETS_DATA_KEY => 'promotions', |
| 251 | 221 | ]; |
| 252 | 222 | } |
| 253 | 223 | |
| 224 | + private function is_editor_one_active(): bool { | |
| 225 | + return (bool) Plugin::instance()->modules_manager->get_modules( 'editor-one' ); | |
| 226 | + } | |
| 227 | + | |
| 254 | 228 | private function is_atomic_widgets_active(): bool { |
| 255 | 229 | return Plugin::$instance->experiments->is_feature_active( 'e_atomic_elements' ); |
| 256 | 230 | } |
| 257 | 231 | |
| @@ -290,13 +264,9 @@ | ||
| 290 | 264 | $config['priority'], |
| 291 | 265 | 2 |
| 292 | 266 | ); |
| 293 | 267 | } |
| 294 | - | |
| 295 | - ( new Birthday_Easter_Egg_Promotion() )->register(); | |
| 296 | 268 | } ); |
| 297 | - | |
| 298 | - ( new Atomic_Form_Widget_Promotion() )->register(); | |
| 299 | 269 | } |
| 300 | 270 | |
| 301 | 271 | public function inject_atomic_promotion_props( array $schema ): array { |
| 302 | 272 | foreach ( $this->get_atomic_promotion_configs() as $config ) { |