| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\Promotions; |
| 4 |
|
| 5 |
use Elementor\Core\Admin\Menu\Admin_Menu_Manager; |
| 6 |
use Elementor\Core\Base\Module as Base_Module; |
| 7 |
use Elementor\Modules\Promotions\AdminMenuItems\Custom_Code_Promotion_Item; |
| 8 |
use Elementor\Modules\Promotions\AdminMenuItems\Custom_Fonts_Promotion_Item; |
| 9 |
use Elementor\Modules\Promotions\AdminMenuItems\Custom_Icons_Promotion_Item; |
| 10 |
use Elementor\Modules\Promotions\AdminMenuItems\Form_Submissions_Promotion_Item; |
| 11 |
use Elementor\Modules\Promotions\AdminMenuItems\Go_Pro_Promotion_Item; |
| 12 |
use Elementor\Modules\Promotions\AdminMenuItems\Popups_Promotion_Item; |
| 13 |
use Elementor\Utils; |
| 14 |
|
| 15 |
if ( ! defined( 'ABSPATH' ) ) { |
| 16 |
exit; // Exit if accessed directly |
| 17 |
} |
| 18 |
|
| 19 |
class Module extends Base_Module { |
| 20 |
|
| 21 |
const ADMIN_MENU_PRIORITY = 100; |
| 22 |
|
| 23 |
const ADMIN_MENU_PROMOTIONS_PRIORITY = 120; |
| 24 |
|
| 25 |
public static function is_active() { |
| 26 |
return ! Utils::has_pro(); |
| 27 |
} |
| 28 |
|
| 29 |
public function get_name() { |
| 30 |
return 'promotions'; |
| 31 |
} |
| 32 |
|
| 33 |
public function __construct() { |
| 34 |
parent::__construct(); |
| 35 |
|
| 36 |
add_action( 'admin_init', function () { |
| 37 |
$this->handle_external_redirects(); |
| 38 |
} ); |
| 39 |
|
| 40 |
add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) { |
| 41 |
$this->register_menu_items( $admin_menu ); |
| 42 |
}, static::ADMIN_MENU_PRIORITY ); |
| 43 |
|
| 44 |
add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) { |
| 45 |
$this->register_promotion_menu_item( $admin_menu ); |
| 46 |
}, static::ADMIN_MENU_PROMOTIONS_PRIORITY ); |
| 47 |
} |
| 48 |
|
| 49 |
private function handle_external_redirects() { |
| 50 |
if ( empty( $_GET['page'] ) ) { |
| 51 |
return; |
| 52 |
} |
| 53 |
|
| 54 |
if ( 'go_elementor_pro' === $_GET['page'] ) { |
| 55 |
wp_redirect( Go_Pro_Promotion_Item::URL ); |
| 56 |
die; |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
private function register_menu_items( Admin_Menu_Manager $admin_menu ) { |
| 61 |
$admin_menu->register( 'e-form-submissions', new Form_Submissions_Promotion_Item() ); |
| 62 |
$admin_menu->register( 'elementor_custom_fonts', new Custom_Fonts_Promotion_Item() ); |
| 63 |
$admin_menu->register( 'elementor_custom_icons', new Custom_Icons_Promotion_Item() ); |
| 64 |
$admin_menu->register( 'elementor_custom_code', new Custom_Code_Promotion_Item() ); |
| 65 |
$admin_menu->register( 'popup_templates', new Popups_Promotion_Item() ); |
| 66 |
} |
| 67 |
|
| 68 |
private function register_promotion_menu_item( Admin_Menu_Manager $admin_menu ) { |
| 69 |
$admin_menu->register( 'go_elementor_pro', new Go_Pro_Promotion_Item() ); |
| 70 |
} |
| 71 |
} |
| 72 |
|