| @@ -3,10 +3,13 @@ | ||
| 3 | 3 | namespace Elementor\Modules\Promotions; |
| 4 | 4 | |
| 5 | 5 | use Elementor\Api; |
| 6 | 6 | use Elementor\Controls_Manager; |
| 7 | +use Elementor\Core\Admin\Menu\Admin_Menu_Manager; | |
| 7 | 8 | use Elementor\Core\Base\Module as Base_Module; |
| 8 | -use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager; | |
| 9 | +use Elementor\Modules\Promotions\AdminMenuItems\Custom_Code_Promotion_Item; | |
| 10 | +use Elementor\Modules\Promotions\AdminMenuItems\Custom_Fonts_Promotion_Item; | |
| 11 | +use Elementor\Modules\Promotions\AdminMenuItems\Custom_Icons_Promotion_Item; | |
| 9 | 12 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Custom_Code_Menu; |
| 10 | 13 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Custom_Elements_Menu; |
| 11 | 14 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Fonts_Menu; |
| 12 | 15 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Icons_Menu; |
| @@ -11,22 +14,20 @@ | ||
| 11 | 14 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Fonts_Menu; |
| 12 | 15 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Icons_Menu; |
| 13 | 16 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Popups_Menu; |
| 14 | 17 | use Elementor\Modules\Promotions\AdminMenuItems\Editor_One_Submissions_Menu; |
| 18 | +use Elementor\Modules\Promotions\AdminMenuItems\Form_Submissions_Promotion_Item; | |
| 15 | 19 | use Elementor\Modules\Promotions\AdminMenuItems\Go_Pro_Promotion_Item; |
| 20 | +use Elementor\Modules\Promotions\AdminMenuItems\Popups_Promotion_Item; | |
| 16 | 21 | use Elementor\Modules\Promotions\Controls\Atomic_Promotion_Control; |
| 17 | -use Elementor\Modules\Promotions\Conversion_Banner; | |
| 18 | 22 | use Elementor\Modules\Promotions\Pointers\Birthday; |
| 19 | 23 | use Elementor\Modules\Promotions\Pointers\Black_Friday; |
| 20 | 24 | use Elementor\Modules\Promotions\PropTypes\Promotion_Prop_Type; |
| 21 | 25 | use Elementor\Modules\Promotions\Widgets\Ally_Dashboard_Widget; |
| 22 | -use Elementor\Modules\Promotions\Widgets\Atomic_Form_Widget_Promotion; | |
| 23 | -use Elementor\Modules\Promotions\Widgets\Collection_Loop_Widget_Promotion; | |
| 24 | 26 | use Elementor\Widgets_Manager; |
| 25 | 27 | use Elementor\Utils; |
| 26 | 28 | use Elementor\Includes\EditorAssetsAPI; |
| 27 | 29 | use Elementor\Plugin; |
| 28 | -use Elementor\Modules\EditorOne\Classes\Menu_Config; | |
| 29 | 30 | use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider; |
| 30 | 31 | |
| 31 | 32 | if ( ! defined( 'ABSPATH' ) ) { |
| 32 | 33 | exit; // Exit if accessed directly. |
| @@ -38,9 +39,9 @@ | ||
| 38 | 39 | |
| 39 | 40 | const ADMIN_MENU_PROMOTIONS_PRIORITY = 120; |
| 40 | 41 | |
| 41 | 42 | public static function is_active() { |
| 42 | - return ! Utils::has_pro() || ! Utils::is_license_active(); | |
| 43 | + return ! Utils::has_pro(); | |
| 43 | 44 | } |
| 44 | 45 | |
| 45 | 46 | public function get_name() { |
| 46 | 47 | return 'promotions'; |
| @@ -48,28 +49,23 @@ | ||
| 48 | 49 | |
| 49 | 50 | public function __construct() { |
| 50 | 51 | parent::__construct(); |
| 51 | 52 | |
| 52 | - add_filter( 'elementor/editor/localize_settings', [ $this, 'add_v4_promotions_data' ] ); | |
| 53 | - | |
| 54 | - if ( Utils::has_pro() ) { | |
| 55 | - add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_react_data' ] ); | |
| 56 | - $this->register_atomic_promotions(); | |
| 57 | - | |
| 58 | - return; | |
| 59 | - } | |
| 60 | - | |
| 61 | 53 | add_action( 'admin_init', function () { |
| 62 | 54 | $this->handle_external_redirects(); |
| 63 | 55 | } ); |
| 64 | 56 | |
| 57 | + add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) { | |
| 58 | + $this->register_menu_items( $admin_menu ); | |
| 59 | + }, static::ADMIN_MENU_PRIORITY ); | |
| 60 | + | |
| 65 | 61 | add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) { |
| 66 | 62 | $this->register_editor_one_menu_items( $menu_data_provider ); |
| 67 | 63 | } ); |
| 68 | 64 | |
| 69 | - if ( Utils::is_sale_time() ) { | |
| 70 | - add_filter( 'add_menu_classes', [ $this, 'override_one_menu_upgrade_label_during_sale' ] ); | |
| 71 | - } | |
| 65 | + add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) { | |
| 66 | + $this->register_promotion_menu_item( $admin_menu ); | |
| 67 | + }, static::ADMIN_MENU_PROMOTIONS_PRIORITY ); | |
| 72 | 68 | |
| 73 | 69 | add_action( 'elementor/widgets/register', function( Widgets_Manager $manager ) { |
| 74 | 70 | foreach ( Api::get_promotion_widgets() as $widget_data ) { |
| 75 | 71 | $manager->register( new Widgets\Pro_Widget_Promotion( [], [ |
| @@ -86,14 +82,12 @@ | ||
| 86 | 82 | if ( Black_Friday::should_display_notice() ) { |
| 87 | 83 | new Black_Friday(); |
| 88 | 84 | } |
| 89 | 85 | |
| 90 | - if ( Conversion_Banner::should_display_banner() ) { | |
| 91 | - new Conversion_Banner(); | |
| 86 | + if ( Utils::has_pro() ) { | |
| 87 | + return; | |
| 92 | 88 | } |
| 93 | 89 | |
| 94 | - add_filter( 'elementor/editor/localize_settings', [ $this, 'add_editing_panel_sticky_promotion' ] ); | |
| 95 | - | |
| 96 | 90 | add_action( 'elementor/controls/register', function ( Controls_Manager $controls_manager ) { |
| 97 | 91 | $controls_manager->register( new Controls\Promotion_Control() ); |
| 98 | 92 | } ); |
| 99 | 93 | |
| @@ -98,8 +92,9 @@ | ||
| 98 | 92 | } ); |
| 99 | 93 | |
| 100 | 94 | add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_react_data' ] ); |
| 101 | 95 | add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_editor_v4_alphachip' ] ); |
| 96 | + add_filter( 'elementor/editor/localize_settings', [ $this, 'add_v4_promotions_data' ] ); | |
| 102 | 97 | |
| 103 | 98 | // Add Ally promo |
| 104 | 99 | Ally_Dashboard_Widget::init(); |
| 105 | 100 | |
| @@ -111,9 +106,9 @@ | ||
| 111 | 106 | * |
| 112 | 107 | * @return string |
| 113 | 108 | */ |
| 114 | 109 | public static function get_ally_external_scanner_url(): string { |
| 115 | - return apply_filters( 'elementor/ally_external_scanner_url', 'https://go.elementor.com/acc-checker-dashboard-plg' ); | |
| 110 | + return apply_filters( 'elementor/ally_external_scanner_url', 'https://elementor.com/tools/ally-accessibility-checker/scanner' ); | |
| 116 | 111 | } |
| 117 | 112 | |
| 118 | 113 | private function handle_external_redirects() { |
| 119 | 114 | $page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_FULL_SPECIAL_CHARS ); |
| @@ -120,32 +115,22 @@ | ||
| 120 | 115 | if ( empty( $page ) ) { |
| 121 | 116 | return; |
| 122 | 117 | } |
| 123 | 118 | |
| 124 | - if ( in_array( $page, [ 'go_elementor_pro', 'elementor-one-upgrade' ], true ) ) { | |
| 119 | + if ( 'go_elementor_pro' === $page ) { | |
| 125 | 120 | wp_redirect( Go_Pro_Promotion_Item::get_url() ); // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect |
| 126 | 121 | die; |
| 127 | 122 | } |
| 128 | 123 | } |
| 129 | 124 | |
| 130 | - public function override_one_menu_upgrade_label_during_sale( $menu ) { | |
| 131 | - global $submenu; | |
| 132 | - | |
| 133 | - $parent_slug = Menu_Config::ELEMENTOR_HOME_MENU_SLUG; | |
| 134 | - $upgrade_slug = 'elementor-one-upgrade'; | |
| 135 | - | |
| 136 | - if ( empty( $submenu[ $parent_slug ] ) ) { | |
| 137 | - return $menu; | |
| 125 | + private function register_menu_items( Admin_Menu_Manager $admin_menu ) { | |
| 126 | + if ( ! $this->is_editor_one_active() ) { | |
| 127 | + $admin_menu->register( 'e-form-submissions', new Form_Submissions_Promotion_Item() ); | |
| 128 | + $admin_menu->register( 'elementor_custom_fonts', new Custom_Fonts_Promotion_Item() ); | |
| 129 | + $admin_menu->register( 'elementor_custom_icons', new Custom_Icons_Promotion_Item() ); | |
| 130 | + $admin_menu->register( 'elementor_custom_code', new Custom_Code_Promotion_Item() ); | |
| 131 | + $admin_menu->register( 'popup_templates', new Popups_Promotion_Item() ); | |
| 138 | 132 | } |
| 139 | - | |
| 140 | - foreach ( $submenu[ $parent_slug ] as &$item ) { | |
| 141 | - if ( isset( $item[2] ) && $upgrade_slug === $item[2] ) { | |
| 142 | - $item[0] = esc_html__( 'Sale!', 'elementor' ) . '<br />' . esc_html__( 'Upgrade Now', 'elementor' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited | |
| 143 | - break; | |
| 144 | - } | |
| 145 | - } | |
| 146 | - | |
| 147 | - return $menu; | |
| 148 | 133 | } |
| 149 | 134 | |
| 150 | 135 | private function register_editor_one_menu_items( Menu_Data_Provider $menu_data_provider ) { |
| 151 | 136 | $menu_data_provider->register_menu( new Editor_One_Custom_Elements_Menu() ); |
| @@ -155,8 +140,14 @@ | ||
| 155 | 140 | $menu_data_provider->register_menu( new Editor_One_Custom_Code_Menu() ); |
| 156 | 141 | $menu_data_provider->register_menu( new Editor_One_Popups_Menu() ); |
| 157 | 142 | } |
| 158 | 143 | |
| 144 | + private function register_promotion_menu_item( Admin_Menu_Manager $admin_menu ) { | |
| 145 | + if ( ! $this->is_editor_one_active() ) { | |
| 146 | + $admin_menu->register( 'go_elementor_pro', new Go_Pro_Promotion_Item() ); | |
| 147 | + } | |
| 148 | + } | |
| 149 | + | |
| 159 | 150 | public function enqueue_react_data(): void { |
| 160 | 151 | if ( ! current_user_can( 'manage_options' ) ) { |
| 161 | 152 | return; |
| 162 | 153 | } |
| @@ -171,9 +162,8 @@ | ||
| 171 | 162 | 'react-dom', |
| 172 | 163 | 'backbone-marionette', |
| 173 | 164 | 'elementor-editor-modules', |
| 174 | 165 | 'elementor-v2-ui', |
| 175 | - 'elementor-v2-icons', | |
| 176 | 166 | ], |
| 177 | 167 | ELEMENTOR_VERSION, |
| 178 | 168 | true |
| 179 | 169 | ); |
| @@ -222,18 +212,8 @@ | ||
| 222 | 212 | EditorAssetsAPI::ASSETS_DATA_KEY => 'free-to-pro-upsell', |
| 223 | 213 | ]; |
| 224 | 214 | } |
| 225 | 215 | |
| 226 | - public function add_editing_panel_sticky_promotion( array $settings ): array { | |
| 227 | - if ( ! Plugin::$instance->experiments->is_feature_active( 'e_panel_promotions' ) ) { | |
| 228 | - return $settings; | |
| 229 | - } | |
| 230 | - | |
| 231 | - $settings['editingPanelStickyPromotion'] = Filtered_Promotions_Manager::get_editor_panel_sticky_promotion(); | |
| 232 | - | |
| 233 | - return $settings; | |
| 234 | - } | |
| 235 | - | |
| 236 | 216 | public function add_v4_promotions_data( array $settings ): array { |
| 237 | 217 | if ( ! current_user_can( 'manage_options' ) ) { |
| 238 | 218 | return $settings; |
| 239 | 219 | } |
| @@ -253,8 +233,12 @@ | ||
| 253 | 233 | EditorAssetsAPI::ASSETS_DATA_KEY => 'promotions', |
| 254 | 234 | ]; |
| 255 | 235 | } |
| 256 | 236 | |
| 237 | + private function is_editor_one_active(): bool { | |
| 238 | + return (bool) Plugin::instance()->modules_manager->get_modules( 'editor-one' ); | |
| 239 | + } | |
| 240 | + | |
| 257 | 241 | private function is_atomic_widgets_active(): bool { |
| 258 | 242 | return Plugin::$instance->experiments->is_feature_active( 'e_atomic_elements' ); |
| 259 | 243 | } |
| 260 | 244 | |
| @@ -294,11 +278,8 @@ | ||
| 294 | 278 | 2 |
| 295 | 279 | ); |
| 296 | 280 | } |
| 297 | 281 | } ); |
| 298 | - | |
| 299 | - ( new Atomic_Form_Widget_Promotion() )->register(); | |
| 300 | - ( new Collection_Loop_Widget_Promotion() )->register(); | |
| 301 | 282 | } |
| 302 | 283 | |
| 303 | 284 | public function inject_atomic_promotion_props( array $schema ): array { |
| 304 | 285 | foreach ( $this->get_atomic_promotion_configs() as $config ) { |