PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.2
Elementor Website Builder – more than just a page builder v3.0.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 / common / modules / connect / module.php

module.php in Elementor Website Builder – more than just a page builder 3.0.2, at core/common/modules/connect/module.php

174 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\Common\Modules\Connect;
3
4 use Elementor\Core\Base\Module as BaseModule;
5 use Elementor\Core\Common\Modules\Connect\Apps\Base_App;
6 use Elementor\Core\Common\Modules\Connect\Apps\Connect;
7 use Elementor\Core\Common\Modules\Connect\Apps\Library;
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit; // Exit if accessed directly
11 }
12
13 class Module extends BaseModule {
14
15 /**
16 * @since 2.3.0
17 * @access public
18 */
19 public function get_name() {
20 return 'connect';
21 }
22
23 /**
24 * @var array
25 */
26 protected $registered_apps = [];
27
28 /**
29 * Apps Instances.
30 *
31 * Holds the list of all the apps instances.
32 *
33 * @since 2.3.0
34 * @access protected
35 *
36 * @var Base_App[]
37 */
38 protected $apps = [];
39
40 /**
41 * Registered apps categories.
42 *
43 * Holds the list of all the registered apps categories.
44 *
45 * @since 2.3.0
46 * @access protected
47 *
48 * @var array
49 */
50 protected $categories = [];
51
52 protected $admin_page;
53
54 /**
55 * @since 2.3.0
56 * @access public
57 */
58 public function __construct() {
59 $this->registered_apps = [
60 'connect' => Connect::get_class_name(),
61 'library' => Library::get_class_name(),
62 ];
63
64 // Note: The priority 11 is for allowing plugins to add their register callback on elementor init.
65 add_action( 'elementor/init', [ $this, 'init' ], 11 );
66 }
67
68 /**
69 * Register default apps.
70 *
71 * Registers the default apps.
72 *
73 * @since 2.3.0
74 * @access public
75 */
76 public function init() {
77 if ( is_admin() ) {
78 $this->admin_page = new Admin();
79 }
80
81 /**
82 * Register Elementor apps.
83 *
84 * Fires after Elementor registers the default apps.
85 *
86 * @since 2.3.0
87 *
88 * @param self $this The apps manager instance.
89 */
90 do_action( 'elementor/connect/apps/register', $this );
91
92 foreach ( $this->registered_apps as $slug => $class ) {
93 $this->apps[ $slug ] = new $class();
94 }
95
96 add_filter( 'elementor/editor/localize_settings', [ $this, 'localize_settings' ] );
97 }
98
99 public function localize_settings( $settings ) {
100 return array_replace_recursive( $settings, [
101 'i18n' => [
102 'connect_error' => __( 'Unable to connect', 'elementor' ),
103 'connected_successfully' => __( 'Connected successfully', 'elementor' ),
104 ],
105 ] );
106 }
107
108 /**
109 * Register app.
110 *
111 * Registers an app.
112 *
113 * @since 2.3.0
114 * @access public
115 *
116 * @param string $slug App slug.
117 * @param string $class App full class name.
118 *
119 * @return self The updated apps manager instance.
120 */
121 public function register_app( $slug, $class ) {
122 $this->registered_apps[ $slug ] = $class;
123
124 return $this;
125 }
126
127 /**
128 * Get app instance.
129 *
130 * Retrieve the app instance.
131 *
132 * @since 2.3.0
133 * @access public
134 *
135 * @param $slug
136 *
137 * @return Base_App|null
138 */
139 public function get_app( $slug ) {
140 if ( isset( $this->apps[ $slug ] ) ) {
141 return $this->apps[ $slug ];
142 }
143
144 return null;
145 }
146
147 /**
148 * @since 2.3.0
149 * @access public
150 * @return Base_App[]
151 */
152 public function get_apps() {
153 return $this->apps;
154 }
155
156 /**
157 * @since 2.3.0
158 * @access public
159 */
160 public function register_category( $slug, $args ) {
161 $this->categories[ $slug ] = $args;
162 return $this;
163 }
164
165 /**
166 * @since 2.3.0
167 * @access public
168 */
169 public function get_categories() {
170 return $this->categories;
171 }
172
173 }
174