| @@ -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,23 +14,20 @@ | ||
| 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 | 25 | 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; | |
| 25 | 26 | use Elementor\Widgets_Manager; |
| 26 | 27 | use Elementor\Utils; |
| 27 | 28 | use Elementor\Includes\EditorAssetsAPI; |
| 28 | 29 | use Elementor\Plugin; |
| 29 | -use Elementor\Modules\EditorOne\Classes\Menu_Config; | |
| 30 | 30 | use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider; |
| 31 | 31 | |
| 32 | 32 | if ( ! defined( 'ABSPATH' ) ) { |
| 33 | 33 | exit; // Exit if accessed directly. |
| @@ -53,15 +53,19 @@ | ||
| 53 | 53 | add_action( 'admin_init', function () { |
| 54 | 54 | $this->handle_external_redirects(); |
| 55 | 55 | } ); |
| 56 | 56 | |
| 57 | + add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) { | |
| 58 | + $this->register_menu_items( $admin_menu ); | |
| 59 | + }, static::ADMIN_MENU_PRIORITY ); | |
| 60 | + | |
| 57 | 61 | add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) { |
| 58 | 62 | $this->register_editor_one_menu_items( $menu_data_provider ); |
| 59 | 63 | } ); |
| 60 | 64 | |
| 61 | - if ( Utils::is_sale_time() ) { | |
| 62 | - add_filter( 'add_menu_classes', [ $this, 'override_one_menu_upgrade_label_during_sale' ] ); | |
| 63 | - } | |
| 65 | + add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) { | |
| 66 | + $this->register_promotion_menu_item( $admin_menu ); | |
| 67 | + }, static::ADMIN_MENU_PROMOTIONS_PRIORITY ); | |
| 64 | 68 | |
| 65 | 69 | add_action( 'elementor/widgets/register', function( Widgets_Manager $manager ) { |
| 66 | 70 | foreach ( Api::get_promotion_widgets() as $widget_data ) { |
| 67 | 71 | $manager->register( new Widgets\Pro_Widget_Promotion( [], [ |
| @@ -78,20 +82,12 @@ | ||
| 78 | 82 | if ( Black_Friday::should_display_notice() ) { |
| 79 | 83 | new Black_Friday(); |
| 80 | 84 | } |
| 81 | 85 | |
| 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 | 86 | if ( Utils::has_pro() ) { |
| 89 | 87 | return; |
| 90 | 88 | } |
| 91 | 89 | |
| 92 | - add_filter( 'elementor/editor/localize_settings', [ $this, 'add_editing_panel_sticky_promotion' ] ); | |
| 93 | - | |
| 94 | 90 | add_action( 'elementor/controls/register', function ( Controls_Manager $controls_manager ) { |
| 95 | 91 | $controls_manager->register( new Controls\Promotion_Control() ); |
| 96 | 92 | } ); |
| 97 | 93 | |
| @@ -96,8 +92,9 @@ | ||
| 96 | 92 | } ); |
| 97 | 93 | |
| 98 | 94 | add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_react_data' ] ); |
| 99 | 95 | add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_editor_v4_alphachip' ] ); |
| 96 | + add_filter( 'elementor/editor/localize_settings', [ $this, 'add_v4_promotions_data' ] ); | |
| 100 | 97 | |
| 101 | 98 | // Add Ally promo |
| 102 | 99 | Ally_Dashboard_Widget::init(); |
| 103 | 100 | |
| @@ -109,9 +106,9 @@ | ||
| 109 | 106 | * |
| 110 | 107 | * @return string |
| 111 | 108 | */ |
| 112 | 109 | 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' ); | |
| 110 | + return apply_filters( 'elementor/ally_external_scanner_url', 'https://elementor.com/tools/ally-accessibility-checker/scanner' ); | |
| 114 | 111 | } |
| 115 | 112 | |
| 116 | 113 | private function handle_external_redirects() { |
| 117 | 114 | $page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); |
| @@ -124,26 +121,16 @@ | ||
| 124 | 121 | die; |
| 125 | 122 | } |
| 126 | 123 | } |
| 127 | 124 | |
| 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; | |
| 125 | + private function register_menu_items( Admin_Menu_Manager $admin_menu ) { | |
| 126 | + if ( ! $this->is_editor_one_active() ) { | |
| 127 | + $admin_menu->register( 'e-form-submissions', new Form_Submissions_Promotion_Item() ); | |
| 128 | + $admin_menu->register( 'elementor_custom_fonts', new Custom_Fonts_Promotion_Item() ); | |
| 129 | + $admin_menu->register( 'elementor_custom_icons', new Custom_Icons_Promotion_Item() ); | |
| 130 | + $admin_menu->register( 'elementor_custom_code', new Custom_Code_Promotion_Item() ); | |
| 131 | + $admin_menu->register( 'popup_templates', new Popups_Promotion_Item() ); | |
| 136 | 132 | } |
| 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; | |
| 146 | 133 | } |
| 147 | 134 | |
| 148 | 135 | private function register_editor_one_menu_items( Menu_Data_Provider $menu_data_provider ) { |
| 149 | 136 | $menu_data_provider->register_menu( new Editor_One_Custom_Elements_Menu() ); |
| @@ -153,8 +140,14 @@ | ||
| 153 | 140 | $menu_data_provider->register_menu( new Editor_One_Custom_Code_Menu() ); |
| 154 | 141 | $menu_data_provider->register_menu( new Editor_One_Popups_Menu() ); |
| 155 | 142 | } |
| 156 | 143 | |
| 144 | + private function register_promotion_menu_item( Admin_Menu_Manager $admin_menu ) { | |
| 145 | + if ( ! $this->is_editor_one_active() ) { | |
| 146 | + $admin_menu->register( 'go_elementor_pro', new Go_Pro_Promotion_Item() ); | |
| 147 | + } | |
| 148 | + } | |
| 149 | + | |
| 157 | 150 | public function enqueue_react_data(): void { |
| 158 | 151 | if ( ! current_user_can( 'manage_options' ) ) { |
| 159 | 152 | return; |
| 160 | 153 | } |
| @@ -169,9 +162,8 @@ | ||
| 169 | 162 | 'react-dom', |
| 170 | 163 | 'backbone-marionette', |
| 171 | 164 | 'elementor-editor-modules', |
| 172 | 165 | 'elementor-v2-ui', |
| 173 | - 'elementor-v2-icons', | |
| 174 | 166 | ], |
| 175 | 167 | ELEMENTOR_VERSION, |
| 176 | 168 | true |
| 177 | 169 | ); |
| @@ -220,18 +212,8 @@ | ||
| 220 | 212 | EditorAssetsAPI::ASSETS_DATA_KEY => 'free-to-pro-upsell', |
| 221 | 213 | ]; |
| 222 | 214 | } |
| 223 | 215 | |
| 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 | 216 | public function add_v4_promotions_data( array $settings ): array { |
| 235 | 217 | if ( ! current_user_can( 'manage_options' ) ) { |
| 236 | 218 | return $settings; |
| 237 | 219 | } |
| @@ -251,8 +233,12 @@ | ||
| 251 | 233 | EditorAssetsAPI::ASSETS_DATA_KEY => 'promotions', |
| 252 | 234 | ]; |
| 253 | 235 | } |
| 254 | 236 | |
| 237 | + private function is_editor_one_active(): bool { | |
| 238 | + return (bool) Plugin::instance()->modules_manager->get_modules( 'editor-one' ); | |
| 239 | + } | |
| 240 | + | |
| 255 | 241 | private function is_atomic_widgets_active(): bool { |
| 256 | 242 | return Plugin::$instance->experiments->is_feature_active( 'e_atomic_elements' ); |
| 257 | 243 | } |
| 258 | 244 | |
| @@ -291,14 +277,9 @@ | ||
| 291 | 277 | $config['priority'], |
| 292 | 278 | 2 |
| 293 | 279 | ); |
| 294 | 280 | } |
| 295 | - | |
| 296 | - ( new Birthday_Easter_Egg_Promotion() )->register(); | |
| 297 | 281 | } ); |
| 298 | - | |
| 299 | - ( new Atomic_Form_Widget_Promotion() )->register(); | |
| 300 | - ( new Collection_Loop_Widget_Promotion() )->register(); | |
| 301 | 282 | } |
| 302 | 283 | |
| 303 | 284 | public function inject_atomic_promotion_props( array $schema ): array { |
| 304 | 285 | foreach ( $this->get_atomic_promotion_configs() as $config ) { |