| @@ -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; |
| @@ -10,10 +12,8 @@ | ||
| 10 | 12 | use Elementor\App\Modules\KitLibrary\Data\Kits\Controller as Kits_Controller; |
| 11 | 13 | use Elementor\App\Modules\KitLibrary\Data\Taxonomies\Controller as Taxonomies_Controller; |
| 12 | 14 | use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager; |
| 13 | 15 | use Elementor\Utils as ElementorUtils; |
| 14 | -use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider; | |
| 15 | -use Elementor\App\Modules\KitLibrary\AdminMenuItems\Editor_One_Website_Templates_Menu; | |
| 16 | 16 | |
| 17 | 17 | if ( ! defined( 'ABSPATH' ) ) { |
| 18 | 18 | exit; // Exit if accessed directly. |
| 19 | 19 | } |
| @@ -29,12 +29,27 @@ | ||
| 29 | 29 | public function get_name() { |
| 30 | 30 | return 'kit-library'; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - private function register_editor_one_menu( Menu_Data_Provider $menu_data_provider ) { | |
| 34 | - $menu_data_provider->register_menu( new Editor_One_Website_Templates_Menu() ); | |
| 33 | + private function register_admin_menu( MainMenu $menu ) { | |
| 34 | + $menu->add_submenu( [ | |
| 35 | + 'page_title' => esc_html__( 'Website Templates', 'elementor' ), | |
| 36 | + 'menu_title' => '<span id="e-admin-menu__kit-library">' . esc_html__( 'Website Templates', 'elementor' ) . '</span>', | |
| 37 | + 'menu_slug' => Plugin::$instance->app->get_base_url() . '#/kit-library', | |
| 38 | + 'index' => 40, | |
| 39 | + ] ); | |
| 35 | 40 | } |
| 36 | 41 | |
| 42 | + /** | |
| 43 | + * Register the admin menu the old way. | |
| 44 | + */ | |
| 45 | + private function register_admin_menu_legacy( Admin_Menu_Manager $admin_menu ) { | |
| 46 | + $admin_menu->register( | |
| 47 | + Plugin::$instance->app->get_base_url() . '#/kit-library', | |
| 48 | + new Kit_Library_Menu_Item() | |
| 49 | + ); | |
| 50 | + } | |
| 51 | + | |
| 37 | 52 | private function set_kit_library_settings() { |
| 38 | 53 | if ( ! Plugin::$instance->common ) { |
| 39 | 54 | return; |
| 40 | 55 | } |
| @@ -59,11 +74,8 @@ | ||
| 59 | 74 | 'access_level' => ConnectModule::ACCESS_LEVEL_CORE, |
| 60 | 75 | 'access_tier' => ConnectModule::ACCESS_TIER_FREE, |
| 61 | 76 | 'plan_type' => ConnectModule::ACCESS_TIER_FREE, |
| 62 | 77 | '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 | 78 | ] ); |
| 67 | 79 | } |
| 68 | 80 | |
| 69 | 81 | private function apply_filter_subscription_plans( array $subscription_plans ): array { |
| @@ -97,16 +109,11 @@ | ||
| 97 | 109 | public function register_actions() { |
| 98 | 110 | // Assigning this action here since the repository is being loaded by demand. |
| 99 | 111 | add_action( 'elementor/experiments/feature-state-change/container', [ Repository::class, 'clear_cache' ], 10, 0 ); |
| 100 | 112 | |
| 101 | - add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) { | |
| 102 | - $this->register_editor_one_menu( $menu_data_provider ); | |
| 103 | - } ); | |
| 104 | - | |
| 105 | - add_filter( 'elementor/editor-one/menu/protected_templates_submenu_slugs', function ( array $protected_slugs ): array { | |
| 106 | - $protected_slugs[] = 'edit-tags.php?taxonomy=elementor_library_category&post_type=elementor_library'; | |
| 107 | - return $protected_slugs; | |
| 108 | - } ); | |
| 113 | + add_action( 'elementor/admin/menu/register', function( Admin_Menu_Manager $admin_menu ) { | |
| 114 | + $this->register_admin_menu_legacy( $admin_menu ); | |
| 115 | + }, Source_Local::ADMIN_MENU_PRIORITY + 30 ); | |
| 109 | 116 | |
| 110 | 117 | add_action( 'elementor/connect/apps/register', function ( ConnectModule $connect_module ) { |
| 111 | 118 | $connect_module->register_app( 'kit-library', Kit_Library::get_class_name() ); |
| 112 | 119 | } ); |