| @@ -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; |
| @@ -12,17 +13,19 @@ | ||
| 12 | 13 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Popups_Menu; |
| 13 | 14 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Submissions_Menu; |
| 14 | 15 | use Elementor\Modules\Promotions\AdminMenuItems\Go_Pro_Promotion_Item; |
| 15 | 16 | use Elementor\Modules\Promotions\Controls\Atomic_Promotion_Control; |
| 17 | +use Elementor\Modules\Promotions\Conversion_Banner; | |
| 16 | 18 | use Elementor\Modules\Promotions\Pointers\Birthday; |
| 17 | 19 | use Elementor\Modules\Promotions\Pointers\Black_Friday; |
| 18 | 20 | use Elementor\Modules\Promotions\PropTypes\Promotion_Prop_Type; |
| 19 | -use Elementor\Modules\Promotions\Widgets\Ally_Dashboard_Widget; | |
| 20 | 21 | use Elementor\Modules\Promotions\Widgets\Atomic_Form_Widget_Promotion; |
| 22 | +use Elementor\Modules\Promotions\Widgets\Collection_Loop_Widget_Promotion; | |
| 21 | 23 | use Elementor\Widgets_Manager; |
| 22 | 24 | use Elementor\Utils; |
| 23 | 25 | use Elementor\Includes\EditorAssetsAPI; |
| 24 | 26 | use Elementor\Plugin; |
| 27 | +use Elementor\Modules\EditorOne\Classes\Menu_Config; | |
| 25 | 28 | use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider; |
| 26 | 29 | |
| 27 | 30 | if ( ! defined( 'ABSPATH' ) ) { |
| 28 | 31 | exit; // Exit if accessed directly. |
| @@ -34,9 +37,9 @@ | ||
| 34 | 37 | |
| 35 | 38 | const ADMIN_MENU_PROMOTIONS_PRIORITY = 120; |
| 36 | 39 | |
| 37 | 40 | public static function is_active() { |
| 38 | - return ! Utils::has_pro(); | |
| 41 | + return ! Utils::has_pro() || ! Utils::is_license_active(); | |
| 39 | 42 | } |
| 40 | 43 | |
| 41 | 44 | public function get_name() { |
| 42 | 45 | return 'promotions'; |
| @@ -44,8 +47,17 @@ | ||
| 44 | 47 | |
| 45 | 48 | public function __construct() { |
| 46 | 49 | parent::__construct(); |
| 47 | 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 | + | |
| 48 | 60 | add_action( 'admin_init', function () { |
| 49 | 61 | $this->handle_external_redirects(); |
| 50 | 62 | } ); |
| 51 | 63 | |
| @@ -52,8 +64,12 @@ | ||
| 52 | 64 | add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) { |
| 53 | 65 | $this->register_editor_one_menu_items( $menu_data_provider ); |
| 54 | 66 | } ); |
| 55 | 67 | |
| 68 | + if ( Utils::is_sale_time() ) { | |
| 69 | + add_filter( 'add_menu_classes', [ $this, 'override_one_menu_upgrade_label_during_sale' ] ); | |
| 70 | + } | |
| 71 | + | |
| 56 | 72 | add_action( 'elementor/widgets/register', function( Widgets_Manager $manager ) { |
| 57 | 73 | foreach ( Api::get_promotion_widgets() as $widget_data ) { |
| 58 | 74 | $manager->register( new Widgets\Pro_Widget_Promotion( [], [ |
| 59 | 75 | 'widget_name' => $widget_data['name'], |
| @@ -69,13 +85,13 @@ | ||
| 69 | 85 | if ( Black_Friday::should_display_notice() ) { |
| 70 | 86 | new Black_Friday(); |
| 71 | 87 | } |
| 72 | 88 | |
| 73 | - add_filter( 'elementor/editor/localize_settings', [ $this, 'add_v4_promotions_data' ] ); | |
| 89 | + if ( Conversion_Banner::should_display_banner() ) { | |
| 90 | + new Conversion_Banner(); | |
| 91 | + } | |
| 74 | 92 | |
| 75 | - if ( Utils::has_pro() ) { | |
| 76 | - return; | |
| 77 | - } | |
| 93 | + add_filter( 'elementor/editor/localize_settings', [ $this, 'add_editing_panel_sticky_promotion' ] ); | |
| 78 | 94 | |
| 79 | 95 | add_action( 'elementor/controls/register', function ( Controls_Manager $controls_manager ) { |
| 80 | 96 | $controls_manager->register( new Controls\Promotion_Control() ); |
| 81 | 97 | } ); |
| @@ -82,23 +98,11 @@ | ||
| 82 | 98 | |
| 83 | 99 | add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_react_data' ] ); |
| 84 | 100 | add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_editor_v4_alphachip' ] ); |
| 85 | 101 | |
| 86 | - // Add Ally promo | |
| 87 | - Ally_Dashboard_Widget::init(); | |
| 88 | - | |
| 89 | 102 | $this->register_atomic_promotions(); |
| 90 | 103 | } |
| 91 | 104 | |
| 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 | - | |
| 101 | 105 | private function handle_external_redirects() { |
| 102 | 106 | $page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); |
| 103 | 107 | if ( empty( $page ) ) { |
| 104 | 108 | return; |
| @@ -103,14 +107,34 @@ | ||
| 103 | 107 | if ( empty( $page ) ) { |
| 104 | 108 | return; |
| 105 | 109 | } |
| 106 | 110 | |
| 107 | - if ( 'go_elementor_pro' === $page ) { | |
| 111 | + if ( in_array( $page, [ 'go_elementor_pro', 'elementor-one-upgrade' ], true ) ) { | |
| 108 | 112 | wp_redirect( Go_Pro_Promotion_Item::get_url() ); // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect |
| 109 | 113 | die; |
| 110 | 114 | } |
| 111 | 115 | } |
| 112 | 116 | |
| 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 | + | |
| 113 | 137 | private function register_editor_one_menu_items( Menu_Data_Provider $menu_data_provider ) { |
| 114 | 138 | $menu_data_provider->register_menu( new Editor_One_Custom_Elements_Menu() ); |
| 115 | 139 | $menu_data_provider->register_menu( new Editor_One_Submissions_Menu() ); |
| 116 | 140 | $menu_data_provider->register_menu( new Editor_One_Fonts_Menu() ); |
| @@ -134,8 +158,9 @@ | ||
| 134 | 158 | 'react-dom', |
| 135 | 159 | 'backbone-marionette', |
| 136 | 160 | 'elementor-editor-modules', |
| 137 | 161 | 'elementor-v2-ui', |
| 162 | + 'elementor-v2-icons', | |
| 138 | 163 | ], |
| 139 | 164 | ELEMENTOR_VERSION, |
| 140 | 165 | true |
| 141 | 166 | ); |
| @@ -184,8 +209,18 @@ | ||
| 184 | 209 | EditorAssetsAPI::ASSETS_DATA_KEY => 'free-to-pro-upsell', |
| 185 | 210 | ]; |
| 186 | 211 | } |
| 187 | 212 | |
| 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 | + | |
| 188 | 223 | public function add_v4_promotions_data( array $settings ): array { |
| 189 | 224 | if ( ! current_user_can( 'manage_options' ) ) { |
| 190 | 225 | return $settings; |
| 191 | 226 | } |
| @@ -248,8 +283,9 @@ | ||
| 248 | 283 | } |
| 249 | 284 | } ); |
| 250 | 285 | |
| 251 | 286 | ( new Atomic_Form_Widget_Promotion() )->register(); |
| 287 | + ( new Collection_Loop_Widget_Promotion() )->register(); | |
| 252 | 288 | } |
| 253 | 289 | |
| 254 | 290 | public function inject_atomic_promotion_props( array $schema ): array { |
| 255 | 291 | foreach ( $this->get_atomic_promotion_configs() as $config ) { |