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

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