| @@ -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; |
| @@ -16,11 +17,10 @@ | ||
| 16 | 17 | use Elementor\Modules\Promotions\Conversion_Banner; |
| 17 | 18 | use Elementor\Modules\Promotions\Pointers\Birthday; |
| 18 | 19 | use Elementor\Modules\Promotions\Pointers\Black_Friday; |
| 19 | 20 | use Elementor\Modules\Promotions\PropTypes\Promotion_Prop_Type; |
| 20 | -use Elementor\Modules\Promotions\Widgets\Ally_Dashboard_Widget; | |
| 21 | 21 | use Elementor\Modules\Promotions\Widgets\Atomic_Form_Widget_Promotion; |
| 22 | -use Elementor\Modules\Promotions\Widgets\Birthday_Easter_Egg_Promotion; | |
| 22 | +use Elementor\Modules\Promotions\Widgets\Collection_Loop_Widget_Promotion; | |
| 23 | 23 | use Elementor\Widgets_Manager; |
| 24 | 24 | use Elementor\Utils; |
| 25 | 25 | use Elementor\Includes\EditorAssetsAPI; |
| 26 | 26 | use Elementor\Plugin; |
| @@ -37,9 +37,13 @@ | ||
| 37 | 37 | |
| 38 | 38 | const ADMIN_MENU_PROMOTIONS_PRIORITY = 120; |
| 39 | 39 | |
| 40 | 40 | public static function is_active() { |
| 41 | - return ! Utils::has_pro(); | |
| 41 | + if ( Utils::has_pro() ) { | |
| 42 | + return true; | |
| 43 | + } | |
| 44 | + | |
| 45 | + return ! Utils::is_license_active(); | |
| 42 | 46 | } |
| 43 | 47 | |
| 44 | 48 | public function get_name() { |
| 45 | 49 | return 'promotions'; |
| @@ -47,8 +51,17 @@ | ||
| 47 | 51 | |
| 48 | 52 | public function __construct() { |
| 49 | 53 | parent::__construct(); |
| 50 | 54 | |
| 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 | + | |
| 51 | 64 | add_action( 'admin_init', function () { |
| 52 | 65 | $this->handle_external_redirects(); |
| 53 | 66 | } ); |
| 54 | 67 | |
| @@ -76,18 +89,18 @@ | ||
| 76 | 89 | if ( Black_Friday::should_display_notice() ) { |
| 77 | 90 | new Black_Friday(); |
| 78 | 91 | } |
| 79 | 92 | |
| 80 | - if ( Conversion_Banner::should_display_banner() ) { | |
| 81 | - new Conversion_Banner(); | |
| 93 | + if ( ! Utils::has_pro() ) { | |
| 94 | + Conversion_Banner::register_cache_invalidation_hooks(); | |
| 95 | + | |
| 96 | + if ( Conversion_Banner::should_display_banner() ) { | |
| 97 | + new Conversion_Banner(); | |
| 98 | + } | |
| 82 | 99 | } |
| 83 | 100 | |
| 84 | - add_filter( 'elementor/editor/localize_settings', [ $this, 'add_v4_promotions_data' ] ); | |
| 101 | + add_filter( 'elementor/editor/localize_settings', [ $this, 'add_editing_panel_sticky_promotion' ] ); | |
| 85 | 102 | |
| 86 | - if ( Utils::has_pro() ) { | |
| 87 | - return; | |
| 88 | - } | |
| 89 | - | |
| 90 | 103 | add_action( 'elementor/controls/register', function ( Controls_Manager $controls_manager ) { |
| 91 | 104 | $controls_manager->register( new Controls\Promotion_Control() ); |
| 92 | 105 | } ); |
| 93 | 106 | |
| @@ -93,23 +106,11 @@ | ||
| 93 | 106 | |
| 94 | 107 | add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_react_data' ] ); |
| 95 | 108 | add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_editor_v4_alphachip' ] ); |
| 96 | 109 | |
| 97 | - // Add Ally promo | |
| 98 | - Ally_Dashboard_Widget::init(); | |
| 99 | - | |
| 100 | 110 | $this->register_atomic_promotions(); |
| 101 | 111 | } |
| 102 | 112 | |
| 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 | 113 | private function handle_external_redirects() { |
| 113 | 114 | $page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); |
| 114 | 115 | if ( empty( $page ) ) { |
| 115 | 116 | return; |
| @@ -114,9 +115,9 @@ | ||
| 114 | 115 | if ( empty( $page ) ) { |
| 115 | 116 | return; |
| 116 | 117 | } |
| 117 | 118 | |
| 118 | - if ( 'go_elementor_pro' === $page ) { | |
| 119 | + if ( in_array( $page, [ 'go_elementor_pro', 'elementor-one-upgrade' ], true ) ) { | |
| 119 | 120 | wp_redirect( Go_Pro_Promotion_Item::get_url() ); // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect |
| 120 | 121 | die; |
| 121 | 122 | } |
| 122 | 123 | } |
| @@ -165,8 +166,9 @@ | ||
| 165 | 166 | 'react-dom', |
| 166 | 167 | 'backbone-marionette', |
| 167 | 168 | 'elementor-editor-modules', |
| 168 | 169 | 'elementor-v2-ui', |
| 170 | + 'elementor-v2-icons', | |
| 169 | 171 | ], |
| 170 | 172 | ELEMENTOR_VERSION, |
| 171 | 173 | true |
| 172 | 174 | ); |
| @@ -215,8 +217,14 @@ | ||
| 215 | 217 | EditorAssetsAPI::ASSETS_DATA_KEY => 'free-to-pro-upsell', |
| 216 | 218 | ]; |
| 217 | 219 | } |
| 218 | 220 | |
| 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 | + | |
| 219 | 227 | public function add_v4_promotions_data( array $settings ): array { |
| 220 | 228 | if ( ! current_user_can( 'manage_options' ) ) { |
| 221 | 229 | return $settings; |
| 222 | 230 | } |
| @@ -257,9 +265,19 @@ | ||
| 257 | 265 | ], |
| 258 | 266 | ]; |
| 259 | 267 | } |
| 260 | 268 | |
| 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 | + | |
| 261 | 275 | private function register_atomic_promotions(): void { |
| 276 | + if ( ! $this->should_register_core_atomic_panel_promotions() ) { | |
| 277 | + return; | |
| 278 | + } | |
| 279 | + | |
| 262 | 280 | add_action( 'elementor/init', function() { |
| 263 | 281 | if ( ! $this->is_atomic_widgets_active() ) { |
| 264 | 282 | return; |
| 265 | 283 | } |
| @@ -276,13 +294,12 @@ | ||
| 276 | 294 | $config['priority'], |
| 277 | 295 | 2 |
| 278 | 296 | ); |
| 279 | 297 | } |
| 280 | - | |
| 281 | - ( new Birthday_Easter_Egg_Promotion() )->register(); | |
| 282 | 298 | } ); |
| 283 | 299 | |
| 284 | 300 | ( new Atomic_Form_Widget_Promotion() )->register(); |
| 301 | + ( new Collection_Loop_Widget_Promotion() )->register(); | |
| 285 | 302 | } |
| 286 | 303 | |
| 287 | 304 | public function inject_atomic_promotion_props( array $schema ): array { |
| 288 | 305 | foreach ( $this->get_atomic_promotion_configs() as $config ) { |