PluginProbe
Elementor Website Builder – more than just a page builder / 3.30.0-beta1
Elementor Website Builder – more than just a page builder v3.30.0-beta1
4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 All 457 releases
← All changes | app/modules/kit-library/module.php +45 -23 4.3.0-beta2 → 3.30.0-beta1 View file →
@@ -1,19 +1,22 @@
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;
7 +use Elementor\Core\Utils\Exceptions;
5 8 use Elementor\Plugin;
6 9 use Elementor\TemplateLibrary\Source_Local;
7 10 use Elementor\Core\Base\Module as BaseModule;
8 11 use Elementor\App\Modules\KitLibrary\Connect\Kit_Library;
12 +use Elementor\App\Modules\KitLibrary\Connect\Cloud_Kits;
9 13 use Elementor\Core\Common\Modules\Connect\Module as ConnectModule;
10 14 use Elementor\App\Modules\KitLibrary\Data\Kits\Controller as Kits_Controller;
11 15 use Elementor\App\Modules\KitLibrary\Data\Taxonomies\Controller as Taxonomies_Controller;
16 +use Elementor\App\Modules\KitLibrary\Data\CloudKits\Controller as Cloud_Kits_Controller;
12 17 use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager;
13 18 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 19
17 20 if ( ! defined( 'ABSPATH' ) ) {
18 21 exit; // Exit if accessed directly.
19 22 }
@@ -29,12 +32,27 @@
29 32 public function get_name() {
30 33 return 'kit-library';
31 34 }
32 35
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() );
36 + private function register_admin_menu( MainMenu $menu ) {
37 + $menu->add_submenu( [
38 + 'page_title' => esc_html__( 'Kit Library', 'elementor' ),
39 + 'menu_title' => '<span id="e-admin-menu__kit-library">' . esc_html__( 'Kit Library', 'elementor' ) . '</span>',
40 + 'menu_slug' => Plugin::$instance->app->get_base_url() . '#/kit-library',
41 + 'index' => 40,
42 + ] );
35 43 }
36 44
45 + /**
46 + * Register the admin menu the old way.
47 + */
48 + private function register_admin_menu_legacy( Admin_Menu_Manager $admin_menu ) {
49 + $admin_menu->register(
50 + Plugin::$instance->app->get_base_url() . '#/kit-library',
51 + new Kit_Library_Menu_Item()
52 + );
53 + }
54 +
37 55 private function set_kit_library_settings() {
38 56 if ( ! Plugin::$instance->common ) {
39 57 return;
40 58 }
@@ -57,13 +75,9 @@
57 75 'utm_term' => '%%page%%', // Will be replaced in the frontend.
58 76 ] ),
59 77 'access_level' => ConnectModule::ACCESS_LEVEL_CORE,
60 78 'access_tier' => ConnectModule::ACCESS_TIER_FREE,
61 - 'plan_type' => ConnectModule::ACCESS_TIER_FREE,
62 79 '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 80 ] );
67 81 }
68 82
69 83 private function apply_filter_subscription_plans( array $subscription_plans ): array {
@@ -87,29 +101,23 @@
87 101 */
88 102 public function __construct() {
89 103 Plugin::$instance->data_manager_v2->register_controller( new Kits_Controller() );
90 104 Plugin::$instance->data_manager_v2->register_controller( new Taxonomies_Controller() );
105 + Plugin::$instance->data_manager_v2->register_controller( new Cloud_Kits_Controller() );
91 106
92 - $this->register_actions();
93 -
94 - do_action( 'elementor/kit_library/registered', $this );
95 - }
96 -
97 - public function register_actions() {
98 107 // Assigning this action here since the repository is being loaded by demand.
99 108 add_action( 'elementor/experiments/feature-state-change/container', [ Repository::class, 'clear_cache' ], 10, 0 );
100 109
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 - } );
110 + add_action( 'elementor/admin/menu/register', function( Admin_Menu_Manager $admin_menu ) {
111 + $this->register_admin_menu_legacy( $admin_menu );
112 + }, Source_Local::ADMIN_MENU_PRIORITY + 30 );
104 113
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&amp;post_type=elementor_library';
107 - return $protected_slugs;
108 - } );
109 -
110 114 add_action( 'elementor/connect/apps/register', function ( ConnectModule $connect_module ) {
111 115 $connect_module->register_app( 'kit-library', Kit_Library::get_class_name() );
116 +
117 + if ( Plugin::$instance->experiments->is_feature_active( 'cloud-library' ) ) {
118 + $connect_module->register_app( 'cloud-kits', Cloud_Kits::get_class_name() );
119 + }
112 120 } );
113 121
114 122 add_action( 'elementor/init', function () {
115 123 $this->set_kit_library_settings();
@@ -114,9 +122,11 @@
114 122 add_action( 'elementor/init', function () {
115 123 $this->set_kit_library_settings();
116 124 }, 12 /** After the initiation of the connect kit library */ );
117 125
118 - add_action( 'template_redirect', [ $this, 'handle_kit_screenshot_generation' ] );
126 + if ( Plugin::$instance->experiments->is_feature_active( 'cloud-library' ) ) {
127 + add_action( 'template_redirect', [ $this, 'handle_kit_screenshot_generation' ] );
128 + }
119 129 }
120 130
121 131 public function handle_kit_screenshot_generation() {
122 132 $is_kit_preview = ElementorUtils::get_super_global_value( $_GET, 'kit_thumbnail' );
@@ -162,6 +172,18 @@
162 172 ];
163 173
164 174 wp_add_inline_script( 'cloud-library-screenshot', 'var ElementorScreenshotConfig = ' . wp_json_encode( $config ) . ';' );
165 175 }
176 + }
177 +
178 + public static function get_cloud_app(): Cloud_Kits {
179 + $cloud_kits_app = Plugin::$instance->common->get_component( 'connect' )->get_app( 'cloud-kits' );
180 +
181 + if ( ! $cloud_kits_app ) {
182 + $error_message = esc_html__( 'Cloud-Kits is not instantiated.', 'elementor' );
183 +
184 + throw new \Exception( $error_message, Exceptions::FORBIDDEN ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
185 + }
186 +
187 + return $cloud_kits_app;
166 188 }
167 189 }