PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.3.1
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.3.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.3.1, at includes/Plugin.php

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