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

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

101 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\App\Modules\KitLibrary;
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;
8 use Elementor\Core\Base\Module as BaseModule;
9 use Elementor\App\Modules\KitLibrary\Connect\Kit_Library;
10 use Elementor\Core\Common\Modules\Connect\Module as ConnectModule;
11 use Elementor\App\Modules\KitLibrary\Data\Kits\Controller as Kits_Controller;
12 use Elementor\App\Modules\KitLibrary\Data\Taxonomies\Controller as Taxonomies_Controller;
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit; // Exit if accessed directly
16 }
17
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 }
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
39 /**
40 * Register the admin menu the old way.
41 */
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 }
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
75 /**
76 * Module constructor.
77 */
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 */ );
99 }
100 }
101