PluginProbe
Elementor Website Builder – more than just a page builder / 3.7.5
Elementor Website Builder – more than just a page builder v3.7.5
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 | core/app/modules/kit-library/module.php +83 -11 4.2.23.7.5 View file →
@@ -1,28 +1,100 @@
1 1 <?php
2 2 namespace Elementor\Core\App\Modules\KitLibrary;
3 3
4 +use Elementor\Core\Admin\Menu\Admin_Menu_Manager;
5 +use Elementor\Core\Admin\Menu\Main as MainMenu;
6 +use Elementor\Plugin;
7 +use Elementor\TemplateLibrary\Source_Local;
4 8 use Elementor\Core\Base\Module as BaseModule;
9 +use Elementor\Core\App\Modules\KitLibrary\Connect\Kit_Library;
10 +use Elementor\Core\Common\Modules\Connect\Module as ConnectModule;
11 +use Elementor\Core\App\Modules\KitLibrary\Data\Kits\Controller as Kits_Controller;
12 +use Elementor\Core\App\Modules\KitLibrary\Data\Taxonomies\Controller as Taxonomies_Controller;
5 13
6 14 if ( ! defined( 'ABSPATH' ) ) {
7 - exit; // Exit if accessed directly.
15 + exit; // Exit if accessed directly
8 16 }
9 17
10 -/**
11 - * This App class exists for backwards compatibility with 3rd parties.
12 - *
13 - * @deprecated 3.8.0
14 - */
15 18 class Module extends BaseModule {
19 + /**
20 + * Get name.
21 + *
22 + * @access public
23 + *
24 + * @return string
25 + */
26 + public function get_name() {
27 + return 'kit-library';
28 + }
16 29
30 + private function register_admin_menu( MainMenu $menu ) {
31 + $menu->add_submenu( [
32 + 'page_title' => __( 'Kit Library', 'elementor' ),
33 + 'menu_title' => '<span id="e-admin-menu__kit-library">' . __( 'Kit Library', 'elementor' ) . '</span>',
34 + 'menu_slug' => Plugin::$instance->app->get_base_url() . '#/kit-library',
35 + 'index' => 40,
36 + ] );
37 + }
38 +
17 39 /**
18 - * @deprecated 3.8.0
40 + * Register the admin menu the old way.
19 41 */
20 - const VERSION = '1.0.0';
42 + private function register_admin_menu_legacy( Admin_Menu_Manager $admin_menu ) {
43 + $admin_menu->register(
44 + Plugin::$instance->app->get_base_url() . '#/kit-library',
45 + new Kit_Library_Menu_Item()
46 + );
47 + }
21 48
49 + private function set_kit_library_settings() {
50 + if ( ! Plugin::$instance->common ) {
51 + return;
52 + }
53 +
54 + /** @var ConnectModule $connect */
55 + $connect = Plugin::$instance->common->get_component( 'connect' );
56 +
57 + /** @var Kit_Library $kit_library */
58 + $kit_library = $connect->get_app( 'kit-library' );
59 +
60 + Plugin::$instance->app->set_settings( 'kit-library', [
61 + 'has_access_to_module' => current_user_can( 'administrator' ),
62 + 'subscription_plans' => $connect->get_subscription_plans( 'kit-library' ),
63 + 'is_pro' => false,
64 + 'is_library_connected' => $kit_library->is_connected(),
65 + 'library_connect_url' => $kit_library->get_admin_url( 'authorize', [
66 + 'utm_source' => 'kit-library',
67 + 'utm_medium' => 'wp-dash',
68 + 'utm_campaign' => 'library-connect',
69 + 'utm_term' => '%%page%%', // Will be replaced in the frontend.
70 + ] ),
71 + 'access_level' => ConnectModule::ACCESS_LEVEL_CORE,
72 + ] );
73 + }
74 +
22 75 /**
23 - * @deprecated 3.8.0
76 + * Module constructor.
24 77 */
25 - public function get_name() {
26 - return 'kit-library-bc';
78 + public function __construct() {
79 + Plugin::$instance->data_manager_v2->register_controller( new Kits_Controller() );
80 + Plugin::$instance->data_manager_v2->register_controller( new Taxonomies_Controller() );
81 +
82 + if ( Plugin::$instance->experiments->is_feature_active( 'admin_menu_rearrangement' ) ) {
83 + add_action( 'elementor/admin/menu_registered/elementor', function( MainMenu $menu ) {
84 + $this->register_admin_menu( $menu );
85 + } );
86 + } else {
87 + add_action( 'elementor/admin/menu/register', function( Admin_Menu_Manager $admin_menu ) {
88 + $this->register_admin_menu_legacy( $admin_menu );
89 + }, Source_Local::ADMIN_MENU_PRIORITY + 30 );
90 + }
91 +
92 + add_action( 'elementor/connect/apps/register', function ( ConnectModule $connect_module ) {
93 + $connect_module->register_app( 'kit-library', Kit_Library::get_class_name() );
94 + } );
95 +
96 + add_action( 'elementor/init', function () {
97 + $this->set_kit_library_settings();
98 + }, 12 /** after the initiation of the connect kit library */ );
27 99 }
28 100 }