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

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