| @@ -10,14 +10,17 @@ | ||
| 10 | 10 | exit; // Exit if accessed directly. |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | class Admin_Menu_Manager { |
| 14 | - | |
| 15 | 14 | /** |
| 16 | 15 | * @var Admin_Menu_Item[] |
| 17 | 16 | */ |
| 18 | 17 | private $items = []; |
| 19 | 18 | |
| 19 | + public function __construct() { | |
| 20 | + add_action( 'admin_init', [ $this, 'handle_external_redirects' ] ); | |
| 21 | + } | |
| 22 | + | |
| 20 | 23 | public function register( $item_slug, Admin_Menu_Item $item ) { |
| 21 | 24 | $this->items[ $item_slug ] = $item; |
| 22 | 25 | } |
| 23 | 26 | |
| @@ -44,8 +47,32 @@ | ||
| 44 | 47 | |
| 45 | 48 | add_action( 'admin_head', function () { |
| 46 | 49 | $this->hide_invisible_menus(); |
| 47 | 50 | } ); |
| 51 | + | |
| 52 | + add_action( 'elementor/admin/menu/register', [ $this, 'register_cloud_hosting_plans' ], 999 ); | |
| 53 | + } | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * Register Cloud Hosting Plans menu item. | |
| 57 | + */ | |
| 58 | + public function register_cloud_hosting_plans( Admin_Menu_Manager $admin_menu ) { | |
| 59 | + $admin_menu->register( 'go_cloud_hosting_plans', new Cloud_Hosting_Plans_Menu_Item() ); | |
| 60 | + } | |
| 61 | + | |
| 62 | + /** | |
| 63 | + * Handle external redirects. | |
| 64 | + */ | |
| 65 | + public function handle_external_redirects() { | |
| 66 | + if ( empty( $_GET['page'] ) ) { | |
| 67 | + return; | |
| 68 | + } | |
| 69 | + | |
| 70 | + if ( 'go_cloud_hosting_plans' === $_GET['page'] ) { | |
| 71 | + wp_redirect( Cloud_Hosting_Plans_Menu_Item::get_url() ); | |
| 72 | + | |
| 73 | + exit; | |
| 74 | + } | |
| 48 | 75 | } |
| 49 | 76 | |
| 50 | 77 | private function register_wp_menus() { |
| 51 | 78 | do_action( 'elementor/admin/menu/register', $this ); |