This repository has been archived by the owner on Apr 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
template-tags.php
108 lines (96 loc) · 2.46 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
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
105
106
107
108
<?php
/**
* Get the value of a single field from the current panel.
*
* Example:
* You set up a panel with a text field with the name "my_field".
* get_panel_var( 'my_field' ) returns the value entered for that field.
*
* @param string $name
* @return mixed
*/
function get_panel_var( $name ) {
return \ModularContent\Plugin::instance()->loop()->get_var( $name );
}
/**
* Get the values of all fields from the current panel.
*
* @return array Keys will be the configured field names
*/
function get_panel_vars() {
return \ModularContent\Plugin::instance()->loop()->vars();
}
/**
* Get the value of a single field from the current panel for an external source.
*
* Example:
* You set up a panel with a text field with the name "my_field".
* get_panel_var( 'my_field' ) returns the value entered for that field.
*
* @param string $name
*
* @return mixed
*/
function get_panel_var_for_api( $name ) {
return \ModularContent\Plugin::instance()->loop()->get_var_for_api( $name );
}
/**
* Get the values of all fields from the current panel for using on external sources.
*
* @return array Keys will be the configured field names
*/
function get_panel_vars_for_api() {
return \ModularContent\Plugin::instance()->loop()->vars_for_api();
}
/**
* Advance the panels loop to the next panel.
* Analogous to the_post() from a WP posts loop.
*
* @return void
*/
function the_panel() {
\ModularContent\Plugin::instance()->loop()->the_panel();
}
/**
* Render the current panel.
* Analogous to the_content() when in a WP posts loop.
*
* @return void
*/
function the_panel_content() {
if ( $panel = get_the_panel() ) {
echo $panel->render();
}
}
/**
* Get the Panel object for the current panel.
*
* @return \ModularContent\Panel
*/
function get_the_panel() {
return \ModularContent\Plugin::instance()->loop()->get_the_panel();
}
/**
* Whether the current panel loop has any more panels to iterate over.
* Analogous to have_posts() in a WP posts loop.
*
* @return bool
*/
function have_panels() {
return \ModularContent\Plugin::instance()->loop()->have_panels();
}
/**
* Move back to the start of the panels loop.
* Analogous to rewind_posts() in a WP posts loop.
*
* @return void
*/
function rewind_panels() {
\ModularContent\Plugin::instance()->loop()->rewind();
}
function is_panel_preview() {
return \ModularContent\Plugin::instance()->loop()->is_preview();
}
function get_nest_index() {
return \ModularContent\Plugin::instance()->loop()->get_nest_index();
}