@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | // price td |
109 | 109 | $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c'); |
110 | 110 | // total td |
111 | - $total = $line_item->is_taxable() ? $line_item->total_no_code() . '*' : $line_item->total_no_code(); |
|
111 | + $total = $line_item->is_taxable() ? $line_item->total_no_code().'*' : $line_item->total_no_code(); |
|
112 | 112 | $html .= EEH_HTML::td($total, '', 'item_r'); |
113 | 113 | // end of row |
114 | 114 | $html .= EEH_HTML::trx(); |
@@ -132,10 +132,10 @@ discard block |
||
132 | 132 | $html .= EEH_HTML::td($line_item->name(), '', 'item_l sub-item'); |
133 | 133 | // desc td |
134 | 134 | $html .= $options['show_desc'] ? EEH_HTML::td($line_item->desc(), '', 'item_l') : ''; |
135 | - $html .= EEH_HTML::td() . EEH_HTML::tdx(); |
|
135 | + $html .= EEH_HTML::td().EEH_HTML::tdx(); |
|
136 | 136 | // discount/surcharge td |
137 | 137 | if ($line_item->is_percent()) { |
138 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c'); |
|
138 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c'); |
|
139 | 139 | } else { |
140 | 140 | $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c'); |
141 | 141 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | // desc td |
165 | 165 | $html .= $options['show_desc'] ? EEH_HTML::td($line_item->desc(), '', 'item_l') : ''; |
166 | 166 | // percent td |
167 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c', '', ' colspan="2"'); |
|
167 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c', '', ' colspan="2"'); |
|
168 | 168 | // total td |
169 | 169 | $html .= EEH_HTML::td($line_item->total_no_code(), '', 'item_r'); |
170 | 170 | // end of row |
@@ -1,223 +1,223 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** |
4 | - * |
|
5 | - * Class EE_Invoice_Line_Item_Display_Strategy |
|
6 | - * |
|
7 | - * Description |
|
8 | - * |
|
9 | - * @package Event Espresso |
|
10 | - * @subpackage core |
|
11 | - * @author Brent Christensen |
|
12 | - * |
|
13 | - * |
|
14 | - */ |
|
4 | + * |
|
5 | + * Class EE_Invoice_Line_Item_Display_Strategy |
|
6 | + * |
|
7 | + * Description |
|
8 | + * |
|
9 | + * @package Event Espresso |
|
10 | + * @subpackage core |
|
11 | + * @author Brent Christensen |
|
12 | + * |
|
13 | + * |
|
14 | + */ |
|
15 | 15 | class EE_Invoice_Line_Item_Display_Strategy implements EEI_Line_Item_Display |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @param EE_Line_Item $line_item |
|
20 | - * @param array $options |
|
21 | - * @return mixed |
|
22 | - */ |
|
23 | - public function display_line_item(EE_Line_Item $line_item, $options = array()) |
|
24 | - { |
|
25 | - |
|
26 | - $html = ''; |
|
27 | - // set some default options and merge with incoming |
|
28 | - $default_options = array( |
|
29 | - 'show_desc' => true, |
|
30 | - 'odd' => false |
|
31 | - ); |
|
32 | - $options = array_merge($default_options, (array) $options); |
|
33 | - |
|
34 | - switch ($line_item->type()) { |
|
35 | - case EEM_Line_Item::type_total: |
|
36 | - // loop thru children |
|
37 | - foreach ($line_item->children() as $child_line_item) { |
|
38 | - // recursively feed children back into this method |
|
39 | - $html .= $this->display_line_item($child_line_item, $options); |
|
40 | - } |
|
41 | - $html .= $this->_separator_row($options); |
|
42 | - $html .= $this->_total_row($line_item, esc_html__('Total', 'event_espresso'), $options); |
|
43 | - break; |
|
44 | - |
|
45 | - |
|
46 | - case EEM_Line_Item::type_sub_total: |
|
47 | - // loop thru children |
|
48 | - foreach ($line_item->children() as $child_line_item) { |
|
49 | - // recursively feed children back into this method |
|
50 | - $html .= $this->display_line_item($child_line_item, $options); |
|
51 | - } |
|
52 | - $html .= $this->_total_row($line_item, esc_html__('Sub-Total', 'event_espresso'), $options); |
|
53 | - break; |
|
54 | - |
|
55 | - |
|
56 | - case EEM_Line_Item::type_tax_sub_total: |
|
57 | - // loop thru children |
|
58 | - foreach ($line_item->children() as $child_line_item) { |
|
59 | - // recursively feed children back into this method |
|
60 | - $html .= $this->display_line_item($child_line_item, $options); |
|
61 | - } |
|
62 | - $html .= $this->_total_row($line_item, esc_html__('Tax Total', 'event_espresso'), $options); |
|
63 | - break; |
|
64 | - |
|
65 | - |
|
66 | - case EEM_Line_Item::type_line_item: |
|
67 | - // item row |
|
68 | - $html .= $this->_item_row($line_item, $options); |
|
69 | - // got any kids? |
|
70 | - foreach ($line_item->children() as $child_line_item) { |
|
71 | - $this->display_line_item($child_line_item, $options); |
|
72 | - } |
|
73 | - break; |
|
74 | - |
|
75 | - |
|
76 | - case EEM_Line_Item::type_sub_line_item: |
|
77 | - $html .= $this->_sub_item_row($line_item, $options); |
|
78 | - break; |
|
79 | - |
|
80 | - |
|
81 | - case EEM_Line_Item::type_tax: |
|
82 | - $html .= $this->_tax_row($line_item, $options); |
|
83 | - break; |
|
84 | - } |
|
85 | - |
|
86 | - return $html; |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * _total_row |
|
93 | - * |
|
94 | - * @param EE_Line_Item $line_item |
|
95 | - * @param array $options |
|
96 | - * @return mixed |
|
97 | - */ |
|
98 | - private function _item_row(EE_Line_Item $line_item, $options = array()) |
|
99 | - { |
|
100 | - // start of row |
|
101 | - $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
102 | - $html = EEH_HTML::tr('', $row_class); |
|
103 | - // name td |
|
104 | - $html .= EEH_HTML::td($line_item->name(), '', 'item_l'); |
|
105 | - // desc td |
|
106 | - $html .= $options['show_desc'] ? EEH_HTML::td($line_item->desc(), '', 'item_l') : ''; |
|
107 | - // quantity td |
|
108 | - $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l'); |
|
109 | - // price td |
|
110 | - $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c'); |
|
111 | - // total td |
|
112 | - $total = $line_item->is_taxable() ? $line_item->total_no_code() . '*' : $line_item->total_no_code(); |
|
113 | - $html .= EEH_HTML::td($total, '', 'item_r'); |
|
114 | - // end of row |
|
115 | - $html .= EEH_HTML::trx(); |
|
116 | - return $html; |
|
117 | - } |
|
118 | - |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * _sub_item_row |
|
123 | - * |
|
124 | - * @param EE_Line_Item $line_item |
|
125 | - * @param array $options |
|
126 | - * @return mixed |
|
127 | - */ |
|
128 | - private function _sub_item_row(EE_Line_Item $line_item, $options = array()) |
|
129 | - { |
|
130 | - // start of row |
|
131 | - $html = EEH_HTML::tr('', 'item sub-item-row'); |
|
132 | - // name td |
|
133 | - $html .= EEH_HTML::td($line_item->name(), '', 'item_l sub-item'); |
|
134 | - // desc td |
|
135 | - $html .= $options['show_desc'] ? EEH_HTML::td($line_item->desc(), '', 'item_l') : ''; |
|
136 | - $html .= EEH_HTML::td() . EEH_HTML::tdx(); |
|
137 | - // discount/surcharge td |
|
138 | - if ($line_item->is_percent()) { |
|
139 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c'); |
|
140 | - } else { |
|
141 | - $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c'); |
|
142 | - } |
|
143 | - // total td |
|
144 | - $html .= EEH_HTML::td($line_item->total_no_code(), '', 'item_r'); |
|
145 | - // end of row |
|
146 | - $html .= EEH_HTML::trx(); |
|
147 | - return $html; |
|
148 | - } |
|
149 | - |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * _tax_row |
|
154 | - * |
|
155 | - * @param EE_Line_Item $line_item |
|
156 | - * @param array $options |
|
157 | - * @return mixed |
|
158 | - */ |
|
159 | - private function _tax_row(EE_Line_Item $line_item, $options = array()) |
|
160 | - { |
|
161 | - // start of row |
|
162 | - $html = EEH_HTML::tr('', 'item sub-item tax-total'); |
|
163 | - // name td |
|
164 | - $html .= EEH_HTML::td($line_item->name(), '', 'item_l sub-item'); |
|
165 | - // desc td |
|
166 | - $html .= $options['show_desc'] ? EEH_HTML::td($line_item->desc(), '', 'item_l') : ''; |
|
167 | - // percent td |
|
168 | - $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c', '', ' colspan="2"'); |
|
169 | - // total td |
|
170 | - $html .= EEH_HTML::td($line_item->total_no_code(), '', 'item_r'); |
|
171 | - // end of row |
|
172 | - $html .= EEH_HTML::trx(); |
|
173 | - return $html; |
|
174 | - } |
|
175 | - |
|
176 | - |
|
177 | - |
|
178 | - /** |
|
179 | - * _total_row |
|
180 | - * |
|
181 | - * @param EE_Line_Item $line_item |
|
182 | - * @param string $text |
|
183 | - * @param array $options |
|
184 | - * @return mixed |
|
185 | - */ |
|
186 | - private function _total_row(EE_Line_Item $line_item, $text = '', $options = array()) |
|
187 | - { |
|
188 | - // colspan |
|
189 | - $colspan = $options['show_desc'] ? ' colspan="2"' : ''; |
|
190 | - // start of row |
|
191 | - $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
192 | - // empty td |
|
193 | - $html .= EEH_HTML::td(EEH_HTML::nbsp(), '', '', '', $colspan); |
|
194 | - // total td |
|
195 | - $html .= EEH_HTML::td($text, '', 'total_currency total', '', $colspan); |
|
196 | - // total td |
|
197 | - $html .= EEH_HTML::td($line_item->total_no_code(), '', 'total'); |
|
198 | - // end of row |
|
199 | - $html .= EEH_HTML::trx(); |
|
200 | - return $html; |
|
201 | - } |
|
202 | - |
|
203 | - |
|
204 | - |
|
205 | - /** |
|
206 | - * _separator_row |
|
207 | - * |
|
208 | - * @param array $options |
|
209 | - * @return mixed |
|
210 | - */ |
|
211 | - private function _separator_row($options = array()) |
|
212 | - { |
|
213 | - // colspan |
|
214 | - $colspan = $options['show_desc'] ? ' colspan="5"' : ' colspan="4"'; |
|
215 | - // start of row |
|
216 | - $html = EEH_HTML::tr(EEH_HTML::td('<hr>', '', '', '', $colspan)); |
|
18 | + /** |
|
19 | + * @param EE_Line_Item $line_item |
|
20 | + * @param array $options |
|
21 | + * @return mixed |
|
22 | + */ |
|
23 | + public function display_line_item(EE_Line_Item $line_item, $options = array()) |
|
24 | + { |
|
25 | + |
|
26 | + $html = ''; |
|
27 | + // set some default options and merge with incoming |
|
28 | + $default_options = array( |
|
29 | + 'show_desc' => true, |
|
30 | + 'odd' => false |
|
31 | + ); |
|
32 | + $options = array_merge($default_options, (array) $options); |
|
33 | + |
|
34 | + switch ($line_item->type()) { |
|
35 | + case EEM_Line_Item::type_total: |
|
36 | + // loop thru children |
|
37 | + foreach ($line_item->children() as $child_line_item) { |
|
38 | + // recursively feed children back into this method |
|
39 | + $html .= $this->display_line_item($child_line_item, $options); |
|
40 | + } |
|
41 | + $html .= $this->_separator_row($options); |
|
42 | + $html .= $this->_total_row($line_item, esc_html__('Total', 'event_espresso'), $options); |
|
43 | + break; |
|
44 | + |
|
45 | + |
|
46 | + case EEM_Line_Item::type_sub_total: |
|
47 | + // loop thru children |
|
48 | + foreach ($line_item->children() as $child_line_item) { |
|
49 | + // recursively feed children back into this method |
|
50 | + $html .= $this->display_line_item($child_line_item, $options); |
|
51 | + } |
|
52 | + $html .= $this->_total_row($line_item, esc_html__('Sub-Total', 'event_espresso'), $options); |
|
53 | + break; |
|
54 | + |
|
55 | + |
|
56 | + case EEM_Line_Item::type_tax_sub_total: |
|
57 | + // loop thru children |
|
58 | + foreach ($line_item->children() as $child_line_item) { |
|
59 | + // recursively feed children back into this method |
|
60 | + $html .= $this->display_line_item($child_line_item, $options); |
|
61 | + } |
|
62 | + $html .= $this->_total_row($line_item, esc_html__('Tax Total', 'event_espresso'), $options); |
|
63 | + break; |
|
64 | + |
|
65 | + |
|
66 | + case EEM_Line_Item::type_line_item: |
|
67 | + // item row |
|
68 | + $html .= $this->_item_row($line_item, $options); |
|
69 | + // got any kids? |
|
70 | + foreach ($line_item->children() as $child_line_item) { |
|
71 | + $this->display_line_item($child_line_item, $options); |
|
72 | + } |
|
73 | + break; |
|
74 | + |
|
75 | + |
|
76 | + case EEM_Line_Item::type_sub_line_item: |
|
77 | + $html .= $this->_sub_item_row($line_item, $options); |
|
78 | + break; |
|
79 | + |
|
80 | + |
|
81 | + case EEM_Line_Item::type_tax: |
|
82 | + $html .= $this->_tax_row($line_item, $options); |
|
83 | + break; |
|
84 | + } |
|
85 | + |
|
86 | + return $html; |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * _total_row |
|
93 | + * |
|
94 | + * @param EE_Line_Item $line_item |
|
95 | + * @param array $options |
|
96 | + * @return mixed |
|
97 | + */ |
|
98 | + private function _item_row(EE_Line_Item $line_item, $options = array()) |
|
99 | + { |
|
100 | + // start of row |
|
101 | + $row_class = $options['odd'] ? 'item odd' : 'item'; |
|
102 | + $html = EEH_HTML::tr('', $row_class); |
|
103 | + // name td |
|
104 | + $html .= EEH_HTML::td($line_item->name(), '', 'item_l'); |
|
105 | + // desc td |
|
106 | + $html .= $options['show_desc'] ? EEH_HTML::td($line_item->desc(), '', 'item_l') : ''; |
|
107 | + // quantity td |
|
108 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l'); |
|
109 | + // price td |
|
110 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c'); |
|
111 | + // total td |
|
112 | + $total = $line_item->is_taxable() ? $line_item->total_no_code() . '*' : $line_item->total_no_code(); |
|
113 | + $html .= EEH_HTML::td($total, '', 'item_r'); |
|
114 | + // end of row |
|
115 | + $html .= EEH_HTML::trx(); |
|
116 | + return $html; |
|
117 | + } |
|
118 | + |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * _sub_item_row |
|
123 | + * |
|
124 | + * @param EE_Line_Item $line_item |
|
125 | + * @param array $options |
|
126 | + * @return mixed |
|
127 | + */ |
|
128 | + private function _sub_item_row(EE_Line_Item $line_item, $options = array()) |
|
129 | + { |
|
130 | + // start of row |
|
131 | + $html = EEH_HTML::tr('', 'item sub-item-row'); |
|
132 | + // name td |
|
133 | + $html .= EEH_HTML::td($line_item->name(), '', 'item_l sub-item'); |
|
134 | + // desc td |
|
135 | + $html .= $options['show_desc'] ? EEH_HTML::td($line_item->desc(), '', 'item_l') : ''; |
|
136 | + $html .= EEH_HTML::td() . EEH_HTML::tdx(); |
|
137 | + // discount/surcharge td |
|
138 | + if ($line_item->is_percent()) { |
|
139 | + $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c'); |
|
140 | + } else { |
|
141 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c'); |
|
142 | + } |
|
143 | + // total td |
|
144 | + $html .= EEH_HTML::td($line_item->total_no_code(), '', 'item_r'); |
|
145 | + // end of row |
|
146 | + $html .= EEH_HTML::trx(); |
|
147 | + return $html; |
|
148 | + } |
|
149 | + |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * _tax_row |
|
154 | + * |
|
155 | + * @param EE_Line_Item $line_item |
|
156 | + * @param array $options |
|
157 | + * @return mixed |
|
158 | + */ |
|
159 | + private function _tax_row(EE_Line_Item $line_item, $options = array()) |
|
160 | + { |
|
161 | + // start of row |
|
162 | + $html = EEH_HTML::tr('', 'item sub-item tax-total'); |
|
163 | + // name td |
|
164 | + $html .= EEH_HTML::td($line_item->name(), '', 'item_l sub-item'); |
|
165 | + // desc td |
|
166 | + $html .= $options['show_desc'] ? EEH_HTML::td($line_item->desc(), '', 'item_l') : ''; |
|
167 | + // percent td |
|
168 | + $html .= EEH_HTML::td($line_item->percent() . '%', '', 'item_c', '', ' colspan="2"'); |
|
169 | + // total td |
|
170 | + $html .= EEH_HTML::td($line_item->total_no_code(), '', 'item_r'); |
|
171 | + // end of row |
|
172 | + $html .= EEH_HTML::trx(); |
|
173 | + return $html; |
|
174 | + } |
|
175 | + |
|
176 | + |
|
177 | + |
|
178 | + /** |
|
179 | + * _total_row |
|
180 | + * |
|
181 | + * @param EE_Line_Item $line_item |
|
182 | + * @param string $text |
|
183 | + * @param array $options |
|
184 | + * @return mixed |
|
185 | + */ |
|
186 | + private function _total_row(EE_Line_Item $line_item, $text = '', $options = array()) |
|
187 | + { |
|
188 | + // colspan |
|
189 | + $colspan = $options['show_desc'] ? ' colspan="2"' : ''; |
|
190 | + // start of row |
|
191 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
192 | + // empty td |
|
193 | + $html .= EEH_HTML::td(EEH_HTML::nbsp(), '', '', '', $colspan); |
|
194 | + // total td |
|
195 | + $html .= EEH_HTML::td($text, '', 'total_currency total', '', $colspan); |
|
196 | + // total td |
|
197 | + $html .= EEH_HTML::td($line_item->total_no_code(), '', 'total'); |
|
198 | + // end of row |
|
199 | + $html .= EEH_HTML::trx(); |
|
200 | + return $html; |
|
201 | + } |
|
202 | + |
|
203 | + |
|
204 | + |
|
205 | + /** |
|
206 | + * _separator_row |
|
207 | + * |
|
208 | + * @param array $options |
|
209 | + * @return mixed |
|
210 | + */ |
|
211 | + private function _separator_row($options = array()) |
|
212 | + { |
|
213 | + // colspan |
|
214 | + $colspan = $options['show_desc'] ? ' colspan="5"' : ' colspan="4"'; |
|
215 | + // start of row |
|
216 | + $html = EEH_HTML::tr(EEH_HTML::td('<hr>', '', '', '', $colspan)); |
|
217 | 217 | // // separator td |
218 | 218 | // $html .= EEH_HTML::td( '<hr>', '', '', '', $colspan ); |
219 | 219 | // // end of row |
220 | 220 | // $html .= EEH_HTML::trx(); |
221 | - return $html; |
|
222 | - } |
|
221 | + return $html; |
|
222 | + } |
|
223 | 223 | } |
@@ -22,30 +22,30 @@ |
||
22 | 22 | |
23 | 23 | interface JobHandlerInterface |
24 | 24 | { |
25 | - /** |
|
26 | - * Performs any necessary setup for starting the job. This is also a good |
|
27 | - * place to setup the $job_arguments which will be used for subsequent HTTP requests |
|
28 | - * when continue_job will be called |
|
29 | - * @param JobParameters $job_parameters |
|
30 | - * @throws BatchRequestException |
|
31 | - * @return JobStepResponse |
|
32 | - */ |
|
33 | - public function create_job(JobParameters $job_parameters); |
|
25 | + /** |
|
26 | + * Performs any necessary setup for starting the job. This is also a good |
|
27 | + * place to setup the $job_arguments which will be used for subsequent HTTP requests |
|
28 | + * when continue_job will be called |
|
29 | + * @param JobParameters $job_parameters |
|
30 | + * @throws BatchRequestException |
|
31 | + * @return JobStepResponse |
|
32 | + */ |
|
33 | + public function create_job(JobParameters $job_parameters); |
|
34 | 34 | |
35 | - /** |
|
36 | - * Performs another step of the job |
|
37 | - * @param JobParameters $job_parameters |
|
38 | - * @param int $batch_size |
|
39 | - * @return JobStepResponse |
|
40 | - * @throws BatchRequestException |
|
41 | - */ |
|
42 | - public function continue_job(JobParameters $job_parameters, $batch_size = 50); |
|
35 | + /** |
|
36 | + * Performs another step of the job |
|
37 | + * @param JobParameters $job_parameters |
|
38 | + * @param int $batch_size |
|
39 | + * @return JobStepResponse |
|
40 | + * @throws BatchRequestException |
|
41 | + */ |
|
42 | + public function continue_job(JobParameters $job_parameters, $batch_size = 50); |
|
43 | 43 | |
44 | - /** |
|
45 | - * Performs any clean-up logic when we know the job is completed |
|
46 | - * @param JobParameters $job_parameters |
|
47 | - * @return JobStepResponse |
|
48 | - * @throws BatchRequestException |
|
49 | - */ |
|
50 | - public function cleanup_job(JobParameters $job_parameters); |
|
44 | + /** |
|
45 | + * Performs any clean-up logic when we know the job is completed |
|
46 | + * @param JobParameters $job_parameters |
|
47 | + * @return JobStepResponse |
|
48 | + * @throws BatchRequestException |
|
49 | + */ |
|
50 | + public function cleanup_job(JobParameters $job_parameters); |
|
51 | 51 | } |
@@ -13,146 +13,146 @@ |
||
13 | 13 | class EE_Response |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @access protected |
|
18 | - * @type array $_notice |
|
19 | - */ |
|
20 | - protected $_notice = array(); |
|
21 | - |
|
22 | - /** |
|
23 | - * rendered output to be returned to WP |
|
24 | - * |
|
25 | - * @access protected |
|
26 | - * @type string |
|
27 | - */ |
|
28 | - protected $_output = ''; |
|
29 | - |
|
30 | - /** |
|
31 | - * @access protected |
|
32 | - * @type bool |
|
33 | - */ |
|
34 | - protected $request_terminated = false; |
|
35 | - |
|
36 | - /** |
|
37 | - * @access protected |
|
38 | - * @type bool |
|
39 | - */ |
|
40 | - protected $deactivate_plugin = false; |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * @deprecated 4.9.53 |
|
45 | - * @return \EE_Response |
|
46 | - */ |
|
47 | - public function __construct() |
|
48 | - { |
|
49 | - $this->terminate_request(false); |
|
50 | - EE_Error::doing_it_wrong( |
|
51 | - __METHOD__, |
|
52 | - sprintf( |
|
53 | - esc_html__( |
|
54 | - 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
55 | - 'event_espresso' |
|
56 | - ), |
|
57 | - 'EventEspresso\core\services\request\Response', |
|
58 | - '\core\services\request', |
|
59 | - 'EventEspresso\core\services\request' |
|
60 | - ), |
|
61 | - '4.9.53' |
|
62 | - ); |
|
63 | - } |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * @deprecated 4.9.53 |
|
68 | - * @param $key |
|
69 | - * @param $value |
|
70 | - * @return void |
|
71 | - */ |
|
72 | - public function set_notice($key, $value) |
|
73 | - { |
|
74 | - $this->_notice[ $key ] = $value; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * @deprecated 4.9.53 |
|
80 | - * @param $key |
|
81 | - * @return mixed |
|
82 | - */ |
|
83 | - public function get_notice($key) |
|
84 | - { |
|
85 | - return isset($this->_notice[ $key ]) ? $this->_notice[ $key ] : null; |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * @deprecated 4.9.53 |
|
91 | - * @return array |
|
92 | - */ |
|
93 | - public function get_notices() |
|
94 | - { |
|
95 | - return $this->_notice; |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * @deprecated 4.9.53 |
|
101 | - * @param $string |
|
102 | - * @param bool $append |
|
103 | - */ |
|
104 | - public function add_output($string, $append = true) |
|
105 | - { |
|
106 | - $this->_output = $append ? $this->_output . $string : $string . $this->_output; |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * @deprecated 4.9.53 |
|
112 | - * @return string |
|
113 | - */ |
|
114 | - public function get_output() |
|
115 | - { |
|
116 | - return $this->_output; |
|
117 | - } |
|
118 | - |
|
119 | - |
|
120 | - /** |
|
121 | - * @deprecated 4.9.53 |
|
122 | - * @return boolean |
|
123 | - */ |
|
124 | - public function request_terminated() |
|
125 | - { |
|
126 | - return $this->request_terminated; |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * @deprecated 4.9.53 |
|
132 | - * @param boolean $request_terminated |
|
133 | - */ |
|
134 | - public function terminate_request($request_terminated = true) |
|
135 | - { |
|
136 | - $this->request_terminated = filter_var($request_terminated, FILTER_VALIDATE_BOOLEAN); |
|
137 | - } |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * @deprecated 4.9.53 |
|
142 | - * @return boolean |
|
143 | - */ |
|
144 | - public function plugin_deactivated() |
|
145 | - { |
|
146 | - return $this->deactivate_plugin; |
|
147 | - } |
|
148 | - |
|
149 | - |
|
150 | - /** |
|
151 | - * @deprecated 4.9.53 |
|
152 | - * sets $deactivate_plugin to true |
|
153 | - */ |
|
154 | - public function deactivate_plugin() |
|
155 | - { |
|
156 | - $this->deactivate_plugin = true; |
|
157 | - } |
|
16 | + /** |
|
17 | + * @access protected |
|
18 | + * @type array $_notice |
|
19 | + */ |
|
20 | + protected $_notice = array(); |
|
21 | + |
|
22 | + /** |
|
23 | + * rendered output to be returned to WP |
|
24 | + * |
|
25 | + * @access protected |
|
26 | + * @type string |
|
27 | + */ |
|
28 | + protected $_output = ''; |
|
29 | + |
|
30 | + /** |
|
31 | + * @access protected |
|
32 | + * @type bool |
|
33 | + */ |
|
34 | + protected $request_terminated = false; |
|
35 | + |
|
36 | + /** |
|
37 | + * @access protected |
|
38 | + * @type bool |
|
39 | + */ |
|
40 | + protected $deactivate_plugin = false; |
|
41 | + |
|
42 | + |
|
43 | + /** |
|
44 | + * @deprecated 4.9.53 |
|
45 | + * @return \EE_Response |
|
46 | + */ |
|
47 | + public function __construct() |
|
48 | + { |
|
49 | + $this->terminate_request(false); |
|
50 | + EE_Error::doing_it_wrong( |
|
51 | + __METHOD__, |
|
52 | + sprintf( |
|
53 | + esc_html__( |
|
54 | + 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
55 | + 'event_espresso' |
|
56 | + ), |
|
57 | + 'EventEspresso\core\services\request\Response', |
|
58 | + '\core\services\request', |
|
59 | + 'EventEspresso\core\services\request' |
|
60 | + ), |
|
61 | + '4.9.53' |
|
62 | + ); |
|
63 | + } |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * @deprecated 4.9.53 |
|
68 | + * @param $key |
|
69 | + * @param $value |
|
70 | + * @return void |
|
71 | + */ |
|
72 | + public function set_notice($key, $value) |
|
73 | + { |
|
74 | + $this->_notice[ $key ] = $value; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * @deprecated 4.9.53 |
|
80 | + * @param $key |
|
81 | + * @return mixed |
|
82 | + */ |
|
83 | + public function get_notice($key) |
|
84 | + { |
|
85 | + return isset($this->_notice[ $key ]) ? $this->_notice[ $key ] : null; |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * @deprecated 4.9.53 |
|
91 | + * @return array |
|
92 | + */ |
|
93 | + public function get_notices() |
|
94 | + { |
|
95 | + return $this->_notice; |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * @deprecated 4.9.53 |
|
101 | + * @param $string |
|
102 | + * @param bool $append |
|
103 | + */ |
|
104 | + public function add_output($string, $append = true) |
|
105 | + { |
|
106 | + $this->_output = $append ? $this->_output . $string : $string . $this->_output; |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * @deprecated 4.9.53 |
|
112 | + * @return string |
|
113 | + */ |
|
114 | + public function get_output() |
|
115 | + { |
|
116 | + return $this->_output; |
|
117 | + } |
|
118 | + |
|
119 | + |
|
120 | + /** |
|
121 | + * @deprecated 4.9.53 |
|
122 | + * @return boolean |
|
123 | + */ |
|
124 | + public function request_terminated() |
|
125 | + { |
|
126 | + return $this->request_terminated; |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * @deprecated 4.9.53 |
|
132 | + * @param boolean $request_terminated |
|
133 | + */ |
|
134 | + public function terminate_request($request_terminated = true) |
|
135 | + { |
|
136 | + $this->request_terminated = filter_var($request_terminated, FILTER_VALIDATE_BOOLEAN); |
|
137 | + } |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * @deprecated 4.9.53 |
|
142 | + * @return boolean |
|
143 | + */ |
|
144 | + public function plugin_deactivated() |
|
145 | + { |
|
146 | + return $this->deactivate_plugin; |
|
147 | + } |
|
148 | + |
|
149 | + |
|
150 | + /** |
|
151 | + * @deprecated 4.9.53 |
|
152 | + * sets $deactivate_plugin to true |
|
153 | + */ |
|
154 | + public function deactivate_plugin() |
|
155 | + { |
|
156 | + $this->deactivate_plugin = true; |
|
157 | + } |
|
158 | 158 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function set_notice($key, $value) |
73 | 73 | { |
74 | - $this->_notice[ $key ] = $value; |
|
74 | + $this->_notice[$key] = $value; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function get_notice($key) |
84 | 84 | { |
85 | - return isset($this->_notice[ $key ]) ? $this->_notice[ $key ] : null; |
|
85 | + return isset($this->_notice[$key]) ? $this->_notice[$key] : null; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function add_output($string, $append = true) |
105 | 105 | { |
106 | - $this->_output = $append ? $this->_output . $string : $string . $this->_output; |
|
106 | + $this->_output = $append ? $this->_output.$string : $string.$this->_output; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 |
@@ -13,46 +13,46 @@ |
||
13 | 13 | class EE_Request_Stack_Builder |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * EE_Request_Stack_Builder |
|
18 | - */ |
|
19 | - public function __construct() |
|
20 | - { |
|
21 | - EE_Error::doing_it_wrong( |
|
22 | - __METHOD__, |
|
23 | - sprintf( |
|
24 | - esc_html__( |
|
25 | - 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
26 | - 'event_espresso' |
|
27 | - ), |
|
28 | - 'EventEspresso\core\services\request\RequestStackBuilder', |
|
29 | - '\core\services\request', |
|
30 | - 'EventEspresso\core\services\request' |
|
31 | - ), |
|
32 | - '4.9.53' |
|
33 | - ); |
|
34 | - } |
|
16 | + /** |
|
17 | + * EE_Request_Stack_Builder |
|
18 | + */ |
|
19 | + public function __construct() |
|
20 | + { |
|
21 | + EE_Error::doing_it_wrong( |
|
22 | + __METHOD__, |
|
23 | + sprintf( |
|
24 | + esc_html__( |
|
25 | + 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
26 | + 'event_espresso' |
|
27 | + ), |
|
28 | + 'EventEspresso\core\services\request\RequestStackBuilder', |
|
29 | + '\core\services\request', |
|
30 | + 'EventEspresso\core\services\request' |
|
31 | + ), |
|
32 | + '4.9.53' |
|
33 | + ); |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * @deprecated 4.9.53 |
|
38 | - */ |
|
39 | - public function unshift() |
|
40 | - { |
|
41 | - } |
|
36 | + /** |
|
37 | + * @deprecated 4.9.53 |
|
38 | + */ |
|
39 | + public function unshift() |
|
40 | + { |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /** |
|
45 | - * @deprecated 4.9.53 |
|
46 | - */ |
|
47 | - public function push() |
|
48 | - { |
|
49 | - } |
|
44 | + /** |
|
45 | + * @deprecated 4.9.53 |
|
46 | + */ |
|
47 | + public function push() |
|
48 | + { |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * @deprecated 4.9.53 |
|
54 | - */ |
|
55 | - public function resolve(EEI_Request_Decorator $application) |
|
56 | - { |
|
57 | - } |
|
52 | + /** |
|
53 | + * @deprecated 4.9.53 |
|
54 | + */ |
|
55 | + public function resolve(EEI_Request_Decorator $application) |
|
56 | + { |
|
57 | + } |
|
58 | 58 | } |
@@ -13,25 +13,25 @@ |
||
13 | 13 | { |
14 | 14 | |
15 | 15 | |
16 | - /** |
|
17 | - * @deprecated 4.9.53 |
|
18 | - * @param EEI_Request_Decorator $application |
|
19 | - * @param array $middlewares |
|
20 | - */ |
|
21 | - public function __construct(EEI_Request_Decorator $application, $middlewares = array()) |
|
22 | - { |
|
23 | - EE_Error::doing_it_wrong( |
|
24 | - __METHOD__, |
|
25 | - sprintf( |
|
26 | - esc_html__( |
|
27 | - 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
28 | - 'event_espresso' |
|
29 | - ), |
|
30 | - 'EventEspresso\core\services\request\RequestStack', |
|
31 | - '\core\services\request', |
|
32 | - 'EventEspresso\core\services\request' |
|
33 | - ), |
|
34 | - '4.9.53' |
|
35 | - ); |
|
36 | - } |
|
16 | + /** |
|
17 | + * @deprecated 4.9.53 |
|
18 | + * @param EEI_Request_Decorator $application |
|
19 | + * @param array $middlewares |
|
20 | + */ |
|
21 | + public function __construct(EEI_Request_Decorator $application, $middlewares = array()) |
|
22 | + { |
|
23 | + EE_Error::doing_it_wrong( |
|
24 | + __METHOD__, |
|
25 | + sprintf( |
|
26 | + esc_html__( |
|
27 | + 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
28 | + 'event_espresso' |
|
29 | + ), |
|
30 | + 'EventEspresso\core\services\request\RequestStack', |
|
31 | + '\core\services\request', |
|
32 | + 'EventEspresso\core\services\request' |
|
33 | + ), |
|
34 | + '4.9.53' |
|
35 | + ); |
|
36 | + } |
|
37 | 37 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | // what shortcode was actually parsed ? |
105 | 105 | $shortcode_class = get_called_class(); |
106 | 106 | // notify rest of system that fallback processor was triggered |
107 | - add_filter('FHEE__fallback_shortcode_processor__' . $shortcode_class, '__return_true'); |
|
107 | + add_filter('FHEE__fallback_shortcode_processor__'.$shortcode_class, '__return_true'); |
|
108 | 108 | // get instance of actual shortcode |
109 | 109 | $shortcode_obj = self::instance($shortcode_class); |
110 | 110 | // verify class |
@@ -159,13 +159,13 @@ discard block |
||
159 | 159 | { |
160 | 160 | foreach ($attributes as $key => $value) { |
161 | 161 | // is a custom sanitization callback specified ? |
162 | - if (isset($custom_sanitization[ $key ])) { |
|
163 | - $callback = $custom_sanitization[ $key ]; |
|
162 | + if (isset($custom_sanitization[$key])) { |
|
163 | + $callback = $custom_sanitization[$key]; |
|
164 | 164 | if ($callback === 'skip_sanitization') { |
165 | - $attributes[ $key ] = $value; |
|
165 | + $attributes[$key] = $value; |
|
166 | 166 | continue; |
167 | 167 | } elseif (function_exists($callback)) { |
168 | - $attributes[ $key ] = $callback($value); |
|
168 | + $attributes[$key] = $callback($value); |
|
169 | 169 | continue; |
170 | 170 | } |
171 | 171 | } |
@@ -175,18 +175,18 @@ discard block |
||
175 | 175 | case is_float($value): |
176 | 176 | // typical booleans |
177 | 177 | case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true): |
178 | - $attributes[ $key ] = $value; |
|
178 | + $attributes[$key] = $value; |
|
179 | 179 | break; |
180 | 180 | case is_string($value): |
181 | - $attributes[ $key ] = sanitize_text_field($value); |
|
181 | + $attributes[$key] = sanitize_text_field($value); |
|
182 | 182 | break; |
183 | 183 | case is_array($value): |
184 | - $attributes[ $key ] = \EES_Shortcode::sanitize_attributes($value); |
|
184 | + $attributes[$key] = \EES_Shortcode::sanitize_attributes($value); |
|
185 | 185 | break; |
186 | 186 | default: |
187 | 187 | // only remaining data types are Object and Resource |
188 | 188 | // which are not allowed as shortcode attributes |
189 | - $attributes[ $key ] = null; |
|
189 | + $attributes[$key] = null; |
|
190 | 190 | break; |
191 | 191 | } |
192 | 192 | } |
@@ -15,186 +15,186 @@ |
||
15 | 15 | abstract class EES_Shortcode extends EE_Base |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @protected public |
|
20 | - * @var array $_attributes |
|
21 | - */ |
|
22 | - protected $_attributes = array(); |
|
23 | - |
|
24 | - |
|
25 | - |
|
26 | - /** |
|
27 | - * class constructor - should ONLY be instantiated by EE_Front_Controller |
|
28 | - */ |
|
29 | - final public function __construct() |
|
30 | - { |
|
31 | - $shortcode = LegacyShortcodesManager::generateShortcodeTagFromClassName(get_class($this)); |
|
32 | - // assign shortcode to the preferred callback, which overwrites the "fallback shortcode processor" assigned earlier |
|
33 | - add_shortcode($shortcode, array($this, 'process_shortcode')); |
|
34 | - // make sure system knows this is an EE page |
|
35 | - /** @var CurrentPage $current_page */ |
|
36 | - $current_page = LoaderFactory::getLoader()->getShared(CurrentPage::class); |
|
37 | - $current_page->setEspressoPage(true); |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * run - initial shortcode module setup called during "parse_request" hook by |
|
44 | - * \EE_Front_Controller::_initialize_shortcodes() IF this shortcode is going to execute during this request ! |
|
45 | - * It may also get called by \EES_Shortcode::fallback_shortcode_processor() if the shortcode is being implemented |
|
46 | - * by a theme or plugin in a non-standard way. |
|
47 | - * Basically this method is primarily used for loading resources and assets like CSS or JS |
|
48 | - * that will be required by the shortcode when it is actually processed. |
|
49 | - * Please note that assets may not load if the fallback_shortcode_processor() is being used. |
|
50 | - * |
|
51 | - * @access public |
|
52 | - * @param WP $WP |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - abstract public function run(WP $WP); |
|
56 | - |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * process_shortcode |
|
61 | - * this method is the callback function for the actual shortcode, and is what runs when WP encounters the shortcode within the_content |
|
62 | - * |
|
63 | - * @access public |
|
64 | - * @param array $attributes |
|
65 | - * @return mixed |
|
66 | - */ |
|
67 | - abstract public function process_shortcode($attributes = array()); |
|
68 | - |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * instance - returns instance of child class object |
|
73 | - * |
|
74 | - * @access public |
|
75 | - * @param string $shortcode_class |
|
76 | - * @return \EES_Shortcode |
|
77 | - */ |
|
78 | - final public static function instance($shortcode_class = null) |
|
79 | - { |
|
80 | - $shortcode_class = ! empty($shortcode_class) ? $shortcode_class : get_called_class(); |
|
81 | - if ($shortcode_class === 'EES_Shortcode' || empty($shortcode_class)) { |
|
82 | - return null; |
|
83 | - } |
|
84 | - $shortcode = str_replace('EES_', '', strtoupper($shortcode_class)); |
|
85 | - $shortcode_obj = isset(EE_Registry::instance()->shortcodes->{$shortcode}) |
|
86 | - ? EE_Registry::instance()->shortcodes->{$shortcode} |
|
87 | - : null; |
|
88 | - return $shortcode_obj instanceof $shortcode_class || $shortcode_class === 'self' |
|
89 | - ? $shortcode_obj |
|
90 | - : new $shortcode_class(); |
|
91 | - } |
|
92 | - |
|
93 | - |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * fallback_shortcode_processor - create instance and call process_shortcode |
|
98 | - * NOTE: shortcode may not function perfectly dues to missing assets, but it's better than not having things work at all |
|
99 | - * |
|
100 | - * @access public |
|
101 | - * @param $attributes |
|
102 | - * @return mixed |
|
103 | - */ |
|
104 | - final public static function fallback_shortcode_processor($attributes) |
|
105 | - { |
|
106 | - if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) { |
|
107 | - return null; |
|
108 | - } |
|
109 | - // what shortcode was actually parsed ? |
|
110 | - $shortcode_class = get_called_class(); |
|
111 | - // notify rest of system that fallback processor was triggered |
|
112 | - add_filter('FHEE__fallback_shortcode_processor__' . $shortcode_class, '__return_true'); |
|
113 | - // get instance of actual shortcode |
|
114 | - $shortcode_obj = self::instance($shortcode_class); |
|
115 | - // verify class |
|
116 | - if ($shortcode_obj instanceof EES_Shortcode) { |
|
117 | - global $wp; |
|
118 | - $shortcode_obj->run($wp); |
|
119 | - // set attributes and run the shortcode |
|
120 | - $shortcode_obj->_attributes = (array) $attributes; |
|
121 | - return $shortcode_obj->process_shortcode($shortcode_obj->_attributes); |
|
122 | - } else { |
|
123 | - return null; |
|
124 | - } |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * invalid_shortcode_processor - used in cases where we know the shortcode is invalid, most likely due to a deactivated addon, and simply returns an empty string |
|
132 | - * |
|
133 | - * @access public |
|
134 | - * @param $attributes |
|
135 | - * @return string |
|
136 | - */ |
|
137 | - final public static function invalid_shortcode_processor($attributes) |
|
138 | - { |
|
139 | - return ''; |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * Performs basic sanitization on shortcode attributes |
|
148 | - * Since incoming attributes from the shortcode usage in the WP editor will all be strings, |
|
149 | - * most attributes will by default be sanitized using the sanitize_text_field() function. |
|
150 | - * This can be overridden by supplying an array for the $custom_sanitization param, |
|
151 | - * where keys match keys in your attributes array, |
|
152 | - * and values represent the sanitization function you wish to be applied to that attribute. |
|
153 | - * So for example, if you had an integer attribute named "event_id" |
|
154 | - * that you wanted to be sanitized using absint(), |
|
155 | - * then you would pass the following for your $custom_sanitization array: |
|
156 | - * array('event_id' => 'absint') |
|
157 | - * all other attributes would be sanitized using the defaults in the switch statement below |
|
158 | - * |
|
159 | - * @param array $attributes |
|
160 | - * @param array $custom_sanitization |
|
161 | - * @return array |
|
162 | - */ |
|
163 | - public static function sanitize_attributes(array $attributes, $custom_sanitization = array()) |
|
164 | - { |
|
165 | - foreach ($attributes as $key => $value) { |
|
166 | - // is a custom sanitization callback specified ? |
|
167 | - if (isset($custom_sanitization[ $key ])) { |
|
168 | - $callback = $custom_sanitization[ $key ]; |
|
169 | - if ($callback === 'skip_sanitization') { |
|
170 | - $attributes[ $key ] = $value; |
|
171 | - continue; |
|
172 | - } elseif (function_exists($callback)) { |
|
173 | - $attributes[ $key ] = $callback($value); |
|
174 | - continue; |
|
175 | - } |
|
176 | - } |
|
177 | - switch (true) { |
|
178 | - case $value === null: |
|
179 | - case is_int($value): |
|
180 | - case is_float($value): |
|
181 | - // typical booleans |
|
182 | - case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true): |
|
183 | - $attributes[ $key ] = $value; |
|
184 | - break; |
|
185 | - case is_string($value): |
|
186 | - $attributes[ $key ] = sanitize_text_field($value); |
|
187 | - break; |
|
188 | - case is_array($value): |
|
189 | - $attributes[ $key ] = \EES_Shortcode::sanitize_attributes($value); |
|
190 | - break; |
|
191 | - default: |
|
192 | - // only remaining data types are Object and Resource |
|
193 | - // which are not allowed as shortcode attributes |
|
194 | - $attributes[ $key ] = null; |
|
195 | - break; |
|
196 | - } |
|
197 | - } |
|
198 | - return $attributes; |
|
199 | - } |
|
18 | + /** |
|
19 | + * @protected public |
|
20 | + * @var array $_attributes |
|
21 | + */ |
|
22 | + protected $_attributes = array(); |
|
23 | + |
|
24 | + |
|
25 | + |
|
26 | + /** |
|
27 | + * class constructor - should ONLY be instantiated by EE_Front_Controller |
|
28 | + */ |
|
29 | + final public function __construct() |
|
30 | + { |
|
31 | + $shortcode = LegacyShortcodesManager::generateShortcodeTagFromClassName(get_class($this)); |
|
32 | + // assign shortcode to the preferred callback, which overwrites the "fallback shortcode processor" assigned earlier |
|
33 | + add_shortcode($shortcode, array($this, 'process_shortcode')); |
|
34 | + // make sure system knows this is an EE page |
|
35 | + /** @var CurrentPage $current_page */ |
|
36 | + $current_page = LoaderFactory::getLoader()->getShared(CurrentPage::class); |
|
37 | + $current_page->setEspressoPage(true); |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * run - initial shortcode module setup called during "parse_request" hook by |
|
44 | + * \EE_Front_Controller::_initialize_shortcodes() IF this shortcode is going to execute during this request ! |
|
45 | + * It may also get called by \EES_Shortcode::fallback_shortcode_processor() if the shortcode is being implemented |
|
46 | + * by a theme or plugin in a non-standard way. |
|
47 | + * Basically this method is primarily used for loading resources and assets like CSS or JS |
|
48 | + * that will be required by the shortcode when it is actually processed. |
|
49 | + * Please note that assets may not load if the fallback_shortcode_processor() is being used. |
|
50 | + * |
|
51 | + * @access public |
|
52 | + * @param WP $WP |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + abstract public function run(WP $WP); |
|
56 | + |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * process_shortcode |
|
61 | + * this method is the callback function for the actual shortcode, and is what runs when WP encounters the shortcode within the_content |
|
62 | + * |
|
63 | + * @access public |
|
64 | + * @param array $attributes |
|
65 | + * @return mixed |
|
66 | + */ |
|
67 | + abstract public function process_shortcode($attributes = array()); |
|
68 | + |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * instance - returns instance of child class object |
|
73 | + * |
|
74 | + * @access public |
|
75 | + * @param string $shortcode_class |
|
76 | + * @return \EES_Shortcode |
|
77 | + */ |
|
78 | + final public static function instance($shortcode_class = null) |
|
79 | + { |
|
80 | + $shortcode_class = ! empty($shortcode_class) ? $shortcode_class : get_called_class(); |
|
81 | + if ($shortcode_class === 'EES_Shortcode' || empty($shortcode_class)) { |
|
82 | + return null; |
|
83 | + } |
|
84 | + $shortcode = str_replace('EES_', '', strtoupper($shortcode_class)); |
|
85 | + $shortcode_obj = isset(EE_Registry::instance()->shortcodes->{$shortcode}) |
|
86 | + ? EE_Registry::instance()->shortcodes->{$shortcode} |
|
87 | + : null; |
|
88 | + return $shortcode_obj instanceof $shortcode_class || $shortcode_class === 'self' |
|
89 | + ? $shortcode_obj |
|
90 | + : new $shortcode_class(); |
|
91 | + } |
|
92 | + |
|
93 | + |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * fallback_shortcode_processor - create instance and call process_shortcode |
|
98 | + * NOTE: shortcode may not function perfectly dues to missing assets, but it's better than not having things work at all |
|
99 | + * |
|
100 | + * @access public |
|
101 | + * @param $attributes |
|
102 | + * @return mixed |
|
103 | + */ |
|
104 | + final public static function fallback_shortcode_processor($attributes) |
|
105 | + { |
|
106 | + if (EE_Maintenance_Mode::disable_frontend_for_maintenance()) { |
|
107 | + return null; |
|
108 | + } |
|
109 | + // what shortcode was actually parsed ? |
|
110 | + $shortcode_class = get_called_class(); |
|
111 | + // notify rest of system that fallback processor was triggered |
|
112 | + add_filter('FHEE__fallback_shortcode_processor__' . $shortcode_class, '__return_true'); |
|
113 | + // get instance of actual shortcode |
|
114 | + $shortcode_obj = self::instance($shortcode_class); |
|
115 | + // verify class |
|
116 | + if ($shortcode_obj instanceof EES_Shortcode) { |
|
117 | + global $wp; |
|
118 | + $shortcode_obj->run($wp); |
|
119 | + // set attributes and run the shortcode |
|
120 | + $shortcode_obj->_attributes = (array) $attributes; |
|
121 | + return $shortcode_obj->process_shortcode($shortcode_obj->_attributes); |
|
122 | + } else { |
|
123 | + return null; |
|
124 | + } |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * invalid_shortcode_processor - used in cases where we know the shortcode is invalid, most likely due to a deactivated addon, and simply returns an empty string |
|
132 | + * |
|
133 | + * @access public |
|
134 | + * @param $attributes |
|
135 | + * @return string |
|
136 | + */ |
|
137 | + final public static function invalid_shortcode_processor($attributes) |
|
138 | + { |
|
139 | + return ''; |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * Performs basic sanitization on shortcode attributes |
|
148 | + * Since incoming attributes from the shortcode usage in the WP editor will all be strings, |
|
149 | + * most attributes will by default be sanitized using the sanitize_text_field() function. |
|
150 | + * This can be overridden by supplying an array for the $custom_sanitization param, |
|
151 | + * where keys match keys in your attributes array, |
|
152 | + * and values represent the sanitization function you wish to be applied to that attribute. |
|
153 | + * So for example, if you had an integer attribute named "event_id" |
|
154 | + * that you wanted to be sanitized using absint(), |
|
155 | + * then you would pass the following for your $custom_sanitization array: |
|
156 | + * array('event_id' => 'absint') |
|
157 | + * all other attributes would be sanitized using the defaults in the switch statement below |
|
158 | + * |
|
159 | + * @param array $attributes |
|
160 | + * @param array $custom_sanitization |
|
161 | + * @return array |
|
162 | + */ |
|
163 | + public static function sanitize_attributes(array $attributes, $custom_sanitization = array()) |
|
164 | + { |
|
165 | + foreach ($attributes as $key => $value) { |
|
166 | + // is a custom sanitization callback specified ? |
|
167 | + if (isset($custom_sanitization[ $key ])) { |
|
168 | + $callback = $custom_sanitization[ $key ]; |
|
169 | + if ($callback === 'skip_sanitization') { |
|
170 | + $attributes[ $key ] = $value; |
|
171 | + continue; |
|
172 | + } elseif (function_exists($callback)) { |
|
173 | + $attributes[ $key ] = $callback($value); |
|
174 | + continue; |
|
175 | + } |
|
176 | + } |
|
177 | + switch (true) { |
|
178 | + case $value === null: |
|
179 | + case is_int($value): |
|
180 | + case is_float($value): |
|
181 | + // typical booleans |
|
182 | + case in_array($value, array(true, 'true', '1', 'on', 'yes', false, 'false', '0', 'off', 'no'), true): |
|
183 | + $attributes[ $key ] = $value; |
|
184 | + break; |
|
185 | + case is_string($value): |
|
186 | + $attributes[ $key ] = sanitize_text_field($value); |
|
187 | + break; |
|
188 | + case is_array($value): |
|
189 | + $attributes[ $key ] = \EES_Shortcode::sanitize_attributes($value); |
|
190 | + break; |
|
191 | + default: |
|
192 | + // only remaining data types are Object and Resource |
|
193 | + // which are not allowed as shortcode attributes |
|
194 | + $attributes[ $key ] = null; |
|
195 | + break; |
|
196 | + } |
|
197 | + } |
|
198 | + return $attributes; |
|
199 | + } |
|
200 | 200 | } |
@@ -16,108 +16,108 @@ |
||
16 | 16 | abstract class EE_Base_Class_Repository extends EE_Object_Repository implements EEI_Deletable |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * EE_Base_Class_Repository constructor. |
|
21 | - */ |
|
22 | - public function __construct() |
|
23 | - { |
|
24 | - $this->persist_method = 'save'; |
|
25 | - } |
|
19 | + /** |
|
20 | + * EE_Base_Class_Repository constructor. |
|
21 | + */ |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + $this->persist_method = 'save'; |
|
25 | + } |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * save |
|
30 | - * |
|
31 | - * calls EE_Base_Class::save() on the current object |
|
32 | - * an array of arguments can also be supplied that will be passed along to EE_Base_Class::save(), |
|
33 | - * where each element of the $arguments array corresponds to a parameter for the callback method |
|
34 | - * PLZ NOTE: if the first argument of the callback requires an array, for example array( 'key' => 'value' ) |
|
35 | - * then $arguments needs to be a DOUBLE array ie: array( array( 'key' => 'value' ) ) |
|
36 | - * |
|
37 | - * @access public |
|
38 | - * @param array $arguments arrays of arguments that will be passed to the object's save method |
|
39 | - * @return bool | int |
|
40 | - */ |
|
41 | - public function save($arguments = array()) |
|
42 | - { |
|
43 | - return $this->persist('save', $arguments); |
|
44 | - } |
|
28 | + /** |
|
29 | + * save |
|
30 | + * |
|
31 | + * calls EE_Base_Class::save() on the current object |
|
32 | + * an array of arguments can also be supplied that will be passed along to EE_Base_Class::save(), |
|
33 | + * where each element of the $arguments array corresponds to a parameter for the callback method |
|
34 | + * PLZ NOTE: if the first argument of the callback requires an array, for example array( 'key' => 'value' ) |
|
35 | + * then $arguments needs to be a DOUBLE array ie: array( array( 'key' => 'value' ) ) |
|
36 | + * |
|
37 | + * @access public |
|
38 | + * @param array $arguments arrays of arguments that will be passed to the object's save method |
|
39 | + * @return bool | int |
|
40 | + */ |
|
41 | + public function save($arguments = array()) |
|
42 | + { |
|
43 | + return $this->persist('save', $arguments); |
|
44 | + } |
|
45 | 45 | |
46 | 46 | |
47 | - /** |
|
48 | - * save_all |
|
49 | - * |
|
50 | - * calls EE_Base_Class::save() on ALL objects in the repository |
|
51 | - * |
|
52 | - * @access public |
|
53 | - * @return bool | int |
|
54 | - */ |
|
55 | - public function save_all() |
|
56 | - { |
|
57 | - return $this->persist_all('save'); |
|
58 | - } |
|
47 | + /** |
|
48 | + * save_all |
|
49 | + * |
|
50 | + * calls EE_Base_Class::save() on ALL objects in the repository |
|
51 | + * |
|
52 | + * @access public |
|
53 | + * @return bool | int |
|
54 | + */ |
|
55 | + public function save_all() |
|
56 | + { |
|
57 | + return $this->persist_all('save'); |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | - /** |
|
62 | - * Calls EE_Base_Class::delete() on the current object |
|
63 | - * Keep in mind that this always detaches the object from the collection |
|
64 | - * regardless of whether the delete was successful for the db. This is because |
|
65 | - * its possible that the object ONLY existed in the collection. |
|
66 | - * |
|
67 | - * @access public |
|
68 | - * @return bool |
|
69 | - */ |
|
70 | - public function delete() |
|
71 | - { |
|
72 | - $success = $this->_call_user_func_array_on_current('delete'); |
|
73 | - $this->remove($this->current()); |
|
74 | - return $success; |
|
75 | - } |
|
61 | + /** |
|
62 | + * Calls EE_Base_Class::delete() on the current object |
|
63 | + * Keep in mind that this always detaches the object from the collection |
|
64 | + * regardless of whether the delete was successful for the db. This is because |
|
65 | + * its possible that the object ONLY existed in the collection. |
|
66 | + * |
|
67 | + * @access public |
|
68 | + * @return bool |
|
69 | + */ |
|
70 | + public function delete() |
|
71 | + { |
|
72 | + $success = $this->_call_user_func_array_on_current('delete'); |
|
73 | + $this->remove($this->current()); |
|
74 | + return $success; |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | - /** |
|
79 | - * delete_all |
|
80 | - * |
|
81 | - * calls EE_Base_Class::delete() on ALL objects in the repository |
|
82 | - * |
|
83 | - * @access public |
|
84 | - * @return bool |
|
85 | - */ |
|
86 | - public function delete_all() |
|
87 | - { |
|
88 | - $success = true; |
|
89 | - $this->rewind(); |
|
90 | - while ($this->valid()) { |
|
91 | - // any db error will result in false being returned |
|
92 | - $success = $this->_call_user_func_array_on_current('delete') !== false ? $success : false; |
|
93 | - // can't remove current object because valid() requires it |
|
94 | - // so just capture current object temporarily |
|
95 | - $object = $this->current(); |
|
96 | - // advance the pointer |
|
97 | - $this->next(); |
|
98 | - // THEN remove the object from the repository |
|
99 | - $this->remove($object); |
|
100 | - } |
|
101 | - return $success; |
|
102 | - } |
|
78 | + /** |
|
79 | + * delete_all |
|
80 | + * |
|
81 | + * calls EE_Base_Class::delete() on ALL objects in the repository |
|
82 | + * |
|
83 | + * @access public |
|
84 | + * @return bool |
|
85 | + */ |
|
86 | + public function delete_all() |
|
87 | + { |
|
88 | + $success = true; |
|
89 | + $this->rewind(); |
|
90 | + while ($this->valid()) { |
|
91 | + // any db error will result in false being returned |
|
92 | + $success = $this->_call_user_func_array_on_current('delete') !== false ? $success : false; |
|
93 | + // can't remove current object because valid() requires it |
|
94 | + // so just capture current object temporarily |
|
95 | + $object = $this->current(); |
|
96 | + // advance the pointer |
|
97 | + $this->next(); |
|
98 | + // THEN remove the object from the repository |
|
99 | + $this->remove($object); |
|
100 | + } |
|
101 | + return $success; |
|
102 | + } |
|
103 | 103 | |
104 | 104 | |
105 | - /** |
|
106 | - * update_extra_meta |
|
107 | - * |
|
108 | - * calls EE_Base_Class::update_extra_meta() on the current object using the supplied values |
|
109 | - * |
|
110 | - * @access public |
|
111 | - * @param string $meta_key |
|
112 | - * @param string $meta_value |
|
113 | - * @param string $previous_value |
|
114 | - * @return bool | int |
|
115 | - */ |
|
116 | - public function update_extra_meta($meta_key, $meta_value, $previous_value = null) |
|
117 | - { |
|
118 | - return $this->_call_user_func_array_on_current( |
|
119 | - 'update_extra_meta', |
|
120 | - array($meta_key, $meta_value, $previous_value) |
|
121 | - ); |
|
122 | - } |
|
105 | + /** |
|
106 | + * update_extra_meta |
|
107 | + * |
|
108 | + * calls EE_Base_Class::update_extra_meta() on the current object using the supplied values |
|
109 | + * |
|
110 | + * @access public |
|
111 | + * @param string $meta_key |
|
112 | + * @param string $meta_value |
|
113 | + * @param string $previous_value |
|
114 | + * @return bool | int |
|
115 | + */ |
|
116 | + public function update_extra_meta($meta_key, $meta_value, $previous_value = null) |
|
117 | + { |
|
118 | + return $this->_call_user_func_array_on_current( |
|
119 | + 'update_extra_meta', |
|
120 | + array($meta_key, $meta_value, $previous_value) |
|
121 | + ); |
|
122 | + } |
|
123 | 123 | } |
@@ -62,49 +62,49 @@ discard block |
||
62 | 62 | ); |
63 | 63 | $cpt_models = array_keys(EE_Registry::instance()->cpt_models()); |
64 | 64 | foreach ($cpt_models as $model_name) { |
65 | - $this->_model_relations[ $model_name ] = new EE_HABTM_Relation('Term_Relationship'); |
|
65 | + $this->_model_relations[$model_name] = new EE_HABTM_Relation('Term_Relationship'); |
|
66 | 66 | } |
67 | 67 | $this->_wp_core_model = true; |
68 | 68 | $this->_indexes = array( |
69 | 69 | 'term_id_taxonomy' => new EE_Unique_Index(array('term_id', 'taxonomy')), |
70 | 70 | ); |
71 | 71 | $path_to_tax_model = ''; |
72 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
73 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
72 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
73 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
74 | 74 | $path_to_tax_model |
75 | 75 | ); |
76 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false; |
|
77 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false; |
|
76 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = false; |
|
77 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = false; |
|
78 | 78 | // add cap restrictions for editing relating to the "ee_edit_*" |
79 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
79 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
80 | 80 | array( |
81 | - $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
81 | + $path_to_tax_model.'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
82 | 82 | ) |
83 | 83 | ); |
84 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
84 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
85 | 85 | array( |
86 | - $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
86 | + $path_to_tax_model.'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
87 | 87 | ) |
88 | 88 | ); |
89 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
89 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
90 | 90 | array( |
91 | - $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
91 | + $path_to_tax_model.'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
92 | 92 | ) |
93 | 93 | ); |
94 | 94 | // add cap restrictions for deleting relating to the "ee_deleting_*" |
95 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
95 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
96 | 96 | array( |
97 | - $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
97 | + $path_to_tax_model.'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
98 | 98 | ) |
99 | 99 | ); |
100 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
100 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
101 | 101 | array( |
102 | - $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
102 | + $path_to_tax_model.'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
103 | 103 | ) |
104 | 104 | ); |
105 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
105 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
106 | 106 | array( |
107 | - $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
107 | + $path_to_tax_model.'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
108 | 108 | ) |
109 | 109 | ); |
110 | 110 | parent::__construct($timezone); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | { |
127 | 127 | if ($model === EEM_Term_Taxonomy::instance()) { |
128 | 128 | $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
129 | - if (! empty($taxonomies)) { |
|
129 | + if ( ! empty($taxonomies)) { |
|
130 | 130 | $model_query_params[0]['taxonomy'] = array('IN', $taxonomies); |
131 | 131 | } |
132 | 132 | } |
@@ -11,128 +11,128 @@ |
||
11 | 11 | class EEM_Term_Taxonomy extends EEM_Base |
12 | 12 | { |
13 | 13 | |
14 | - // private instance of the Attendee object |
|
15 | - protected static $_instance = null; |
|
14 | + // private instance of the Attendee object |
|
15 | + protected static $_instance = null; |
|
16 | 16 | |
17 | 17 | |
18 | 18 | |
19 | - protected function __construct($timezone = null) |
|
20 | - { |
|
21 | - $this->singular_item = esc_html__('Term Taxonomy', 'event_espresso'); |
|
22 | - $this->plural_item = esc_html__('Term Taxonomy', 'event_espresso'); |
|
23 | - $this->_tables = array( |
|
24 | - 'Term_Taxonomy' => new EE_Primary_Table('term_taxonomy', 'term_taxonomy_id'), |
|
25 | - ); |
|
26 | - $this->_fields = array( |
|
27 | - 'Term_Taxonomy' => array( |
|
28 | - 'term_taxonomy_id' => new EE_Primary_Key_Int_Field( |
|
29 | - 'term_taxonomy_id', |
|
30 | - esc_html__('Term-Taxonomy ID', 'event_espresso') |
|
31 | - ), |
|
32 | - 'term_id' => new EE_Foreign_Key_Int_Field( |
|
33 | - 'term_id', |
|
34 | - esc_html__("Term Id", "event_espresso"), |
|
35 | - false, |
|
36 | - 0, |
|
37 | - 'Term' |
|
38 | - ), |
|
39 | - 'taxonomy' => new EE_Plain_Text_Field( |
|
40 | - 'taxonomy', |
|
41 | - esc_html__('Taxonomy Name', 'event_espresso'), |
|
42 | - false, |
|
43 | - 'category' |
|
44 | - ), |
|
45 | - 'description' => new EE_Post_Content_Field( |
|
46 | - 'description', |
|
47 | - esc_html__("Description of Term", "event_espresso"), |
|
48 | - false, |
|
49 | - '' |
|
50 | - ), |
|
51 | - 'parent' => new EE_Integer_Field('parent', esc_html__("Parent Term ID", "event_espresso"), false, 0), |
|
52 | - 'term_count' => new EE_Integer_Field( |
|
53 | - 'count', |
|
54 | - esc_html__("Count of Objects attached", 'event_espresso'), |
|
55 | - false, |
|
56 | - 0 |
|
57 | - ), |
|
58 | - ), |
|
59 | - ); |
|
60 | - $this->_model_relations = array( |
|
61 | - 'Term_Relationship' => new EE_Has_Many_Relation(), |
|
62 | - 'Term' => new EE_Belongs_To_Relation(), |
|
63 | - ); |
|
64 | - $cpt_models = array_keys(EE_Registry::instance()->cpt_models()); |
|
65 | - foreach ($cpt_models as $model_name) { |
|
66 | - $this->_model_relations[ $model_name ] = new EE_HABTM_Relation('Term_Relationship'); |
|
67 | - } |
|
68 | - $this->_wp_core_model = true; |
|
69 | - $this->_indexes = array( |
|
70 | - 'term_id_taxonomy' => new EE_Unique_Index(array('term_id', 'taxonomy')), |
|
71 | - ); |
|
72 | - $path_to_tax_model = ''; |
|
73 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
74 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
75 | - $path_to_tax_model |
|
76 | - ); |
|
77 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false; |
|
78 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false; |
|
79 | - // add cap restrictions for editing relating to the "ee_edit_*" |
|
80 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
81 | - array( |
|
82 | - $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
83 | - ) |
|
84 | - ); |
|
85 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
86 | - array( |
|
87 | - $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
88 | - ) |
|
89 | - ); |
|
90 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
91 | - array( |
|
92 | - $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
93 | - ) |
|
94 | - ); |
|
95 | - // add cap restrictions for deleting relating to the "ee_deleting_*" |
|
96 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
97 | - array( |
|
98 | - $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
99 | - ) |
|
100 | - ); |
|
101 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
102 | - array( |
|
103 | - $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
104 | - ) |
|
105 | - ); |
|
106 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
107 | - array( |
|
108 | - $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
109 | - ) |
|
110 | - ); |
|
111 | - parent::__construct($timezone); |
|
112 | - add_filter('FHEE__Read__create_model_query_params', array('EEM_Term_Taxonomy', 'rest_api_query_params'), 10, 3); |
|
113 | - } |
|
19 | + protected function __construct($timezone = null) |
|
20 | + { |
|
21 | + $this->singular_item = esc_html__('Term Taxonomy', 'event_espresso'); |
|
22 | + $this->plural_item = esc_html__('Term Taxonomy', 'event_espresso'); |
|
23 | + $this->_tables = array( |
|
24 | + 'Term_Taxonomy' => new EE_Primary_Table('term_taxonomy', 'term_taxonomy_id'), |
|
25 | + ); |
|
26 | + $this->_fields = array( |
|
27 | + 'Term_Taxonomy' => array( |
|
28 | + 'term_taxonomy_id' => new EE_Primary_Key_Int_Field( |
|
29 | + 'term_taxonomy_id', |
|
30 | + esc_html__('Term-Taxonomy ID', 'event_espresso') |
|
31 | + ), |
|
32 | + 'term_id' => new EE_Foreign_Key_Int_Field( |
|
33 | + 'term_id', |
|
34 | + esc_html__("Term Id", "event_espresso"), |
|
35 | + false, |
|
36 | + 0, |
|
37 | + 'Term' |
|
38 | + ), |
|
39 | + 'taxonomy' => new EE_Plain_Text_Field( |
|
40 | + 'taxonomy', |
|
41 | + esc_html__('Taxonomy Name', 'event_espresso'), |
|
42 | + false, |
|
43 | + 'category' |
|
44 | + ), |
|
45 | + 'description' => new EE_Post_Content_Field( |
|
46 | + 'description', |
|
47 | + esc_html__("Description of Term", "event_espresso"), |
|
48 | + false, |
|
49 | + '' |
|
50 | + ), |
|
51 | + 'parent' => new EE_Integer_Field('parent', esc_html__("Parent Term ID", "event_espresso"), false, 0), |
|
52 | + 'term_count' => new EE_Integer_Field( |
|
53 | + 'count', |
|
54 | + esc_html__("Count of Objects attached", 'event_espresso'), |
|
55 | + false, |
|
56 | + 0 |
|
57 | + ), |
|
58 | + ), |
|
59 | + ); |
|
60 | + $this->_model_relations = array( |
|
61 | + 'Term_Relationship' => new EE_Has_Many_Relation(), |
|
62 | + 'Term' => new EE_Belongs_To_Relation(), |
|
63 | + ); |
|
64 | + $cpt_models = array_keys(EE_Registry::instance()->cpt_models()); |
|
65 | + foreach ($cpt_models as $model_name) { |
|
66 | + $this->_model_relations[ $model_name ] = new EE_HABTM_Relation('Term_Relationship'); |
|
67 | + } |
|
68 | + $this->_wp_core_model = true; |
|
69 | + $this->_indexes = array( |
|
70 | + 'term_id_taxonomy' => new EE_Unique_Index(array('term_id', 'taxonomy')), |
|
71 | + ); |
|
72 | + $path_to_tax_model = ''; |
|
73 | + $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
74 | + $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected( |
|
75 | + $path_to_tax_model |
|
76 | + ); |
|
77 | + $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false; |
|
78 | + $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false; |
|
79 | + // add cap restrictions for editing relating to the "ee_edit_*" |
|
80 | + $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
81 | + array( |
|
82 | + $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories'), |
|
83 | + ) |
|
84 | + ); |
|
85 | + $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
86 | + array( |
|
87 | + $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories'), |
|
88 | + ) |
|
89 | + ); |
|
90 | + $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
91 | + array( |
|
92 | + $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type'), |
|
93 | + ) |
|
94 | + ); |
|
95 | + // add cap restrictions for deleting relating to the "ee_deleting_*" |
|
96 | + $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
97 | + array( |
|
98 | + $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories'), |
|
99 | + ) |
|
100 | + ); |
|
101 | + $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
102 | + array( |
|
103 | + $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories'), |
|
104 | + ) |
|
105 | + ); |
|
106 | + $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
107 | + array( |
|
108 | + $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type'), |
|
109 | + ) |
|
110 | + ); |
|
111 | + parent::__construct($timezone); |
|
112 | + add_filter('FHEE__Read__create_model_query_params', array('EEM_Term_Taxonomy', 'rest_api_query_params'), 10, 3); |
|
113 | + } |
|
114 | 114 | |
115 | 115 | |
116 | 116 | |
117 | - /** |
|
118 | - * Makes sure that during REST API queries, we only return term-taxonomies |
|
119 | - * for term taxonomies which should be shown in the rest api |
|
120 | - * |
|
121 | - * @param array $model_query_params |
|
122 | - * @param array $querystring_query_params |
|
123 | - * @param EEM_Base $model |
|
124 | - * @return array |
|
125 | - */ |
|
126 | - public static function rest_api_query_params($model_query_params, $querystring_query_params, $model) |
|
127 | - { |
|
128 | - if ($model === EEM_Term_Taxonomy::instance()) { |
|
129 | - $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
|
130 | - if (! empty($taxonomies)) { |
|
131 | - $model_query_params[0]['taxonomy'] = array('IN', $taxonomies); |
|
132 | - } |
|
133 | - } |
|
134 | - return $model_query_params; |
|
135 | - } |
|
117 | + /** |
|
118 | + * Makes sure that during REST API queries, we only return term-taxonomies |
|
119 | + * for term taxonomies which should be shown in the rest api |
|
120 | + * |
|
121 | + * @param array $model_query_params |
|
122 | + * @param array $querystring_query_params |
|
123 | + * @param EEM_Base $model |
|
124 | + * @return array |
|
125 | + */ |
|
126 | + public static function rest_api_query_params($model_query_params, $querystring_query_params, $model) |
|
127 | + { |
|
128 | + if ($model === EEM_Term_Taxonomy::instance()) { |
|
129 | + $taxonomies = get_taxonomies(array('show_in_rest' => true)); |
|
130 | + if (! empty($taxonomies)) { |
|
131 | + $model_query_params[0]['taxonomy'] = array('IN', $taxonomies); |
|
132 | + } |
|
133 | + } |
|
134 | + return $model_query_params; |
|
135 | + } |
|
136 | 136 | } |
137 | 137 | // End of file EEM_Term_Taxonomy.model.php |
138 | 138 | // Location: /includes/models/EEM_Term_Taxonomy.model.php |
@@ -113,17 +113,17 @@ discard block |
||
113 | 113 | ), |
114 | 114 | ), |
115 | 115 | ); |
116 | - $this->_model_relations = array(); |
|
116 | + $this->_model_relations = array(); |
|
117 | 117 | foreach ($models_this_can_attach_to as $model) { |
118 | 118 | if ($model != 'Change_Log') { |
119 | - $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation(); |
|
119 | + $this->_model_relations[$model] = new EE_Belongs_To_Any_Relation(); |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | // use completely custom caps for this |
123 | 123 | $this->_cap_restriction_generators = false; |
124 | 124 | // caps-wise this is all-or-nothing: if you have the default role you can access anything, otherwise nothing |
125 | 125 | foreach ($this->_cap_contexts_to_cap_action_map as $cap_context => $action) { |
126 | - $this->_cap_restrictions[ $cap_context ][ EE_Restriction_Generator_Base::get_default_restrictions_cap() ] |
|
126 | + $this->_cap_restrictions[$cap_context][EE_Restriction_Generator_Base::get_default_restrictions_cap()] |
|
127 | 127 | = new EE_Return_None_Where_Conditions(); |
128 | 128 | } |
129 | 129 | parent::__construct($timezone); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function gateway_log($message, $related_obj_id, $related_obj_type) |
170 | 170 | { |
171 | - if (! EE_Registry::instance()->is_model_name($related_obj_type)) { |
|
171 | + if ( ! EE_Registry::instance()->is_model_name($related_obj_type)) { |
|
172 | 172 | throw new EE_Error( |
173 | 173 | sprintf( |
174 | 174 | esc_html__( |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | global $wpdb; |
218 | 218 | return $wpdb->query( |
219 | 219 | $wpdb->prepare( |
220 | - 'DELETE FROM ' . $this->table() . ' WHERE LOG_type = %s AND LOG_time < %s', |
|
220 | + 'DELETE FROM '.$this->table().' WHERE LOG_type = %s AND LOG_time < %s', |
|
221 | 221 | EEM_Change_Log::type_gateway, |
222 | 222 | $datetime->format(EE_Datetime_Field::mysql_timestamp_format) |
223 | 223 | ) |
@@ -256,8 +256,8 @@ discard block |
||
256 | 256 | { |
257 | 257 | $type_identifier_map = self::get_pretty_label_map_for_registered_types(); |
258 | 258 | // we fallback to the incoming type identifier if there is no localized label for it. |
259 | - return isset($type_identifier_map[ $type_identifier ]) |
|
260 | - ? $type_identifier_map[ $type_identifier ] |
|
259 | + return isset($type_identifier_map[$type_identifier]) |
|
260 | + ? $type_identifier_map[$type_identifier] |
|
261 | 261 | : $type_identifier; |
262 | 262 | } |
263 | 263 | } |
@@ -11,93 +11,93 @@ discard block |
||
11 | 11 | class EEM_Change_Log extends EEM_Base |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * the related object was created log type |
|
16 | - */ |
|
17 | - const type_create = 'create'; |
|
18 | - /** |
|
19 | - * the related object was updated (changed, or soft-deleted) |
|
20 | - */ |
|
21 | - const type_update = 'update'; |
|
22 | - /** |
|
23 | - * the related object was deleted permanently |
|
24 | - */ |
|
25 | - const type_delete = 'delete'; |
|
26 | - /** |
|
27 | - * the related item had something worth noting happen on it, but |
|
28 | - * only for the purposes of debugging problems |
|
29 | - */ |
|
30 | - const type_debug = 'debug'; |
|
31 | - /** |
|
32 | - * the related item had an error occur on it |
|
33 | - */ |
|
34 | - const type_error = 'error'; |
|
35 | - /** |
|
36 | - * the related item is regarding some gateway interaction, like an IPN |
|
37 | - * or request to process a payment |
|
38 | - */ |
|
39 | - const type_gateway = 'gateway'; |
|
14 | + /** |
|
15 | + * the related object was created log type |
|
16 | + */ |
|
17 | + const type_create = 'create'; |
|
18 | + /** |
|
19 | + * the related object was updated (changed, or soft-deleted) |
|
20 | + */ |
|
21 | + const type_update = 'update'; |
|
22 | + /** |
|
23 | + * the related object was deleted permanently |
|
24 | + */ |
|
25 | + const type_delete = 'delete'; |
|
26 | + /** |
|
27 | + * the related item had something worth noting happen on it, but |
|
28 | + * only for the purposes of debugging problems |
|
29 | + */ |
|
30 | + const type_debug = 'debug'; |
|
31 | + /** |
|
32 | + * the related item had an error occur on it |
|
33 | + */ |
|
34 | + const type_error = 'error'; |
|
35 | + /** |
|
36 | + * the related item is regarding some gateway interaction, like an IPN |
|
37 | + * or request to process a payment |
|
38 | + */ |
|
39 | + const type_gateway = 'gateway'; |
|
40 | 40 | |
41 | - /** |
|
42 | - * private instance of the EEM_Change_Log object |
|
43 | - * |
|
44 | - * @access private |
|
45 | - * @var EEM_Change_Log $_instance |
|
46 | - */ |
|
47 | - protected static $_instance = null; |
|
41 | + /** |
|
42 | + * private instance of the EEM_Change_Log object |
|
43 | + * |
|
44 | + * @access private |
|
45 | + * @var EEM_Change_Log $_instance |
|
46 | + */ |
|
47 | + protected static $_instance = null; |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * constructor |
|
52 | - * |
|
53 | - * @access protected |
|
54 | - * @param null $timezone |
|
55 | - * @throws EE_Error |
|
56 | - */ |
|
57 | - protected function __construct($timezone = null) |
|
58 | - { |
|
59 | - global $current_user; |
|
60 | - $this->singular_item = esc_html__('Log', 'event_espresso'); |
|
61 | - $this->plural_item = esc_html__('Logs', 'event_espresso'); |
|
62 | - $this->_tables = array( |
|
63 | - 'Log' => new EE_Primary_Table('esp_log', 'LOG_ID'), |
|
64 | - ); |
|
65 | - $models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models); |
|
66 | - $this->_fields = array( |
|
67 | - 'Log' => array( |
|
68 | - 'LOG_ID' => new EE_Primary_Key_Int_Field('LOG_ID', esc_html__('Log ID', 'event_espresso')), |
|
69 | - 'LOG_time' => new EE_Datetime_Field( |
|
70 | - 'LOG_time', |
|
71 | - esc_html__("Log Time", 'event_espresso'), |
|
72 | - false, |
|
73 | - EE_Datetime_Field::now |
|
74 | - ), |
|
75 | - 'OBJ_ID' => new EE_Foreign_Key_String_Field( |
|
76 | - 'OBJ_ID', |
|
77 | - esc_html__("Object ID (int or string)", 'event_espresso'), |
|
78 | - true, |
|
79 | - null, |
|
80 | - $models_this_can_attach_to |
|
81 | - ), |
|
82 | - 'OBJ_type' => new EE_Any_Foreign_Model_Name_Field( |
|
83 | - 'OBJ_type', |
|
84 | - esc_html__("Object Type", 'event_espresso'), |
|
85 | - true, |
|
86 | - null, |
|
87 | - $models_this_can_attach_to |
|
88 | - ), |
|
89 | - 'LOG_type' => new EE_Plain_Text_Field( |
|
90 | - 'LOG_type', |
|
91 | - esc_html__("Type of log entry", "event_espresso"), |
|
92 | - false, |
|
93 | - self::type_debug |
|
94 | - ), |
|
95 | - 'LOG_message' => new EE_Maybe_Serialized_Text_Field( |
|
96 | - 'LOG_message', |
|
97 | - esc_html__("Log Message (body)", 'event_espresso'), |
|
98 | - true |
|
99 | - ), |
|
100 | - /* |
|
50 | + /** |
|
51 | + * constructor |
|
52 | + * |
|
53 | + * @access protected |
|
54 | + * @param null $timezone |
|
55 | + * @throws EE_Error |
|
56 | + */ |
|
57 | + protected function __construct($timezone = null) |
|
58 | + { |
|
59 | + global $current_user; |
|
60 | + $this->singular_item = esc_html__('Log', 'event_espresso'); |
|
61 | + $this->plural_item = esc_html__('Logs', 'event_espresso'); |
|
62 | + $this->_tables = array( |
|
63 | + 'Log' => new EE_Primary_Table('esp_log', 'LOG_ID'), |
|
64 | + ); |
|
65 | + $models_this_can_attach_to = array_keys(EE_Registry::instance()->non_abstract_db_models); |
|
66 | + $this->_fields = array( |
|
67 | + 'Log' => array( |
|
68 | + 'LOG_ID' => new EE_Primary_Key_Int_Field('LOG_ID', esc_html__('Log ID', 'event_espresso')), |
|
69 | + 'LOG_time' => new EE_Datetime_Field( |
|
70 | + 'LOG_time', |
|
71 | + esc_html__("Log Time", 'event_espresso'), |
|
72 | + false, |
|
73 | + EE_Datetime_Field::now |
|
74 | + ), |
|
75 | + 'OBJ_ID' => new EE_Foreign_Key_String_Field( |
|
76 | + 'OBJ_ID', |
|
77 | + esc_html__("Object ID (int or string)", 'event_espresso'), |
|
78 | + true, |
|
79 | + null, |
|
80 | + $models_this_can_attach_to |
|
81 | + ), |
|
82 | + 'OBJ_type' => new EE_Any_Foreign_Model_Name_Field( |
|
83 | + 'OBJ_type', |
|
84 | + esc_html__("Object Type", 'event_espresso'), |
|
85 | + true, |
|
86 | + null, |
|
87 | + $models_this_can_attach_to |
|
88 | + ), |
|
89 | + 'LOG_type' => new EE_Plain_Text_Field( |
|
90 | + 'LOG_type', |
|
91 | + esc_html__("Type of log entry", "event_espresso"), |
|
92 | + false, |
|
93 | + self::type_debug |
|
94 | + ), |
|
95 | + 'LOG_message' => new EE_Maybe_Serialized_Text_Field( |
|
96 | + 'LOG_message', |
|
97 | + esc_html__("Log Message (body)", 'event_espresso'), |
|
98 | + true |
|
99 | + ), |
|
100 | + /* |
|
101 | 101 | * Note: when querying for a change log's user, the OBJ_ID and OBJ_type fields are used, |
102 | 102 | * not the LOG_wp_user field. E.g., |
103 | 103 | * `EEM_Change_Log::instance()->get_all(array(array('WP_User.ID'=>1)))` will actually return |
@@ -106,158 +106,158 @@ discard block |
||
106 | 106 | * If you want the latter, you can't use the model's magic joining. E.g, you would need to do |
107 | 107 | * `EEM_Change_Log::instance()->get_all(array(array('LOG_wp_user' => 1)))`. |
108 | 108 | */ |
109 | - 'LOG_wp_user' => new EE_WP_User_Field( |
|
110 | - 'LOG_wp_user', |
|
111 | - esc_html__("User who was logged in while this occurred", 'event_espresso'), |
|
112 | - true |
|
113 | - ), |
|
114 | - ), |
|
115 | - ); |
|
116 | - $this->_model_relations = array(); |
|
117 | - foreach ($models_this_can_attach_to as $model) { |
|
118 | - if ($model != 'Change_Log') { |
|
119 | - $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation(); |
|
120 | - } |
|
121 | - } |
|
122 | - // use completely custom caps for this |
|
123 | - $this->_cap_restriction_generators = false; |
|
124 | - // caps-wise this is all-or-nothing: if you have the default role you can access anything, otherwise nothing |
|
125 | - foreach ($this->_cap_contexts_to_cap_action_map as $cap_context => $action) { |
|
126 | - $this->_cap_restrictions[ $cap_context ][ EE_Restriction_Generator_Base::get_default_restrictions_cap() ] |
|
127 | - = new EE_Return_None_Where_Conditions(); |
|
128 | - } |
|
129 | - parent::__construct($timezone); |
|
130 | - } |
|
109 | + 'LOG_wp_user' => new EE_WP_User_Field( |
|
110 | + 'LOG_wp_user', |
|
111 | + esc_html__("User who was logged in while this occurred", 'event_espresso'), |
|
112 | + true |
|
113 | + ), |
|
114 | + ), |
|
115 | + ); |
|
116 | + $this->_model_relations = array(); |
|
117 | + foreach ($models_this_can_attach_to as $model) { |
|
118 | + if ($model != 'Change_Log') { |
|
119 | + $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation(); |
|
120 | + } |
|
121 | + } |
|
122 | + // use completely custom caps for this |
|
123 | + $this->_cap_restriction_generators = false; |
|
124 | + // caps-wise this is all-or-nothing: if you have the default role you can access anything, otherwise nothing |
|
125 | + foreach ($this->_cap_contexts_to_cap_action_map as $cap_context => $action) { |
|
126 | + $this->_cap_restrictions[ $cap_context ][ EE_Restriction_Generator_Base::get_default_restrictions_cap() ] |
|
127 | + = new EE_Return_None_Where_Conditions(); |
|
128 | + } |
|
129 | + parent::__construct($timezone); |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * @param string $log_type !see the acceptable values of LOG_type in EEM__Change_Log::__construct |
|
134 | - * @param mixed $message array|string of the message you want to record |
|
135 | - * @param EE_Base_Class $related_model_obj |
|
136 | - * @return EE_Change_Log |
|
137 | - * @throws EE_Error |
|
138 | - */ |
|
139 | - public function log($log_type, $message, $related_model_obj) |
|
140 | - { |
|
141 | - if ($related_model_obj instanceof EE_Base_Class) { |
|
142 | - $obj_id = $related_model_obj->ID(); |
|
143 | - $obj_type = $related_model_obj->get_model()->get_this_model_name(); |
|
144 | - } else { |
|
145 | - $obj_id = null; |
|
146 | - $obj_type = null; |
|
147 | - } |
|
148 | - /** @var EE_Change_Log $log */ |
|
149 | - $log = EE_Change_Log::new_instance(array( |
|
150 | - 'LOG_type' => $log_type, |
|
151 | - 'LOG_message' => $message, |
|
152 | - 'OBJ_ID' => $obj_id, |
|
153 | - 'OBJ_type' => $obj_type, |
|
154 | - )); |
|
155 | - $log->save(); |
|
156 | - return $log; |
|
157 | - } |
|
132 | + /** |
|
133 | + * @param string $log_type !see the acceptable values of LOG_type in EEM__Change_Log::__construct |
|
134 | + * @param mixed $message array|string of the message you want to record |
|
135 | + * @param EE_Base_Class $related_model_obj |
|
136 | + * @return EE_Change_Log |
|
137 | + * @throws EE_Error |
|
138 | + */ |
|
139 | + public function log($log_type, $message, $related_model_obj) |
|
140 | + { |
|
141 | + if ($related_model_obj instanceof EE_Base_Class) { |
|
142 | + $obj_id = $related_model_obj->ID(); |
|
143 | + $obj_type = $related_model_obj->get_model()->get_this_model_name(); |
|
144 | + } else { |
|
145 | + $obj_id = null; |
|
146 | + $obj_type = null; |
|
147 | + } |
|
148 | + /** @var EE_Change_Log $log */ |
|
149 | + $log = EE_Change_Log::new_instance(array( |
|
150 | + 'LOG_type' => $log_type, |
|
151 | + 'LOG_message' => $message, |
|
152 | + 'OBJ_ID' => $obj_id, |
|
153 | + 'OBJ_type' => $obj_type, |
|
154 | + )); |
|
155 | + $log->save(); |
|
156 | + return $log; |
|
157 | + } |
|
158 | 158 | |
159 | 159 | |
160 | - /** |
|
161 | - * Adds a gateway log for the specified object, given its ID and type |
|
162 | - * |
|
163 | - * @param string $message |
|
164 | - * @param mixed $related_obj_id |
|
165 | - * @param string $related_obj_type |
|
166 | - * @throws EE_Error |
|
167 | - * @return EE_Change_Log |
|
168 | - */ |
|
169 | - public function gateway_log($message, $related_obj_id, $related_obj_type) |
|
170 | - { |
|
171 | - if (! EE_Registry::instance()->is_model_name($related_obj_type)) { |
|
172 | - throw new EE_Error( |
|
173 | - sprintf( |
|
174 | - esc_html__( |
|
175 | - "'%s' is not a model name. A model name must be provided when making a gateway log. Eg, 'Payment', 'Payment_Method', etc", |
|
176 | - "event_espresso" |
|
177 | - ), |
|
178 | - $related_obj_type |
|
179 | - ) |
|
180 | - ); |
|
181 | - } |
|
182 | - /** @var EE_Change_Log $log */ |
|
183 | - $log = EE_Change_Log::new_instance(array( |
|
184 | - 'LOG_type' => EEM_Change_Log::type_gateway, |
|
185 | - 'LOG_message' => $message, |
|
186 | - 'OBJ_ID' => $related_obj_id, |
|
187 | - 'OBJ_type' => $related_obj_type, |
|
188 | - )); |
|
189 | - $log->save(); |
|
190 | - return $log; |
|
191 | - } |
|
160 | + /** |
|
161 | + * Adds a gateway log for the specified object, given its ID and type |
|
162 | + * |
|
163 | + * @param string $message |
|
164 | + * @param mixed $related_obj_id |
|
165 | + * @param string $related_obj_type |
|
166 | + * @throws EE_Error |
|
167 | + * @return EE_Change_Log |
|
168 | + */ |
|
169 | + public function gateway_log($message, $related_obj_id, $related_obj_type) |
|
170 | + { |
|
171 | + if (! EE_Registry::instance()->is_model_name($related_obj_type)) { |
|
172 | + throw new EE_Error( |
|
173 | + sprintf( |
|
174 | + esc_html__( |
|
175 | + "'%s' is not a model name. A model name must be provided when making a gateway log. Eg, 'Payment', 'Payment_Method', etc", |
|
176 | + "event_espresso" |
|
177 | + ), |
|
178 | + $related_obj_type |
|
179 | + ) |
|
180 | + ); |
|
181 | + } |
|
182 | + /** @var EE_Change_Log $log */ |
|
183 | + $log = EE_Change_Log::new_instance(array( |
|
184 | + 'LOG_type' => EEM_Change_Log::type_gateway, |
|
185 | + 'LOG_message' => $message, |
|
186 | + 'OBJ_ID' => $related_obj_id, |
|
187 | + 'OBJ_type' => $related_obj_type, |
|
188 | + )); |
|
189 | + $log->save(); |
|
190 | + return $log; |
|
191 | + } |
|
192 | 192 | |
193 | 193 | |
194 | - /** |
|
195 | - * Just gets the bare-bones wpdb results as an array in cases where efficiency is essential |
|
196 | - * |
|
197 | - * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
198 | - * @return array of arrays |
|
199 | - * @throws EE_Error |
|
200 | - */ |
|
201 | - public function get_all_efficiently($query_params) |
|
202 | - { |
|
203 | - return $this->_get_all_wpdb_results($query_params); |
|
204 | - } |
|
194 | + /** |
|
195 | + * Just gets the bare-bones wpdb results as an array in cases where efficiency is essential |
|
196 | + * |
|
197 | + * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
198 | + * @return array of arrays |
|
199 | + * @throws EE_Error |
|
200 | + */ |
|
201 | + public function get_all_efficiently($query_params) |
|
202 | + { |
|
203 | + return $this->_get_all_wpdb_results($query_params); |
|
204 | + } |
|
205 | 205 | |
206 | 206 | |
207 | - /** |
|
208 | - * Executes a database query to delete gateway logs. Does not affect model objects, so if you attempt to use |
|
209 | - * models after this, they may be out-of-sync with the database |
|
210 | - * |
|
211 | - * @param DateTime $datetime |
|
212 | - * @return false|int |
|
213 | - * @throws EE_Error |
|
214 | - */ |
|
215 | - public function delete_gateway_logs_older_than(DateTime $datetime) |
|
216 | - { |
|
217 | - global $wpdb; |
|
218 | - return $wpdb->query( |
|
219 | - $wpdb->prepare( |
|
220 | - 'DELETE FROM ' . $this->table() . ' WHERE LOG_type = %s AND LOG_time < %s', |
|
221 | - EEM_Change_Log::type_gateway, |
|
222 | - $datetime->format(EE_Datetime_Field::mysql_timestamp_format) |
|
223 | - ) |
|
224 | - ); |
|
225 | - } |
|
207 | + /** |
|
208 | + * Executes a database query to delete gateway logs. Does not affect model objects, so if you attempt to use |
|
209 | + * models after this, they may be out-of-sync with the database |
|
210 | + * |
|
211 | + * @param DateTime $datetime |
|
212 | + * @return false|int |
|
213 | + * @throws EE_Error |
|
214 | + */ |
|
215 | + public function delete_gateway_logs_older_than(DateTime $datetime) |
|
216 | + { |
|
217 | + global $wpdb; |
|
218 | + return $wpdb->query( |
|
219 | + $wpdb->prepare( |
|
220 | + 'DELETE FROM ' . $this->table() . ' WHERE LOG_type = %s AND LOG_time < %s', |
|
221 | + EEM_Change_Log::type_gateway, |
|
222 | + $datetime->format(EE_Datetime_Field::mysql_timestamp_format) |
|
223 | + ) |
|
224 | + ); |
|
225 | + } |
|
226 | 226 | |
227 | 227 | |
228 | - /** |
|
229 | - * Returns the map of type to pretty label for identifiers used for `LOG_type`. Client code can register their own |
|
230 | - * map vai the given filter. |
|
231 | - * |
|
232 | - * @return array |
|
233 | - */ |
|
234 | - public static function get_pretty_label_map_for_registered_types() |
|
235 | - { |
|
236 | - return apply_filters( |
|
237 | - 'FHEE__EEM_Change_Log__get_pretty_label_map_for_registered_types', |
|
238 | - array( |
|
239 | - self::type_create => esc_html__("Create", "event_espresso"), |
|
240 | - self::type_update => esc_html__("Update", "event_espresso"), |
|
241 | - self::type_delete => esc_html__("Delete", "event_espresso"), |
|
242 | - self::type_debug => esc_html__("Debug", "event_espresso"), |
|
243 | - self::type_error => esc_html__("Error", "event_espresso"), |
|
244 | - self::type_gateway => esc_html__("Gateway Interaction (IPN or Direct Payment)", 'event_espresso') |
|
245 | - ) |
|
246 | - ); |
|
247 | - } |
|
228 | + /** |
|
229 | + * Returns the map of type to pretty label for identifiers used for `LOG_type`. Client code can register their own |
|
230 | + * map vai the given filter. |
|
231 | + * |
|
232 | + * @return array |
|
233 | + */ |
|
234 | + public static function get_pretty_label_map_for_registered_types() |
|
235 | + { |
|
236 | + return apply_filters( |
|
237 | + 'FHEE__EEM_Change_Log__get_pretty_label_map_for_registered_types', |
|
238 | + array( |
|
239 | + self::type_create => esc_html__("Create", "event_espresso"), |
|
240 | + self::type_update => esc_html__("Update", "event_espresso"), |
|
241 | + self::type_delete => esc_html__("Delete", "event_espresso"), |
|
242 | + self::type_debug => esc_html__("Debug", "event_espresso"), |
|
243 | + self::type_error => esc_html__("Error", "event_espresso"), |
|
244 | + self::type_gateway => esc_html__("Gateway Interaction (IPN or Direct Payment)", 'event_espresso') |
|
245 | + ) |
|
246 | + ); |
|
247 | + } |
|
248 | 248 | |
249 | 249 | |
250 | - /** |
|
251 | - * Return the pretty (localized) label for the given log type identifier. |
|
252 | - * @param string $type_identifier |
|
253 | - * @return string |
|
254 | - */ |
|
255 | - public static function get_pretty_label_for_type($type_identifier) |
|
256 | - { |
|
257 | - $type_identifier_map = self::get_pretty_label_map_for_registered_types(); |
|
258 | - // we fallback to the incoming type identifier if there is no localized label for it. |
|
259 | - return isset($type_identifier_map[ $type_identifier ]) |
|
260 | - ? $type_identifier_map[ $type_identifier ] |
|
261 | - : $type_identifier; |
|
262 | - } |
|
250 | + /** |
|
251 | + * Return the pretty (localized) label for the given log type identifier. |
|
252 | + * @param string $type_identifier |
|
253 | + * @return string |
|
254 | + */ |
|
255 | + public static function get_pretty_label_for_type($type_identifier) |
|
256 | + { |
|
257 | + $type_identifier_map = self::get_pretty_label_map_for_registered_types(); |
|
258 | + // we fallback to the incoming type identifier if there is no localized label for it. |
|
259 | + return isset($type_identifier_map[ $type_identifier ]) |
|
260 | + ? $type_identifier_map[ $type_identifier ] |
|
261 | + : $type_identifier; |
|
262 | + } |
|
263 | 263 | } |