| @@ -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 | } |
| @@ -57,13 +72,9 @@ | ||
| 57 | 72 | 'utm_term' => '%%page%%', // Will be replaced in the frontend. |
| 58 | 73 | ] ), |
| 59 | 74 | 'access_level' => ConnectModule::ACCESS_LEVEL_CORE, |
| 60 | 75 | 'access_tier' => ConnectModule::ACCESS_TIER_FREE, |
| 61 | - 'plan_type' => ConnectModule::ACCESS_TIER_FREE, | |
| 62 | 76 | '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 | 77 | ] ); |
| 67 | 78 | } |
| 68 | 79 | |
| 69 | 80 | private function apply_filter_subscription_plans( array $subscription_plans ): array { |
| @@ -97,17 +108,12 @@ | ||
| 97 | 108 | public function register_actions() { |
| 98 | 109 | // Assigning this action here since the repository is being loaded by demand. |
| 99 | 110 | add_action( 'elementor/experiments/feature-state-change/container', [ Repository::class, 'clear_cache' ], 10, 0 ); |
| 100 | 111 | |
| 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 | - } ); | |
| 112 | + add_action( 'elementor/admin/menu/register', function( Admin_Menu_Manager $admin_menu ) { | |
| 113 | + $this->register_admin_menu_legacy( $admin_menu ); | |
| 114 | + }, Source_Local::ADMIN_MENU_PRIORITY + 30 ); | |
| 104 | 115 | |
| 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 | - } ); | |
| 109 | - | |
| 110 | 116 | add_action( 'elementor/connect/apps/register', function ( ConnectModule $connect_module ) { |
| 111 | 117 | $connect_module->register_app( 'kit-library', Kit_Library::get_class_name() ); |
| 112 | 118 | } ); |
| 113 | 119 | |
| @@ -114,9 +120,11 @@ | ||
| 114 | 120 | add_action( 'elementor/init', function () { |
| 115 | 121 | $this->set_kit_library_settings(); |
| 116 | 122 | }, 12 /** After the initiation of the connect kit library */ ); |
| 117 | 123 | |
| 118 | - add_action( 'template_redirect', [ $this, 'handle_kit_screenshot_generation' ] ); | |
| 124 | + if ( Plugin::$instance->experiments->is_feature_active( 'cloud-library' ) ) { | |
| 125 | + add_action( 'template_redirect', [ $this, 'handle_kit_screenshot_generation' ] ); | |
| 126 | + } | |
| 119 | 127 | } |
| 120 | 128 | |
| 121 | 129 | public function handle_kit_screenshot_generation() { |
| 122 | 130 | $is_kit_preview = ElementorUtils::get_super_global_value( $_GET, 'kit_thumbnail' ); |