forked from level-level/Clarkson-Core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clarkson-core.php
103 lines (85 loc) · 2.02 KB
/
clarkson-core.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
/**
* Plugin Name: Clarkson Core
* Version: 1.1.0
* Plugin URI: http://wp-clarkson.com/core
* Description: A mu-plugin to write Object-Oriented code in combination with the Twig templating engine while keeping the WordPress Way of working in mind.
* Author: Level Level
* Author URI: https://www.level-level.com
* License: GPL v2
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
*
* Text Domain: clarkson-core
* Domain Path: /lang/
*/
namespace Clarkson_Core;
use Clarkson_Core\Gutenberg\Block_Manager;
/**
* The main entry point, responsible for registering all objects and hooks.
*/
class Clarkson_Core {
/**
* Container for autoloadable files.
*
* @var Autoloader
*/
public $autoloader;
/**
* Initializes all neccessery objects. Is automatically called on 'init'.
*
* Should not be called manually. This method is public because it needs to be
* called by an action.
*
* @internal
*/
public function init():void {
// Load post objects.
Objects::get_instance();
// Load template routing.
Templates::get_instance();
// Load template routing.
$block_manager = new Block_Manager();
$block_manager->init();
}
/**
* Define instance.
*
* @var null|Clarkson_Core
*/
protected static $instance = null;
/**
* Setting up the class instance.
*/
public static function get_instance(): Clarkson_Core {
if ( null === self::$instance ) {
self::$instance = new Clarkson_Core();
}
return self::$instance;
}
/**
* Clarkson_Core constructor.
*/
protected function __construct() {
// Load vendor files.
$autoload_file = __DIR__ . '/vendor/autoload.php';
if ( file_exists( $autoload_file ) ) {
require_once $autoload_file;
}
if ( is_callable( 'add_action' ) ) {
add_action( 'init', array( $this, 'init' ) );
}
$this->autoloader = new Autoloader();
}
/**
* Clone.
*/
private function __clone() {
}
/**
* Wakeup.
*/
public function __wakeup() {
}
}
// Initialize Clarkson Core
Clarkson_Core::get_instance();