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

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