/
source-class-elasticsearch.Theme.html
142 lines (122 loc) · 8.06 KB
/
source-class-elasticsearch.Theme.html
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="robots" content="noindex">
<title>File Theme.php</title>
<link rel="stylesheet" href="resources/style.css?e99947befd7bf673c6b43ff75e9e0f170c88a60e">
</head>
<body>
<div id="left">
<div id="menu">
<a href="index.html" title="Overview"><span>Overview</span></a>
<div id="groups">
<h3>Namespaces</h3>
<ul>
<li>
<a href="namespace-elasticsearch.html">
elasticsearch </a>
</li>
</ul>
</div>
<hr>
<div id="elements">
<h3>Classes</h3>
<ul>
<li><a href="class-elasticsearch.Config.html">elasticsearch\Config</a></li>
<li><a href="class-elasticsearch.Defaults.html">elasticsearch\Defaults</a></li>
<li><a href="class-elasticsearch.Faceting.html">elasticsearch\Faceting</a></li>
<li><a href="class-elasticsearch.Indexer.html">elasticsearch\Indexer</a></li>
<li><a href="class-elasticsearch.Searcher.html">elasticsearch\Searcher</a></li>
<li><a href="class-elasticsearch.Theme.html">elasticsearch\Theme</a></li>
</ul>
</div>
</div>
</div>
<div id="splitter"></div>
<div id="right">
<div id="rightInner">
<form id="search">
<input type="hidden" name="cx" value="">
<input type="hidden" name="ie" value="UTF-8">
<input type="text" name="q" class="text" placeholder="Search">
</form>
<div id="navigation">
<ul>
<li>
<a href="index.html" title="Overview"><span>Overview</span></a>
</li>
<li>
<span>Namespace</span> </li>
<li>
<span>Class</span> </li>
</ul>
<ul>
</ul>
<ul>
</ul>
</div>
<pre><code><span id="1" class="l"><a href="#1"> 1: </a><span class="xlang"><?php</span>
</span><span id="2" class="l"><a href="#2"> 2: </a><span class="php-keyword1">namespace</span> elasticsearch;
</span><span id="3" class="l"><a href="#3"> 3: </a>
</span><span id="4" class="l"><a href="#4"> 4: </a><span class="php-comment">/**
</span></span><span id="5" class="l"><a href="#5"> 5: </a><span class="php-comment">* This theme class provides utilities for introducing advanced functionality (such as ajax faceting) to your theme.
</span></span><span id="6" class="l"><a href="#6"> 6: </a><span class="php-comment">*
</span></span><span id="7" class="l"><a href="#7"> 7: </a><span class="php-comment">* @license http://opensource.org/licenses/MIT
</span></span><span id="8" class="l"><a href="#8"> 8: </a><span class="php-comment">* @author Paris Holley <mail@parisholley.com>
</span></span><span id="9" class="l"><a href="#9"> 9: </a><span class="php-comment">* @version 4.0.1
</span></span><span id="10" class="l"><a href="#10">10: </a><span class="php-comment">**/</span>
</span><span id="11" class="l"><a href="#11">11: </a><span class="php-keyword1">class</span> Theme{
</span><span id="12" class="l"><a href="#12">12: </a> <span class="php-keyword1">private</span> <span class="php-keyword1">static</span> <span class="php-var">$selector</span>;
</span><span id="13" class="l"><a href="#13">13: </a> <span class="php-keyword1">private</span> <span class="php-keyword1">static</span> <span class="php-var">$instance</span>;
</span><span id="14" class="l"><a href="#14">14: </a>
</span><span id="15" class="l"><a href="#15">15: </a> <span class="php-comment">/**
</span></span><span id="16" class="l"><a href="#16">16: </a><span class="php-comment"> * Tells wordpress to detect when ?esajax=1 is in the URL and remove header/footer so content can be replaced on page with AJX
</span></span><span id="17" class="l"><a href="#17">17: </a><span class="php-comment"> **/</span>
</span><span id="18" class="l"><a href="#18">18: </a> <span class="php-keyword1">public</span> <span class="php-keyword1">static</span> <span class="php-keyword1">function</span> enableAjaxHooks(){
</span><span id="19" class="l"><a href="#19">19: </a> <span class="php-keyword1">if</span>(<span class="php-keyword1">isset</span>(<span class="php-var">$_GET</span>[<span class="php-quote">'esasync'</span>])){
</span><span id="20" class="l"><a href="#20">20: </a> add_action(<span class="php-quote">'get_header'</span>, <span class="php-keyword1">function</span>(){
</span><span id="21" class="l"><a href="#21">21: </a> <span class="php-keyword2">ob_start</span>();
</span><span id="22" class="l"><a href="#22">22: </a> });
</span><span id="23" class="l"><a href="#23">23: </a>
</span><span id="24" class="l"><a href="#24">24: </a> add_action(<span class="php-quote">'get_footer'</span>, <span class="php-keyword1">array</span>(__NAMESPACE__ .<span class="php-quote">'\Theme'</span>, <span class="php-quote">'_ajax_footer'</span>));
</span><span id="25" class="l"><a href="#25">25: </a> }
</span><span id="26" class="l"><a href="#26">26: </a> }
</span><span id="27" class="l"><a href="#27">27: </a>
</span><span id="28" class="l"><a href="#28">28: </a> <span class="php-keyword1">public</span> <span class="php-keyword1">static</span> <span class="php-keyword1">function</span> setSelector(<span class="php-var">$selector</span>){
</span><span id="29" class="l"><a href="#29">29: </a> self::<span class="php-var">$selector</span> = <span class="php-var">$selector</span>;
</span><span id="30" class="l"><a href="#30">30: </a> }
</span><span id="31" class="l"><a href="#31">31: </a>
</span><span id="32" class="l"><a href="#32">32: </a> <span class="php-keyword1">public</span> <span class="php-keyword1">static</span> <span class="php-keyword1">function</span> _ajax_footer(){
</span><span id="33" class="l"><a href="#33">33: </a> <span class="php-var">$html</span> = <span class="php-keyword2">ob_get_contents</span>();
</span><span id="34" class="l"><a href="#34">34: </a> <span class="php-keyword2">ob_clean</span>();
</span><span id="35" class="l"><a href="#35">35: </a>
</span><span id="36" class="l"><a href="#36">36: </a> \phpQuery::newDocumentHTML(<span class="php-var">$html</span>);
</span><span id="37" class="l"><a href="#37">37: </a>
</span><span id="38" class="l"><a href="#38">38: </a> <span class="php-keyword1">global</span> <span class="php-var">$wp_query</span>;
</span><span id="39" class="l"><a href="#39">39: </a>
</span><span id="40" class="l"><a href="#40">40: </a> <span class="php-var">$result</span> = <span class="php-keyword1">array</span>(
</span><span id="41" class="l"><a href="#41">41: </a> <span class="php-quote">'content'</span> => pq(self::<span class="php-var">$selector</span>)->html(),
</span><span id="42" class="l"><a href="#42">42: </a> <span class="php-quote">'faceting'</span> => Faceting::all(),
</span><span id="43" class="l"><a href="#43">43: </a> <span class="php-quote">'found'</span> => <span class="php-var">$wp_query</span>->found_posts
</span><span id="44" class="l"><a href="#44">44: </a> );
</span><span id="45" class="l"><a href="#45">45: </a>
</span><span id="46" class="l"><a href="#46">46: </a> <span class="php-keyword1">echo</span> <span class="php-keyword2">json_encode</span>(<span class="php-var">$result</span>);
</span><span id="47" class="l"><a href="#47">47: </a>
</span><span id="48" class="l"><a href="#48">48: </a> <span class="php-keyword1">if</span>(!<span class="php-keyword1">empty</span>(<span class="php-var">$_REQUEST</span>)){
</span><span id="49" class="l"><a href="#49">49: </a> <span class="php-comment">// only fail on webserver, not tests</span>
</span><span id="50" class="l"><a href="#50">50: </a> <span class="php-keyword1">die</span>();
</span><span id="51" class="l"><a href="#51">51: </a> }
</span><span id="52" class="l"><a href="#52">52: </a> }
</span><span id="53" class="l"><a href="#53">53: </a>}
</span><span id="54" class="l"><a href="#54">54: </a><span class="xlang">?></span>
</span><span id="55" class="l"><a href="#55">55: </a></span></code></pre>
<div id="footer">
API documentation generated by <a href="http://apigen.org">ApiGen</a>
</div>
</div>
</div>
<script src="resources/combined.js?cd021bc814832c24a7cec5319ea03335bfba1caf"></script>
<script src="elementlist.js?d541635a4c8f164b89f2149f030e42e0d76d7e39"></script>
</body>
</html>