PluginProbe
BlockSpare – Gutenberg Blocks, AI Content Generator & Site Builder for News, Magazine & Blogs / 5.0.1
BlockSpare – Gutenberg Blocks, AI Content Generator & Site Builder for News, Magazine & Blogs v5.0.1
5.0.1 4.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.1.2 2.5.0 2.5.3 All 39 releases
blockspare / inc / theme-builder / class-blockspare-tb-plugin.php

class-blockspare-tb-plugin.php in BlockSpare – Gutenberg Blocks, AI Content Generator & Site Builder for News, Magazine & Blogs 5.0.1, at inc/theme-builder/class-blockspare-tb-plugin.php

84 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 defined('ABSPATH') || exit;
4
5
6 final class Blockspare_TB_Plugin
7 {
8
9 /**
10 * The single instance of this class.
11 *
12 * @var Blockspare_TB_Plugin|null
13 */
14 private static $instance = null;
15
16 /**
17 * Condition registry, shared across REST + frontend rendering.
18 *
19 * @var Blockspare_TB_Condition_Registry
20 */
21 public $conditions;
22
23 /**
24 * Get (and lazily create) the single Plugin instance.
25 *
26 * @return Blockspare_TB_Plugin
27 */
28 public static function instance()
29 {
30 if (null === self::$instance) {
31 self::$instance = new self();
32 self::$instance->setup();
33 }
34
35 return self::$instance;
36 }
37 private function __construct() {}
38
39
40 private function setup()
41 {
42 // Condition engine must exist before REST + Frontend, both depend on it.
43 $this->conditions = new Blockspare_TB_Condition_Registry();
44 $this->conditions->register_core_conditions();
45
46 add_action('init', array(new Blockspare_TB_Template_Post_Type(), 'register'));
47 add_action('init', array(new Blockspare_TB_Template_Type_Taxonomy(), 'register'));
48
49 $conditions = $this->conditions;
50 add_action(
51 'rest_api_init',
52 function () use ($conditions) {
53 (new Blockspare_TB_Templates_Controller())->register_routes();
54 (new Blockspare_TB_Conditions_Controller($conditions))->register_routes();
55 }
56 );
57
58 if (is_admin()) {
59 $admin_menu = new Blockspare_TB_Admin_Menu();
60 add_action('admin_menu', array($admin_menu, 'blocksspare_builder_register'));
61
62 $assets = new Blockspare_TB_Assets();
63 add_action('admin_enqueue_scripts', array($assets, 'blocksspare_builder_enqueue'));
64 add_action('enqueue_block_editor_assets', array($assets, 'blocksspare_builder_enqueue_editor'));
65 }
66
67
68 (new Blockspare_TB_Template_Loader($this->conditions))->init();
69 }
70
71 /**
72 * Prevent cloning of the instance (Singleton integrity).
73 */
74 private function __clone() {}
75
76 /**
77 * Prevent unserializing of the instance (Singleton integrity).
78 */
79 public function __wakeup()
80 {
81 throw new Exception('Cannot unserialize a singleton.');
82 }
83 }
84