-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.php
104 lines (86 loc) · 3.06 KB
/
index.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
104
<?php
/**
* Language module
*
* Implements dynamic template tags with extensible content type loops and
* logic conditions. Previously called Template module.
*
* It integrates feature modules such as Loop, Logic, HTML, Date, and others
* from /framework and /modules.
*/
use tangible\template_system;
use tangible\ajax;
use tangible\date;
use tangible\select;
use tangible\html;
if ( ! function_exists( 'tangible_template' ) ) :
function tangible_template( $arg = false ) {
static $html;
return !$html
? ( $html = $arg )
: ( $arg !== false ? html\render_with_catch_exit( $arg ) : $html );
}
endif;
return tangible_template(new class extends stdClass {
public $name = 'tangible_template';
public $version;
public $html;
public $system;
function __construct() {
$this->system = tangible_template_system();
$this->version = $this->system->version;
/**
* HTML module is the basis of Language module.
*
* It used to be a separate module in the plugin framework. Its features
* are used by the Loop module, for example, to build an image tag with
* attributes.
*/
$this->html = $html = $this;
require_once __DIR__ . '/html/index.php';
$html->path = __DIR__;
$html->file_path = __FILE__;
$html->url = untrailingslashit(plugins_url('/', __FILE__));
$html->version = $this->version;
/**
* Deprecating use of global functions or locally scoped variables like
* below. Use namespaced functions under `tangible`.
*/
$system = $this->system;
$loop = $system->loop = $html->loop = template_system::$loop;
$logic = $system->logic = $html->logic = template_system::$logic;
$system->html = $html;
// @see /framework
$system->date = $html->date = tangible\date();
$system->ajax = tangible\ajax\legacy();
$system->interface = tangible\interfaces\legacy();
/**
* Template language
*/
require_once __DIR__ . '/utils/index.php';
require_once __DIR__ . '/tags/index.php';
require_once __DIR__ . '/format/index.php';
require_once __DIR__ . '/logic/index.php';
require_once __DIR__ . '/control/index.php';
require_once __DIR__ . '/definition.php';
// Page life cycle
require_once __DIR__ . '/enqueue/index.php';
require_once __DIR__ . '/actions/index.php';
require_once __DIR__ . '/ajax/index.php';
// For themes: first action hook available after functions.php is loaded.
add_action('after_setup_theme', function() use ( $html ) {
// Use this action to load templates
do_action( 'tangible_templates_ready', $html );
});
}
/**
* Dynamic methods - Deprecated in favor of functions under namespace
*/
function __call( $method = '', $args = [] ) {
if ( isset( $this->$method ) ) {
return call_user_func_array( $this->$method, $args );
}
$caller = current( debug_backtrace() );
trigger_error( "Undefined method \"$method\" for {$this->name}, called from <b>{$caller['file']}</b> on line <b>{$caller['line']}</b><br>", E_USER_WARNING );
}
});