| @@ -4,9 +4,8 @@ | ||
| 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; | |
| 9 | 8 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Custom_Code_Menu; |
| 10 | 9 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Custom_Elements_Menu; |
| 11 | 10 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Fonts_Menu; |
| 12 | 11 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Icons_Menu; |
| @@ -13,19 +12,17 @@ | ||
| 13 | 12 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Popups_Menu; |
| 14 | 13 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Submissions_Menu; |
| 15 | 14 | use Elementor\Modules\Promotions\AdminMenuItems\Go_Pro_Promotion_Item; |
| 16 | 15 | use Elementor\Modules\Promotions\Controls\Atomic_Promotion_Control; |
| 17 | -use Elementor\Modules\Promotions\Conversion_Banner; | |
| 18 | 16 | use Elementor\Modules\Promotions\Pointers\Birthday; |
| 19 | 17 | use Elementor\Modules\Promotions\Pointers\Black_Friday; |
| 20 | 18 | use Elementor\Modules\Promotions\PropTypes\Promotion_Prop_Type; |
| 19 | +use Elementor\Modules\Promotions\Widgets\Ally_Dashboard_Widget; | |
| 21 | 20 | use Elementor\Modules\Promotions\Widgets\Atomic_Form_Widget_Promotion; |
| 22 | -use Elementor\Modules\Promotions\Widgets\Collection_Loop_Widget_Promotion; | |
| 23 | 21 | use Elementor\Widgets_Manager; |
| 24 | 22 | use Elementor\Utils; |
| 25 | 23 | use Elementor\Includes\EditorAssetsAPI; |
| 26 | 24 | use Elementor\Plugin; |
| 27 | -use Elementor\Modules\EditorOne\Classes\Menu_Config; | |
| 28 | 25 | use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider; |
| 29 | 26 | |
| 30 | 27 | if ( ! defined( 'ABSPATH' ) ) { |
| 31 | 28 | exit; // Exit if accessed directly. |
| @@ -37,13 +34,9 @@ | ||
| 37 | 34 | |
| 38 | 35 | const ADMIN_MENU_PROMOTIONS_PRIORITY = 120; |
| 39 | 36 | |
| 40 | 37 | public static function is_active() { |
| 41 | - if ( Utils::has_pro() ) { | |
| 42 | - return true; | |
| 43 | - } | |
| 44 | - | |
| 45 | - return ! Utils::is_license_active(); | |
| 38 | + return ! Utils::has_pro(); | |
| 46 | 39 | } |
| 47 | 40 | |
| 48 | 41 | public function get_name() { |
| 49 | 42 | return 'promotions'; |
| @@ -51,17 +44,8 @@ | ||
| 51 | 44 | |
| 52 | 45 | public function __construct() { |
| 53 | 46 | parent::__construct(); |
| 54 | 47 | |
| 55 | - add_filter( 'elementor/editor/localize_settings', [ $this, 'add_v4_promotions_data' ] ); | |
| 56 | - | |
| 57 | - if ( Utils::has_pro() ) { | |
| 58 | - add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_react_data' ] ); | |
| 59 | - $this->register_atomic_promotions(); | |
| 60 | - | |
| 61 | - return; | |
| 62 | - } | |
| 63 | - | |
| 64 | 48 | add_action( 'admin_init', function () { |
| 65 | 49 | $this->handle_external_redirects(); |
| 66 | 50 | } ); |
| 67 | 51 | |
| @@ -68,12 +52,8 @@ | ||
| 68 | 52 | add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) { |
| 69 | 53 | $this->register_editor_one_menu_items( $menu_data_provider ); |
| 70 | 54 | } ); |
| 71 | 55 | |
| 72 | - if ( Utils::is_sale_time() ) { | |
| 73 | - add_filter( 'add_menu_classes', [ $this, 'override_one_menu_upgrade_label_during_sale' ] ); | |
| 74 | - } | |
| 75 | - | |
| 76 | 56 | add_action( 'elementor/widgets/register', function( Widgets_Manager $manager ) { |
| 77 | 57 | foreach ( Api::get_promotion_widgets() as $widget_data ) { |
| 78 | 58 | $manager->register( new Widgets\Pro_Widget_Promotion( [], [ |
| 79 | 59 | 'widget_name' => $widget_data['name'], |
| @@ -89,18 +69,14 @@ | ||
| 89 | 69 | if ( Black_Friday::should_display_notice() ) { |
| 90 | 70 | new Black_Friday(); |
| 91 | 71 | } |
| 92 | 72 | |
| 93 | - if ( ! Utils::has_pro() ) { | |
| 94 | - Conversion_Banner::register_cache_invalidation_hooks(); | |
| 73 | + add_filter( 'elementor/editor/localize_settings', [ $this, 'add_v4_promotions_data' ] ); | |
| 95 | 74 | |
| 96 | - if ( Conversion_Banner::should_display_banner() ) { | |
| 97 | - new Conversion_Banner(); | |
| 98 | - } | |
| 75 | + if ( Utils::has_pro() ) { | |
| 76 | + return; | |
| 99 | 77 | } |
| 100 | 78 | |
| 101 | - add_filter( 'elementor/editor/localize_settings', [ $this, 'add_editing_panel_sticky_promotion' ] ); | |
| 102 | - | |
| 103 | 79 | add_action( 'elementor/controls/register', function ( Controls_Manager $controls_manager ) { |
| 104 | 80 | $controls_manager->register( new Controls\Promotion_Control() ); |
| 105 | 81 | } ); |
| 106 | 82 | |
| @@ -106,11 +82,23 @@ | ||
| 106 | 82 | |
| 107 | 83 | add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_react_data' ] ); |
| 108 | 84 | add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_editor_v4_alphachip' ] ); |
| 109 | 85 | |
| 86 | + // Add Ally promo | |
| 87 | + Ally_Dashboard_Widget::init(); | |
| 88 | + | |
| 110 | 89 | $this->register_atomic_promotions(); |
| 111 | 90 | } |
| 112 | 91 | |
| 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 | + | |
| 113 | 101 | private function handle_external_redirects() { |
| 114 | 102 | $page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); |
| 115 | 103 | if ( empty( $page ) ) { |
| 116 | 104 | return; |
| @@ -115,34 +103,14 @@ | ||
| 115 | 103 | if ( empty( $page ) ) { |
| 116 | 104 | return; |
| 117 | 105 | } |
| 118 | 106 | |
| 119 | - if ( in_array( $page, [ 'go_elementor_pro', 'elementor-one-upgrade' ], true ) ) { | |
| 107 | + if ( 'go_elementor_pro' === $page ) { | |
| 120 | 108 | wp_redirect( Go_Pro_Promotion_Item::get_url() ); // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect |
| 121 | 109 | die; |
| 122 | 110 | } |
| 123 | 111 | } |
| 124 | 112 | |
| 125 | - public function override_one_menu_upgrade_label_during_sale( $menu ) { | |
| 126 | - global $submenu; | |
| 127 | - | |
| 128 | - $parent_slug = Menu_Config::ELEMENTOR_HOME_MENU_SLUG; | |
| 129 | - $upgrade_slug = 'elementor-one-upgrade'; | |
| 130 | - | |
| 131 | - if ( empty( $submenu[ $parent_slug ] ) ) { | |
| 132 | - return $menu; | |
| 133 | - } | |
| 134 | - | |
| 135 | - foreach ( $submenu[ $parent_slug ] as &$item ) { | |
| 136 | - if ( isset( $item[2] ) && $upgrade_slug === $item[2] ) { | |
| 137 | - $item[0] = esc_html__( 'Sale!', 'elementor' ) . '<br />' . esc_html__( 'Upgrade Now', 'elementor' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited | |
| 138 | - break; | |
| 139 | - } | |
| 140 | - } | |
| 141 | - | |
| 142 | - return $menu; | |
| 143 | - } | |
| 144 | - | |
| 145 | 113 | private function register_editor_one_menu_items( Menu_Data_Provider $menu_data_provider ) { |
| 146 | 114 | $menu_data_provider->register_menu( new Editor_One_Custom_Elements_Menu() ); |
| 147 | 115 | $menu_data_provider->register_menu( new Editor_One_Submissions_Menu() ); |
| 148 | 116 | $menu_data_provider->register_menu( new Editor_One_Fonts_Menu() ); |
| @@ -166,9 +134,8 @@ | ||
| 166 | 134 | 'react-dom', |
| 167 | 135 | 'backbone-marionette', |
| 168 | 136 | 'elementor-editor-modules', |
| 169 | 137 | 'elementor-v2-ui', |
| 170 | - 'elementor-v2-icons', | |
| 171 | 138 | ], |
| 172 | 139 | ELEMENTOR_VERSION, |
| 173 | 140 | true |
| 174 | 141 | ); |
| @@ -217,14 +184,8 @@ | ||
| 217 | 184 | EditorAssetsAPI::ASSETS_DATA_KEY => 'free-to-pro-upsell', |
| 218 | 185 | ]; |
| 219 | 186 | } |
| 220 | 187 | |
| 221 | - public function add_editing_panel_sticky_promotion( array $settings ): array { | |
| 222 | - $settings['editingPanelStickyPromotion'] = Filtered_Promotions_Manager::get_editor_panel_sticky_promotion(); | |
| 223 | - | |
| 224 | - return $settings; | |
| 225 | - } | |
| 226 | - | |
| 227 | 188 | public function add_v4_promotions_data( array $settings ): array { |
| 228 | 189 | if ( ! current_user_can( 'manage_options' ) ) { |
| 229 | 190 | return $settings; |
| 230 | 191 | } |
| @@ -265,19 +226,9 @@ | ||
| 265 | 226 | ], |
| 266 | 227 | ]; |
| 267 | 228 | } |
| 268 | 229 | |
| 269 | - private function should_register_core_atomic_panel_promotions(): bool { | |
| 270 | - // Pro with an active license registers real atomic widgets (or its own panel | |
| 271 | - // promotion layer). Core stubs caused duplicate panel entries after ED-25600. | |
| 272 | - return ! Utils::has_pro() || ! Utils::is_license_active(); | |
| 273 | - } | |
| 274 | - | |
| 275 | 230 | private function register_atomic_promotions(): void { |
| 276 | - if ( ! $this->should_register_core_atomic_panel_promotions() ) { | |
| 277 | - return; | |
| 278 | - } | |
| 279 | - | |
| 280 | 231 | add_action( 'elementor/init', function() { |
| 281 | 232 | if ( ! $this->is_atomic_widgets_active() ) { |
| 282 | 233 | return; |
| 283 | 234 | } |
| @@ -297,9 +248,8 @@ | ||
| 297 | 248 | } |
| 298 | 249 | } ); |
| 299 | 250 | |
| 300 | 251 | ( new Atomic_Form_Widget_Promotion() )->register(); |
| 301 | - ( new Collection_Loop_Widget_Promotion() )->register(); | |
| 302 | 252 | } |
| 303 | 253 | |
| 304 | 254 | public function inject_atomic_promotion_props( array $schema ): array { |
| 305 | 255 | foreach ( $this->get_atomic_promotion_configs() as $config ) { |