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

106 lines 3.6 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\App\Modules\KitLibrary\Data\Repository;
5 use Elementor\Core\Admin\Menu\Admin_Menu_Manager;
6 use Elementor\Core\Admin\Menu\Main as MainMenu;
7 use Elementor\Plugin;
8 use Elementor\TemplateLibrary\Source_Local;
9 use Elementor\Core\Base\Module as BaseModule;
10 use Elementor\App\Modules\KitLibrary\Connect\Kit_Library;
11 use Elementor\Core\Common\Modules\Connect\Module as ConnectModule;
12 use Elementor\App\Modules\KitLibrary\Data\Kits\Controller as Kits_Controller;
13 use Elementor\App\Modules\KitLibrary\Data\Taxonomies\Controller as Taxonomies_Controller;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit; // Exit if accessed directly
17 }
18
19 class Module extends BaseModule {
20 /**
21 * Get name.
22 *
23 * @access public
24 *
25 * @return string
26 */
27 public function get_name() {
28 return 'kit-library';
29 }
30
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 ] );
38 }
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
50 private function set_kit_library_settings() {
51 if ( ! Plugin::$instance->common ) {
52 return;
53 }
54
55 /** @var ConnectModule $connect */
56 $connect = Plugin::$instance->common->get_component( 'connect' );
57
58 /** @var Kit_Library $kit_library */
59 $kit_library = $connect->get_app( 'kit-library' );
60
61 Plugin::$instance->app->set_settings( 'kit-library', [
62 'has_access_to_module' => current_user_can( 'administrator' ),
63 'subscription_plans' => $connect->get_subscription_plans( 'kit-library' ),
64 'is_pro' => false,
65 'is_library_connected' => $kit_library->is_connected(),
66 'library_connect_url' => $kit_library->get_admin_url( 'authorize', [
67 'utm_source' => 'kit-library',
68 'utm_medium' => 'wp-dash',
69 'utm_campaign' => 'library-connect',
70 'utm_term' => '%%page%%', // Will be replaced in the frontend.
71 ] ),
72 'access_level' => ConnectModule::ACCESS_LEVEL_CORE,
73 'app_url' => Plugin::$instance->app->get_base_url() . '#/' . $this->get_name(),
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 // Assigning this action here since the repository is being loaded by demand.
85 add_action( 'elementor/experiments/feature-state-change/container', [ Repository::class, 'clear_cache' ], 10, 0 );
86
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 }
96
97 add_action( 'elementor/connect/apps/register', function ( ConnectModule $connect_module ) {
98 $connect_module->register_app( 'kit-library', Kit_Library::get_class_name() );
99 } );
100
101 add_action( 'elementor/init', function () {
102 $this->set_kit_library_settings();
103 }, 12 /** after the initiation of the connect kit library */ );
104 }
105 }
106