PluginProbe
Elementor Website Builder – more than just a page builder / 3.6.2
Elementor Website Builder – more than just a page builder v3.6.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
elementor / core / app / modules / kit-library / module.php

module.php in Elementor Website Builder – more than just a page builder 3.6.2, at core/app/modules/kit-library/module.php

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