| @@ -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,9 @@ | ||
| 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 | + return ! Utils::has_pro() || ! Utils::is_license_active(); | |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | public function get_name() { |
| 45 | 45 | return 'promotions'; |
| @@ -47,8 +47,17 @@ | ||
| 47 | 47 | |
| 48 | 48 | public function __construct() { |
| 49 | 49 | parent::__construct(); |
| 50 | 50 | |
| 51 | + add_filter( 'elementor/editor/localize_settings', [ $this, 'add_v4_promotions_data' ] ); | |
| 52 | + | |
| 53 | + if ( Utils::has_pro() ) { | |
| 54 | + add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_react_data' ] ); | |
| 55 | + $this->register_atomic_promotions(); | |
| 56 | + | |
| 57 | + return; | |
| 58 | + } | |
| 59 | + | |
| 51 | 60 | add_action( 'admin_init', function () { |
| 52 | 61 | $this->handle_external_redirects(); |
| 53 | 62 | } ); |
| 54 | 63 | |
| @@ -76,18 +85,18 @@ | ||
| 76 | 85 | if ( Black_Friday::should_display_notice() ) { |
| 77 | 86 | new Black_Friday(); |
| 78 | 87 | } |
| 79 | 88 | |
| 80 | - if ( Conversion_Banner::should_display_banner() ) { | |
| 81 | - new Conversion_Banner(); | |
| 89 | + if ( ! Utils::has_pro() ) { | |
| 90 | + Conversion_Banner::register_cache_invalidation_hooks(); | |
| 91 | + | |
| 92 | + if ( Conversion_Banner::should_display_banner() ) { | |
| 93 | + new Conversion_Banner(); | |
| 94 | + } | |
| 82 | 95 | } |
| 83 | 96 | |
| 84 | - add_filter( 'elementor/editor/localize_settings', [ $this, 'add_v4_promotions_data' ] ); | |
| 97 | + add_filter( 'elementor/editor/localize_settings', [ $this, 'add_editing_panel_sticky_promotion' ] ); | |
| 85 | 98 | |
| 86 | - if ( Utils::has_pro() ) { | |
| 87 | - return; | |
| 88 | - } | |
| 89 | - | |
| 90 | 99 | add_action( 'elementor/controls/register', function ( Controls_Manager $controls_manager ) { |
| 91 | 100 | $controls_manager->register( new Controls\Promotion_Control() ); |
| 92 | 101 | } ); |
| 93 | 102 | |
| @@ -93,23 +102,11 @@ | ||
| 93 | 102 | |
| 94 | 103 | add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_react_data' ] ); |
| 95 | 104 | add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_editor_v4_alphachip' ] ); |
| 96 | 105 | |
| 97 | - // Add Ally promo | |
| 98 | - Ally_Dashboard_Widget::init(); | |
| 99 | - | |
| 100 | 106 | $this->register_atomic_promotions(); |
| 101 | 107 | } |
| 102 | 108 | |
| 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 | 109 | private function handle_external_redirects() { |
| 113 | 110 | $page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); |
| 114 | 111 | if ( empty( $page ) ) { |
| 115 | 112 | return; |
| @@ -114,9 +111,9 @@ | ||
| 114 | 111 | if ( empty( $page ) ) { |
| 115 | 112 | return; |
| 116 | 113 | } |
| 117 | 114 | |
| 118 | - if ( 'go_elementor_pro' === $page ) { | |
| 115 | + if ( in_array( $page, [ 'go_elementor_pro', 'elementor-one-upgrade' ], true ) ) { | |
| 119 | 116 | wp_redirect( Go_Pro_Promotion_Item::get_url() ); // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect |
| 120 | 117 | die; |
| 121 | 118 | } |
| 122 | 119 | } |
| @@ -165,8 +162,9 @@ | ||
| 165 | 162 | 'react-dom', |
| 166 | 163 | 'backbone-marionette', |
| 167 | 164 | 'elementor-editor-modules', |
| 168 | 165 | 'elementor-v2-ui', |
| 166 | + 'elementor-v2-icons', | |
| 169 | 167 | ], |
| 170 | 168 | ELEMENTOR_VERSION, |
| 171 | 169 | true |
| 172 | 170 | ); |
| @@ -215,8 +213,14 @@ | ||
| 215 | 213 | EditorAssetsAPI::ASSETS_DATA_KEY => 'free-to-pro-upsell', |
| 216 | 214 | ]; |
| 217 | 215 | } |
| 218 | 216 | |
| 217 | + public function add_editing_panel_sticky_promotion( array $settings ): array { | |
| 218 | + $settings['editingPanelStickyPromotion'] = Filtered_Promotions_Manager::get_editor_panel_sticky_promotion(); | |
| 219 | + | |
| 220 | + return $settings; | |
| 221 | + } | |
| 222 | + | |
| 219 | 223 | public function add_v4_promotions_data( array $settings ): array { |
| 220 | 224 | if ( ! current_user_can( 'manage_options' ) ) { |
| 221 | 225 | return $settings; |
| 222 | 226 | } |
| @@ -276,13 +280,12 @@ | ||
| 276 | 280 | $config['priority'], |
| 277 | 281 | 2 |
| 278 | 282 | ); |
| 279 | 283 | } |
| 280 | - | |
| 281 | - ( new Birthday_Easter_Egg_Promotion() )->register(); | |
| 282 | 284 | } ); |
| 283 | 285 | |
| 284 | 286 | ( new Atomic_Form_Widget_Promotion() )->register(); |
| 287 | + ( new Collection_Loop_Widget_Promotion() )->register(); | |
| 285 | 288 | } |
| 286 | 289 | |
| 287 | 290 | public function inject_atomic_promotion_props( array $schema ): array { |
| 288 | 291 | foreach ( $this->get_atomic_promotion_configs() as $config ) { |