| @@ -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,9 +34,9 @@ | ||
| 37 | 34 | |
| 38 | 35 | const ADMIN_MENU_PROMOTIONS_PRIORITY = 120; |
| 39 | 36 | |
| 40 | 37 | public static function is_active() { |
| 41 | - return ! Utils::has_pro() || ! Utils::is_license_active(); | |
| 38 | + return ! Utils::has_pro(); | |
| 42 | 39 | } |
| 43 | 40 | |
| 44 | 41 | public function get_name() { |
| 45 | 42 | return 'promotions'; |
| @@ -47,17 +44,8 @@ | ||
| 47 | 44 | |
| 48 | 45 | public function __construct() { |
| 49 | 46 | parent::__construct(); |
| 50 | 47 | |
| 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 | - | |
| 60 | 48 | add_action( 'admin_init', function () { |
| 61 | 49 | $this->handle_external_redirects(); |
| 62 | 50 | } ); |
| 63 | 51 | |
| @@ -64,12 +52,8 @@ | ||
| 64 | 52 | add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) { |
| 65 | 53 | $this->register_editor_one_menu_items( $menu_data_provider ); |
| 66 | 54 | } ); |
| 67 | 55 | |
| 68 | - if ( Utils::is_sale_time() ) { | |
| 69 | - add_filter( 'add_menu_classes', [ $this, 'override_one_menu_upgrade_label_during_sale' ] ); | |
| 70 | - } | |
| 71 | - | |
| 72 | 56 | add_action( 'elementor/widgets/register', function( Widgets_Manager $manager ) { |
| 73 | 57 | foreach ( Api::get_promotion_widgets() as $widget_data ) { |
| 74 | 58 | $manager->register( new Widgets\Pro_Widget_Promotion( [], [ |
| 75 | 59 | 'widget_name' => $widget_data['name'], |
| @@ -85,14 +69,12 @@ | ||
| 85 | 69 | if ( Black_Friday::should_display_notice() ) { |
| 86 | 70 | new Black_Friday(); |
| 87 | 71 | } |
| 88 | 72 | |
| 89 | - if ( Conversion_Banner::should_display_banner() ) { | |
| 90 | - new Conversion_Banner(); | |
| 73 | + if ( Utils::has_pro() ) { | |
| 74 | + return; | |
| 91 | 75 | } |
| 92 | 76 | |
| 93 | - add_filter( 'elementor/editor/localize_settings', [ $this, 'add_editing_panel_sticky_promotion' ] ); | |
| 94 | - | |
| 95 | 77 | add_action( 'elementor/controls/register', function ( Controls_Manager $controls_manager ) { |
| 96 | 78 | $controls_manager->register( new Controls\Promotion_Control() ); |
| 97 | 79 | } ); |
| 98 | 80 | |
| @@ -97,12 +79,25 @@ | ||
| 97 | 79 | } ); |
| 98 | 80 | |
| 99 | 81 | add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_react_data' ] ); |
| 100 | 82 | add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_editor_v4_alphachip' ] ); |
| 83 | + add_filter( 'elementor/editor/localize_settings', [ $this, 'add_v4_promotions_data' ] ); | |
| 101 | 84 | |
| 85 | + // Add Ally promo | |
| 86 | + Ally_Dashboard_Widget::init(); | |
| 87 | + | |
| 102 | 88 | $this->register_atomic_promotions(); |
| 103 | 89 | } |
| 104 | 90 | |
| 91 | + /** | |
| 92 | + * Get Ally Scanner URL | |
| 93 | + * | |
| 94 | + * @return string | |
| 95 | + */ | |
| 96 | + public static function get_ally_external_scanner_url(): string { | |
| 97 | + return apply_filters( 'elementor/ally_external_scanner_url', 'https://go.elementor.com/acc-checker-dashboard-plg' ); | |
| 98 | + } | |
| 99 | + | |
| 105 | 100 | private function handle_external_redirects() { |
| 106 | 101 | $page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); |
| 107 | 102 | if ( empty( $page ) ) { |
| 108 | 103 | return; |
| @@ -107,34 +102,14 @@ | ||
| 107 | 102 | if ( empty( $page ) ) { |
| 108 | 103 | return; |
| 109 | 104 | } |
| 110 | 105 | |
| 111 | - if ( in_array( $page, [ 'go_elementor_pro', 'elementor-one-upgrade' ], true ) ) { | |
| 106 | + if ( 'go_elementor_pro' === $page ) { | |
| 112 | 107 | wp_redirect( Go_Pro_Promotion_Item::get_url() ); // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect |
| 113 | 108 | die; |
| 114 | 109 | } |
| 115 | 110 | } |
| 116 | 111 | |
| 117 | - public function override_one_menu_upgrade_label_during_sale( $menu ) { | |
| 118 | - global $submenu; | |
| 119 | - | |
| 120 | - $parent_slug = Menu_Config::ELEMENTOR_HOME_MENU_SLUG; | |
| 121 | - $upgrade_slug = 'elementor-one-upgrade'; | |
| 122 | - | |
| 123 | - if ( empty( $submenu[ $parent_slug ] ) ) { | |
| 124 | - return $menu; | |
| 125 | - } | |
| 126 | - | |
| 127 | - foreach ( $submenu[ $parent_slug ] as &$item ) { | |
| 128 | - if ( isset( $item[2] ) && $upgrade_slug === $item[2] ) { | |
| 129 | - $item[0] = esc_html__( 'Sale!', 'elementor' ) . '<br />' . esc_html__( 'Upgrade Now', 'elementor' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited | |
| 130 | - break; | |
| 131 | - } | |
| 132 | - } | |
| 133 | - | |
| 134 | - return $menu; | |
| 135 | - } | |
| 136 | - | |
| 137 | 112 | private function register_editor_one_menu_items( Menu_Data_Provider $menu_data_provider ) { |
| 138 | 113 | $menu_data_provider->register_menu( new Editor_One_Custom_Elements_Menu() ); |
| 139 | 114 | $menu_data_provider->register_menu( new Editor_One_Submissions_Menu() ); |
| 140 | 115 | $menu_data_provider->register_menu( new Editor_One_Fonts_Menu() ); |
| @@ -158,9 +133,8 @@ | ||
| 158 | 133 | 'react-dom', |
| 159 | 134 | 'backbone-marionette', |
| 160 | 135 | 'elementor-editor-modules', |
| 161 | 136 | 'elementor-v2-ui', |
| 162 | - 'elementor-v2-icons', | |
| 163 | 137 | ], |
| 164 | 138 | ELEMENTOR_VERSION, |
| 165 | 139 | true |
| 166 | 140 | ); |
| @@ -209,18 +183,8 @@ | ||
| 209 | 183 | EditorAssetsAPI::ASSETS_DATA_KEY => 'free-to-pro-upsell', |
| 210 | 184 | ]; |
| 211 | 185 | } |
| 212 | 186 | |
| 213 | - public function add_editing_panel_sticky_promotion( array $settings ): array { | |
| 214 | - if ( ! Plugin::$instance->experiments->is_feature_active( 'e_panel_promotions' ) ) { | |
| 215 | - return $settings; | |
| 216 | - } | |
| 217 | - | |
| 218 | - $settings['editingPanelStickyPromotion'] = Filtered_Promotions_Manager::get_editor_panel_sticky_promotion(); | |
| 219 | - | |
| 220 | - return $settings; | |
| 221 | - } | |
| 222 | - | |
| 223 | 187 | public function add_v4_promotions_data( array $settings ): array { |
| 224 | 188 | if ( ! current_user_can( 'manage_options' ) ) { |
| 225 | 189 | return $settings; |
| 226 | 190 | } |
| @@ -283,9 +247,8 @@ | ||
| 283 | 247 | } |
| 284 | 248 | } ); |
| 285 | 249 | |
| 286 | 250 | ( new Atomic_Form_Widget_Promotion() )->register(); |
| 287 | - ( new Collection_Loop_Widget_Promotion() )->register(); | |
| 288 | 251 | } |
| 289 | 252 | |
| 290 | 253 | public function inject_atomic_promotion_props( array $schema ): array { |
| 291 | 254 | foreach ( $this->get_atomic_promotion_configs() as $config ) { |