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

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