| @@ -1,8 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elementor\App\Modules\KitLibrary; |
| 3 | 3 | |
| 4 | 4 | use Elementor\App\Modules\KitLibrary\Data\Repository; |
| 5 | +use Elementor\Core\Admin\Menu\Admin_Menu_Manager; | |
| 6 | +use Elementor\Core\Admin\Menu\Main as MainMenu; | |
| 5 | 7 | use Elementor\Plugin; |
| 6 | 8 | use Elementor\TemplateLibrary\Source_Local; |
| 7 | 9 | use Elementor\Core\Base\Module as BaseModule; |
| 8 | 10 | use Elementor\App\Modules\KitLibrary\Connect\Kit_Library; |
| @@ -29,12 +31,34 @@ | ||
| 29 | 31 | public function get_name() { |
| 30 | 32 | return 'kit-library'; |
| 31 | 33 | } |
| 32 | 34 | |
| 35 | + private function register_admin_menu( MainMenu $menu ) { | |
| 36 | + $menu->add_submenu( [ | |
| 37 | + 'page_title' => esc_html__( 'Website Templates', 'elementor' ), | |
| 38 | + 'menu_title' => '<span id="e-admin-menu__kit-library">' . esc_html__( 'Website Templates', 'elementor' ) . '</span>', | |
| 39 | + 'menu_slug' => Plugin::$instance->app->get_base_url() . '&source=wp_db_templates_menu#/kit-library', | |
| 40 | + 'index' => 40, | |
| 41 | + ] ); | |
| 42 | + } | |
| 43 | + | |
| 44 | + private function register_admin_menu_legacy( Admin_Menu_Manager $admin_menu ) { | |
| 45 | + if ( ! $this->is_editor_one_active() ) { | |
| 46 | + $admin_menu->register( | |
| 47 | + Plugin::$instance->app->get_base_url() . '&source=wp_db_templates_menu#/kit-library', | |
| 48 | + new Kit_Library_Menu_Item() | |
| 49 | + ); | |
| 50 | + } | |
| 51 | + } | |
| 52 | + | |
| 33 | 53 | private function register_editor_one_menu( Menu_Data_Provider $menu_data_provider ) { |
| 34 | 54 | $menu_data_provider->register_menu( new Editor_One_Website_Templates_Menu() ); |
| 35 | 55 | } |
| 36 | 56 | |
| 57 | + private function is_editor_one_active(): bool { | |
| 58 | + return (bool) Plugin::instance()->modules_manager->get_modules( 'editor-one' ); | |
| 59 | + } | |
| 60 | + | |
| 37 | 61 | private function set_kit_library_settings() { |
| 38 | 62 | if ( ! Plugin::$instance->common ) { |
| 39 | 63 | return; |
| 40 | 64 | } |
| @@ -59,11 +83,8 @@ | ||
| 59 | 83 | 'access_level' => ConnectModule::ACCESS_LEVEL_CORE, |
| 60 | 84 | 'access_tier' => ConnectModule::ACCESS_TIER_FREE, |
| 61 | 85 | 'plan_type' => ConnectModule::ACCESS_TIER_FREE, |
| 62 | 86 | 'app_url' => Plugin::$instance->app->get_base_url() . '#/' . $this->get_name(), |
| 63 | - 'urls' => [ | |
| 64 | - 'createNewPage' => Plugin::$instance->documents->get_create_new_post_url(), | |
| 65 | - ], | |
| 66 | 87 | ] ); |
| 67 | 88 | } |
| 68 | 89 | |
| 69 | 90 | private function apply_filter_subscription_plans( array $subscription_plans ): array { |
| @@ -96,8 +117,12 @@ | ||
| 96 | 117 | |
| 97 | 118 | public function register_actions() { |
| 98 | 119 | // Assigning this action here since the repository is being loaded by demand. |
| 99 | 120 | add_action( 'elementor/experiments/feature-state-change/container', [ Repository::class, 'clear_cache' ], 10, 0 ); |
| 121 | + | |
| 122 | + add_action( 'elementor/admin/menu/register', function( Admin_Menu_Manager $admin_menu ) { | |
| 123 | + $this->register_admin_menu_legacy( $admin_menu ); | |
| 124 | + }, Source_Local::ADMIN_MENU_PRIORITY + 30 ); | |
| 100 | 125 | |
| 101 | 126 | add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) { |
| 102 | 127 | $this->register_editor_one_menu( $menu_data_provider ); |
| 103 | 128 | } ); |