PluginProbe
Elementor Website Builder – more than just a page builder / 3.17.2
Elementor Website Builder – more than just a page builder v3.17.2
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 +32 -94 4.2.23.17.2 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;
@@ -8,15 +10,11 @@
8 10 use Elementor\App\Modules\KitLibrary\Connect\Kit_Library;
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 -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 14
17 15 if ( ! defined( 'ABSPATH' ) ) {
18 - exit; // Exit if accessed directly.
16 + exit; // Exit if accessed directly
19 17 }
20 18
21 19 class Module extends BaseModule {
22 20 /**
@@ -29,12 +27,27 @@
29 27 public function get_name() {
30 28 return 'kit-library';
31 29 }
32 30
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() );
31 + private function register_admin_menu( MainMenu $menu ) {
32 + $menu->add_submenu( [
33 + 'page_title' => esc_html__( 'Kit Library', 'elementor' ),
34 + 'menu_title' => '<span id="e-admin-menu__kit-library">' . esc_html__( 'Kit Library', 'elementor' ) . '</span>',
35 + 'menu_slug' => Plugin::$instance->app->get_base_url() . '#/kit-library',
36 + 'index' => 40,
37 + ] );
35 38 }
36 39
40 + /**
41 + * Register the admin menu the old way.
42 + */
43 + private function register_admin_menu_legacy( Admin_Menu_Manager $admin_menu ) {
44 + $admin_menu->register(
45 + Plugin::$instance->app->get_base_url() . '#/kit-library',
46 + new Kit_Library_Menu_Item()
47 + );
48 + }
49 +
37 50 private function set_kit_library_settings() {
38 51 if ( ! Plugin::$instance->common ) {
39 52 return;
40 53 }
@@ -45,10 +58,10 @@
45 58 /** @var Kit_Library $kit_library */
46 59 $kit_library = $connect->get_app( 'kit-library' );
47 60
48 61 Plugin::$instance->app->set_settings( 'kit-library', [
49 - 'has_access_to_module' => current_user_can( 'manage_options' ),
50 - 'subscription_plans' => $this->apply_filter_subscription_plans( $connect->get_subscription_plans( 'kit-library' ) ),
62 + 'has_access_to_module' => current_user_can( 'administrator' ),
63 + 'subscription_plans' => $connect->get_subscription_plans( 'kit-library' ),
51 64 'is_pro' => false,
52 65 'is_library_connected' => $kit_library->is_connected(),
53 66 'library_connect_url' => $kit_library->get_admin_url( 'authorize', [
54 67 'utm_source' => 'kit-library',
@@ -56,33 +69,12 @@
56 69 'utm_campaign' => 'library-connect',
57 70 'utm_term' => '%%page%%', // Will be replaced in the frontend.
58 71 ] ),
59 72 'access_level' => ConnectModule::ACCESS_LEVEL_CORE,
60 - 'access_tier' => ConnectModule::ACCESS_TIER_FREE,
61 - 'plan_type' => ConnectModule::ACCESS_TIER_FREE,
62 73 '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 74 ] );
67 75 }
68 76
69 - private function apply_filter_subscription_plans( array $subscription_plans ): array {
70 - foreach ( $subscription_plans as $key => $plan ) {
71 - if ( null === $plan['promotion_url'] ) {
72 - continue;
73 - }
74 -
75 - $subscription_plans[ $key ] = Filtered_Promotions_Manager::get_filtered_promotion_data(
76 - $plan,
77 - 'elementor/kit_library/' . $key . '/promotion',
78 - 'promotion_url'
79 - );
80 - }
81 -
82 - return $subscription_plans;
83 - }
84 -
85 77 /**
86 78 * Module constructor.
87 79 */
88 80 public function __construct() {
@@ -88,26 +80,21 @@
88 80 public function __construct() {
89 81 Plugin::$instance->data_manager_v2->register_controller( new Kits_Controller() );
90 82 Plugin::$instance->data_manager_v2->register_controller( new Taxonomies_Controller() );
91 83
92 - $this->register_actions();
93 -
94 - do_action( 'elementor/kit_library/registered', $this );
95 - }
96 -
97 - public function register_actions() {
98 84 // Assigning this action here since the repository is being loaded by demand.
99 85 add_action( 'elementor/experiments/feature-state-change/container', [ Repository::class, 'clear_cache' ], 10, 0 );
100 86
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 - } );
87 + if ( Plugin::$instance->experiments->is_feature_active( 'admin_menu_rearrangement' ) ) {
88 + add_action( 'elementor/admin/menu_registered/elementor', function( MainMenu $menu ) {
89 + $this->register_admin_menu( $menu );
90 + } );
91 + } else {
92 + add_action( 'elementor/admin/menu/register', function( Admin_Menu_Manager $admin_menu ) {
93 + $this->register_admin_menu_legacy( $admin_menu );
94 + }, Source_Local::ADMIN_MENU_PRIORITY + 30 );
95 + }
104 96
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 97 add_action( 'elementor/connect/apps/register', function ( ConnectModule $connect_module ) {
111 98 $connect_module->register_app( 'kit-library', Kit_Library::get_class_name() );
112 99 } );
113 100
@@ -112,56 +99,7 @@
112 99 } );
113 100
114 101 add_action( 'elementor/init', function () {
115 102 $this->set_kit_library_settings();
116 - }, 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 - }
103 + }, 12 /** after the initiation of the connect kit library */ );
166 104 }
167 105 }