PluginProbe
Elementor Website Builder – more than just a page builder / 3.28.0-dev2
Elementor Website Builder – more than just a page builder v3.28.0-dev2
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 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
← All changes | app/modules/kit-library/module.php +22 -72 4.2.43.28.0-dev2 View file →
@@ -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;
@@ -9,11 +11,8 @@
9 11 use Elementor\Core\Common\Modules\Connect\Module as ConnectModule;
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 -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 15
17 16 if ( ! defined( 'ABSPATH' ) ) {
18 17 exit; // Exit if accessed directly.
19 18 }
@@ -29,12 +28,27 @@
29 28 public function get_name() {
30 29 return 'kit-library';
31 30 }
32 31
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() );
32 + private function register_admin_menu( MainMenu $menu ) {
33 + $menu->add_submenu( [
34 + 'page_title' => esc_html__( 'Kit Library', 'elementor' ),
35 + 'menu_title' => '<span id="e-admin-menu__kit-library">' . esc_html__( 'Kit Library', 'elementor' ) . '</span>',
36 + 'menu_slug' => Plugin::$instance->app->get_base_url() . '#/kit-library',
37 + 'index' => 40,
38 + ] );
35 39 }
36 40
41 + /**
42 + * Register the admin menu the old way.
43 + */
44 + private function register_admin_menu_legacy( Admin_Menu_Manager $admin_menu ) {
45 + $admin_menu->register(
46 + Plugin::$instance->app->get_base_url() . '#/kit-library',
47 + new Kit_Library_Menu_Item()
48 + );
49 + }
50 +
37 51 private function set_kit_library_settings() {
38 52 if ( ! Plugin::$instance->common ) {
39 53 return;
40 54 }
@@ -57,13 +71,9 @@
57 71 'utm_term' => '%%page%%', // Will be replaced in the frontend.
58 72 ] ),
59 73 'access_level' => ConnectModule::ACCESS_LEVEL_CORE,
60 74 'access_tier' => ConnectModule::ACCESS_TIER_FREE,
61 - 'plan_type' => ConnectModule::ACCESS_TIER_FREE,
62 75 '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 76 ] );
67 77 }
68 78
69 79 private function apply_filter_subscription_plans( array $subscription_plans ): array {
@@ -88,26 +98,15 @@
88 98 public function __construct() {
89 99 Plugin::$instance->data_manager_v2->register_controller( new Kits_Controller() );
90 100 Plugin::$instance->data_manager_v2->register_controller( new Taxonomies_Controller() );
91 101
92 - $this->register_actions();
93 -
94 - do_action( 'elementor/kit_library/registered', $this );
95 - }
96 -
97 - public function register_actions() {
98 102 // Assigning this action here since the repository is being loaded by demand.
99 103 add_action( 'elementor/experiments/feature-state-change/container', [ Repository::class, 'clear_cache' ], 10, 0 );
100 104
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 - } );
105 + add_action( 'elementor/admin/menu/register', function( Admin_Menu_Manager $admin_menu ) {
106 + $this->register_admin_menu_legacy( $admin_menu );
107 + }, Source_Local::ADMIN_MENU_PRIORITY + 30 );
104 108
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 109 add_action( 'elementor/connect/apps/register', function ( ConnectModule $connect_module ) {
111 110 $connect_module->register_app( 'kit-library', Kit_Library::get_class_name() );
112 111 } );
113 112
@@ -113,55 +112,6 @@
113 112
114 113 add_action( 'elementor/init', function () {
115 114 $this->set_kit_library_settings();
116 115 }, 12 /** After the initiation of the connect kit library */ );
117 -
118 - add_action( 'template_redirect', [ $this, 'handle_kit_screenshot_generation' ] );
119 - }
120 -
121 - public function handle_kit_screenshot_generation() {
122 - $is_kit_preview = ElementorUtils::get_super_global_value( $_GET, 'kit_thumbnail' );
123 - $nonce = ElementorUtils::get_super_global_value( $_GET, 'nonce' );
124 -
125 - if ( $is_kit_preview ) {
126 - if ( ! wp_verify_nonce( $nonce, 'kit_thumbnail' ) ) {
127 - wp_die( esc_html__( 'Not Authorized', 'elementor' ), esc_html__( 'Error', 'elementor' ), 403 );
128 - }
129 -
130 - $suffix = ( ElementorUtils::is_script_debug() || ElementorUtils::is_elementor_tests() ) ? '' : '.min';
131 -
132 - show_admin_bar( false );
133 -
134 - wp_enqueue_script(
135 - 'dom-to-image',
136 - ELEMENTOR_ASSETS_URL . "/lib/dom-to-image/js/dom-to-image{$suffix}.js",
137 - [],
138 - '2.6.0',
139 - true
140 - );
141 -
142 - wp_enqueue_script(
143 - 'html2canvas',
144 - ELEMENTOR_ASSETS_URL . "/lib/html2canvas/js/html2canvas{$suffix}.js",
145 - [],
146 - '1.4.1',
147 - true
148 - );
149 -
150 - wp_enqueue_script(
151 - 'cloud-library-screenshot',
152 - ELEMENTOR_ASSETS_URL . "/js/cloud-library-screenshot{$suffix}.js",
153 - [ 'dom-to-image', 'html2canvas', 'elementor-common', 'elementor-common-modules' ],
154 - ELEMENTOR_VERSION,
155 - true
156 - );
157 -
158 - $config = [
159 - 'home_url' => home_url(),
160 - 'kit_id' => uniqid(),
161 - 'selector' => 'body',
162 - ];
163 -
164 - wp_add_inline_script( 'cloud-library-screenshot', 'var ElementorScreenshotConfig = ' . wp_json_encode( $config ) . ';' );
165 - }
166 116 }
167 117 }