PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.4.1
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.4.1
3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 All 111 releases
templately / includes / Plugin.php

Plugin.php in Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! 3.4.1, at includes/Plugin.php

227 lines 5.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Templately plugin.
4 *
5 * The main plugin handler class is responsible for initializing Templately. The
6 * class registers and all the components required to run the plugin.
7 *
8 * @package Templately
9 */
10
11 namespace Templately;
12
13 use Templately\Admin\API\Settings as APISettings;
14 use Templately\Admin\Settings;
15 use Templately\API\AIContent;
16 use Templately\API\Conditions;
17 use Templately\API\ThemeBuilderApi;
18 use Templately\Builder\ThemeBuilder;
19 use Templately\Core\Importer\FullSiteImport;
20 use Templately\Utils\Base;
21 use Templately\Utils\Enqueue;
22
23 use Templately\Core\Admin;
24 use Templately\Core\Module;
25
26 use Templately\API\Tags;
27 use Templately\API\Items;
28 use Templately\API\Login;
29 use Templately\API\SignUp;
30 use Templately\API\Profile;
31 use Templately\API\Import;
32 use Templately\API\MyClouds;
33 use Templately\API\WorkSpaces;
34 use Templately\API\Categories;
35 use Templately\API\Dependencies;
36 use Templately\API\DeveloperSettings;
37 use Templately\API\TemplateTypes;
38 use Templately\API\SavedTemplates;
39 use Templately\Core\Maintenance;
40 use Templately\Core\Migrator;
41 use Templately\Core\Developer;
42 use Templately\Core\Platform\Gutenberg;
43 use Templately\Core\Platform\Elementor;
44
45 final class Plugin extends Base {
46 public $version = '3.4.1';
47
48 public $admin;
49 public $settings;
50 /**
51 * Enqueue class responsible for assets
52 * @var Enqueue
53 */
54 public $assets;
55
56 /**
57 * @var ThemeBuilder
58 */
59 public $theme_builder;
60
61 /**
62 * @var Developer
63 */
64 public $developer;
65
66 /**
67 * Plugin constructor.
68 * Initializing Templately plugin.
69 *
70 * @access private
71 */
72 public function __construct() {
73 $this->define_constants();
74 $this->set_locale();
75
76 Maintenance::init();
77
78 $this->assets = Enqueue::get_instance( TEMPLATELY_URL, TEMPLATELY_PATH, $this->version );
79 $this->admin = Admin::get_instance();
80 $this->settings = Settings::get_instance();
81 $this->theme_builder = ThemeBuilder::get_instance();
82 $this->developer = Developer::get_instance();
83
84 add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ] );
85 add_action( 'rest_api_init', [ $this, 'register_routes' ] );
86 /**
87 * Initialize.
88 */
89 do_action( 'templately_init' );
90
91 }
92
93 /**
94 * Cloning is forbidden.
95 *
96 * @since 2.0
97 */
98 public function __clone() {
99 _doing_it_wrong( __FUNCTION__, __( 'Cloning is forbidden.', 'templately' ), '2.0' );
100 }
101
102 /**
103 * Un-serializing instances of this class is forbidden.
104 *
105 * @since 2.0
106 */
107 public function __wakeup() {
108 _doing_it_wrong( __FUNCTION__, __( 'Un-serializing instances of this class is forbidden.', 'templately' ), '2.0' );
109 }
110
111 /**
112 * Initializing Things on Plugins Loaded
113 * @return void
114 */
115 public function plugins_loaded() {
116 $this->platforms(); // PLATFORMS LOADED
117 $this->apis(); // APIs LOADED
118
119 /**
120 * Migrator for Templately
121 */
122 Migrator::get_instance();
123
124 /**
125 * Full Site Import
126 */
127 FullSiteImport::get_instance();
128 }
129
130 /**
131 * Initialize all platforms
132 * @return void
133 */
134 public function platforms() {
135 Gutenberg::get_instance();
136 Elementor::get_instance();
137 }
138
139 /**
140 * All the API instantiated
141 *
142 * @return void
143 */
144 private function apis() {
145 Conditions::get_instance();
146 Categories::get_instance();
147 TemplateTypes::get_instance();
148 Dependencies::get_instance();
149 Tags::get_instance();
150 ThemeBuilderApi::get_instance();
151
152 AIContent::get_instance();
153 Items::get_instance();
154 SavedTemplates::get_instance();
155
156 Login::get_instance();
157 SignUp::get_instance();
158 Import::get_instance();
159 Profile::get_instance();
160 MyClouds::get_instance();
161 WorkSpaces::get_instance();
162
163 APISettings::get_instance();
164 DeveloperSettings::get_instance();
165 }
166
167 /**
168 * Register all REST API endpoints
169 * @return void
170 */
171 public function register_routes() {
172 if ( ! empty( $modules = Module::get_instance()->get( 'API' ) ) ) {
173 foreach ( $modules as $module ) {
174 $module->object->register_routes();
175 }
176 }
177 }
178
179 /**
180 * Define CONSTANTS
181 *
182 * @return void
183 * @since 2.0.0
184 */
185 public function define_constants() {
186 $this->define( 'TEMPLATELY_URL', plugin_dir_url( TEMPLATELY_FILE ) );
187 $this->define( 'TEMPLATELY_ASSETS', TEMPLATELY_URL . 'assets/' );
188 $this->define( 'TEMPLATELY_PLUGIN_BASENAME', plugin_basename( TEMPLATELY_FILE ) );
189 $this->define( 'TEMPLATELY_VERSION', $this->version );
190 $this->define( 'TEMPLATELY_API_NAMESPACE', 'templately/v1' );
191 $this->define( 'TEMPLATELY_VIEWS_ABSPATH', TEMPLATELY_PATH . 'views/' );
192 }
193
194 /**
195 * Define constant if not already set.
196 *
197 * @param string $name Constant name.
198 * @param mixed $value Constant value.
199 *
200 * @return void
201 */
202 private function define( string $name, $value ) {
203 if ( ! defined( $name ) ) {
204 define( $name, $value );
205 }
206 }
207
208 /**
209 * Setting the locale for translation availability
210 * @return void
211 * @since 1.0.0
212 */
213 public function set_locale() {
214 add_action( 'init', [ $this, 'load_textdomain' ] );
215 }
216
217 /**
218 * Loading Text Domain on init HOOK
219 * @return void
220 * @since 1.0.0
221 *
222 */
223 public function load_textdomain() {
224 load_plugin_textdomain( 'templately', false, dirname( TEMPLATELY_PLUGIN_BASENAME ) . '/languages' );
225 }
226 }
227