-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblock.php
More file actions
69 lines (55 loc) · 1.2 KB
/
block.php
File metadata and controls
69 lines (55 loc) · 1.2 KB
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
<?php
namespace inRage\Blocks;
/**
* Sage Namespace
*/
function sage()
{
// Determine if project namespace has been changed
$sage = apply_filters('inrage/blocks/sage/namespace', 'App') . '\sage';
// Return the function if it exists
if (function_exists($sage)) {
return $sage;
}
// Return false if function does not exist
return false;
}
/**
* Loader
*/
function loader()
{
// Get Sage function
$sage = sage();
// Return if function does not exist
if (!$sage) {
return;
}
$loader = new Loader('Block');
$container = $sage();
foreach ($loader->getClassesToRun() as $class) {
$block = $container->make($class);
$block->registerBlockType();
}
}
function fieldLoader()
{
// Get Sage function
$sage = sage();
// Return if function does not exist
if (!$sage) {
return;
}
$loader = new Loader('Field');
$container = $sage();
foreach ($loader->getClassesToRun() as $class) {
$container->make($class);
}
}
/**
* Hooks
*/
if (function_exists('add_action')) {
add_action('init', __NAMESPACE__ . '\loader');
add_action('init', __NAMESPACE__ . '\fieldLoader');
}