| @@ -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,22 +14,19 @@ | ||
| 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; |
| 20 | +use Elementor\Modules\Promotions\AdminMenuItems\Popups_Promotion_Item; | |
| 15 | 21 | use Elementor\Modules\Promotions\Controls\Atomic_Promotion_Control; |
| 16 | -use Elementor\Modules\Promotions\Conversion_Banner; | |
| 17 | 22 | use Elementor\Modules\Promotions\Pointers\Birthday; |
| 18 | 23 | use Elementor\Modules\Promotions\Pointers\Black_Friday; |
| 19 | 24 | use Elementor\Modules\Promotions\PropTypes\Promotion_Prop_Type; |
| 20 | -use Elementor\Modules\Promotions\Widgets\Ally_Dashboard_Widget; | |
| 21 | -use Elementor\Modules\Promotions\Widgets\Atomic_Form_Widget_Promotion; | |
| 22 | -use Elementor\Modules\Promotions\Widgets\Birthday_Easter_Egg_Promotion; | |
| 23 | 25 | use Elementor\Widgets_Manager; |
| 24 | 26 | use Elementor\Utils; |
| 25 | 27 | use Elementor\Includes\EditorAssetsAPI; |
| 26 | 28 | use Elementor\Plugin; |
| 27 | -use Elementor\Modules\EditorOne\Classes\Menu_Config; | |
| 28 | 29 | use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider; |
| 29 | 30 | |
| 30 | 31 | if ( ! defined( 'ABSPATH' ) ) { |
| 31 | 32 | exit; // Exit if accessed directly. |
| @@ -51,15 +52,19 @@ | ||
| 51 | 52 | add_action( 'admin_init', function () { |
| 52 | 53 | $this->handle_external_redirects(); |
| 53 | 54 | } ); |
| 54 | 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 | + | |
| 55 | 60 | add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) { |
| 56 | 61 | $this->register_editor_one_menu_items( $menu_data_provider ); |
| 57 | 62 | } ); |
| 58 | 63 | |
| 59 | - if ( Utils::is_sale_time() ) { | |
| 60 | - add_filter( 'add_menu_classes', [ $this, 'override_one_menu_upgrade_label_during_sale' ] ); | |
| 61 | - } | |
| 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 ); | |
| 62 | 67 | |
| 63 | 68 | add_action( 'elementor/widgets/register', function( Widgets_Manager $manager ) { |
| 64 | 69 | foreach ( Api::get_promotion_widgets() as $widget_data ) { |
| 65 | 70 | $manager->register( new Widgets\Pro_Widget_Promotion( [], [ |
| @@ -76,14 +81,8 @@ | ||
| 76 | 81 | if ( Black_Friday::should_display_notice() ) { |
| 77 | 82 | new Black_Friday(); |
| 78 | 83 | } |
| 79 | 84 | |
| 80 | - if ( Conversion_Banner::should_display_banner() ) { | |
| 81 | - new Conversion_Banner(); | |
| 82 | - } | |
| 83 | - | |
| 84 | - add_filter( 'elementor/editor/localize_settings', [ $this, 'add_v4_promotions_data' ] ); | |
| 85 | - | |
| 86 | 85 | if ( Utils::has_pro() ) { |
| 87 | 86 | return; |
| 88 | 87 | } |
| 89 | 88 | |
| @@ -92,24 +91,13 @@ | ||
| 92 | 91 | } ); |
| 93 | 92 | |
| 94 | 93 | add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_react_data' ] ); |
| 95 | 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' ] ); | |
| 96 | 96 | |
| 97 | - // Add Ally promo | |
| 98 | - Ally_Dashboard_Widget::init(); | |
| 99 | - | |
| 100 | 97 | $this->register_atomic_promotions(); |
| 101 | 98 | } |
| 102 | 99 | |
| 103 | - /** | |
| 104 | - * Get Ally Scanner URL | |
| 105 | - * | |
| 106 | - * @return string | |
| 107 | - */ | |
| 108 | - public static function get_ally_external_scanner_url(): string { | |
| 109 | - return apply_filters( 'elementor/ally_external_scanner_url', 'https://go.elementor.com/acc-checker-dashboard-plg' ); | |
| 110 | - } | |
| 111 | - | |
| 112 | 100 | private function handle_external_redirects() { |
| 113 | 101 | $page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); |
| 114 | 102 | if ( empty( $page ) ) { |
| 115 | 103 | return; |
| @@ -120,26 +108,16 @@ | ||
| 120 | 108 | die; |
| 121 | 109 | } |
| 122 | 110 | } |
| 123 | 111 | |
| 124 | - public function override_one_menu_upgrade_label_during_sale( $menu ) { | |
| 125 | - global $submenu; | |
| 126 | - | |
| 127 | - $parent_slug = Menu_Config::ELEMENTOR_HOME_MENU_SLUG; | |
| 128 | - $upgrade_slug = 'elementor-one-upgrade'; | |
| 129 | - | |
| 130 | - if ( empty( $submenu[ $parent_slug ] ) ) { | |
| 131 | - 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() ); | |
| 132 | 119 | } |
| 133 | - | |
| 134 | - foreach ( $submenu[ $parent_slug ] as &$item ) { | |
| 135 | - if ( isset( $item[2] ) && $upgrade_slug === $item[2] ) { | |
| 136 | - $item[0] = esc_html__( 'Sale!', 'elementor' ) . '<br />' . esc_html__( 'Upgrade Now', 'elementor' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited | |
| 137 | - break; | |
| 138 | - } | |
| 139 | - } | |
| 140 | - | |
| 141 | - return $menu; | |
| 142 | 120 | } |
| 143 | 121 | |
| 144 | 122 | private function register_editor_one_menu_items( Menu_Data_Provider $menu_data_provider ) { |
| 145 | 123 | $menu_data_provider->register_menu( new Editor_One_Custom_Elements_Menu() ); |
| @@ -149,8 +127,14 @@ | ||
| 149 | 127 | $menu_data_provider->register_menu( new Editor_One_Custom_Code_Menu() ); |
| 150 | 128 | $menu_data_provider->register_menu( new Editor_One_Popups_Menu() ); |
| 151 | 129 | } |
| 152 | 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 | + | |
| 153 | 137 | public function enqueue_react_data(): void { |
| 154 | 138 | if ( ! current_user_can( 'manage_options' ) ) { |
| 155 | 139 | return; |
| 156 | 140 | } |
| @@ -236,8 +220,12 @@ | ||
| 236 | 220 | EditorAssetsAPI::ASSETS_DATA_KEY => 'promotions', |
| 237 | 221 | ]; |
| 238 | 222 | } |
| 239 | 223 | |
| 224 | + private function is_editor_one_active(): bool { | |
| 225 | + return (bool) Plugin::instance()->modules_manager->get_modules( 'editor-one' ); | |
| 226 | + } | |
| 227 | + | |
| 240 | 228 | private function is_atomic_widgets_active(): bool { |
| 241 | 229 | return Plugin::$instance->experiments->is_feature_active( 'e_atomic_elements' ); |
| 242 | 230 | } |
| 243 | 231 | |
| @@ -276,13 +264,9 @@ | ||
| 276 | 264 | $config['priority'], |
| 277 | 265 | 2 |
| 278 | 266 | ); |
| 279 | 267 | } |
| 280 | - | |
| 281 | - ( new Birthday_Easter_Egg_Promotion() )->register(); | |
| 282 | 268 | } ); |
| 283 | - | |
| 284 | - ( new Atomic_Form_Widget_Promotion() )->register(); | |
| 285 | 269 | } |
| 286 | 270 | |
| 287 | 271 | public function inject_atomic_promotion_props( array $schema ): array { |
| 288 | 272 | foreach ( $this->get_atomic_promotion_configs() as $config ) { |