| @@ -41,12 +41,22 @@ | ||
| 41 | 41 | |
| 42 | 42 | return $validated; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | + public function register_admin_menu( Admin_Menu_Manager $admin_menu ) { | |
| 46 | + if ( ! $this->is_editor_one_active() ) { | |
| 47 | + $admin_menu->register( static::PAGE_ID, new Connect_Menu_Item() ); | |
| 48 | + } | |
| 49 | + } | |
| 50 | + | |
| 45 | 51 | public function register_editor_one_menu( Menu_Data_Provider $menu_data_provider ) { |
| 46 | 52 | $menu_data_provider->register_menu( new Editor_One_Connect_Menu() ); |
| 47 | 53 | } |
| 48 | 54 | |
| 55 | + private function is_editor_one_active(): bool { | |
| 56 | + return (bool) Plugin::instance()->modules_manager->get_modules( 'editor-one' ); | |
| 57 | + } | |
| 58 | + | |
| 49 | 59 | /** |
| 50 | 60 | * @since 2.3.0 |
| 51 | 61 | * @access public |
| 52 | 62 | */ |
| @@ -111,9 +121,17 @@ | ||
| 111 | 121 | */ |
| 112 | 122 | public function __construct() { |
| 113 | 123 | self::$url = admin_url( 'admin.php?page=' . self::PAGE_ID ); |
| 114 | 124 | |
| 125 | + add_action( 'elementor/admin/menu/register', [ $this, 'register_admin_menu' ] ); | |
| 126 | + | |
| 115 | 127 | add_action( 'elementor/editor-one/menu/register', [ $this, 'register_editor_one_menu' ] ); |
| 128 | + | |
| 129 | + add_action( 'elementor/admin/menu/after_register', function ( Admin_Menu_Manager $admin_menu, array $hooks ) { | |
| 130 | + if ( ! empty( $hooks[ static::PAGE_ID ] ) ) { | |
| 131 | + add_action( 'load-' . $hooks[ static::PAGE_ID ], [ $this, 'on_load_page' ] ); | |
| 132 | + } | |
| 133 | + }, 10, 2 ); | |
| 116 | 134 | |
| 117 | 135 | add_action( 'elementor/editor-one/menu/after_register_hidden_submenus', function ( array $hooks ) { |
| 118 | 136 | if ( ! empty( $hooks[ static::PAGE_ID ] ) ) { |
| 119 | 137 | add_action( 'load-' . $hooks[ static::PAGE_ID ], [ $this, 'on_load_page' ] ); |