-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathtemplate-tags.php
executable file
·73 lines (63 loc) · 1.73 KB
/
template-tags.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
<?php
/**
* Templating class instance
* @return string Template class
*/
function eab_get_template_class () {
$class = apply_filters('eab-templating-template_class', 'Eab_Template');
return class_exists( $class )
? $class
: 'Eab_Template'
;
}
/**
* Template class caller wrapper.
* A simplest wrapper, for now.
*/
function eab_call_template ( $method ) {
$class_name = eab_get_template_class();
if ( !class_exists( $class_name ) ) {
return false;
}
$callback = array( $class_name, $method );
if ( !is_callable( $callback ) ) {
return false;
}
$args = func_get_args();
array_shift( $args );
return call_user_func_array( $callback, $args );
}
/**
* Template method checker.
* @param string $method Method to check
* @return bool Exists or not.
*/
function eab_has_template_method ($method) {
if ( !$method ) {
return false;
}
$class_name = eab_get_template_class();
if ( !class_exists( $class_name ) ) {
return false;
}
return is_callable( array( $class_name, $method ) );
}
function eab_current_time () {
return current_time('timestamp');
}
/* ----- PI compatibility layer ----- */
function eab_has_post_indexer () {
return class_exists( 'postindexermodel' ) || function_exists( 'post_indexer_make_current' );
}
function eab_pi_get_table () {
return class_exists( 'postindexermodel' ) ? 'network_posts' : 'site_posts';
}
function eab_pi_get_post_date () {
return class_exists( 'postindexermodel' ) ? 'post_date' : 'post_published_stamp';
}
function eab_pi_get_blog_id () {
return class_exists( 'postindexermodel' ) ? 'BLOG_ID' : 'blog_id';
}
function eab_pi_get_post_id () {
return class_exists( 'postindexermodel' ) ? 'ID' : 'post_id';
}