@@ -15,36 +15,36 @@ |
||
15 | 15 | abstract class EE_Onsite_Gateway extends EE_Gateway |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @return EE_Onsite_Gateway |
|
20 | - */ |
|
21 | - public function __construct() |
|
22 | - { |
|
23 | - $this->_supports_sending_refunds = true; |
|
24 | - parent::__construct(); |
|
25 | - } |
|
18 | + /** |
|
19 | + * @return EE_Onsite_Gateway |
|
20 | + */ |
|
21 | + public function __construct() |
|
22 | + { |
|
23 | + $this->_supports_sending_refunds = true; |
|
24 | + parent::__construct(); |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * Asks the gateway to do whatever it does to process the payment. Onsite gateways will |
|
29 | - * usually send a request directly to the payment provider and update the payment's status based on that; |
|
30 | - * whereas offsite gateways will usually just update the payment with the URL and query parameters to use |
|
31 | - * for sending the request via http_remote_request(). Saving the payment from within this method is unnecessary, |
|
32 | - * as it is the responsibility of client code to save it. |
|
33 | - * |
|
34 | - * @param EEI_Payment $payment |
|
35 | - * @param array $billing_info { |
|
36 | - * @type $first_name string |
|
37 | - * @type $last_name string |
|
38 | - * @type $email string |
|
39 | - * @type $address string |
|
40 | - * @type $address2 string |
|
41 | - * @type $city string |
|
42 | - * @type $state string name of the state (NOT int) |
|
43 | - * @type $country string 2-character ISO code see http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 |
|
44 | - * @type $zip string |
|
45 | - * @type $phone string |
|
46 | - * } unless a child class specifies these array keys are NOT present |
|
47 | - * @return EE_Payment updated |
|
48 | - */ |
|
49 | - abstract public function do_direct_payment($payment, $billing_info = null); |
|
27 | + /** |
|
28 | + * Asks the gateway to do whatever it does to process the payment. Onsite gateways will |
|
29 | + * usually send a request directly to the payment provider and update the payment's status based on that; |
|
30 | + * whereas offsite gateways will usually just update the payment with the URL and query parameters to use |
|
31 | + * for sending the request via http_remote_request(). Saving the payment from within this method is unnecessary, |
|
32 | + * as it is the responsibility of client code to save it. |
|
33 | + * |
|
34 | + * @param EEI_Payment $payment |
|
35 | + * @param array $billing_info { |
|
36 | + * @type $first_name string |
|
37 | + * @type $last_name string |
|
38 | + * @type $email string |
|
39 | + * @type $address string |
|
40 | + * @type $address2 string |
|
41 | + * @type $city string |
|
42 | + * @type $state string name of the state (NOT int) |
|
43 | + * @type $country string 2-character ISO code see http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 |
|
44 | + * @type $zip string |
|
45 | + * @type $phone string |
|
46 | + * } unless a child class specifies these array keys are NOT present |
|
47 | + * @return EE_Payment updated |
|
48 | + */ |
|
49 | + abstract public function do_direct_payment($payment, $billing_info = null); |
|
50 | 50 | } |
@@ -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 |