PluginProbe
Templateberg – Gutenberg Templates, WordPress Themes Template Kits & WordPress Templates / 1.1.0
Templateberg – Gutenberg Templates, WordPress Themes Template Kits & WordPress Templates v1.1.0
1.2.0 2.0.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9
templateberg / includes / class-templateberg.php

class-templateberg.php in Templateberg – Gutenberg Templates, WordPress Themes Template Kits & WordPress Templates 1.1.0, at includes/class-templateberg.php

249 lines 6.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The file that defines the core plugin class
5 *
6 * A class definition that includes attributes and functions used to
7 * add/remove/edit the functionality of the Templateberg Plugin
8 *
9 * @link https://www.templateberg.com/
10 * @since 1.0.0
11 *
12 * @package Templateberg
13 */
14
15 /**
16 * The core plugin class.
17 *
18 * This is used to define internationalization, admin-specific hooks, and
19 * functionality of the plugin
20 *
21 * Also maintains the unique identifier of this plugin as well as the current
22 * version of the plugin.
23 *
24 * @since 1.0.0
25 * @package Templateberg
26 * @author Templateberg <info@templateberg.com>
27 */
28 class Templateberg
29 {
30
31 /**
32 * The loader that's responsible for maintaining and registering all hooks that power
33 * the plugin.
34 *
35 * @since 1.0.0
36 * @access protected
37 * @var Templateberg_Loader $loader Maintains and registers all hooks for the plugin.
38 */
39 protected $loader;
40
41 /**
42 * The unique identifier of this plugin.
43 *
44 * @since 1.0.0
45 * @access protected
46 * @var string $plugin_name The string used to uniquely identify this plugin.
47 */
48 protected $plugin_name;
49
50 /**
51 * Full Name of plugin.
52 *
53 * @since 1.0.0
54 * @access protected
55 * @var string $plugin_full_name The string used to uniquely identify this plugin.
56 */
57 protected $plugin_full_name;
58
59 /**
60 * The current version of the plugin.
61 *
62 * @since 1.0.0
63 * @access protected
64 * @var string $version The current version of the plugin.
65 */
66 protected $version;
67
68 /**
69 * Main Instance
70 *
71 * Insures that only one instance of Templateberg exists in memory at any one
72 * time. Also prevents needing to define globals all over the place.
73 *
74 * @since 1.0.0
75 * @access public
76 *
77 * @return object
78 */
79 public static function instance()
80 {
81
82 // Store the instance locally to avoid private static replication
83 static $instance = null;
84
85 // Only run these methods if they haven't been ran previously
86 if (null === $instance) {
87 $instance = new Templateberg();
88
89 do_action('templateberg_loaded');
90 }
91
92 // Always return the instance
93 return $instance;
94 }
95
96 /**
97 * Define the core functionality of the plugin.
98 *
99 * Set the plugin name and the plugin version that can be used throughout the plugin.
100 * Load the dependencies, define the locale, and set the hooks for the admin area and
101 * the public-facing side of the site.
102 *
103 * @since 1.0.0
104 */
105 public function run()
106 {
107 if (defined('TEMPLATEBERG_VERSION')) {
108 $this->version = TEMPLATEBERG_VERSION;
109 } else {
110 $this->version = '1.0.0';
111 }
112 $this->plugin_name = TEMPLATEBERG_PLUGIN_NAME;
113 $this->plugin_full_name = esc_html__('Templateberg', 'templateberg');
114
115 $this->load_dependencies();
116 $this->set_locale();
117
118 $this->define_hooks();
119 $this->load_hooks();
120 }
121
122
123 /**
124 * Load the required dependencies for this plugin.
125 *
126 * Include the following files that make up the plugin:
127 *
128 * - Templateberg_Loader. Orchestrates the hooks of the plugin.
129 * - Templateberg_i18n. Defines internationalization functionality.
130 * - Templateberg. Defines all hooks for the admin area.
131 * - Templateberg_Public. Defines all hooks for the public side of the site.
132 *
133 * Create an instance of the loader which will be used to register the hooks
134 * with WordPress.
135 *
136 * @since 1.0.0
137 * @access private
138 */
139 private function load_dependencies()
140 {
141
142 require_once TEMPLATEBERG_PATH . 'includes/class-templateberg-loader.php';
143
144 require_once TEMPLATEBERG_PATH . 'includes/class-templateberg-i18n.php';
145
146 /*Functions*/
147 require_once TEMPLATEBERG_PATH . 'includes/functions.php';
148
149 /*Hooks*/
150 require_once TEMPLATEBERG_PATH . 'includes/class-templateberg-hooks.php';
151
152 /*Admin*/
153 require_once TEMPLATEBERG_PATH . 'includes/admin/class-templateberg-connect.php';
154
155 /*Templates*/
156 require_once TEMPLATEBERG_PATH . 'includes/lists/templateberg-template-lists-data.php';
157 require_once TEMPLATEBERG_PATH . 'includes/lists/class-templateberg-gutenberg-templates.php';
158 require_once TEMPLATEBERG_PATH . 'includes/lists/class-templateberg-themes-template-kits.php';
159
160 /*Rest API*/
161 require_once TEMPLATEBERG_PATH . 'includes/admin/class-templateberg-template-api.php';
162
163
164 $this->loader = new Templateberg_Loader();
165 }
166
167 /**
168 * Define the locale for this plugin for internationalization.
169 *
170 * Uses the Templateberg_i18n class in order to set the domain and to register the hook
171 * with WordPress.
172 *
173 * @since 1.0.0
174 * @access private
175 */
176 private function set_locale()
177 {
178
179 $plugin_i18n = new Templateberg_i18n();
180
181 $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');
182 }
183
184 /**
185 * Register all of the hooks related to the admin area functionality
186 * of the plugin.
187 *
188 * @since 1.0.0
189 * @access private
190 */
191 private function define_hooks()
192 {
193
194 $plugin_hooks = templateberg_hooks();
195
196 /*Hook : Admin page*/
197 $this->loader->add_action('admin_enqueue_scripts', $plugin_hooks, 'admin_scripts');
198
199 /*Hook: Editor assets.*/
200 $this->loader->add_action('enqueue_block_editor_assets', $plugin_hooks, 'block_editor_assets');
201
202 $this->loader->add_action('block_categories_all', $plugin_hooks, 'add_block_categories', 9999);
203 }
204
205 /**
206 * Run the loader to execute all of the hooks with WordPress.
207 *
208 * @since 1.0.0
209 */
210 public function load_hooks()
211 {
212 $this->loader->run();
213 }
214
215 /**
216 * The name of the plugin used to uniquely identify it within the context of
217 * WordPress and to define internationalization functionality.
218 *
219 * @since 1.0.0
220 * @return string The name of the plugin.
221 */
222 public function get_plugin_name()
223 {
224 return $this->plugin_name;
225 }
226
227 /**
228 * The reference to the class that orchestrates the hooks with the plugin.
229 *
230 * @since 1.0.0
231 * @return Templateberg_Loader Orchestrates the hooks of the plugin.
232 */
233 public function get_loader()
234 {
235 return $this->loader;
236 }
237
238 /**
239 * Retrieve the version number of the plugin.
240 *
241 * @since 1.0.0
242 * @return string The version number of the plugin.
243 */
244 public function get_version()
245 {
246 return $this->version;
247 }
248 }
249