@@ -30,6 +30,7 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * |
32 | 32 | * @param string $status |
33 | + * @return void |
|
33 | 34 | */ |
34 | 35 | public function set_status($status); |
35 | 36 | |
@@ -37,6 +38,7 @@ discard block |
||
37 | 38 | * Sets the response from the gateway, which is displayable to the user. |
38 | 39 | * Eg, 'payment was approved', 'payment failed because invalid date', etc. |
39 | 40 | * @param string $response |
41 | + * @return void |
|
40 | 42 | */ |
41 | 43 | public function set_gateway_response($response); |
42 | 44 | |
@@ -44,6 +46,7 @@ discard block |
||
44 | 46 | * Sets the response details, usually the entire contents of an IPN request, |
45 | 47 | * or data about the direct payment data sent |
46 | 48 | * @param mixed $response_details |
49 | + * @return void |
|
47 | 50 | */ |
48 | 51 | public function set_details($response_details); |
49 | 52 | |
@@ -56,12 +59,14 @@ discard block |
||
56 | 59 | /** |
57 | 60 | * Sets the URl to redirect to, to process payment |
58 | 61 | * @param string $url |
62 | + * @return void |
|
59 | 63 | */ |
60 | 64 | public function set_redirect_url($url); |
61 | 65 | |
62 | 66 | /** |
63 | 67 | * Sets the argument which should be passed to the redirect url (ie, usually POST variables) |
64 | 68 | * @param array $args |
69 | + * @return void |
|
65 | 70 | */ |
66 | 71 | public function set_redirect_args($args); |
67 | 72 | |
@@ -80,25 +85,27 @@ discard block |
||
80 | 85 | /** |
81 | 86 | * Sets the amount for this payment |
82 | 87 | * @param float $amount |
88 | + * @return void |
|
83 | 89 | */ |
84 | 90 | public function set_amount($amount); |
85 | 91 | |
86 | 92 | /** |
87 | 93 | * Sets the ID of the gateway transaction |
88 | 94 | * @param string $txn_id |
95 | + * @return void |
|
89 | 96 | */ |
90 | 97 | public function set_txn_id_chq_nmbr($txn_id); |
91 | 98 | |
92 | 99 | /** |
93 | 100 | * Sets a string for some extra accounting info |
94 | 101 | * @param string $extra_accounting_info |
102 | + * @return void |
|
95 | 103 | */ |
96 | 104 | public function set_extra_accntng($extra_accounting_info); |
97 | 105 | |
98 | 106 | /** |
99 | 107 | * Gets the first event for this payment (it's possible that it could be for multiple) |
100 | 108 | * |
101 | - * @param EE_Payment $payment |
|
102 | 109 | * @return EE_Event|null |
103 | 110 | */ |
104 | 111 | public function get_first_event(); |
@@ -106,7 +113,6 @@ discard block |
||
106 | 113 | /** |
107 | 114 | * Gets the name of the first event for which is being paid |
108 | 115 | * |
109 | - * @param EE_Payment $payment |
|
110 | 116 | * @return string |
111 | 117 | */ |
112 | 118 | public function get_first_event_name(); |
@@ -139,22 +145,27 @@ discard block |
||
139 | 145 | interface EEMI_Payment { |
140 | 146 | /** |
141 | 147 | * returns a string for the approved status |
148 | + * @return string |
|
142 | 149 | */ |
143 | 150 | public function approved_status(); |
144 | 151 | /** |
145 | 152 | * returns a string for the pending status |
153 | + * @return string |
|
146 | 154 | */ |
147 | 155 | public function pending_status(); |
148 | 156 | /** |
149 | 157 | * returns a string for the cancelled status |
158 | + * @return string |
|
150 | 159 | */ |
151 | 160 | public function cancelled_status(); |
152 | 161 | /** |
153 | 162 | * returns a string for the failed status |
163 | + * @return string |
|
154 | 164 | */ |
155 | 165 | public function failed_status(); |
156 | 166 | /** |
157 | 167 | * returns a string for the declined status |
168 | + * @return string |
|
158 | 169 | */ |
159 | 170 | public function declined_status(); |
160 | 171 | |
@@ -208,6 +219,10 @@ discard block |
||
208 | 219 | * Interface for an event being registered for |
209 | 220 | */ |
210 | 221 | interface EEI_Event { |
222 | + |
|
223 | + /** |
|
224 | + * @return boolean |
|
225 | + */ |
|
211 | 226 | public function name(); |
212 | 227 | } |
213 | 228 |
@@ -95,34 +95,34 @@ |
||
95 | 95 | */ |
96 | 96 | public function set_extra_accntng($extra_accounting_info); |
97 | 97 | |
98 | - /** |
|
99 | - * Gets the first event for this payment (it's possible that it could be for multiple) |
|
100 | - * |
|
101 | - * @param EE_Payment $payment |
|
102 | - * @return EE_Event|null |
|
103 | - */ |
|
104 | - public function get_first_event(); |
|
105 | - |
|
106 | - /** |
|
107 | - * Gets the name of the first event for which is being paid |
|
108 | - * |
|
109 | - * @param EE_Payment $payment |
|
110 | - * @return string |
|
111 | - */ |
|
112 | - public function get_first_event_name(); |
|
113 | - |
|
114 | - /** |
|
115 | - * Returns the payment's transaction's primary registration |
|
116 | - * |
|
117 | - * @return EE_Registration|null |
|
118 | - */ |
|
119 | - public function get_primary_registration(); |
|
120 | - |
|
121 | - /** |
|
122 | - * Gets the payment's transaction's primary registration's attendee, or null |
|
123 | - * @return EE_Attendee|null |
|
124 | - */ |
|
125 | - public function get_primary_attendee(); |
|
98 | + /** |
|
99 | + * Gets the first event for this payment (it's possible that it could be for multiple) |
|
100 | + * |
|
101 | + * @param EE_Payment $payment |
|
102 | + * @return EE_Event|null |
|
103 | + */ |
|
104 | + public function get_first_event(); |
|
105 | + |
|
106 | + /** |
|
107 | + * Gets the name of the first event for which is being paid |
|
108 | + * |
|
109 | + * @param EE_Payment $payment |
|
110 | + * @return string |
|
111 | + */ |
|
112 | + public function get_first_event_name(); |
|
113 | + |
|
114 | + /** |
|
115 | + * Returns the payment's transaction's primary registration |
|
116 | + * |
|
117 | + * @return EE_Registration|null |
|
118 | + */ |
|
119 | + public function get_primary_registration(); |
|
120 | + |
|
121 | + /** |
|
122 | + * Gets the payment's transaction's primary registration's attendee, or null |
|
123 | + * @return EE_Attendee|null |
|
124 | + */ |
|
125 | + public function get_primary_attendee(); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | /** |
@@ -20,9 +20,9 @@ discard block |
||
20 | 20 | * @return EE_Payment |
21 | 21 | * @throws \EE_Error |
22 | 22 | */ |
23 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
24 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
25 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
23 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
24 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
25 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | * @return EE_Payment |
35 | 35 | * @throws \EE_Error |
36 | 36 | */ |
37 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
38 | - return new self( $props_n_values, true, $timezone ); |
|
37 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
38 | + return new self($props_n_values, true, $timezone); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | * @param int $TXN_ID |
48 | 48 | * @throws \EE_Error |
49 | 49 | */ |
50 | - public function set_transaction_id( $TXN_ID = 0 ) { |
|
51 | - $this->set( 'TXN_ID', $TXN_ID ); |
|
50 | + public function set_transaction_id($TXN_ID = 0) { |
|
51 | + $this->set('TXN_ID', $TXN_ID); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @throws \EE_Error |
61 | 61 | */ |
62 | 62 | public function transaction() { |
63 | - return $this->get_first_related( 'Transaction' ); |
|
63 | + return $this->get_first_related('Transaction'); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | * @param string $STS_ID |
73 | 73 | * @throws \EE_Error |
74 | 74 | */ |
75 | - public function set_status( $STS_ID = '' ) { |
|
76 | - $this->set( 'STS_ID', $STS_ID ); |
|
75 | + public function set_status($STS_ID = '') { |
|
76 | + $this->set('STS_ID', $STS_ID); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | * @param int $timestamp |
86 | 86 | * @throws \EE_Error |
87 | 87 | */ |
88 | - public function set_timestamp( $timestamp = 0 ) { |
|
89 | - $this->set( 'PAY_timestamp', $timestamp ); |
|
88 | + public function set_timestamp($timestamp = 0) { |
|
89 | + $this->set('PAY_timestamp', $timestamp); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | * @param string $PAY_source |
99 | 99 | * @throws \EE_Error |
100 | 100 | */ |
101 | - public function set_source( $PAY_source = '' ) { |
|
102 | - $this->set( 'PAY_source', $PAY_source ); |
|
101 | + public function set_source($PAY_source = '') { |
|
102 | + $this->set('PAY_source', $PAY_source); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | * @param float $amount |
112 | 112 | * @throws \EE_Error |
113 | 113 | */ |
114 | - public function set_amount( $amount = 0.00 ) { |
|
115 | - $this->set( 'PAY_amount', (float)$amount ); |
|
114 | + public function set_amount($amount = 0.00) { |
|
115 | + $this->set('PAY_amount', (float) $amount); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | * @param string $gateway_response |
125 | 125 | * @throws \EE_Error |
126 | 126 | */ |
127 | - public function set_gateway_response( $gateway_response = '' ) { |
|
128 | - $this->set( 'PAY_gateway_response', $gateway_response ); |
|
127 | + public function set_gateway_response($gateway_response = '') { |
|
128 | + $this->set('PAY_gateway_response', $gateway_response); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | ), |
149 | 149 | '4.6.0' |
150 | 150 | ); |
151 | - return $this->payment_method() ? $this->payment_method()->name() : __( 'Unknown', 'event_espresso' ); |
|
151 | + return $this->payment_method() ? $this->payment_method()->name() : __('Unknown', 'event_espresso'); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | * @param string $txn_id_chq_nmbr |
161 | 161 | * @throws \EE_Error |
162 | 162 | */ |
163 | - public function set_txn_id_chq_nmbr( $txn_id_chq_nmbr = '' ) { |
|
164 | - $this->set( 'PAY_txn_id_chq_nmbr', $txn_id_chq_nmbr ); |
|
163 | + public function set_txn_id_chq_nmbr($txn_id_chq_nmbr = '') { |
|
164 | + $this->set('PAY_txn_id_chq_nmbr', $txn_id_chq_nmbr); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | * @param string $po_number |
174 | 174 | * @throws \EE_Error |
175 | 175 | */ |
176 | - public function set_po_number( $po_number = '' ) { |
|
177 | - $this->set( 'PAY_po_number', $po_number ); |
|
176 | + public function set_po_number($po_number = '') { |
|
177 | + $this->set('PAY_po_number', $po_number); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | * @param string $extra_accntng |
187 | 187 | * @throws \EE_Error |
188 | 188 | */ |
189 | - public function set_extra_accntng( $extra_accntng = '' ) { |
|
190 | - $this->set( 'PAY_extra_accntng', $extra_accntng ); |
|
189 | + public function set_extra_accntng($extra_accntng = '') { |
|
190 | + $this->set('PAY_extra_accntng', $extra_accntng); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | * @param bool $via_admin |
200 | 200 | * @throws \EE_Error |
201 | 201 | */ |
202 | - public function set_payment_made_via_admin( $via_admin = false ) { |
|
203 | - if ( $via_admin ) { |
|
204 | - $this->set( 'PAY_source', EEM_Payment_Method::scope_admin ); |
|
202 | + public function set_payment_made_via_admin($via_admin = false) { |
|
203 | + if ($via_admin) { |
|
204 | + $this->set('PAY_source', EEM_Payment_Method::scope_admin); |
|
205 | 205 | } else { |
206 | - $this->set( 'PAY_source', EEM_Payment_Method::scope_cart ); |
|
206 | + $this->set('PAY_source', EEM_Payment_Method::scope_cart); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | * @param string|array $details |
217 | 217 | * @throws \EE_Error |
218 | 218 | */ |
219 | - public function set_details( $details = '' ) { |
|
220 | - if ( is_array( $details ) ) { |
|
221 | - array_walk_recursive( $details, array( $this, '_strip_all_tags_within_array' ) ); |
|
219 | + public function set_details($details = '') { |
|
220 | + if (is_array($details)) { |
|
221 | + array_walk_recursive($details, array($this, '_strip_all_tags_within_array')); |
|
222 | 222 | } else { |
223 | - $details = wp_strip_all_tags( $details ); |
|
223 | + $details = wp_strip_all_tags($details); |
|
224 | 224 | } |
225 | - $this->set( 'PAY_details', $details ); |
|
225 | + $this->set('PAY_details', $details); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | * @param string $redirect_url |
234 | 234 | * @throws \EE_Error |
235 | 235 | */ |
236 | - public function set_redirect_url( $redirect_url ) { |
|
237 | - $this->set( 'PAY_redirect_url', $redirect_url ); |
|
236 | + public function set_redirect_url($redirect_url) { |
|
237 | + $this->set('PAY_redirect_url', $redirect_url); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | |
@@ -245,8 +245,8 @@ discard block |
||
245 | 245 | * @param array $redirect_args |
246 | 246 | * @throws \EE_Error |
247 | 247 | */ |
248 | - public function set_redirect_args( $redirect_args ) { |
|
249 | - $this->set( 'PAY_redirect_args', $redirect_args ); |
|
248 | + public function set_redirect_args($redirect_args) { |
|
249 | + $this->set('PAY_redirect_args', $redirect_args); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @throws \EE_Error |
259 | 259 | */ |
260 | 260 | public function TXN_ID() { |
261 | - return $this->get( 'TXN_ID' ); |
|
261 | + return $this->get('TXN_ID'); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @throws \EE_Error |
271 | 271 | */ |
272 | 272 | public function status() { |
273 | - return $this->get( 'STS_ID' ); |
|
273 | + return $this->get('STS_ID'); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @throws \EE_Error |
283 | 283 | */ |
284 | 284 | public function STS_ID() { |
285 | - return $this->get( 'STS_ID' ); |
|
285 | + return $this->get('STS_ID'); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | |
@@ -296,8 +296,8 @@ discard block |
||
296 | 296 | * @return string |
297 | 297 | * @throws \EE_Error |
298 | 298 | */ |
299 | - public function timestamp( $dt_frmt = '', $tm_frmt = '' ) { |
|
300 | - return $this->get_i18n_datetime( 'PAY_timestamp', trim( $dt_frmt . ' ' . $tm_frmt) ); |
|
299 | + public function timestamp($dt_frmt = '', $tm_frmt = '') { |
|
300 | + return $this->get_i18n_datetime('PAY_timestamp', trim($dt_frmt.' '.$tm_frmt)); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @throws \EE_Error |
310 | 310 | */ |
311 | 311 | public function source() { |
312 | - return $this->get( 'PAY_source' ); |
|
312 | + return $this->get('PAY_source'); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * @throws \EE_Error |
323 | 323 | */ |
324 | 324 | public function amount() { |
325 | - return (float)$this->get( 'PAY_amount' ); |
|
325 | + return (float) $this->get('PAY_amount'); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * @throws \EE_Error |
333 | 333 | */ |
334 | 334 | public function amount_no_code() { |
335 | - return $this->get_pretty( 'PAY_amount', 'no_currency_code' ); |
|
335 | + return $this->get_pretty('PAY_amount', 'no_currency_code'); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * @throws \EE_Error |
345 | 345 | */ |
346 | 346 | public function gateway_response() { |
347 | - return $this->get( 'PAY_gateway_response' ); |
|
347 | + return $this->get('PAY_gateway_response'); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * @throws \EE_Error |
357 | 357 | */ |
358 | 358 | public function txn_id_chq_nmbr() { |
359 | - return $this->get( 'PAY_txn_id_chq_nmbr' ); |
|
359 | + return $this->get('PAY_txn_id_chq_nmbr'); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * @throws \EE_Error |
369 | 369 | */ |
370 | 370 | public function po_number() { |
371 | - return $this->get( 'PAY_po_number' ); |
|
371 | + return $this->get('PAY_po_number'); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | * @throws \EE_Error |
381 | 381 | */ |
382 | 382 | public function extra_accntng() { |
383 | - return $this->get( 'PAY_extra_accntng' ); |
|
383 | + return $this->get('PAY_extra_accntng'); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | * @throws \EE_Error |
393 | 393 | */ |
394 | 394 | public function payment_made_via_admin() { |
395 | - return ( $this->get( 'PAY_source' ) === EEM_Payment_Method::scope_admin ); |
|
395 | + return ($this->get('PAY_source') === EEM_Payment_Method::scope_admin); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | * @throws \EE_Error |
405 | 405 | */ |
406 | 406 | public function details() { |
407 | - return $this->get( 'PAY_details' ); |
|
407 | + return $this->get('PAY_details'); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | * @throws \EE_Error |
417 | 417 | */ |
418 | 418 | public function redirect_url() { |
419 | - return $this->get( 'PAY_redirect_url' ); |
|
419 | + return $this->get('PAY_redirect_url'); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * @throws \EE_Error |
429 | 429 | */ |
430 | 430 | public function redirect_args() { |
431 | - return $this->get( 'PAY_redirect_args' ); |
|
431 | + return $this->get('PAY_redirect_args'); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | |
@@ -440,8 +440,8 @@ discard block |
||
440 | 440 | * @return void |
441 | 441 | * @throws \EE_Error |
442 | 442 | */ |
443 | - public function e_pretty_status( $show_icons = false ) { |
|
444 | - echo $this->pretty_status( $show_icons ); |
|
443 | + public function e_pretty_status($show_icons = false) { |
|
444 | + echo $this->pretty_status($show_icons); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | |
@@ -453,14 +453,14 @@ discard block |
||
453 | 453 | * @return string |
454 | 454 | * @throws \EE_Error |
455 | 455 | */ |
456 | - public function pretty_status( $show_icons = false ) { |
|
456 | + public function pretty_status($show_icons = false) { |
|
457 | 457 | $status = EEM_Status::instance()->localized_status( |
458 | - array( $this->STS_ID() => __( 'unknown', 'event_espresso' ) ), |
|
458 | + array($this->STS_ID() => __('unknown', 'event_espresso')), |
|
459 | 459 | false, |
460 | 460 | 'sentence' |
461 | 461 | ); |
462 | 462 | $icon = ''; |
463 | - switch ( $this->STS_ID() ) { |
|
463 | + switch ($this->STS_ID()) { |
|
464 | 464 | case EEM_Payment::status_id_approved: |
465 | 465 | $icon = $show_icons |
466 | 466 | ? '<span class="dashicons dashicons-yes ee-icon-size-24 green-text"></span>' |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | : ''; |
483 | 483 | break; |
484 | 484 | } |
485 | - return $icon . $status[ $this->STS_ID() ]; |
|
485 | + return $icon.$status[$this->STS_ID()]; |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | * @throws \EE_Error |
495 | 495 | */ |
496 | 496 | public function is_approved() { |
497 | - return $this->status_is( EEM_Payment::status_id_approved ); |
|
497 | + return $this->status_is(EEM_Payment::status_id_approved); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | * @return boolean whether the status of this payment equals the status id |
509 | 509 | * @throws \EE_Error |
510 | 510 | */ |
511 | - protected function status_is( $STS_ID ) { |
|
511 | + protected function status_is($STS_ID) { |
|
512 | 512 | return $STS_ID === $this->STS_ID() ? true : false; |
513 | 513 | } |
514 | 514 | |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | * @throws \EE_Error |
522 | 522 | */ |
523 | 523 | public function is_pending() { |
524 | - return $this->status_is( EEM_Payment::status_id_pending ); |
|
524 | + return $this->status_is(EEM_Payment::status_id_pending); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | * @throws \EE_Error |
534 | 534 | */ |
535 | 535 | public function is_cancelled() { |
536 | - return $this->status_is( EEM_Payment::status_id_cancelled ); |
|
536 | + return $this->status_is(EEM_Payment::status_id_cancelled); |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | * @throws \EE_Error |
546 | 546 | */ |
547 | 547 | public function is_declined() { |
548 | - return $this->status_is( EEM_Payment::status_id_declined ); |
|
548 | + return $this->status_is(EEM_Payment::status_id_declined); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | * @throws \EE_Error |
558 | 558 | */ |
559 | 559 | public function is_failed() { |
560 | - return $this->status_is( EEM_Payment::status_id_failed ); |
|
560 | + return $this->status_is(EEM_Payment::status_id_failed); |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | * @throws \EE_Error |
582 | 582 | */ |
583 | 583 | public function status_obj() { |
584 | - return $this->get_first_related( 'Status' ); |
|
584 | + return $this->get_first_related('Status'); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | |
@@ -593,8 +593,8 @@ discard block |
||
593 | 593 | * @return EE_Extra_Meta |
594 | 594 | * @throws \EE_Error |
595 | 595 | */ |
596 | - public function extra_meta( $query_params = array() ) { |
|
597 | - return $this->get_many_related( 'Extra_Meta', $query_params ); |
|
596 | + public function extra_meta($query_params = array()) { |
|
597 | + return $this->get_many_related('Extra_Meta', $query_params); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | * @throws \EE_Error |
609 | 609 | */ |
610 | 610 | public function payment_method() { |
611 | - return $this->get_first_related( 'Payment_Method' ); |
|
611 | + return $this->get_first_related('Payment_Method'); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | |
@@ -626,18 +626,18 @@ discard block |
||
626 | 626 | * @return string html |
627 | 627 | * @throws \EE_Error |
628 | 628 | */ |
629 | - public function redirect_form( $inside_form_html = null ) { |
|
629 | + public function redirect_form($inside_form_html = null) { |
|
630 | 630 | $redirect_url = $this->redirect_url(); |
631 | - if ( ! empty( $redirect_url ) ) { |
|
631 | + if ( ! empty($redirect_url)) { |
|
632 | 632 | // what ? no inner form content? |
633 | - if ( $inside_form_html === null ) { |
|
633 | + if ($inside_form_html === null) { |
|
634 | 634 | $inside_form_html = EEH_HTML::p( |
635 | 635 | sprintf( |
636 | 636 | __( |
637 | 637 | 'If you are not automatically redirected to the payment website within 10 seconds... %1$s %2$s Click Here %3$s', |
638 | 638 | 'event_espresso' |
639 | 639 | ), |
640 | - EEH_HTML::br( 2 ), |
|
640 | + EEH_HTML::br(2), |
|
641 | 641 | '<input type="submit" value="', |
642 | 642 | '">' |
643 | 643 | ), |
@@ -653,22 +653,22 @@ discard block |
||
653 | 653 | ); |
654 | 654 | //if it's a GET request, we need to remove all the GET params in the querystring |
655 | 655 | //and put them into the form instead |
656 | - if ( $method === 'GET' ) { |
|
657 | - $querystring = parse_url( $redirect_url, PHP_URL_QUERY ); |
|
656 | + if ($method === 'GET') { |
|
657 | + $querystring = parse_url($redirect_url, PHP_URL_QUERY); |
|
658 | 658 | $get_params = null; |
659 | - parse_str( $querystring, $get_params ); |
|
660 | - $inside_form_html .= $this->_args_as_inputs( $get_params ); |
|
661 | - $redirect_url = str_replace( '?' . $querystring, '', $redirect_url ); |
|
659 | + parse_str($querystring, $get_params); |
|
660 | + $inside_form_html .= $this->_args_as_inputs($get_params); |
|
661 | + $redirect_url = str_replace('?'.$querystring, '', $redirect_url); |
|
662 | 662 | } |
663 | - $form = EEH_HTML::nl( 1 ) |
|
663 | + $form = EEH_HTML::nl(1) |
|
664 | 664 | . '<form method="' |
665 | 665 | . $method |
666 | 666 | . '" name="gateway_form" action="' |
667 | 667 | . $redirect_url |
668 | 668 | . '">'; |
669 | - $form .= EEH_HTML::nl( 1 ) . $this->redirect_args_as_inputs(); |
|
669 | + $form .= EEH_HTML::nl(1).$this->redirect_args_as_inputs(); |
|
670 | 670 | $form .= $inside_form_html; |
671 | - $form .= EEH_HTML::nl( -1 ) . '</form>' . EEH_HTML::nl( -1 ); |
|
671 | + $form .= EEH_HTML::nl( -1 ).'</form>'.EEH_HTML::nl( -1 ); |
|
672 | 672 | return $form; |
673 | 673 | } else { |
674 | 674 | return null; |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | * @throws \EE_Error |
686 | 686 | */ |
687 | 687 | public function redirect_args_as_inputs() { |
688 | - return $this->_args_as_inputs( $this->redirect_args() ); |
|
688 | + return $this->_args_as_inputs($this->redirect_args()); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | |
@@ -697,15 +697,15 @@ discard block |
||
697 | 697 | * @param array $args key-value pairs |
698 | 698 | * @return string |
699 | 699 | */ |
700 | - protected function _args_as_inputs( $args ) { |
|
700 | + protected function _args_as_inputs($args) { |
|
701 | 701 | $html = ''; |
702 | - if ( $args !== null && is_array( $args ) ) { |
|
703 | - foreach ( $args as $name => $value ) { |
|
704 | - $html .= EEH_HTML::nl( 0 ) |
|
702 | + if ($args !== null && is_array($args)) { |
|
703 | + foreach ($args as $name => $value) { |
|
704 | + $html .= EEH_HTML::nl(0) |
|
705 | 705 | . '<input type="hidden" name="' |
706 | 706 | . $name |
707 | 707 | . '" value="' |
708 | - . esc_attr( $value ) |
|
708 | + . esc_attr($value) |
|
709 | 709 | . '"/>'; |
710 | 710 | } |
711 | 711 | } |
@@ -734,14 +734,14 @@ discard block |
||
734 | 734 | * @access private |
735 | 735 | * @param mixed $item |
736 | 736 | */ |
737 | - private function _strip_all_tags_within_array( &$item ) { |
|
738 | - if ( is_object( $item ) ) { |
|
739 | - $item = (array)$item; |
|
737 | + private function _strip_all_tags_within_array(&$item) { |
|
738 | + if (is_object($item)) { |
|
739 | + $item = (array) $item; |
|
740 | 740 | } |
741 | - if ( is_array( $item ) ) { |
|
742 | - array_walk_recursive( $item, array( $this, '_strip_all_tags_within_array' ) ); |
|
741 | + if (is_array($item)) { |
|
742 | + array_walk_recursive($item, array($this, '_strip_all_tags_within_array')); |
|
743 | 743 | } else { |
744 | - $item = wp_strip_all_tags( $item ); |
|
744 | + $item = wp_strip_all_tags($item); |
|
745 | 745 | } |
746 | 746 | } |
747 | 747 | |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | $original_status = EEH_Array::is_set( |
759 | 759 | $this->_props_n_values_provided_in_constructor, |
760 | 760 | 'STS_ID', |
761 | - $this->get_model()->field_settings_for( 'STS_ID' )->get_default_value() |
|
761 | + $this->get_model()->field_settings_for('STS_ID')->get_default_value() |
|
762 | 762 | ); |
763 | 763 | $current_status = $this->status(); |
764 | 764 | if ( |
@@ -784,11 +784,11 @@ discard block |
||
784 | 784 | * @return mixed |
785 | 785 | * @throws \EE_Error |
786 | 786 | */ |
787 | - public function get_pretty( $field_name, $extra_cache_ref = null ) { |
|
788 | - if ( $field_name === 'PAY_gateway' ) { |
|
789 | - return $this->payment_method() ? $this->payment_method()->name() : __( 'Unknown', 'event_espresso' ); |
|
787 | + public function get_pretty($field_name, $extra_cache_ref = null) { |
|
788 | + if ($field_name === 'PAY_gateway') { |
|
789 | + return $this->payment_method() ? $this->payment_method()->name() : __('Unknown', 'event_espresso'); |
|
790 | 790 | } |
791 | - return $this->_get_cached_property( $field_name, true, $extra_cache_ref ); |
|
791 | + return $this->_get_cached_property($field_name, true, $extra_cache_ref); |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | |
@@ -800,8 +800,8 @@ discard block |
||
800 | 800 | * @return EE_Registration_Payment[] |
801 | 801 | * @throws \EE_Error |
802 | 802 | */ |
803 | - public function registration_payments( $query_params = array() ) { |
|
804 | - return $this->get_many_related( 'Registration_Payment', $query_params ); |
|
803 | + public function registration_payments($query_params = array()) { |
|
804 | + return $this->get_many_related('Registration_Payment', $query_params); |
|
805 | 805 | } |
806 | 806 | |
807 | 807 | |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | public function get_primary_attendee() |
863 | 863 | { |
864 | 864 | $primary_reg = $this->get_primary_registration(); |
865 | - if( $primary_reg instanceof EE_Registration) { |
|
865 | + if ($primary_reg instanceof EE_Registration) { |
|
866 | 866 | return $primary_reg->attendee(); |
867 | 867 | } |
868 | 868 | return null; |
@@ -661,11 +661,11 @@ discard block |
||
661 | 661 | $redirect_url = str_replace( '?' . $querystring, '', $redirect_url ); |
662 | 662 | } |
663 | 663 | $form = EEH_HTML::nl( 1 ) |
664 | - . '<form method="' |
|
665 | - . $method |
|
666 | - . '" name="gateway_form" action="' |
|
667 | - . $redirect_url |
|
668 | - . '">'; |
|
664 | + . '<form method="' |
|
665 | + . $method |
|
666 | + . '" name="gateway_form" action="' |
|
667 | + . $redirect_url |
|
668 | + . '">'; |
|
669 | 669 | $form .= EEH_HTML::nl( 1 ) . $this->redirect_args_as_inputs(); |
670 | 670 | $form .= $inside_form_html; |
671 | 671 | $form .= EEH_HTML::nl( -1 ) . '</form>' . EEH_HTML::nl( -1 ); |
@@ -702,11 +702,11 @@ discard block |
||
702 | 702 | if ( $args !== null && is_array( $args ) ) { |
703 | 703 | foreach ( $args as $name => $value ) { |
704 | 704 | $html .= EEH_HTML::nl( 0 ) |
705 | - . '<input type="hidden" name="' |
|
706 | - . $name |
|
707 | - . '" value="' |
|
708 | - . esc_attr( $value ) |
|
709 | - . '"/>'; |
|
705 | + . '<input type="hidden" name="' |
|
706 | + . $name |
|
707 | + . '" value="' |
|
708 | + . esc_attr( $value ) |
|
709 | + . '"/>'; |
|
710 | 710 | } |
711 | 711 | } |
712 | 712 | return $html; |
@@ -806,64 +806,64 @@ discard block |
||
806 | 806 | |
807 | 807 | |
808 | 808 | |
809 | - /** |
|
810 | - * Gets the first event for this payment (it's possible that it could be for multiple) |
|
811 | - * |
|
812 | - * @return EE_Event|null |
|
813 | - */ |
|
814 | - public function get_first_event() |
|
815 | - { |
|
816 | - $transaction = $this->transaction(); |
|
817 | - if ($transaction instanceof EE_Transaction) { |
|
818 | - $primary_registrant = $transaction->primary_registration(); |
|
819 | - if ($primary_registrant instanceof EE_Registration) { |
|
820 | - return $primary_registrant->event_obj(); |
|
821 | - } |
|
822 | - } |
|
823 | - return null; |
|
824 | - } |
|
825 | - |
|
826 | - |
|
827 | - |
|
828 | - /** |
|
829 | - * Gets the name of the first event for which is being paid |
|
830 | - * |
|
831 | - * @return string |
|
832 | - */ |
|
833 | - public function get_first_event_name() |
|
834 | - { |
|
835 | - $event = $this->get_first_event(); |
|
836 | - return $event instanceof EE_Event ? $event->name() : __('Event', 'event_espresso'); |
|
837 | - } |
|
838 | - |
|
839 | - |
|
840 | - |
|
841 | - /** |
|
842 | - * Returns the payment's transaction's primary registration |
|
843 | - * @return EE_Registration|null |
|
844 | - */ |
|
845 | - public function get_primary_registration() |
|
846 | - { |
|
847 | - if ($this->transaction() instanceof EE_Transaction) { |
|
848 | - return $this->transaction()->primary_registration(); |
|
849 | - } |
|
850 | - return null; |
|
851 | - } |
|
852 | - |
|
853 | - |
|
854 | - |
|
855 | - /** |
|
856 | - * Gets the payment's transaction's primary registration's attendee, or null |
|
857 | - * @return EE_Attendee|null |
|
858 | - */ |
|
859 | - public function get_primary_attendee() |
|
860 | - { |
|
861 | - $primary_reg = $this->get_primary_registration(); |
|
862 | - if( $primary_reg instanceof EE_Registration) { |
|
863 | - return $primary_reg->attendee(); |
|
864 | - } |
|
865 | - return null; |
|
866 | - } |
|
809 | + /** |
|
810 | + * Gets the first event for this payment (it's possible that it could be for multiple) |
|
811 | + * |
|
812 | + * @return EE_Event|null |
|
813 | + */ |
|
814 | + public function get_first_event() |
|
815 | + { |
|
816 | + $transaction = $this->transaction(); |
|
817 | + if ($transaction instanceof EE_Transaction) { |
|
818 | + $primary_registrant = $transaction->primary_registration(); |
|
819 | + if ($primary_registrant instanceof EE_Registration) { |
|
820 | + return $primary_registrant->event_obj(); |
|
821 | + } |
|
822 | + } |
|
823 | + return null; |
|
824 | + } |
|
825 | + |
|
826 | + |
|
827 | + |
|
828 | + /** |
|
829 | + * Gets the name of the first event for which is being paid |
|
830 | + * |
|
831 | + * @return string |
|
832 | + */ |
|
833 | + public function get_first_event_name() |
|
834 | + { |
|
835 | + $event = $this->get_first_event(); |
|
836 | + return $event instanceof EE_Event ? $event->name() : __('Event', 'event_espresso'); |
|
837 | + } |
|
838 | + |
|
839 | + |
|
840 | + |
|
841 | + /** |
|
842 | + * Returns the payment's transaction's primary registration |
|
843 | + * @return EE_Registration|null |
|
844 | + */ |
|
845 | + public function get_primary_registration() |
|
846 | + { |
|
847 | + if ($this->transaction() instanceof EE_Transaction) { |
|
848 | + return $this->transaction()->primary_registration(); |
|
849 | + } |
|
850 | + return null; |
|
851 | + } |
|
852 | + |
|
853 | + |
|
854 | + |
|
855 | + /** |
|
856 | + * Gets the payment's transaction's primary registration's attendee, or null |
|
857 | + * @return EE_Attendee|null |
|
858 | + */ |
|
859 | + public function get_primary_attendee() |
|
860 | + { |
|
861 | + $primary_reg = $this->get_primary_registration(); |
|
862 | + if( $primary_reg instanceof EE_Registration) { |
|
863 | + return $primary_reg->attendee(); |
|
864 | + } |
|
865 | + return null; |
|
866 | + } |
|
867 | 867 | } |
868 | 868 | /* End of file EE_Payment.class.php */ |
869 | 869 | /* Location: /includes/classes/EE_Payment.class.php */ |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @param array $props_n_values incoming values |
16 | 16 | * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
17 | 17 | * used.) |
18 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
18 | + * @param string[] $date_formats incoming date_formats in an array where the first value is the |
|
19 | 19 | * date_format and the second value is the time format |
20 | 20 | * @return EE_Payment |
21 | 21 | * @throws \EE_Error |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | * Gets all the extra meta info on this payment |
591 | 591 | * |
592 | 592 | * @param array $query_params like EEM_Base::get_all |
593 | - * @return EE_Extra_Meta |
|
593 | + * @return EE_Base_Class[] |
|
594 | 594 | * @throws \EE_Error |
595 | 595 | */ |
596 | 596 | public function extra_meta( $query_params = array() ) { |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | |
841 | 841 | /** |
842 | 842 | * Returns the payment's transaction's primary registration |
843 | - * @return EE_Registration|null |
|
843 | + * @return EE_Base_Class|null |
|
844 | 844 | */ |
845 | 845 | public function get_primary_registration() |
846 | 846 | { |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | * set session data |
434 | 434 | * @access public |
435 | 435 | * @param array $data |
436 | - * @return TRUE on success, FALSE on fail |
|
436 | + * @return boolean on success, FALSE on fail |
|
437 | 437 | */ |
438 | 438 | public function set_session_data( $data ) { |
439 | 439 | |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | /** |
462 | 462 | * @initiate session |
463 | 463 | * @access private |
464 | - * @return TRUE on success, FALSE on fail |
|
464 | + * @return boolean on success, FALSE on fail |
|
465 | 465 | * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
466 | 466 | * @throws \EE_Error |
467 | 467 | */ |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | * @update session data prior to saving to the db |
682 | 682 | * @access public |
683 | 683 | * @param bool $new_session |
684 | - * @return TRUE on success, FALSE on fail |
|
684 | + * @return boolean on success, FALSE on fail |
|
685 | 685 | * @throws \EE_Error |
686 | 686 | */ |
687 | 687 | public function update( $new_session = FALSE ) { |
@@ -787,7 +787,7 @@ discard block |
||
787 | 787 | * _save_session_to_db |
788 | 788 | * |
789 | 789 | * @access public |
790 | - * @return string |
|
790 | + * @return boolean |
|
791 | 791 | * @throws \EE_Error |
792 | 792 | */ |
793 | 793 | private function _save_session_to_db() { |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | * @access public |
960 | 960 | * @param array $data_to_reset |
961 | 961 | * @param bool $show_all_notices |
962 | - * @return TRUE on success, FALSE on fail |
|
962 | + * @return boolean on success, FALSE on fail |
|
963 | 963 | */ |
964 | 964 | public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) { |
965 | 965 | // if $data_to_reset is not in an array, then put it in one |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php use EventEspresso\core\exceptions\InvalidSessionDataException; |
2 | 2 | use EventEspresso\core\services\cache\CacheStorageInterface; |
3 | 3 | |
4 | -if (!defined( 'EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
5 | 5 | /** |
6 | 6 | * |
7 | 7 | * EE_Session class |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * array for defining default session vars |
107 | 107 | * @var array |
108 | 108 | */ |
109 | - private $_default_session_vars = array ( |
|
109 | + private $_default_session_vars = array( |
|
110 | 110 | 'id' => null, |
111 | 111 | 'user_id' => null, |
112 | 112 | 'ip_address' => null, |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | // check if class object is instantiated |
135 | 135 | // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: |
136 | 136 | // add_filter( 'FHEE_load_EE_Session', '__return_false' ); |
137 | - if ( ! self::$_instance instanceof EE_Session && apply_filters( 'FHEE_load_EE_Session', true ) ) { |
|
138 | - self::$_instance = new self($cache_storage, $encryption ); |
|
137 | + if ( ! self::$_instance instanceof EE_Session && apply_filters('FHEE_load_EE_Session', true)) { |
|
138 | + self::$_instance = new self($cache_storage, $encryption); |
|
139 | 139 | } |
140 | 140 | return self::$_instance; |
141 | 141 | } |
@@ -150,15 +150,15 @@ discard block |
||
150 | 150 | * @throws \EE_Error |
151 | 151 | * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
152 | 152 | */ |
153 | - protected function __construct(CacheStorageInterface $cache_storage, EE_Encryption $encryption = null ) { |
|
153 | + protected function __construct(CacheStorageInterface $cache_storage, EE_Encryption $encryption = null) { |
|
154 | 154 | |
155 | 155 | // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: add_filter( 'FHEE_load_EE_Session', '__return_false' ); |
156 | - if ( ! apply_filters( 'FHEE_load_EE_Session', true ) ) { |
|
156 | + if ( ! apply_filters('FHEE_load_EE_Session', true)) { |
|
157 | 157 | return; |
158 | 158 | } |
159 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
160 | - if ( ! defined( 'ESPRESSO_SESSION' ) ) { |
|
161 | - define( 'ESPRESSO_SESSION', true ); |
|
159 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
160 | + if ( ! defined('ESPRESSO_SESSION')) { |
|
161 | + define('ESPRESSO_SESSION', true); |
|
162 | 162 | } |
163 | 163 | // default session lifespan in seconds |
164 | 164 | $this->_lifespan = apply_filters( |
@@ -172,12 +172,12 @@ discard block |
||
172 | 172 | * } |
173 | 173 | */ |
174 | 174 | // retrieve session options from db |
175 | - $session_settings = (array) get_option( 'ee_session_settings', array() ); |
|
176 | - if ( ! empty( $session_settings )) { |
|
175 | + $session_settings = (array) get_option('ee_session_settings', array()); |
|
176 | + if ( ! empty($session_settings)) { |
|
177 | 177 | // cycle though existing session options |
178 | - foreach ( $session_settings as $var_name => $session_setting ) { |
|
178 | + foreach ($session_settings as $var_name => $session_setting) { |
|
179 | 179 | // set values for class properties |
180 | - $var_name = '_' . $var_name; |
|
180 | + $var_name = '_'.$var_name; |
|
181 | 181 | $this->{$var_name} = $session_setting; |
182 | 182 | } |
183 | 183 | } |
@@ -188,15 +188,15 @@ discard block |
||
188 | 188 | // encrypt data via: $this->encryption->encrypt(); |
189 | 189 | $this->encryption = $encryption; |
190 | 190 | // filter hook allows outside functions/classes/plugins to change default empty cart |
191 | - $extra_default_session_vars = apply_filters( 'FHEE__EE_Session__construct__extra_default_session_vars', array() ); |
|
192 | - array_merge( $this->_default_session_vars, $extra_default_session_vars ); |
|
191 | + $extra_default_session_vars = apply_filters('FHEE__EE_Session__construct__extra_default_session_vars', array()); |
|
192 | + array_merge($this->_default_session_vars, $extra_default_session_vars); |
|
193 | 193 | // apply default session vars |
194 | 194 | $this->_set_defaults(); |
195 | 195 | add_action('AHEE__EE_System__initialize', array($this, 'open_session')); |
196 | 196 | // check request for 'clear_session' param |
197 | - add_action( 'AHEE__EE_Request_Handler__construct__complete', array( $this, 'wp_loaded' )); |
|
197 | + add_action('AHEE__EE_Request_Handler__construct__complete', array($this, 'wp_loaded')); |
|
198 | 198 | // once everything is all said and done, |
199 | - add_action( 'shutdown', array( $this, 'update' ), 100 ); |
|
199 | + add_action('shutdown', array($this, 'update'), 100); |
|
200 | 200 | $this->configure_garbage_collection_filters(); |
201 | 201 | } |
202 | 202 | |
@@ -284,11 +284,11 @@ discard block |
||
284 | 284 | */ |
285 | 285 | private function _set_defaults() { |
286 | 286 | // set some defaults |
287 | - foreach ( $this->_default_session_vars as $key => $default_var ) { |
|
288 | - if ( is_array( $default_var )) { |
|
289 | - $this->_session_data[ $key ] = array(); |
|
287 | + foreach ($this->_default_session_vars as $key => $default_var) { |
|
288 | + if (is_array($default_var)) { |
|
289 | + $this->_session_data[$key] = array(); |
|
290 | 290 | } else { |
291 | - $this->_session_data[ $key ] = ''; |
|
291 | + $this->_session_data[$key] = ''; |
|
292 | 292 | } |
293 | 293 | } |
294 | 294 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * @param \EE_Checkout $checkout |
344 | 344 | * @return bool |
345 | 345 | */ |
346 | - public function set_checkout( EE_Checkout $checkout ) { |
|
346 | + public function set_checkout(EE_Checkout $checkout) { |
|
347 | 347 | $this->_session_data['checkout'] = $checkout; |
348 | 348 | return TRUE; |
349 | 349 | } |
@@ -376,9 +376,9 @@ discard block |
||
376 | 376 | * @return bool |
377 | 377 | * @throws \EE_Error |
378 | 378 | */ |
379 | - public function set_transaction( EE_Transaction $transaction ) { |
|
379 | + public function set_transaction(EE_Transaction $transaction) { |
|
380 | 380 | // first remove the session from the transaction before we save the transaction in the session |
381 | - $transaction->set_txn_session_data( NULL ); |
|
381 | + $transaction->set_txn_session_data(NULL); |
|
382 | 382 | $this->_session_data['transaction'] = $transaction; |
383 | 383 | return TRUE; |
384 | 384 | } |
@@ -414,15 +414,15 @@ discard block |
||
414 | 414 | * @param bool $reset_cache |
415 | 415 | * @return array |
416 | 416 | */ |
417 | - public function get_session_data( $key = NULL, $reset_cache = FALSE ) { |
|
418 | - if ( $reset_cache ) { |
|
417 | + public function get_session_data($key = NULL, $reset_cache = FALSE) { |
|
418 | + if ($reset_cache) { |
|
419 | 419 | $this->reset_cart(); |
420 | 420 | $this->reset_checkout(); |
421 | 421 | $this->reset_transaction(); |
422 | 422 | } |
423 | - if ( ! empty( $key )) { |
|
424 | - return isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL; |
|
425 | - } else { |
|
423 | + if ( ! empty($key)) { |
|
424 | + return isset($this->_session_data[$key]) ? $this->_session_data[$key] : NULL; |
|
425 | + } else { |
|
426 | 426 | return $this->_session_data; |
427 | 427 | } |
428 | 428 | } |
@@ -435,20 +435,20 @@ discard block |
||
435 | 435 | * @param array $data |
436 | 436 | * @return TRUE on success, FALSE on fail |
437 | 437 | */ |
438 | - public function set_session_data( $data ) { |
|
438 | + public function set_session_data($data) { |
|
439 | 439 | |
440 | 440 | // nothing ??? bad data ??? go home! |
441 | - if ( empty( $data ) || ! is_array( $data )) { |
|
442 | - EE_Error::add_error( __( 'No session data or invalid session data was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
441 | + if (empty($data) || ! is_array($data)) { |
|
442 | + EE_Error::add_error(__('No session data or invalid session data was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
443 | 443 | return FALSE; |
444 | 444 | } |
445 | 445 | |
446 | - foreach ( $data as $key =>$value ) { |
|
447 | - if ( isset( $this->_default_session_vars[ $key ] )) { |
|
448 | - EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $key ), __FILE__, __FUNCTION__, __LINE__ ); |
|
446 | + foreach ($data as $key =>$value) { |
|
447 | + if (isset($this->_default_session_vars[$key])) { |
|
448 | + EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $key), __FILE__, __FUNCTION__, __LINE__); |
|
449 | 449 | return FALSE; |
450 | 450 | } else { |
451 | - $this->_session_data[ $key ] = $value; |
|
451 | + $this->_session_data[$key] = $value; |
|
452 | 452 | } |
453 | 453 | } |
454 | 454 | |
@@ -466,9 +466,9 @@ discard block |
||
466 | 466 | * @throws \EE_Error |
467 | 467 | */ |
468 | 468 | private function _espresso_session() { |
469 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
469 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
470 | 470 | // check that session has started |
471 | - if ( session_id() === '' ) { |
|
471 | + if (session_id() === '') { |
|
472 | 472 | //starts a new session if one doesn't already exist, or re-initiates an existing one |
473 | 473 | session_start(); |
474 | 474 | } |
@@ -477,39 +477,39 @@ discard block |
||
477 | 477 | // and the visitors IP |
478 | 478 | $this->_ip_address = $this->_visitor_ip(); |
479 | 479 | // set the "user agent" |
480 | - $this->_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? esc_attr( $_SERVER['HTTP_USER_AGENT'] ) : FALSE; |
|
480 | + $this->_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? esc_attr($_SERVER['HTTP_USER_AGENT']) : FALSE; |
|
481 | 481 | // now let's retrieve what's in the db |
482 | 482 | $session_data = $this->_retrieve_session_data(); |
483 | - if (! empty($session_data)) { |
|
483 | + if ( ! empty($session_data)) { |
|
484 | 484 | // get the current time in UTC |
485 | - $this->_time = isset( $this->_time ) ? $this->_time : time(); |
|
485 | + $this->_time = isset($this->_time) ? $this->_time : time(); |
|
486 | 486 | // and reset the session expiration |
487 | - $this->_expiration = isset( $session_data['expiration'] ) |
|
487 | + $this->_expiration = isset($session_data['expiration']) |
|
488 | 488 | ? $session_data['expiration'] |
489 | 489 | : $this->_time + $this->_lifespan; |
490 | 490 | } else { |
491 | 491 | // set initial site access time and the session expiration |
492 | 492 | $this->_set_init_access_and_expiration(); |
493 | 493 | // set referer |
494 | - $this->_session_data[ 'pages_visited' ][ $this->_session_data['init_access'] ] = isset( $_SERVER['HTTP_REFERER'] ) |
|
495 | - ? esc_attr( $_SERVER['HTTP_REFERER'] ) |
|
494 | + $this->_session_data['pages_visited'][$this->_session_data['init_access']] = isset($_SERVER['HTTP_REFERER']) |
|
495 | + ? esc_attr($_SERVER['HTTP_REFERER']) |
|
496 | 496 | : ''; |
497 | 497 | // no previous session = go back and create one (on top of the data above) |
498 | 498 | return FALSE; |
499 | 499 | } |
500 | 500 | // now the user agent |
501 | - if ( $session_data['user_agent'] !== $this->_user_agent ) { |
|
501 | + if ($session_data['user_agent'] !== $this->_user_agent) { |
|
502 | 502 | return FALSE; |
503 | 503 | } |
504 | 504 | // wait a minute... how old are you? |
505 | - if ( $this->_time > $this->_expiration ) { |
|
505 | + if ($this->_time > $this->_expiration) { |
|
506 | 506 | // yer too old fer me! |
507 | 507 | $this->_expired = true; |
508 | 508 | // wipe out everything that isn't a default session datum |
509 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
509 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
510 | 510 | } |
511 | 511 | // make event espresso session data available to plugin |
512 | - $this->_session_data = array_merge( $this->_session_data, $session_data ); |
|
512 | + $this->_session_data = array_merge($this->_session_data, $session_data); |
|
513 | 513 | return TRUE; |
514 | 514 | |
515 | 515 | } |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | */ |
526 | 526 | protected function _retrieve_session_data() |
527 | 527 | { |
528 | - $ssn_key = EE_Session::session_id_prefix . $this->_sid; |
|
528 | + $ssn_key = EE_Session::session_id_prefix.$this->_sid; |
|
529 | 529 | try { |
530 | 530 | // we're using WP's Transient API to store session data using the PHP session ID as the option name |
531 | 531 | $session_data = $this->cache_storage->get($ssn_key, false); |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | } |
535 | 535 | if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
536 | 536 | $hash_check = $this->cache_storage->get( |
537 | - EE_Session::hash_check_prefix . $this->_sid, |
|
537 | + EE_Session::hash_check_prefix.$this->_sid, |
|
538 | 538 | false |
539 | 539 | ); |
540 | 540 | if ($hash_check && $hash_check !== md5($session_data)) { |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | 'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', |
545 | 545 | 'event_espresso' |
546 | 546 | ), |
547 | - EE_Session::session_id_prefix . $this->_sid |
|
547 | + EE_Session::session_id_prefix.$this->_sid |
|
548 | 548 | ), |
549 | 549 | __FILE__, __FUNCTION__, __LINE__ |
550 | 550 | ); |
@@ -556,17 +556,17 @@ discard block |
||
556 | 556 | $row = $wpdb->get_row( |
557 | 557 | $wpdb->prepare( |
558 | 558 | "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1", |
559 | - '_transient_' . $ssn_key |
|
559 | + '_transient_'.$ssn_key |
|
560 | 560 | ) |
561 | 561 | ); |
562 | 562 | $session_data = is_object($row) ? $row->option_value : null; |
563 | 563 | if ($session_data) { |
564 | 564 | $session_data = preg_replace_callback( |
565 | 565 | '!s:(d+):"(.*?)";!', |
566 | - function ($match) { |
|
566 | + function($match) { |
|
567 | 567 | return $match[1] === strlen($match[2]) |
568 | 568 | ? $match[0] |
569 | - : 's:' . strlen($match[2]) . ':"' . $match[2] . '";'; |
|
569 | + : 's:'.strlen($match[2]).':"'.$match[2].'";'; |
|
570 | 570 | }, |
571 | 571 | $session_data |
572 | 572 | ); |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | 'event_espresso' |
588 | 588 | ); |
589 | 589 | $msg .= WP_DEBUG |
590 | - ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data) |
|
590 | + ? '<br><pre>'.print_r($session_data, true).'</pre><br>'.$this->find_serialize_error($session_data) |
|
591 | 591 | : ''; |
592 | 592 | throw new InvalidSessionDataException($msg, 0, $e); |
593 | 593 | } |
@@ -600,11 +600,11 @@ discard block |
||
600 | 600 | 'event_espresso' |
601 | 601 | ); |
602 | 602 | $msg .= WP_DEBUG |
603 | - ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data) |
|
603 | + ? '<br><pre>'.print_r($session_data, true).'</pre><br>'.$this->find_serialize_error($session_data) |
|
604 | 604 | : ''; |
605 | 605 | throw new InvalidSessionDataException($msg); |
606 | 606 | } |
607 | - if ( isset($session_data['transaction'] ) && absint($session_data['transaction'] ) !== 0 ) { |
|
607 | + if (isset($session_data['transaction']) && absint($session_data['transaction']) !== 0) { |
|
608 | 608 | $session_data['transaction'] = EEM_Transaction::instance()->get_one_by_ID( |
609 | 609 | $session_data['transaction'] |
610 | 610 | ); |
@@ -625,12 +625,12 @@ discard block |
||
625 | 625 | */ |
626 | 626 | protected function _generate_session_id() { |
627 | 627 | // check if the SID was passed explicitly, otherwise get from session, then add salt and hash it to reduce length |
628 | - if ( isset( $_REQUEST[ 'EESID' ] ) ) { |
|
629 | - $session_id = sanitize_text_field( $_REQUEST[ 'EESID' ] ); |
|
628 | + if (isset($_REQUEST['EESID'])) { |
|
629 | + $session_id = sanitize_text_field($_REQUEST['EESID']); |
|
630 | 630 | } else { |
631 | - $session_id = md5( session_id() . get_current_blog_id() . $this->_get_sid_salt() ); |
|
631 | + $session_id = md5(session_id().get_current_blog_id().$this->_get_sid_salt()); |
|
632 | 632 | } |
633 | - return apply_filters( 'FHEE__EE_Session___generate_session_id__session_id', $session_id ); |
|
633 | + return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id); |
|
634 | 634 | } |
635 | 635 | |
636 | 636 | |
@@ -642,20 +642,20 @@ discard block |
||
642 | 642 | */ |
643 | 643 | protected function _get_sid_salt() { |
644 | 644 | // was session id salt already saved to db ? |
645 | - if ( empty( $this->_sid_salt ) ) { |
|
645 | + if (empty($this->_sid_salt)) { |
|
646 | 646 | // no? then maybe use WP defined constant |
647 | - if ( defined( 'AUTH_SALT' ) ) { |
|
647 | + if (defined('AUTH_SALT')) { |
|
648 | 648 | $this->_sid_salt = AUTH_SALT; |
649 | 649 | } |
650 | 650 | // if salt doesn't exist or is too short |
651 | - if ( strlen( $this->_sid_salt ) < 32 ) { |
|
651 | + if (strlen($this->_sid_salt) < 32) { |
|
652 | 652 | // create a new one |
653 | - $this->_sid_salt = wp_generate_password( 64 ); |
|
653 | + $this->_sid_salt = wp_generate_password(64); |
|
654 | 654 | } |
655 | 655 | // and save it as a permanent session setting |
656 | - $session_settings = get_option( 'ee_session_settings' ); |
|
657 | - $session_settings[ 'sid_salt' ] = $this->_sid_salt; |
|
658 | - update_option( 'ee_session_settings', $session_settings ); |
|
656 | + $session_settings = get_option('ee_session_settings'); |
|
657 | + $session_settings['sid_salt'] = $this->_sid_salt; |
|
658 | + update_option('ee_session_settings', $session_settings); |
|
659 | 659 | } |
660 | 660 | return $this->_sid_salt; |
661 | 661 | } |
@@ -684,19 +684,19 @@ discard block |
||
684 | 684 | * @return TRUE on success, FALSE on fail |
685 | 685 | * @throws \EE_Error |
686 | 686 | */ |
687 | - public function update( $new_session = FALSE ) { |
|
688 | - $this->_session_data = isset( $this->_session_data ) |
|
689 | - && is_array( $this->_session_data ) |
|
690 | - && isset( $this->_session_data['id']) |
|
687 | + public function update($new_session = FALSE) { |
|
688 | + $this->_session_data = isset($this->_session_data) |
|
689 | + && is_array($this->_session_data) |
|
690 | + && isset($this->_session_data['id']) |
|
691 | 691 | ? $this->_session_data |
692 | 692 | : array(); |
693 | - if ( empty( $this->_session_data )) { |
|
693 | + if (empty($this->_session_data)) { |
|
694 | 694 | $this->_set_defaults(); |
695 | 695 | } |
696 | 696 | $session_data = array(); |
697 | - foreach ( $this->_session_data as $key => $value ) { |
|
697 | + foreach ($this->_session_data as $key => $value) { |
|
698 | 698 | |
699 | - switch( $key ) { |
|
699 | + switch ($key) { |
|
700 | 700 | |
701 | 701 | case 'id' : |
702 | 702 | // session ID |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | break; |
715 | 715 | |
716 | 716 | case 'init_access' : |
717 | - $session_data['init_access'] = absint( $value ); |
|
717 | + $session_data['init_access'] = absint($value); |
|
718 | 718 | break; |
719 | 719 | |
720 | 720 | case 'last_access' : |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | |
725 | 725 | case 'expiration' : |
726 | 726 | // when the session expires |
727 | - $session_data['expiration'] = ! empty( $this->_expiration ) |
|
727 | + $session_data['expiration'] = ! empty($this->_expiration) |
|
728 | 728 | ? $this->_expiration |
729 | 729 | : $session_data['init_access'] + $this->_lifespan; |
730 | 730 | break; |
@@ -736,11 +736,11 @@ discard block |
||
736 | 736 | |
737 | 737 | case 'pages_visited' : |
738 | 738 | $page_visit = $this->_get_page_visit(); |
739 | - if ( $page_visit ) { |
|
739 | + if ($page_visit) { |
|
740 | 740 | // set pages visited where the first will be the http referrer |
741 | - $this->_session_data[ 'pages_visited' ][ $this->_time ] = $page_visit; |
|
741 | + $this->_session_data['pages_visited'][$this->_time] = $page_visit; |
|
742 | 742 | // we'll only save the last 10 page visits. |
743 | - $session_data[ 'pages_visited' ] = array_slice( $this->_session_data['pages_visited'], -10 ); |
|
743 | + $session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10); |
|
744 | 744 | } |
745 | 745 | break; |
746 | 746 | |
@@ -754,9 +754,9 @@ discard block |
||
754 | 754 | |
755 | 755 | $this->_session_data = $session_data; |
756 | 756 | // creating a new session does not require saving to the db just yet |
757 | - if ( ! $new_session ) { |
|
757 | + if ( ! $new_session) { |
|
758 | 758 | // ready? let's save |
759 | - if ( $this->_save_session_to_db() ) { |
|
759 | + if ($this->_save_session_to_db()) { |
|
760 | 760 | return TRUE; |
761 | 761 | } else { |
762 | 762 | return FALSE; |
@@ -776,9 +776,9 @@ discard block |
||
776 | 776 | * @throws \EE_Error |
777 | 777 | */ |
778 | 778 | private function _create_espresso_session( ) { |
779 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' ); |
|
779 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, ''); |
|
780 | 780 | // use the update function for now with $new_session arg set to TRUE |
781 | - return $this->update( TRUE ) ? TRUE : FALSE; |
|
781 | + return $this->update(TRUE) ? TRUE : FALSE; |
|
782 | 782 | } |
783 | 783 | |
784 | 784 | |
@@ -798,7 +798,7 @@ discard block |
||
798 | 798 | EE_Registry::instance()->REQ->front_ajax |
799 | 799 | || ( |
800 | 800 | // OR an admin request that is NOT AJAX |
801 | - ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) |
|
801 | + ! (defined('DOING_AJAX') && DOING_AJAX) |
|
802 | 802 | && is_admin() |
803 | 803 | ) |
804 | 804 | || ( |
@@ -811,8 +811,8 @@ discard block |
||
811 | 811 | return false; |
812 | 812 | } |
813 | 813 | $transaction = $this->transaction(); |
814 | - if ( $transaction instanceof EE_Transaction ) { |
|
815 | - if ( ! $transaction->ID() ) { |
|
814 | + if ($transaction instanceof EE_Transaction) { |
|
815 | + if ( ! $transaction->ID()) { |
|
816 | 816 | $transaction->save(); |
817 | 817 | } |
818 | 818 | $this->_session_data['transaction'] = $transaction->ID(); |
@@ -821,19 +821,19 @@ discard block |
||
821 | 821 | $session_data = serialize($this->_session_data); |
822 | 822 | // do we need to also encode it to avoid corrupted data when saved to the db? |
823 | 823 | $session_data = $this->_use_encryption |
824 | - ? $this->encryption->base64_string_encode( $session_data ) |
|
824 | + ? $this->encryption->base64_string_encode($session_data) |
|
825 | 825 | : $session_data; |
826 | 826 | // maybe save hash check |
827 | - if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) { |
|
827 | + if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
|
828 | 828 | $this->cache_storage->add( |
829 | - EE_Session::hash_check_prefix . $this->_sid, |
|
829 | + EE_Session::hash_check_prefix.$this->_sid, |
|
830 | 830 | md5($session_data), |
831 | 831 | $this->_lifespan |
832 | 832 | ); |
833 | 833 | } |
834 | 834 | // we're using the Transient API for storing session data, |
835 | 835 | return $this->cache_storage->add( |
836 | - EE_Session::session_id_prefix . $this->_sid, |
|
836 | + EE_Session::session_id_prefix.$this->_sid, |
|
837 | 837 | $session_data, |
838 | 838 | $this->_lifespan |
839 | 839 | ); |
@@ -862,10 +862,10 @@ discard block |
||
862 | 862 | 'HTTP_FORWARDED', |
863 | 863 | 'REMOTE_ADDR' |
864 | 864 | ); |
865 | - foreach ( $server_keys as $key ){ |
|
866 | - if ( isset( $_SERVER[ $key ] )) { |
|
867 | - foreach ( array_map( 'trim', explode( ',', $_SERVER[ $key ] )) as $ip ) { |
|
868 | - if ( $ip === '127.0.0.1' || filter_var( $ip, FILTER_VALIDATE_IP ) !== FALSE ) { |
|
865 | + foreach ($server_keys as $key) { |
|
866 | + if (isset($_SERVER[$key])) { |
|
867 | + foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) { |
|
868 | + if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== FALSE) { |
|
869 | 869 | $visitor_ip = $ip; |
870 | 870 | } |
871 | 871 | } |
@@ -884,32 +884,32 @@ discard block |
||
884 | 884 | * @return string |
885 | 885 | */ |
886 | 886 | public function _get_page_visit() { |
887 | - $page_visit = home_url('/') . 'wp-admin/admin-ajax.php'; |
|
887 | + $page_visit = home_url('/').'wp-admin/admin-ajax.php'; |
|
888 | 888 | // check for request url |
889 | - if ( isset( $_SERVER['REQUEST_URI'] )) { |
|
889 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
890 | 890 | $http_host = ''; |
891 | 891 | $page_id = '?'; |
892 | 892 | $e_reg = ''; |
893 | - $request_uri = esc_url( $_SERVER['REQUEST_URI'] ); |
|
894 | - $ru_bits = explode( '?', $request_uri ); |
|
893 | + $request_uri = esc_url($_SERVER['REQUEST_URI']); |
|
894 | + $ru_bits = explode('?', $request_uri); |
|
895 | 895 | $request_uri = $ru_bits[0]; |
896 | 896 | // check for and grab host as well |
897 | - if ( isset( $_SERVER['HTTP_HOST'] )) { |
|
898 | - $http_host = esc_url( $_SERVER['HTTP_HOST'] ); |
|
897 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
898 | + $http_host = esc_url($_SERVER['HTTP_HOST']); |
|
899 | 899 | } |
900 | 900 | // check for page_id in SERVER REQUEST |
901 | - if ( isset( $_REQUEST['page_id'] )) { |
|
901 | + if (isset($_REQUEST['page_id'])) { |
|
902 | 902 | // rebuild $e_reg without any of the extra parameters |
903 | - $page_id = '?page_id=' . esc_attr( $_REQUEST['page_id'] ) . '&'; |
|
903 | + $page_id = '?page_id='.esc_attr($_REQUEST['page_id']).'&'; |
|
904 | 904 | } |
905 | 905 | // check for $e_reg in SERVER REQUEST |
906 | - if ( isset( $_REQUEST['ee'] )) { |
|
906 | + if (isset($_REQUEST['ee'])) { |
|
907 | 907 | // rebuild $e_reg without any of the extra parameters |
908 | - $e_reg = 'ee=' . esc_attr( $_REQUEST['ee'] ); |
|
908 | + $e_reg = 'ee='.esc_attr($_REQUEST['ee']); |
|
909 | 909 | } |
910 | - $page_visit = rtrim( $http_host . $request_uri . $page_id . $e_reg, '?' ); |
|
910 | + $page_visit = rtrim($http_host.$request_uri.$page_id.$e_reg, '?'); |
|
911 | 911 | } |
912 | - return $page_visit !== home_url( '/wp-admin/admin-ajax.php' ) ? $page_visit : ''; |
|
912 | + return $page_visit !== home_url('/wp-admin/admin-ajax.php') ? $page_visit : ''; |
|
913 | 913 | |
914 | 914 | } |
915 | 915 | |
@@ -939,14 +939,14 @@ discard block |
||
939 | 939 | * @return void |
940 | 940 | * @throws \EE_Error |
941 | 941 | */ |
942 | - public function clear_session( $class = '', $function = '' ) { |
|
942 | + public function clear_session($class = '', $function = '') { |
|
943 | 943 | //echo '<h3 style="color:#999;line-height:.9em;"><span style="color:#2EA2CC">' . __CLASS__ . '</span>::<span style="color:#E76700">' . __FUNCTION__ . '( ' . $class . '::' . $function . '() )</span><br/><span style="font-size:9px;font-weight:normal;">' . __FILE__ . '</span> <b style="font-size:10px;"> ' . __LINE__ . ' </b></h3>'; |
944 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' . $function . '()' ); |
|
944 | + do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : '.$class.'::'.$function.'()'); |
|
945 | 945 | $this->reset_cart(); |
946 | 946 | $this->reset_checkout(); |
947 | 947 | $this->reset_transaction(); |
948 | 948 | // wipe out everything that isn't a default session datum |
949 | - $this->reset_data( array_keys( $this->_session_data )); |
|
949 | + $this->reset_data(array_keys($this->_session_data)); |
|
950 | 950 | // reset initial site access time and the session expiration |
951 | 951 | $this->_set_init_access_and_expiration(); |
952 | 952 | $this->_save_session_to_db(); |
@@ -961,42 +961,42 @@ discard block |
||
961 | 961 | * @param bool $show_all_notices |
962 | 962 | * @return TRUE on success, FALSE on fail |
963 | 963 | */ |
964 | - public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) { |
|
964 | + public function reset_data($data_to_reset = array(), $show_all_notices = FALSE) { |
|
965 | 965 | // if $data_to_reset is not in an array, then put it in one |
966 | - if ( ! is_array( $data_to_reset ) ) { |
|
967 | - $data_to_reset = array ( $data_to_reset ); |
|
966 | + if ( ! is_array($data_to_reset)) { |
|
967 | + $data_to_reset = array($data_to_reset); |
|
968 | 968 | } |
969 | 969 | // nothing ??? go home! |
970 | - if ( empty( $data_to_reset )) { |
|
971 | - EE_Error::add_error( __( 'No session data could be reset, because no session var name was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
970 | + if (empty($data_to_reset)) { |
|
971 | + EE_Error::add_error(__('No session data could be reset, because no session var name was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
972 | 972 | return FALSE; |
973 | 973 | } |
974 | 974 | $return_value = TRUE; |
975 | 975 | // since $data_to_reset is an array, cycle through the values |
976 | - foreach ( $data_to_reset as $reset ) { |
|
976 | + foreach ($data_to_reset as $reset) { |
|
977 | 977 | |
978 | 978 | // first check to make sure it is a valid session var |
979 | - if ( isset( $this->_session_data[ $reset ] )) { |
|
979 | + if (isset($this->_session_data[$reset])) { |
|
980 | 980 | // then check to make sure it is not a default var |
981 | - if ( ! array_key_exists( $reset, $this->_default_session_vars )) { |
|
981 | + if ( ! array_key_exists($reset, $this->_default_session_vars)) { |
|
982 | 982 | // remove session var |
983 | - unset( $this->_session_data[ $reset ] ); |
|
984 | - if ( $show_all_notices ) { |
|
985 | - EE_Error::add_success( sprintf( __( 'The session variable %s was removed.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
983 | + unset($this->_session_data[$reset]); |
|
984 | + if ($show_all_notices) { |
|
985 | + EE_Error::add_success(sprintf(__('The session variable %s was removed.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
986 | 986 | } |
987 | - $return_value = !isset($return_value) ? TRUE : $return_value; |
|
987 | + $return_value = ! isset($return_value) ? TRUE : $return_value; |
|
988 | 988 | |
989 | 989 | } else { |
990 | 990 | // yeeeeeeeeerrrrrrrrrrr OUT !!!! |
991 | - if ( $show_all_notices ) { |
|
992 | - EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
991 | + if ($show_all_notices) { |
|
992 | + EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
993 | 993 | } |
994 | 994 | $return_value = FALSE; |
995 | 995 | } |
996 | 996 | |
997 | - } else if ( $show_all_notices ) { |
|
997 | + } else if ($show_all_notices) { |
|
998 | 998 | // oops! that session var does not exist! |
999 | - EE_Error::add_error( sprintf( __( 'The session item provided, %s, is invalid or does not exist.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
999 | + EE_Error::add_error(sprintf(__('The session item provided, %s, is invalid or does not exist.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
1000 | 1000 | $return_value = FALSE; |
1001 | 1001 | } |
1002 | 1002 | |
@@ -1015,8 +1015,8 @@ discard block |
||
1015 | 1015 | * @throws \EE_Error |
1016 | 1016 | */ |
1017 | 1017 | public function wp_loaded() { |
1018 | - if ( isset( EE_Registry::instance()->REQ ) && EE_Registry::instance()->REQ->is_set( 'clear_session' )) { |
|
1019 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
1018 | + if (isset(EE_Registry::instance()->REQ) && EE_Registry::instance()->REQ->is_set('clear_session')) { |
|
1019 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
1020 | 1020 | } |
1021 | 1021 | } |
1022 | 1022 | |
@@ -1052,7 +1052,7 @@ discard block |
||
1052 | 1052 | // or use that for the new transient cleanup query limit |
1053 | 1053 | add_filter( |
1054 | 1054 | 'FHEE__TransientCacheStorage__clearExpiredTransients__limit', |
1055 | - function () use ($expired_session_transient_delete_query_limit) { |
|
1055 | + function() use ($expired_session_transient_delete_query_limit) { |
|
1056 | 1056 | return $expired_session_transient_delete_query_limit; |
1057 | 1057 | } |
1058 | 1058 | ); |
@@ -1066,34 +1066,34 @@ discard block |
||
1066 | 1066 | * @param $data1 |
1067 | 1067 | * @return string |
1068 | 1068 | */ |
1069 | - private function find_serialize_error( $data1 ) { |
|
1069 | + private function find_serialize_error($data1) { |
|
1070 | 1070 | $error = '<pre>'; |
1071 | 1071 | $data2 = preg_replace_callback( |
1072 | 1072 | '!s:(\d+):"(.*?)";!', |
1073 | - function ( $match ) { |
|
1074 | - return ( $match[1] === strlen( $match[2] ) ) |
|
1073 | + function($match) { |
|
1074 | + return ($match[1] === strlen($match[2])) |
|
1075 | 1075 | ? $match[0] |
1076 | 1076 | : 's:' |
1077 | - . strlen( $match[2] ) |
|
1077 | + . strlen($match[2]) |
|
1078 | 1078 | . ':"' |
1079 | 1079 | . $match[2] |
1080 | 1080 | . '";'; |
1081 | 1081 | }, |
1082 | 1082 | $data1 |
1083 | 1083 | ); |
1084 | - $max = ( strlen( $data1 ) > strlen( $data2 ) ) ? strlen( $data1 ) : strlen( $data2 ); |
|
1085 | - $error .= $data1 . PHP_EOL; |
|
1086 | - $error .= $data2 . PHP_EOL; |
|
1087 | - for ( $i = 0; $i < $max; $i++ ) { |
|
1088 | - if ( @$data1[ $i ] !== @$data2[ $i ] ) { |
|
1089 | - $error .= 'Difference ' . @$data1[ $i ] . ' != ' . @$data2[ $i ] . PHP_EOL; |
|
1090 | - $error .= "\t-> ORD number " . ord( @$data1[ $i ] ) . ' != ' . ord( @$data2[ $i ] ) . PHP_EOL; |
|
1091 | - $error .= "\t-> Line Number = $i" . PHP_EOL; |
|
1092 | - $start = ( $i - 20 ); |
|
1093 | - $start = ( $start < 0 ) ? 0 : $start; |
|
1084 | + $max = (strlen($data1) > strlen($data2)) ? strlen($data1) : strlen($data2); |
|
1085 | + $error .= $data1.PHP_EOL; |
|
1086 | + $error .= $data2.PHP_EOL; |
|
1087 | + for ($i = 0; $i < $max; $i++) { |
|
1088 | + if (@$data1[$i] !== @$data2[$i]) { |
|
1089 | + $error .= 'Difference '.@$data1[$i].' != '.@$data2[$i].PHP_EOL; |
|
1090 | + $error .= "\t-> ORD number ".ord(@$data1[$i]).' != '.ord(@$data2[$i]).PHP_EOL; |
|
1091 | + $error .= "\t-> Line Number = $i".PHP_EOL; |
|
1092 | + $start = ($i - 20); |
|
1093 | + $start = ($start < 0) ? 0 : $start; |
|
1094 | 1094 | $length = 40; |
1095 | 1095 | $point = $max - $i; |
1096 | - if ( $point < 20 ) { |
|
1096 | + if ($point < 20) { |
|
1097 | 1097 | $rlength = 1; |
1098 | 1098 | $rpoint = -$point; |
1099 | 1099 | } else { |
@@ -1102,16 +1102,16 @@ discard block |
||
1102 | 1102 | } |
1103 | 1103 | $error .= "\t-> Section Data1 = "; |
1104 | 1104 | $error .= substr_replace( |
1105 | - substr( $data1, $start, $length ), |
|
1106 | - "<b style=\"color:green\">{$data1[ $i ]}</b>", |
|
1105 | + substr($data1, $start, $length), |
|
1106 | + "<b style=\"color:green\">{$data1[$i]}</b>", |
|
1107 | 1107 | $rpoint, |
1108 | 1108 | $rlength |
1109 | 1109 | ); |
1110 | 1110 | $error .= PHP_EOL; |
1111 | 1111 | $error .= "\t-> Section Data2 = "; |
1112 | 1112 | $error .= substr_replace( |
1113 | - substr( $data2, $start, $length ), |
|
1114 | - "<b style=\"color:red\">{$data2[ $i ]}</b>", |
|
1113 | + substr($data2, $start, $length), |
|
1114 | + "<b style=\"color:red\">{$data2[$i]}</b>", |
|
1115 | 1115 | $rpoint, |
1116 | 1116 | $rlength |
1117 | 1117 | ); |
@@ -22,19 +22,19 @@ discard block |
||
22 | 22 | */ |
23 | 23 | private static $_instance; |
24 | 24 | |
25 | - /** |
|
26 | - * @var CacheStorageInterface $cache_storage |
|
27 | - */ |
|
28 | - protected $cache_storage; |
|
29 | - |
|
30 | - /** |
|
31 | - * EE_Encryption object |
|
32 | - * |
|
33 | - * @var EE_Encryption |
|
34 | - */ |
|
35 | - protected $encryption; |
|
36 | - |
|
37 | - /** |
|
25 | + /** |
|
26 | + * @var CacheStorageInterface $cache_storage |
|
27 | + */ |
|
28 | + protected $cache_storage; |
|
29 | + |
|
30 | + /** |
|
31 | + * EE_Encryption object |
|
32 | + * |
|
33 | + * @var EE_Encryption |
|
34 | + */ |
|
35 | + protected $encryption; |
|
36 | + |
|
37 | + /** |
|
38 | 38 | * the session id |
39 | 39 | * @var string |
40 | 40 | */ |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | */ |
66 | 66 | private $_expiration; |
67 | 67 | |
68 | - /** |
|
69 | - * whether or not session has expired at some point |
|
70 | - * |
|
71 | - * @var boolean |
|
72 | - */ |
|
73 | - private $_expired = false; |
|
68 | + /** |
|
69 | + * whether or not session has expired at some point |
|
70 | + * |
|
71 | + * @var boolean |
|
72 | + */ |
|
73 | + private $_expired = false; |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * current time as Unix timestamp in GMT |
@@ -107,30 +107,30 @@ discard block |
||
107 | 107 | * @var array |
108 | 108 | */ |
109 | 109 | private $_default_session_vars = array ( |
110 | - 'id' => null, |
|
111 | - 'user_id' => null, |
|
112 | - 'ip_address' => null, |
|
113 | - 'user_agent' => null, |
|
114 | - 'init_access' => null, |
|
115 | - 'last_access' => null, |
|
116 | - 'expiration' => null, |
|
117 | - 'pages_visited' => array(), |
|
110 | + 'id' => null, |
|
111 | + 'user_id' => null, |
|
112 | + 'ip_address' => null, |
|
113 | + 'user_agent' => null, |
|
114 | + 'init_access' => null, |
|
115 | + 'last_access' => null, |
|
116 | + 'expiration' => null, |
|
117 | + 'pages_visited' => array(), |
|
118 | 118 | ); |
119 | 119 | |
120 | 120 | |
121 | 121 | |
122 | 122 | /** |
123 | 123 | * @singleton method used to instantiate class object |
124 | - * @param CacheStorageInterface $cache_storage |
|
125 | - * @param \EE_Encryption $encryption |
|
124 | + * @param CacheStorageInterface $cache_storage |
|
125 | + * @param \EE_Encryption $encryption |
|
126 | 126 | * @return EE_Session |
127 | 127 | * @throws InvalidSessionDataException |
128 | 128 | * @throws \EE_Error |
129 | 129 | */ |
130 | 130 | public static function instance( |
131 | - CacheStorageInterface $cache_storage = null, |
|
132 | - EE_Encryption $encryption = null |
|
133 | - ) { |
|
131 | + CacheStorageInterface $cache_storage = null, |
|
132 | + EE_Encryption $encryption = null |
|
133 | + ) { |
|
134 | 134 | // check if class object is instantiated |
135 | 135 | // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: |
136 | 136 | // add_filter( 'FHEE_load_EE_Session', '__return_false' ); |
@@ -143,10 +143,10 @@ discard block |
||
143 | 143 | |
144 | 144 | |
145 | 145 | /** |
146 | - * protected constructor to prevent direct creation |
|
147 | - * |
|
148 | - * @param CacheStorageInterface $cache_storage |
|
149 | - * @param \EE_Encryption $encryption |
|
146 | + * protected constructor to prevent direct creation |
|
147 | + * |
|
148 | + * @param CacheStorageInterface $cache_storage |
|
149 | + * @param \EE_Encryption $encryption |
|
150 | 150 | * @throws \EE_Error |
151 | 151 | * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
152 | 152 | */ |
@@ -181,59 +181,59 @@ discard block |
||
181 | 181 | $this->{$var_name} = $session_setting; |
182 | 182 | } |
183 | 183 | } |
184 | - $this->cache_storage = $cache_storage; |
|
185 | - // are we using encryption? |
|
186 | - $this->_use_encryption = $encryption instanceof EE_Encryption && EE_Registry::instance()->CFG->admin->encode_session_data(); |
|
187 | - // \EEH_Debug_Tools::printr($this->_use_encryption, '$this->_use_encryption', __FILE__, __LINE__); |
|
188 | - // encrypt data via: $this->encryption->encrypt(); |
|
189 | - $this->encryption = $encryption; |
|
184 | + $this->cache_storage = $cache_storage; |
|
185 | + // are we using encryption? |
|
186 | + $this->_use_encryption = $encryption instanceof EE_Encryption && EE_Registry::instance()->CFG->admin->encode_session_data(); |
|
187 | + // \EEH_Debug_Tools::printr($this->_use_encryption, '$this->_use_encryption', __FILE__, __LINE__); |
|
188 | + // encrypt data via: $this->encryption->encrypt(); |
|
189 | + $this->encryption = $encryption; |
|
190 | 190 | // filter hook allows outside functions/classes/plugins to change default empty cart |
191 | 191 | $extra_default_session_vars = apply_filters( 'FHEE__EE_Session__construct__extra_default_session_vars', array() ); |
192 | 192 | array_merge( $this->_default_session_vars, $extra_default_session_vars ); |
193 | 193 | // apply default session vars |
194 | 194 | $this->_set_defaults(); |
195 | - add_action('AHEE__EE_System__initialize', array($this, 'open_session')); |
|
196 | - // check request for 'clear_session' param |
|
195 | + add_action('AHEE__EE_System__initialize', array($this, 'open_session')); |
|
196 | + // check request for 'clear_session' param |
|
197 | 197 | add_action( 'AHEE__EE_Request_Handler__construct__complete', array( $this, 'wp_loaded' )); |
198 | 198 | // once everything is all said and done, |
199 | 199 | add_action( 'shutdown', array( $this, 'update' ), 100 ); |
200 | - $this->configure_garbage_collection_filters(); |
|
200 | + $this->configure_garbage_collection_filters(); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | |
204 | 204 | |
205 | - /** |
|
206 | - * @return void |
|
207 | - * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
|
208 | - * @throws \EE_Error |
|
209 | - */ |
|
205 | + /** |
|
206 | + * @return void |
|
207 | + * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
|
208 | + * @throws \EE_Error |
|
209 | + */ |
|
210 | 210 | public function open_session() { |
211 | - // check for existing session and retrieve it from db |
|
212 | - if ( ! $this->_espresso_session()) { |
|
213 | - // or just start a new one |
|
214 | - $this->_create_espresso_session(); |
|
215 | - } |
|
216 | - } |
|
211 | + // check for existing session and retrieve it from db |
|
212 | + if ( ! $this->_espresso_session()) { |
|
213 | + // or just start a new one |
|
214 | + $this->_create_espresso_session(); |
|
215 | + } |
|
216 | + } |
|
217 | 217 | |
218 | 218 | |
219 | 219 | |
220 | - /** |
|
221 | - * @return bool |
|
222 | - */ |
|
223 | - public function expired() |
|
224 | - { |
|
225 | - return $this->_expired; |
|
226 | - } |
|
220 | + /** |
|
221 | + * @return bool |
|
222 | + */ |
|
223 | + public function expired() |
|
224 | + { |
|
225 | + return $this->_expired; |
|
226 | + } |
|
227 | 227 | |
228 | 228 | |
229 | 229 | |
230 | - /** |
|
231 | - * @return void |
|
232 | - */ |
|
233 | - public function reset_expired() |
|
234 | - { |
|
235 | - $this->_expired = false; |
|
236 | - } |
|
230 | + /** |
|
231 | + * @return void |
|
232 | + */ |
|
233 | + public function reset_expired() |
|
234 | + { |
|
235 | + $this->_expired = false; |
|
236 | + } |
|
237 | 237 | |
238 | 238 | |
239 | 239 | /** |
@@ -245,24 +245,24 @@ discard block |
||
245 | 245 | |
246 | 246 | |
247 | 247 | |
248 | - /** |
|
249 | - * @return int |
|
250 | - */ |
|
251 | - public function extension() |
|
252 | - { |
|
253 | - return apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', (10 * MINUTE_IN_SECONDS)); |
|
254 | - } |
|
248 | + /** |
|
249 | + * @return int |
|
250 | + */ |
|
251 | + public function extension() |
|
252 | + { |
|
253 | + return apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', (10 * MINUTE_IN_SECONDS)); |
|
254 | + } |
|
255 | 255 | |
256 | 256 | |
257 | 257 | |
258 | - /** |
|
259 | - * @param int $time number of seconds to add to session expiration |
|
260 | - */ |
|
261 | - public function extend_expiration($time = 0) |
|
262 | - { |
|
263 | - $time = $time ? $time : $this->extension(); |
|
264 | - $this->_expiration += absint($time); |
|
265 | - } |
|
258 | + /** |
|
259 | + * @param int $time number of seconds to add to session expiration |
|
260 | + */ |
|
261 | + public function extend_expiration($time = 0) |
|
262 | + { |
|
263 | + $time = $time ? $time : $this->extension(); |
|
264 | + $this->_expiration += absint($time); |
|
265 | + } |
|
266 | 266 | |
267 | 267 | |
268 | 268 | |
@@ -306,15 +306,15 @@ discard block |
||
306 | 306 | |
307 | 307 | |
308 | 308 | |
309 | - /** |
|
310 | - * @param \EE_Cart $cart |
|
311 | - * @return bool |
|
312 | - */ |
|
313 | - public function set_cart(EE_Cart $cart) |
|
314 | - { |
|
315 | - $this->_session_data['cart'] = $cart; |
|
316 | - return true; |
|
317 | - } |
|
309 | + /** |
|
310 | + * @param \EE_Cart $cart |
|
311 | + * @return bool |
|
312 | + */ |
|
313 | + public function set_cart(EE_Cart $cart) |
|
314 | + { |
|
315 | + $this->_session_data['cart'] = $cart; |
|
316 | + return true; |
|
317 | + } |
|
318 | 318 | |
319 | 319 | |
320 | 320 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * reset_cart |
323 | 323 | */ |
324 | 324 | public function reset_cart() { |
325 | - do_action('AHEE__EE_Session__reset_cart__before_reset', $this); |
|
325 | + do_action('AHEE__EE_Session__reset_cart__before_reset', $this); |
|
326 | 326 | $this->_session_data['cart'] = NULL; |
327 | 327 | } |
328 | 328 | |
@@ -332,9 +332,9 @@ discard block |
||
332 | 332 | * @return \EE_Cart |
333 | 333 | */ |
334 | 334 | public function cart() { |
335 | - return isset($this->_session_data['cart']) && $this->_session_data['cart'] instanceof EE_Cart |
|
336 | - ? $this->_session_data['cart'] |
|
337 | - : null; |
|
335 | + return isset($this->_session_data['cart']) && $this->_session_data['cart'] instanceof EE_Cart |
|
336 | + ? $this->_session_data['cart'] |
|
337 | + : null; |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | * reset_checkout |
355 | 355 | */ |
356 | 356 | public function reset_checkout() { |
357 | - do_action('AHEE__EE_Session__reset_checkout__before_reset', $this); |
|
357 | + do_action('AHEE__EE_Session__reset_checkout__before_reset', $this); |
|
358 | 358 | $this->_session_data['checkout'] = NULL; |
359 | 359 | } |
360 | 360 | |
@@ -364,9 +364,9 @@ discard block |
||
364 | 364 | * @return \EE_Checkout |
365 | 365 | */ |
366 | 366 | public function checkout() { |
367 | - return isset($this->_session_data['checkout']) && $this->_session_data['checkout'] instanceof EE_Checkout |
|
368 | - ? $this->_session_data['checkout'] |
|
369 | - : null; |
|
367 | + return isset($this->_session_data['checkout']) && $this->_session_data['checkout'] instanceof EE_Checkout |
|
368 | + ? $this->_session_data['checkout'] |
|
369 | + : null; |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | * reset_transaction |
390 | 390 | */ |
391 | 391 | public function reset_transaction() { |
392 | - do_action('AHEE__EE_Session__reset_transaction__before_reset', $this); |
|
392 | + do_action('AHEE__EE_Session__reset_transaction__before_reset', $this); |
|
393 | 393 | $this->_session_data['transaction'] = NULL; |
394 | 394 | } |
395 | 395 | |
@@ -399,10 +399,10 @@ discard block |
||
399 | 399 | * @return \EE_Transaction |
400 | 400 | */ |
401 | 401 | public function transaction() { |
402 | - return isset($this->_session_data['transaction']) |
|
403 | - && $this->_session_data['transaction'] instanceof EE_Transaction |
|
404 | - ? $this->_session_data['transaction'] |
|
405 | - : null; |
|
402 | + return isset($this->_session_data['transaction']) |
|
403 | + && $this->_session_data['transaction'] instanceof EE_Transaction |
|
404 | + ? $this->_session_data['transaction'] |
|
405 | + : null; |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | |
@@ -479,16 +479,16 @@ discard block |
||
479 | 479 | // set the "user agent" |
480 | 480 | $this->_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? esc_attr( $_SERVER['HTTP_USER_AGENT'] ) : FALSE; |
481 | 481 | // now let's retrieve what's in the db |
482 | - $session_data = $this->_retrieve_session_data(); |
|
483 | - if (! empty($session_data)) { |
|
484 | - // get the current time in UTC |
|
482 | + $session_data = $this->_retrieve_session_data(); |
|
483 | + if (! empty($session_data)) { |
|
484 | + // get the current time in UTC |
|
485 | 485 | $this->_time = isset( $this->_time ) ? $this->_time : time(); |
486 | 486 | // and reset the session expiration |
487 | 487 | $this->_expiration = isset( $session_data['expiration'] ) |
488 | 488 | ? $session_data['expiration'] |
489 | 489 | : $this->_time + $this->_lifespan; |
490 | 490 | } else { |
491 | - // set initial site access time and the session expiration |
|
491 | + // set initial site access time and the session expiration |
|
492 | 492 | $this->_set_init_access_and_expiration(); |
493 | 493 | // set referer |
494 | 494 | $this->_session_data[ 'pages_visited' ][ $this->_session_data['init_access'] ] = isset( $_SERVER['HTTP_REFERER'] ) |
@@ -497,14 +497,14 @@ discard block |
||
497 | 497 | // no previous session = go back and create one (on top of the data above) |
498 | 498 | return FALSE; |
499 | 499 | } |
500 | - // now the user agent |
|
500 | + // now the user agent |
|
501 | 501 | if ( $session_data['user_agent'] !== $this->_user_agent ) { |
502 | 502 | return FALSE; |
503 | 503 | } |
504 | 504 | // wait a minute... how old are you? |
505 | 505 | if ( $this->_time > $this->_expiration ) { |
506 | 506 | // yer too old fer me! |
507 | - $this->_expired = true; |
|
507 | + $this->_expired = true; |
|
508 | 508 | // wipe out everything that isn't a default session datum |
509 | 509 | $this->clear_session( __CLASS__, __FUNCTION__ ); |
510 | 510 | } |
@@ -516,101 +516,101 @@ discard block |
||
516 | 516 | |
517 | 517 | |
518 | 518 | |
519 | - /** |
|
520 | - * _get_session_data |
|
521 | - * Retrieves the session data, and attempts to correct any encoding issues that can occur due to improperly setup databases |
|
522 | - * |
|
523 | - * @return array |
|
524 | - * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
|
525 | - */ |
|
526 | - protected function _retrieve_session_data() |
|
527 | - { |
|
528 | - $ssn_key = EE_Session::session_id_prefix . $this->_sid; |
|
529 | - try { |
|
530 | - // we're using WP's Transient API to store session data using the PHP session ID as the option name |
|
531 | - $session_data = $this->cache_storage->get($ssn_key, false); |
|
532 | - if (empty($session_data)) { |
|
533 | - return array(); |
|
534 | - } |
|
535 | - if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
|
536 | - $hash_check = $this->cache_storage->get( |
|
537 | - EE_Session::hash_check_prefix . $this->_sid, |
|
538 | - false |
|
539 | - ); |
|
540 | - if ($hash_check && $hash_check !== md5($session_data)) { |
|
541 | - EE_Error::add_error( |
|
542 | - sprintf( |
|
543 | - __( |
|
544 | - 'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', |
|
545 | - 'event_espresso' |
|
546 | - ), |
|
547 | - EE_Session::session_id_prefix . $this->_sid |
|
548 | - ), |
|
549 | - __FILE__, __FUNCTION__, __LINE__ |
|
550 | - ); |
|
551 | - } |
|
552 | - } |
|
553 | - } catch (Exception $e) { |
|
554 | - // let's just eat that error for now and attempt to correct any corrupted data |
|
555 | - global $wpdb; |
|
556 | - $row = $wpdb->get_row( |
|
557 | - $wpdb->prepare( |
|
558 | - "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1", |
|
559 | - '_transient_' . $ssn_key |
|
560 | - ) |
|
561 | - ); |
|
562 | - $session_data = is_object($row) ? $row->option_value : null; |
|
563 | - if ($session_data) { |
|
564 | - $session_data = preg_replace_callback( |
|
565 | - '!s:(d+):"(.*?)";!', |
|
566 | - function ($match) { |
|
567 | - return $match[1] === strlen($match[2]) |
|
568 | - ? $match[0] |
|
569 | - : 's:' . strlen($match[2]) . ':"' . $match[2] . '";'; |
|
570 | - }, |
|
571 | - $session_data |
|
572 | - ); |
|
573 | - } |
|
574 | - $session_data = maybe_unserialize($session_data); |
|
575 | - } |
|
576 | - // in case the data is encoded... try to decode it |
|
577 | - $session_data = $this->encryption instanceof EE_Encryption |
|
578 | - ? $this->encryption->base64_string_decode($session_data) |
|
579 | - : $session_data; |
|
580 | - |
|
581 | - if ( ! is_array($session_data)) { |
|
582 | - try { |
|
583 | - $session_data = maybe_unserialize($session_data); |
|
584 | - } catch (Exception $e) { |
|
585 | - $msg = esc_html__( |
|
586 | - 'An error occurred while attempting to unserialize the session data.', |
|
587 | - 'event_espresso' |
|
588 | - ); |
|
589 | - $msg .= WP_DEBUG |
|
590 | - ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data) |
|
591 | - : ''; |
|
592 | - throw new InvalidSessionDataException($msg, 0, $e); |
|
593 | - } |
|
594 | - } |
|
595 | - // just a check to make sure the session array is indeed an array |
|
596 | - if ( ! is_array($session_data)) { |
|
597 | - // no?!?! then something is wrong |
|
598 | - $msg = esc_html__( |
|
599 | - 'The session data is missing, invalid, or corrupted.', |
|
600 | - 'event_espresso' |
|
601 | - ); |
|
602 | - $msg .= WP_DEBUG |
|
603 | - ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data) |
|
604 | - : ''; |
|
605 | - throw new InvalidSessionDataException($msg); |
|
606 | - } |
|
607 | - if ( isset($session_data['transaction'] ) && absint($session_data['transaction'] ) !== 0 ) { |
|
608 | - $session_data['transaction'] = EEM_Transaction::instance()->get_one_by_ID( |
|
609 | - $session_data['transaction'] |
|
610 | - ); |
|
611 | - } |
|
612 | - return $session_data; |
|
613 | - } |
|
519 | + /** |
|
520 | + * _get_session_data |
|
521 | + * Retrieves the session data, and attempts to correct any encoding issues that can occur due to improperly setup databases |
|
522 | + * |
|
523 | + * @return array |
|
524 | + * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
|
525 | + */ |
|
526 | + protected function _retrieve_session_data() |
|
527 | + { |
|
528 | + $ssn_key = EE_Session::session_id_prefix . $this->_sid; |
|
529 | + try { |
|
530 | + // we're using WP's Transient API to store session data using the PHP session ID as the option name |
|
531 | + $session_data = $this->cache_storage->get($ssn_key, false); |
|
532 | + if (empty($session_data)) { |
|
533 | + return array(); |
|
534 | + } |
|
535 | + if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
|
536 | + $hash_check = $this->cache_storage->get( |
|
537 | + EE_Session::hash_check_prefix . $this->_sid, |
|
538 | + false |
|
539 | + ); |
|
540 | + if ($hash_check && $hash_check !== md5($session_data)) { |
|
541 | + EE_Error::add_error( |
|
542 | + sprintf( |
|
543 | + __( |
|
544 | + 'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', |
|
545 | + 'event_espresso' |
|
546 | + ), |
|
547 | + EE_Session::session_id_prefix . $this->_sid |
|
548 | + ), |
|
549 | + __FILE__, __FUNCTION__, __LINE__ |
|
550 | + ); |
|
551 | + } |
|
552 | + } |
|
553 | + } catch (Exception $e) { |
|
554 | + // let's just eat that error for now and attempt to correct any corrupted data |
|
555 | + global $wpdb; |
|
556 | + $row = $wpdb->get_row( |
|
557 | + $wpdb->prepare( |
|
558 | + "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1", |
|
559 | + '_transient_' . $ssn_key |
|
560 | + ) |
|
561 | + ); |
|
562 | + $session_data = is_object($row) ? $row->option_value : null; |
|
563 | + if ($session_data) { |
|
564 | + $session_data = preg_replace_callback( |
|
565 | + '!s:(d+):"(.*?)";!', |
|
566 | + function ($match) { |
|
567 | + return $match[1] === strlen($match[2]) |
|
568 | + ? $match[0] |
|
569 | + : 's:' . strlen($match[2]) . ':"' . $match[2] . '";'; |
|
570 | + }, |
|
571 | + $session_data |
|
572 | + ); |
|
573 | + } |
|
574 | + $session_data = maybe_unserialize($session_data); |
|
575 | + } |
|
576 | + // in case the data is encoded... try to decode it |
|
577 | + $session_data = $this->encryption instanceof EE_Encryption |
|
578 | + ? $this->encryption->base64_string_decode($session_data) |
|
579 | + : $session_data; |
|
580 | + |
|
581 | + if ( ! is_array($session_data)) { |
|
582 | + try { |
|
583 | + $session_data = maybe_unserialize($session_data); |
|
584 | + } catch (Exception $e) { |
|
585 | + $msg = esc_html__( |
|
586 | + 'An error occurred while attempting to unserialize the session data.', |
|
587 | + 'event_espresso' |
|
588 | + ); |
|
589 | + $msg .= WP_DEBUG |
|
590 | + ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data) |
|
591 | + : ''; |
|
592 | + throw new InvalidSessionDataException($msg, 0, $e); |
|
593 | + } |
|
594 | + } |
|
595 | + // just a check to make sure the session array is indeed an array |
|
596 | + if ( ! is_array($session_data)) { |
|
597 | + // no?!?! then something is wrong |
|
598 | + $msg = esc_html__( |
|
599 | + 'The session data is missing, invalid, or corrupted.', |
|
600 | + 'event_espresso' |
|
601 | + ); |
|
602 | + $msg .= WP_DEBUG |
|
603 | + ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data) |
|
604 | + : ''; |
|
605 | + throw new InvalidSessionDataException($msg); |
|
606 | + } |
|
607 | + if ( isset($session_data['transaction'] ) && absint($session_data['transaction'] ) !== 0 ) { |
|
608 | + $session_data['transaction'] = EEM_Transaction::instance()->get_one_by_ID( |
|
609 | + $session_data['transaction'] |
|
610 | + ); |
|
611 | + } |
|
612 | + return $session_data; |
|
613 | + } |
|
614 | 614 | |
615 | 615 | |
616 | 616 | |
@@ -677,13 +677,13 @@ discard block |
||
677 | 677 | |
678 | 678 | |
679 | 679 | |
680 | - /** |
|
681 | - * @update session data prior to saving to the db |
|
682 | - * @access public |
|
683 | - * @param bool $new_session |
|
684 | - * @return TRUE on success, FALSE on fail |
|
685 | - * @throws \EE_Error |
|
686 | - */ |
|
680 | + /** |
|
681 | + * @update session data prior to saving to the db |
|
682 | + * @access public |
|
683 | + * @param bool $new_session |
|
684 | + * @return TRUE on success, FALSE on fail |
|
685 | + * @throws \EE_Error |
|
686 | + */ |
|
687 | 687 | public function update( $new_session = FALSE ) { |
688 | 688 | $this->_session_data = isset( $this->_session_data ) |
689 | 689 | && is_array( $this->_session_data ) |
@@ -769,12 +769,12 @@ discard block |
||
769 | 769 | |
770 | 770 | |
771 | 771 | |
772 | - /** |
|
773 | - * @create session data array |
|
774 | - * @access public |
|
775 | - * @return bool |
|
776 | - * @throws \EE_Error |
|
777 | - */ |
|
772 | + /** |
|
773 | + * @create session data array |
|
774 | + * @access public |
|
775 | + * @return bool |
|
776 | + * @throws \EE_Error |
|
777 | + */ |
|
778 | 778 | private function _create_espresso_session( ) { |
779 | 779 | do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' ); |
780 | 780 | // use the update function for now with $new_session arg set to TRUE |
@@ -794,19 +794,19 @@ discard block |
||
794 | 794 | if ( |
795 | 795 | // if the current request is NOT one of the following |
796 | 796 | ! ( |
797 | - // an an AJAX request from the frontend |
|
798 | - EE_Registry::instance()->REQ->front_ajax |
|
799 | - || ( |
|
800 | - // OR an admin request that is NOT AJAX |
|
797 | + // an an AJAX request from the frontend |
|
798 | + EE_Registry::instance()->REQ->front_ajax |
|
799 | + || ( |
|
800 | + // OR an admin request that is NOT AJAX |
|
801 | 801 | ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) |
802 | - && is_admin() |
|
802 | + && is_admin() |
|
803 | 803 | ) |
804 | - || ( |
|
805 | - // OR an espresso page |
|
806 | - EE_Registry::instance()->REQ instanceof EE_Request_Handler |
|
807 | - && EE_Registry::instance()->REQ->is_espresso_page() |
|
808 | - ) |
|
809 | - ) |
|
804 | + || ( |
|
805 | + // OR an espresso page |
|
806 | + EE_Registry::instance()->REQ instanceof EE_Request_Handler |
|
807 | + && EE_Registry::instance()->REQ->is_espresso_page() |
|
808 | + ) |
|
809 | + ) |
|
810 | 810 | ) { |
811 | 811 | return false; |
812 | 812 | } |
@@ -817,27 +817,27 @@ discard block |
||
817 | 817 | } |
818 | 818 | $this->_session_data['transaction'] = $transaction->ID(); |
819 | 819 | } |
820 | - // then serialize all of our session data |
|
820 | + // then serialize all of our session data |
|
821 | 821 | $session_data = serialize($this->_session_data); |
822 | 822 | // do we need to also encode it to avoid corrupted data when saved to the db? |
823 | 823 | $session_data = $this->_use_encryption |
824 | - ? $this->encryption->base64_string_encode( $session_data ) |
|
825 | - : $session_data; |
|
824 | + ? $this->encryption->base64_string_encode( $session_data ) |
|
825 | + : $session_data; |
|
826 | 826 | // maybe save hash check |
827 | 827 | if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) { |
828 | - $this->cache_storage->add( |
|
829 | - EE_Session::hash_check_prefix . $this->_sid, |
|
830 | - md5($session_data), |
|
831 | - $this->_lifespan |
|
832 | - ); |
|
833 | - } |
|
834 | - // we're using the Transient API for storing session data, |
|
835 | - return $this->cache_storage->add( |
|
836 | - EE_Session::session_id_prefix . $this->_sid, |
|
837 | - $session_data, |
|
838 | - $this->_lifespan |
|
839 | - ); |
|
840 | - } |
|
828 | + $this->cache_storage->add( |
|
829 | + EE_Session::hash_check_prefix . $this->_sid, |
|
830 | + md5($session_data), |
|
831 | + $this->_lifespan |
|
832 | + ); |
|
833 | + } |
|
834 | + // we're using the Transient API for storing session data, |
|
835 | + return $this->cache_storage->add( |
|
836 | + EE_Session::session_id_prefix . $this->_sid, |
|
837 | + $session_data, |
|
838 | + $this->_lifespan |
|
839 | + ); |
|
840 | + } |
|
841 | 841 | |
842 | 842 | |
843 | 843 | |
@@ -930,18 +930,18 @@ discard block |
||
930 | 930 | |
931 | 931 | |
932 | 932 | |
933 | - /** |
|
934 | - * Clear EE_Session data |
|
935 | - * |
|
936 | - * @access public |
|
937 | - * @param string $class |
|
938 | - * @param string $function |
|
939 | - * @return void |
|
940 | - * @throws \EE_Error |
|
941 | - */ |
|
933 | + /** |
|
934 | + * Clear EE_Session data |
|
935 | + * |
|
936 | + * @access public |
|
937 | + * @param string $class |
|
938 | + * @param string $function |
|
939 | + * @return void |
|
940 | + * @throws \EE_Error |
|
941 | + */ |
|
942 | 942 | public function clear_session( $class = '', $function = '' ) { |
943 | 943 | //echo '<h3 style="color:#999;line-height:.9em;"><span style="color:#2EA2CC">' . __CLASS__ . '</span>::<span style="color:#E76700">' . __FUNCTION__ . '( ' . $class . '::' . $function . '() )</span><br/><span style="font-size:9px;font-weight:normal;">' . __FILE__ . '</span> <b style="font-size:10px;"> ' . __LINE__ . ' </b></h3>'; |
944 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' . $function . '()' ); |
|
944 | + do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' . $function . '()' ); |
|
945 | 945 | $this->reset_cart(); |
946 | 946 | $this->reset_checkout(); |
947 | 947 | $this->reset_transaction(); |
@@ -1008,12 +1008,12 @@ discard block |
||
1008 | 1008 | |
1009 | 1009 | |
1010 | 1010 | |
1011 | - /** |
|
1012 | - * wp_loaded |
|
1013 | - * |
|
1014 | - * @access public |
|
1015 | - * @throws \EE_Error |
|
1016 | - */ |
|
1011 | + /** |
|
1012 | + * wp_loaded |
|
1013 | + * |
|
1014 | + * @access public |
|
1015 | + * @throws \EE_Error |
|
1016 | + */ |
|
1017 | 1017 | public function wp_loaded() { |
1018 | 1018 | if ( isset( EE_Registry::instance()->REQ ) && EE_Registry::instance()->REQ->is_set( 'clear_session' )) { |
1019 | 1019 | $this->clear_session( __CLASS__, __FUNCTION__ ); |
@@ -1022,12 +1022,12 @@ discard block |
||
1022 | 1022 | |
1023 | 1023 | |
1024 | 1024 | |
1025 | - /** |
|
1026 | - * Used to reset the entire object (for tests). |
|
1027 | - * |
|
1028 | - * @since 4.3.0 |
|
1029 | - * @throws \EE_Error |
|
1030 | - */ |
|
1025 | + /** |
|
1026 | + * Used to reset the entire object (for tests). |
|
1027 | + * |
|
1028 | + * @since 4.3.0 |
|
1029 | + * @throws \EE_Error |
|
1030 | + */ |
|
1031 | 1031 | public function reset_instance() { |
1032 | 1032 | $this->clear_session(); |
1033 | 1033 | self::$_instance = NULL; |
@@ -1035,29 +1035,29 @@ discard block |
||
1035 | 1035 | |
1036 | 1036 | |
1037 | 1037 | |
1038 | - public function configure_garbage_collection_filters() |
|
1039 | - { |
|
1040 | - // run old filter we had for controlling session cleanup |
|
1041 | - $expired_session_transient_delete_query_limit = absint( |
|
1042 | - apply_filters( |
|
1043 | - 'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', |
|
1044 | - 50 |
|
1045 | - ) |
|
1046 | - ); |
|
1047 | - // is there a value? or one that is different than the default 50 records? |
|
1048 | - if ($expired_session_transient_delete_query_limit === 0) { |
|
1049 | - // hook into TransientCacheStorage in case Session cleanup was turned off |
|
1050 | - add_filter('FHEE__TransientCacheStorage__transient_cleanup_schedule', '__return_zero'); |
|
1051 | - } else if ($expired_session_transient_delete_query_limit !== 50) { |
|
1052 | - // or use that for the new transient cleanup query limit |
|
1053 | - add_filter( |
|
1054 | - 'FHEE__TransientCacheStorage__clearExpiredTransients__limit', |
|
1055 | - function () use ($expired_session_transient_delete_query_limit) { |
|
1056 | - return $expired_session_transient_delete_query_limit; |
|
1057 | - } |
|
1058 | - ); |
|
1059 | - } |
|
1060 | - } |
|
1038 | + public function configure_garbage_collection_filters() |
|
1039 | + { |
|
1040 | + // run old filter we had for controlling session cleanup |
|
1041 | + $expired_session_transient_delete_query_limit = absint( |
|
1042 | + apply_filters( |
|
1043 | + 'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', |
|
1044 | + 50 |
|
1045 | + ) |
|
1046 | + ); |
|
1047 | + // is there a value? or one that is different than the default 50 records? |
|
1048 | + if ($expired_session_transient_delete_query_limit === 0) { |
|
1049 | + // hook into TransientCacheStorage in case Session cleanup was turned off |
|
1050 | + add_filter('FHEE__TransientCacheStorage__transient_cleanup_schedule', '__return_zero'); |
|
1051 | + } else if ($expired_session_transient_delete_query_limit !== 50) { |
|
1052 | + // or use that for the new transient cleanup query limit |
|
1053 | + add_filter( |
|
1054 | + 'FHEE__TransientCacheStorage__clearExpiredTransients__limit', |
|
1055 | + function () use ($expired_session_transient_delete_query_limit) { |
|
1056 | + return $expired_session_transient_delete_query_limit; |
|
1057 | + } |
|
1058 | + ); |
|
1059 | + } |
|
1060 | + } |
|
1061 | 1061 | |
1062 | 1062 | |
1063 | 1063 |
@@ -98,14 +98,14 @@ |
||
98 | 98 | </th> |
99 | 99 | <td> |
100 | 100 | <?php |
101 | - $disabled = ! empty( $QST_system ) && $QST_system !== EEM_Attendee::system_question_phone; |
|
102 | - if( $disabled ){ |
|
103 | - $disabled_attr = 'disabled="disabled"'; |
|
104 | - $id = '_disabled'; |
|
105 | - } else { |
|
106 | - $disabled_attr = ''; |
|
107 | - $id = ''; |
|
108 | - } |
|
101 | + $disabled = ! empty( $QST_system ) && $QST_system !== EEM_Attendee::system_question_phone; |
|
102 | + if( $disabled ){ |
|
103 | + $disabled_attr = 'disabled="disabled"'; |
|
104 | + $id = '_disabled'; |
|
105 | + } else { |
|
106 | + $disabled_attr = ''; |
|
107 | + $id = ''; |
|
108 | + } |
|
109 | 109 | |
110 | 110 | echo EEH_Form_Fields::select_input( 'QST_type' . $id, $question_types, $question->type(), 'id="QST_type' . $id . '"' . $disabled_attr ); |
111 | 111 | if( $disabled ) { ?> |
@@ -15,9 +15,9 @@ discard block |
||
15 | 15 | //does question have any answers? cause if it does then we have to disable type |
16 | 16 | $has_answers = $question->has_answers(); |
17 | 17 | |
18 | -if ( $QST_system === 'country' ) { |
|
18 | +if ($QST_system === 'country') { |
|
19 | 19 | echo EEH_HTML::div( |
20 | - EEH_HTML::h4( '<span class="dashicons dashicons-info"></span>' . esc_html__( 'Did you know...', 'event_espresso' ) ) . |
|
20 | + EEH_HTML::h4('<span class="dashicons dashicons-info"></span>'.esc_html__('Did you know...', 'event_espresso')). |
|
21 | 21 | EEH_HTML::p( |
22 | 22 | esc_html__( |
23 | 23 | 'If you add a State/Province Select input immediately after this Country Select input when building your registration form, then the State/Province Select input options will change to correspond with the choice made in this input. So for example, choosing "United States" in this Country Select input will populate the State/Province Select input with just the state options for the United States.', |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | <tbody> |
35 | 35 | <tr> |
36 | 36 | <th> |
37 | - <label for="QST_display_text"><?php echo $fields['QST_display_text']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_text_info');?> |
|
37 | + <label for="QST_display_text"><?php echo $fields['QST_display_text']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_text_info'); ?> |
|
38 | 38 | </th> |
39 | 39 | <td> |
40 | 40 | <input type="text" class="regular-text" id="QST_display_text" name="QST_display_text" value="<?php $question->f('QST_display_text')?>"/> |
@@ -44,23 +44,23 @@ discard block |
||
44 | 44 | |
45 | 45 | <tr> |
46 | 46 | <th> |
47 | - <label for="QST_admin_label"><?php echo $fields['QST_admin_label']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_label_info');?> |
|
47 | + <label for="QST_admin_label"><?php echo $fields['QST_admin_label']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_label_info'); ?> |
|
48 | 48 | </th> |
49 | 49 | <td> |
50 | 50 | <?php |
51 | - $disabled_attr = ! empty( $QST_system ) ? ' disabled="disabled"' : ''; |
|
52 | - $id = ! empty( $QST_system ) ? '_disabled' : ''; |
|
51 | + $disabled_attr = ! empty($QST_system) ? ' disabled="disabled"' : ''; |
|
52 | + $id = ! empty($QST_system) ? '_disabled' : ''; |
|
53 | 53 | ?> |
54 | 54 | <input type="text" class="regular-text" id="QST_admin_label<?php echo $id?>" name="QST_admin_label<?php echo $id?>" value="<?php $question->f('QST_admin_label')?>"<?php echo $disabled_attr?>/> |
55 | 55 | <input class="QST_order" type="hidden" id="QST_order<?php echo $id; ?>" name = "QST_order<?php echo $id; ?>" value="<?php echo $question->get('QST_order'); ?>" /> |
56 | - <?php if ( ! empty( $QST_system )) { ?> |
|
56 | + <?php if ( ! empty($QST_system)) { ?> |
|
57 | 57 | <input type="hidden" id="QST_admin_label" name="QST_admin_label" value="<?php echo $question->admin_label()?>"/> |
58 | 58 | <?php } ?> |
59 | 59 | <br/> |
60 | 60 | <p class="description"> |
61 | - <?php if ( ! empty( $QST_system )) { ?> |
|
61 | + <?php if ( ! empty($QST_system)) { ?> |
|
62 | 62 | <span class="description" style="color:#D54E21;"> |
63 | - <?php esc_html_e('System question! This field cannot be changed.','event_espresso')?> |
|
63 | + <?php esc_html_e('System question! This field cannot be changed.', 'event_espresso')?> |
|
64 | 64 | </span> |
65 | 65 | <?php } ?> |
66 | 66 | |
@@ -70,21 +70,21 @@ discard block |
||
70 | 70 | |
71 | 71 | <tr> |
72 | 72 | <th> |
73 | - <label for="QST_admin_only"><?php echo $fields['QST_admin_only']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_admin_only_info');?> |
|
73 | + <label for="QST_admin_only"><?php echo $fields['QST_admin_only']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_admin_only_info'); ?> |
|
74 | 74 | </th> |
75 | 75 | <td> |
76 | 76 | <?php |
77 | - $disabled_attr = ! empty( $QST_system ) ? ' disabled="disabled"' : ''; |
|
78 | - $id = ! empty( $QST_system ) ? '_disabled' : ''; |
|
77 | + $disabled_attr = ! empty($QST_system) ? ' disabled="disabled"' : ''; |
|
78 | + $id = ! empty($QST_system) ? '_disabled' : ''; |
|
79 | 79 | $admin_only = $question->get('QST_admin_only'); |
80 | - $checked = !empty( $admin_only ) ? ' checked="checked"' : ''; |
|
80 | + $checked = ! empty($admin_only) ? ' checked="checked"' : ''; |
|
81 | 81 | ?> |
82 | 82 | <input class="QST_admin_only" type="checkbox" id="QST_admin_only<?php echo $id; ?>" name = "QST_admin_only<?php echo $id; ?>" value="1"<?php echo $disabled_attr; echo $checked; ?>/> |
83 | 83 | <br/> |
84 | 84 | <p class="description"> |
85 | - <?php if ( ! empty( $QST_system )) { ?> |
|
85 | + <?php if ( ! empty($QST_system)) { ?> |
|
86 | 86 | <span class="description" style="color:#D54E21;"> |
87 | - <?php esc_html_e('System question! This field cannot be changed.','event_espresso')?> |
|
87 | + <?php esc_html_e('System question! This field cannot be changed.', 'event_espresso')?> |
|
88 | 88 | </span> |
89 | 89 | <?php } ?> |
90 | 90 | |
@@ -94,28 +94,28 @@ discard block |
||
94 | 94 | |
95 | 95 | <tr> |
96 | 96 | <th> |
97 | - <label for="QST_type"><?php echo $fields['QST_type']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('question_type_info');?> |
|
97 | + <label for="QST_type"><?php echo $fields['QST_type']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('question_type_info'); ?> |
|
98 | 98 | </th> |
99 | 99 | <td> |
100 | 100 | <?php |
101 | - $disabled = ! empty( $QST_system ) && $QST_system !== EEM_Attendee::system_question_phone; |
|
102 | - if( $disabled ){ |
|
103 | - $disabled_attr = 'disabled="disabled"'; |
|
104 | - $id = '_disabled'; |
|
101 | + $disabled = ! empty($QST_system) && $QST_system !== EEM_Attendee::system_question_phone; |
|
102 | + if ($disabled) { |
|
103 | + $disabled_attr = 'disabled="disabled"'; |
|
104 | + $id = '_disabled'; |
|
105 | 105 | } else { |
106 | 106 | $disabled_attr = ''; |
107 | 107 | $id = ''; |
108 | 108 | } |
109 | 109 | |
110 | - echo EEH_Form_Fields::select_input( 'QST_type' . $id, $question_types, $question->type(), 'id="QST_type' . $id . '"' . $disabled_attr ); |
|
111 | - if( $disabled ) { ?> |
|
110 | + echo EEH_Form_Fields::select_input('QST_type'.$id, $question_types, $question->type(), 'id="QST_type'.$id.'"'.$disabled_attr); |
|
111 | + if ($disabled) { ?> |
|
112 | 112 | <input type="hidden" id="QST_type" name="QST_type" value="<?php echo $question->type()?>"/> |
113 | 113 | <?php |
114 | - $explanatory_text = esc_html__('System question! This field cannot be changed.','event_espresso'); |
|
115 | - }else{ |
|
116 | - $explanatory_text = esc_html__('Because there are currently answers for this question in the database, your options to change the question type have been limited to similar question-types.','event_espresso'); |
|
114 | + $explanatory_text = esc_html__('System question! This field cannot be changed.', 'event_espresso'); |
|
115 | + } else { |
|
116 | + $explanatory_text = esc_html__('Because there are currently answers for this question in the database, your options to change the question type have been limited to similar question-types.', 'event_espresso'); |
|
117 | 117 | } |
118 | - if ( $disabled || $has_answers ) { ?> |
|
118 | + if ($disabled || $has_answers) { ?> |
|
119 | 119 | <p><span class="description" style="color:#D54E21;"> |
120 | 120 | <?php echo $explanatory_text; ?> |
121 | 121 | </span></p> |
@@ -128,22 +128,22 @@ discard block |
||
128 | 128 | <tr id="text_input_question_options"> |
129 | 129 | <th> |
130 | 130 | <label> |
131 | - <?php esc_html_e( 'Maximum Allowed Response Size', 'event_espresso' );?> |
|
131 | + <?php esc_html_e('Maximum Allowed Response Size', 'event_espresso'); ?> |
|
132 | 132 | </label> |
133 | 133 | </th> |
134 | 134 | <td> |
135 | - <input id="QST_max" name="QST_max" type="number" <?php echo $max_max === EE_INF ? '' : "max='$max_max'";?> value="<?php $question->f( 'QST_max' );?>" min="1"> |
|
135 | + <input id="QST_max" name="QST_max" type="number" <?php echo $max_max === EE_INF ? '' : "max='$max_max'"; ?> value="<?php $question->f('QST_max'); ?>" min="1"> |
|
136 | 136 | <p> |
137 | 137 | <span class="description"> |
138 | - <?php esc_html_e( 'Maximum number of characters allowed when answering this question', 'event_espresso' );?> |
|
138 | + <?php esc_html_e('Maximum number of characters allowed when answering this question', 'event_espresso'); ?> |
|
139 | 139 | </span> |
140 | 140 | </p> |
141 | - <?php if ( $QST_system ) { ?> |
|
141 | + <?php if ($QST_system) { ?> |
|
142 | 142 | <p> |
143 | 143 | <span class="description" style="color:#D54E21;"> |
144 | 144 | <?php printf( |
145 | - esc_html__( 'System question! The maximum number of characters that can be used for this question is %1$s', 'event_espresso' ), |
|
146 | - $max_max );?> |
|
145 | + esc_html__('System question! The maximum number of characters that can be used for this question is %1$s', 'event_espresso'), |
|
146 | + $max_max ); ?> |
|
147 | 147 | </span> |
148 | 148 | </p> |
149 | 149 | <?php } ?> |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | <tr id="question_options"> |
153 | 153 | <th> |
154 | 154 | <label> |
155 | - <?php esc_html_e('Answer Options','event_espresso')?> |
|
155 | + <?php esc_html_e('Answer Options', 'event_espresso')?> |
|
156 | 156 | </label> |
157 | 157 | </th> |
158 | 158 | <td> |
@@ -161,10 +161,10 @@ discard block |
||
161 | 161 | <thead> |
162 | 162 | <tr> |
163 | 163 | <th class="option-value-header"> |
164 | - <?php esc_html_e('Value','event_espresso')?> |
|
164 | + <?php esc_html_e('Value', 'event_espresso')?> |
|
165 | 165 | </th> |
166 | 166 | <th class="option-desc-header"> |
167 | - <?php esc_html_e('Description (optional, only shown on registration form)','event_espresso')?> |
|
167 | + <?php esc_html_e('Description (optional, only shown on registration form)', 'event_espresso')?> |
|
168 | 168 | </th> |
169 | 169 | <th> |
170 | 170 | </th> |
@@ -187,17 +187,17 @@ discard block |
||
187 | 187 | </tr> |
188 | 188 | |
189 | 189 | <?php |
190 | - $count=0; |
|
190 | + $count = 0; |
|
191 | 191 | $question_options = $question->options(); |
192 | - if ( ! empty( $question_options )) { |
|
193 | - foreach( $question_options as $option_id => $option ) { |
|
194 | - $disabled_attr = $has_answers || $option->get('QSO_system') ? ' disabled="disabled"' : ''; |
|
192 | + if ( ! empty($question_options)) { |
|
193 | + foreach ($question_options as $option_id => $option) { |
|
194 | + $disabled_attr = $has_answers || $option->get('QSO_system') ? ' disabled="disabled"' : ''; |
|
195 | 195 | ?> |
196 | 196 | <tr class="question-option ee-options-sortable"> |
197 | 197 | <td class="option-value-cell"> |
198 | 198 | <input type="hidden" class="QSO_order" name="question_options[<?php echo $count; ?>][QSO_order]" value="<?php echo $count; ?>"> |
199 | 199 | <input type="text" class="option-value regular-text" name="question_options[<?php echo $count?>][QSO_value]" value="<?php $option->f('QSO_value')?>"<?php echo $disabled_attr; ?>> |
200 | - <?php if ( $has_answers ) : ?> |
|
200 | + <?php if ($has_answers) : ?> |
|
201 | 201 | <input type="hidden" name="question_options[<?php echo $count; ?>][QSO_value]" value="<?php echo $option->f('QSO_value'); ?>" > |
202 | 202 | <?php endif; ?> |
203 | 203 | </td> |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | <input type="text" class="option-desc regular-text" name="question_options[<?php echo $count?>][QSO_desc]" value="<?php $option->f('QSO_desc')?>"> |
206 | 206 | </td> |
207 | 207 | <td> |
208 | - <?php if ( ! $option->system() ) { ?> |
|
208 | + <?php if ( ! $option->system()) { ?> |
|
209 | 209 | <span class="dashicons clickable dashicons-post-trash ee-icon-size-18 remove-option remove-item"></span> |
210 | 210 | <?php } ?> |
211 | 211 | <span class="dashicons dashicons-image-flip-vertical sortable-drag-handle ee-icon-size-18"></span> |
@@ -244,13 +244,13 @@ discard block |
||
244 | 244 | </table> |
245 | 245 | |
246 | 246 | <a id="new-question-option" class="button" style="margin:0 0 1em 3px;"> |
247 | - <?php esc_html_e('Add Another Answer Option','event_espresso')?> |
|
247 | + <?php esc_html_e('Add Another Answer Option', 'event_espresso')?> |
|
248 | 248 | </a><br/> |
249 | 249 | |
250 | 250 | <p class="description"> |
251 | - <?php esc_html_e('Answer Options are the choices that you give people to select from for RADIO_BTN, CHECKBOX or DROPDOWN questions. The Value is a simple key that will be saved to the database and the description is optional. Note that values CANNOT contain any HTML, but descriptions can.','event_espresso')?> |
|
251 | + <?php esc_html_e('Answer Options are the choices that you give people to select from for RADIO_BTN, CHECKBOX or DROPDOWN questions. The Value is a simple key that will be saved to the database and the description is optional. Note that values CANNOT contain any HTML, but descriptions can.', 'event_espresso')?> |
|
252 | 252 | </p> |
253 | - <?php if ( $has_answers ) : ?> |
|
253 | + <?php if ($has_answers) : ?> |
|
254 | 254 | <p class="description" style="color:#D54E21;"> |
255 | 255 | <?php esc_html_e('Answer values that are uneditable are this way because there are registrations in the database that have answers for this question. If you need to correct a mistake, or edit an existing option value, then trash the existing one and create a new option with the changes. This will ensure that the existing registrations that chose the original answer will preserve that answer.', 'event_espresso'); ?> |
256 | 256 | </p> |
@@ -261,32 +261,32 @@ discard block |
||
261 | 261 | |
262 | 262 | <tr> |
263 | 263 | <th> |
264 | - <label for="QST_required"><?php echo $fields['QST_required']->get_nicename();?></label> <?php echo EEH_Template::get_help_tab_link('required_question_info');?> |
|
264 | + <label for="QST_required"><?php echo $fields['QST_required']->get_nicename(); ?></label> <?php echo EEH_Template::get_help_tab_link('required_question_info'); ?> |
|
265 | 265 | </th> |
266 | 266 | <td> |
267 | 267 | <?php |
268 | - $system_required = array( 'fname', 'email' ); |
|
269 | - $disabled_attr = in_array( $QST_system, $system_required ) ? ' disabled="disabled"' : ''; |
|
268 | + $system_required = array('fname', 'email'); |
|
269 | + $disabled_attr = in_array($QST_system, $system_required) ? ' disabled="disabled"' : ''; |
|
270 | 270 | $required_on = $question->get('QST_admin_only'); |
271 | 271 | $show_required_msg = $required_on ? '' : ' display:none;'; |
272 | - $disabled_attr = $required_on || ! empty( $disabled_attr ) ? ' disabled="disabled"' : ''; |
|
273 | - $id = ! empty( $disabled_attr ) && in_array( $QST_system, $system_required) ? '_disabled' : ''; |
|
274 | - $requiredOptions=array( |
|
275 | - array( 'text'=> esc_html__( 'Optional', 'event_espresso' ), 'id'=>0 ), |
|
276 | - array( 'text'=> esc_html__( 'Required', 'event_espresso' ), 'id'=>1 ) |
|
272 | + $disabled_attr = $required_on || ! empty($disabled_attr) ? ' disabled="disabled"' : ''; |
|
273 | + $id = ! empty($disabled_attr) && in_array($QST_system, $system_required) ? '_disabled' : ''; |
|
274 | + $requiredOptions = array( |
|
275 | + array('text'=> esc_html__('Optional', 'event_espresso'), 'id'=>0), |
|
276 | + array('text'=> esc_html__('Required', 'event_espresso'), 'id'=>1) |
|
277 | 277 | ); |
278 | - echo EEH_Form_Fields::select_input('QST_required' . $id, $requiredOptions, $question->required(), 'id="QST_required' . $id . '"' . $disabled_attr ); |
|
278 | + echo EEH_Form_Fields::select_input('QST_required'.$id, $requiredOptions, $question->required(), 'id="QST_required'.$id.'"'.$disabled_attr); |
|
279 | 279 | ?> |
280 | 280 | <p><span id="required_toggled_on" class="description" style="color:#D54E21;<?php echo $show_required_msg; ?>"> |
281 | - <?php esc_html_e('Required is set to optional, and this field is disabled, because the question is Admin-Only.','event_espresso')?> |
|
281 | + <?php esc_html_e('Required is set to optional, and this field is disabled, because the question is Admin-Only.', 'event_espresso')?> |
|
282 | 282 | </span></p> |
283 | 283 | <p><span id="required_toggled_off" class="description" style="color:#D54E21; display: none;"> |
284 | - <?php esc_html_e('Required option field is no longer disabled because the question is not Admin-Only','event_espresso')?> |
|
284 | + <?php esc_html_e('Required option field is no longer disabled because the question is not Admin-Only', 'event_espresso')?> |
|
285 | 285 | </span></p> |
286 | - <?php if (! empty( $disabled_attr ) && in_array( $QST_system, $system_required ) ) { ?> |
|
286 | + <?php if ( ! empty($disabled_attr) && in_array($QST_system, $system_required)) { ?> |
|
287 | 287 | <input type="hidden" id="QST_required" name="QST_required" value="1"/> |
288 | 288 | <p><span class="description" style="color:#D54E21;"> |
289 | - <?php esc_html_e('System question! This field cannot be changed.','event_espresso')?> |
|
289 | + <?php esc_html_e('System question! This field cannot be changed.', 'event_espresso')?> |
|
290 | 290 | </span></p> |
291 | 291 | <?php } ?> |
292 | 292 | |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | |
296 | 296 | <tr> |
297 | 297 | <th> |
298 | - <label for="QST_required_text"><?php esc_html_e('Required Text', 'event_espresso'); ?></label> <?php echo EEH_Template::get_help_tab_link('required_text_info');?> |
|
298 | + <label for="QST_required_text"><?php esc_html_e('Required Text', 'event_espresso'); ?></label> <?php echo EEH_Template::get_help_tab_link('required_text_info'); ?> |
|
299 | 299 | </th> |
300 | 300 | <td> |
301 | 301 | <input type="text" maxlength="100" class="regular-text" id="QST_required_text" name="QST_required_text" value="<?php $question->f('QST_required_text')?>"/> |
@@ -112,7 +112,7 @@ |
||
112 | 112 | <input type="hidden" id="QST_type" name="QST_type" value="<?php echo $question->type()?>"/> |
113 | 113 | <?php |
114 | 114 | $explanatory_text = esc_html__('System question! This field cannot be changed.','event_espresso'); |
115 | - }else{ |
|
115 | + } else{ |
|
116 | 116 | $explanatory_text = esc_html__('Because there are currently answers for this question in the database, your options to change the question type have been limited to similar question-types.','event_espresso'); |
117 | 117 | } |
118 | 118 | if ( $disabled || $has_answers ) { ?> |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('NO direct script access allowed'); |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -28,599 +28,599 @@ discard block |
||
28 | 28 | class Registration_Form_Admin_Page extends EE_Admin_Page |
29 | 29 | { |
30 | 30 | |
31 | - /** |
|
32 | - * _question |
|
33 | - * holds the specific question object for the question details screen |
|
34 | - * |
|
35 | - * @var EE_Question $_question |
|
36 | - */ |
|
37 | - protected $_question; |
|
38 | - |
|
39 | - /** |
|
40 | - * _question_group |
|
41 | - * holds the specific question group object for the question group details screen |
|
42 | - * |
|
43 | - * @var EE_Question_Group $_question_group |
|
44 | - */ |
|
45 | - protected $_question_group; |
|
46 | - |
|
47 | - /** |
|
48 | - *_question_model EEM_Question model instance (for queries) |
|
49 | - * |
|
50 | - * @var EEM_Question $_question_model ; |
|
51 | - */ |
|
52 | - protected $_question_model; |
|
53 | - |
|
54 | - /** |
|
55 | - * _question_group_model EEM_Question_group instance (for queries) |
|
56 | - * |
|
57 | - * @var EEM_Question_Group $_question_group_model |
|
58 | - */ |
|
59 | - protected $_question_group_model; |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * @Constructor |
|
64 | - * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
65 | - * @access public |
|
66 | - */ |
|
67 | - public function __construct($routing = true) |
|
68 | - { |
|
69 | - require_once(EE_MODELS . 'EEM_Question.model.php'); |
|
70 | - require_once(EE_MODELS . 'EEM_Question_Group.model.php'); |
|
71 | - $this->_question_model = EEM_Question::instance(); |
|
72 | - $this->_question_group_model = EEM_Question_Group::instance(); |
|
73 | - parent::__construct($routing); |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - protected function _init_page_props() |
|
78 | - { |
|
79 | - $this->page_slug = REGISTRATION_FORM_PG_SLUG; |
|
80 | - $this->page_label = esc_html__('Registration Form', 'event_espresso'); |
|
81 | - $this->_admin_base_url = REGISTRATION_FORM_ADMIN_URL; |
|
82 | - $this->_admin_base_path = REGISTRATION_FORM_ADMIN; |
|
83 | - } |
|
84 | - |
|
85 | - |
|
86 | - protected function _ajax_hooks() |
|
87 | - { |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - protected function _define_page_props() |
|
92 | - { |
|
93 | - $this->_admin_page_title = esc_html__('Registration Form', 'event_espresso'); |
|
94 | - $this->_labels = array( |
|
95 | - 'buttons' => array( |
|
96 | - 'edit_question' => esc_html__('Edit Question', 'event_espresso'), |
|
97 | - ), |
|
98 | - ); |
|
99 | - } |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - *_set_page_routes |
|
104 | - */ |
|
105 | - protected function _set_page_routes() |
|
106 | - { |
|
107 | - $qst_id = ! empty($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0; |
|
108 | - $this->_page_routes = array( |
|
109 | - 'default' => array( |
|
110 | - 'func' => '_questions_overview_list_table', |
|
111 | - 'capability' => 'ee_read_questions', |
|
112 | - ), |
|
113 | - |
|
114 | - 'edit_question' => array( |
|
115 | - 'func' => '_edit_question', |
|
116 | - 'capability' => 'ee_edit_question', |
|
117 | - 'obj_id' => $qst_id, |
|
118 | - 'args' => array('edit'), |
|
119 | - ), |
|
120 | - |
|
121 | - 'question_groups' => array( |
|
122 | - 'func' => '_questions_groups_preview', |
|
123 | - 'capability' => 'ee_read_question_groups', |
|
124 | - ), |
|
125 | - |
|
126 | - 'update_question' => array( |
|
127 | - 'func' => '_insert_or_update_question', |
|
128 | - 'args' => array('new_question' => false), |
|
129 | - 'capability' => 'ee_edit_question', |
|
130 | - 'obj_id' => $qst_id, |
|
131 | - 'noheader' => true, |
|
132 | - ), |
|
133 | - ); |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - protected function _set_page_config() |
|
138 | - { |
|
139 | - $this->_page_config = array( |
|
140 | - 'default' => array( |
|
141 | - 'nav' => array( |
|
142 | - 'label' => esc_html__('Questions', 'event_espresso'), |
|
143 | - 'order' => 10, |
|
144 | - ), |
|
145 | - 'list_table' => 'Registration_Form_Questions_Admin_List_Table', |
|
146 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
147 | - 'help_tabs' => array( |
|
148 | - 'registration_form_questions_overview_help_tab' => array( |
|
149 | - 'title' => esc_html__('Questions Overview', 'event_espresso'), |
|
150 | - 'filename' => 'registration_form_questions_overview', |
|
151 | - ), |
|
152 | - 'registration_form_questions_overview_table_column_headings_help_tab' => array( |
|
153 | - 'title' => esc_html__('Questions Overview Table Column Headings', 'event_espresso'), |
|
154 | - 'filename' => 'registration_form_questions_overview_table_column_headings', |
|
155 | - ), |
|
156 | - 'registration_form_questions_overview_views_bulk_actions_search_help_tab' => array( |
|
157 | - 'title' => esc_html__('Question Overview Views & Bulk Actions & Search', 'event_espresso'), |
|
158 | - 'filename' => 'registration_form_questions_overview_views_bulk_actions_search', |
|
159 | - ), |
|
160 | - ), |
|
161 | - 'help_tour' => array('Registration_Form_Questions_Overview_Help_Tour'), |
|
162 | - 'require_nonce' => false, |
|
163 | - 'qtips' => array( |
|
164 | - 'EE_Registration_Form_Tips', |
|
165 | - )/**/ |
|
166 | - ), |
|
167 | - |
|
168 | - 'question_groups' => array( |
|
169 | - 'nav' => array( |
|
170 | - 'label' => esc_html__('Question Groups', 'event_espresso'), |
|
171 | - 'order' => 20, |
|
172 | - ), |
|
173 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
174 | - 'help_tabs' => array( |
|
175 | - 'registration_form_question_groups_help_tab' => array( |
|
176 | - 'title' => esc_html__('Question Groups', 'event_espresso'), |
|
177 | - 'filename' => 'registration_form_question_groups', |
|
178 | - ), |
|
179 | - ), |
|
180 | - 'help_tour' => array('Registration_Form_Question_Groups_Help_Tour'), |
|
181 | - 'require_nonce' => false, |
|
182 | - ), |
|
183 | - |
|
184 | - 'edit_question' => array( |
|
185 | - 'nav' => array( |
|
186 | - 'label' => esc_html__('Edit Question', 'event_espresso'), |
|
187 | - 'order' => 15, |
|
188 | - 'persistent' => false, |
|
189 | - 'url' => isset($this->_req_data['question_id']) ? add_query_arg(array('question_id' => $this->_req_data['question_id']), |
|
190 | - $this->_current_page_view_url) : $this->_admin_base_url, |
|
191 | - ), |
|
192 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
193 | - 'help_tabs' => array( |
|
194 | - 'registration_form_edit_question_group_help_tab' => array( |
|
195 | - 'title' => esc_html__('Edit Question', 'event_espresso'), |
|
196 | - 'filename' => 'registration_form_edit_question', |
|
197 | - ), |
|
198 | - ), |
|
199 | - 'help_tour' => array('Registration_Form_Edit_Question_Help_Tour'), |
|
200 | - 'require_nonce' => false, |
|
201 | - ), |
|
202 | - ); |
|
203 | - } |
|
204 | - |
|
205 | - |
|
206 | - protected function _add_screen_options() |
|
207 | - { |
|
208 | - //todo |
|
209 | - } |
|
210 | - |
|
211 | - protected function _add_screen_options_default() |
|
212 | - { |
|
213 | - $page_title = $this->_admin_page_title; |
|
214 | - $this->_admin_page_title = esc_html__('Questions', 'event_espresso'); |
|
215 | - $this->_per_page_screen_option(); |
|
216 | - $this->_admin_page_title = $page_title; |
|
217 | - } |
|
218 | - |
|
219 | - protected function _add_screen_options_question_groups() |
|
220 | - { |
|
221 | - $page_title = $this->_admin_page_title; |
|
222 | - $this->_admin_page_title = esc_html__('Question Groups', 'event_espresso'); |
|
223 | - $this->_per_page_screen_option(); |
|
224 | - $this->_admin_page_title = $page_title; |
|
225 | - } |
|
226 | - |
|
227 | - //none of the below group are currently used for Event Categories |
|
228 | - protected function _add_feature_pointers() |
|
229 | - { |
|
230 | - } |
|
231 | - |
|
232 | - public function load_scripts_styles() |
|
233 | - { |
|
234 | - wp_register_style('espresso_registration', |
|
235 | - REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
236 | - wp_enqueue_style('espresso_registration'); |
|
237 | - } |
|
238 | - |
|
239 | - public function admin_init() |
|
240 | - { |
|
241 | - } |
|
242 | - |
|
243 | - public function admin_notices() |
|
244 | - { |
|
245 | - } |
|
246 | - |
|
247 | - public function admin_footer_scripts() |
|
248 | - { |
|
249 | - } |
|
250 | - |
|
251 | - |
|
252 | - public function load_scripts_styles_default() |
|
253 | - { |
|
254 | - } |
|
255 | - |
|
256 | - |
|
257 | - public function load_scripts_styles_add_question() |
|
258 | - { |
|
259 | - $this->load_scripts_styles_forms(); |
|
260 | - wp_register_script('espresso_registration_form_single', |
|
261 | - REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), |
|
262 | - EVENT_ESPRESSO_VERSION, true); |
|
263 | - wp_enqueue_script('espresso_registration_form_single'); |
|
264 | - } |
|
265 | - |
|
266 | - public function load_scripts_styles_edit_question() |
|
267 | - { |
|
268 | - $this->load_scripts_styles_forms(); |
|
269 | - wp_register_script('espresso_registration_form_single', |
|
270 | - REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), |
|
271 | - EVENT_ESPRESSO_VERSION, true); |
|
272 | - wp_enqueue_script('espresso_registration_form_single'); |
|
273 | - } |
|
274 | - |
|
275 | - |
|
276 | - public function recaptcha_info_help_tab() |
|
277 | - { |
|
278 | - $template = REGISTRATION_FORM_TEMPLATE_PATH . 'recaptcha_info_help_tab.template.php'; |
|
279 | - EEH_Template::display_template($template, array()); |
|
280 | - } |
|
281 | - |
|
282 | - |
|
283 | - public function load_scripts_styles_forms() |
|
284 | - { |
|
285 | - //styles |
|
286 | - wp_enqueue_style('espresso-ui-theme'); |
|
287 | - //scripts |
|
288 | - wp_enqueue_script('ee_admin_js'); |
|
289 | - } |
|
290 | - |
|
291 | - |
|
292 | - protected function _set_list_table_views_default() |
|
293 | - { |
|
294 | - $this->_views = array( |
|
295 | - 'all' => array( |
|
296 | - 'slug' => 'all', |
|
297 | - 'label' => esc_html__('View All Questions', 'event_espresso'), |
|
298 | - 'count' => 0, |
|
31 | + /** |
|
32 | + * _question |
|
33 | + * holds the specific question object for the question details screen |
|
34 | + * |
|
35 | + * @var EE_Question $_question |
|
36 | + */ |
|
37 | + protected $_question; |
|
38 | + |
|
39 | + /** |
|
40 | + * _question_group |
|
41 | + * holds the specific question group object for the question group details screen |
|
42 | + * |
|
43 | + * @var EE_Question_Group $_question_group |
|
44 | + */ |
|
45 | + protected $_question_group; |
|
46 | + |
|
47 | + /** |
|
48 | + *_question_model EEM_Question model instance (for queries) |
|
49 | + * |
|
50 | + * @var EEM_Question $_question_model ; |
|
51 | + */ |
|
52 | + protected $_question_model; |
|
53 | + |
|
54 | + /** |
|
55 | + * _question_group_model EEM_Question_group instance (for queries) |
|
56 | + * |
|
57 | + * @var EEM_Question_Group $_question_group_model |
|
58 | + */ |
|
59 | + protected $_question_group_model; |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * @Constructor |
|
64 | + * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
65 | + * @access public |
|
66 | + */ |
|
67 | + public function __construct($routing = true) |
|
68 | + { |
|
69 | + require_once(EE_MODELS . 'EEM_Question.model.php'); |
|
70 | + require_once(EE_MODELS . 'EEM_Question_Group.model.php'); |
|
71 | + $this->_question_model = EEM_Question::instance(); |
|
72 | + $this->_question_group_model = EEM_Question_Group::instance(); |
|
73 | + parent::__construct($routing); |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + protected function _init_page_props() |
|
78 | + { |
|
79 | + $this->page_slug = REGISTRATION_FORM_PG_SLUG; |
|
80 | + $this->page_label = esc_html__('Registration Form', 'event_espresso'); |
|
81 | + $this->_admin_base_url = REGISTRATION_FORM_ADMIN_URL; |
|
82 | + $this->_admin_base_path = REGISTRATION_FORM_ADMIN; |
|
83 | + } |
|
84 | + |
|
85 | + |
|
86 | + protected function _ajax_hooks() |
|
87 | + { |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + protected function _define_page_props() |
|
92 | + { |
|
93 | + $this->_admin_page_title = esc_html__('Registration Form', 'event_espresso'); |
|
94 | + $this->_labels = array( |
|
95 | + 'buttons' => array( |
|
96 | + 'edit_question' => esc_html__('Edit Question', 'event_espresso'), |
|
97 | + ), |
|
98 | + ); |
|
99 | + } |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + *_set_page_routes |
|
104 | + */ |
|
105 | + protected function _set_page_routes() |
|
106 | + { |
|
107 | + $qst_id = ! empty($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0; |
|
108 | + $this->_page_routes = array( |
|
109 | + 'default' => array( |
|
110 | + 'func' => '_questions_overview_list_table', |
|
111 | + 'capability' => 'ee_read_questions', |
|
112 | + ), |
|
113 | + |
|
114 | + 'edit_question' => array( |
|
115 | + 'func' => '_edit_question', |
|
116 | + 'capability' => 'ee_edit_question', |
|
117 | + 'obj_id' => $qst_id, |
|
118 | + 'args' => array('edit'), |
|
119 | + ), |
|
120 | + |
|
121 | + 'question_groups' => array( |
|
122 | + 'func' => '_questions_groups_preview', |
|
123 | + 'capability' => 'ee_read_question_groups', |
|
124 | + ), |
|
125 | + |
|
126 | + 'update_question' => array( |
|
127 | + 'func' => '_insert_or_update_question', |
|
128 | + 'args' => array('new_question' => false), |
|
129 | + 'capability' => 'ee_edit_question', |
|
130 | + 'obj_id' => $qst_id, |
|
131 | + 'noheader' => true, |
|
132 | + ), |
|
133 | + ); |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + protected function _set_page_config() |
|
138 | + { |
|
139 | + $this->_page_config = array( |
|
140 | + 'default' => array( |
|
141 | + 'nav' => array( |
|
142 | + 'label' => esc_html__('Questions', 'event_espresso'), |
|
143 | + 'order' => 10, |
|
144 | + ), |
|
145 | + 'list_table' => 'Registration_Form_Questions_Admin_List_Table', |
|
146 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
147 | + 'help_tabs' => array( |
|
148 | + 'registration_form_questions_overview_help_tab' => array( |
|
149 | + 'title' => esc_html__('Questions Overview', 'event_espresso'), |
|
150 | + 'filename' => 'registration_form_questions_overview', |
|
151 | + ), |
|
152 | + 'registration_form_questions_overview_table_column_headings_help_tab' => array( |
|
153 | + 'title' => esc_html__('Questions Overview Table Column Headings', 'event_espresso'), |
|
154 | + 'filename' => 'registration_form_questions_overview_table_column_headings', |
|
155 | + ), |
|
156 | + 'registration_form_questions_overview_views_bulk_actions_search_help_tab' => array( |
|
157 | + 'title' => esc_html__('Question Overview Views & Bulk Actions & Search', 'event_espresso'), |
|
158 | + 'filename' => 'registration_form_questions_overview_views_bulk_actions_search', |
|
159 | + ), |
|
160 | + ), |
|
161 | + 'help_tour' => array('Registration_Form_Questions_Overview_Help_Tour'), |
|
162 | + 'require_nonce' => false, |
|
163 | + 'qtips' => array( |
|
164 | + 'EE_Registration_Form_Tips', |
|
165 | + )/**/ |
|
166 | + ), |
|
167 | + |
|
168 | + 'question_groups' => array( |
|
169 | + 'nav' => array( |
|
170 | + 'label' => esc_html__('Question Groups', 'event_espresso'), |
|
171 | + 'order' => 20, |
|
172 | + ), |
|
173 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
174 | + 'help_tabs' => array( |
|
175 | + 'registration_form_question_groups_help_tab' => array( |
|
176 | + 'title' => esc_html__('Question Groups', 'event_espresso'), |
|
177 | + 'filename' => 'registration_form_question_groups', |
|
178 | + ), |
|
179 | + ), |
|
180 | + 'help_tour' => array('Registration_Form_Question_Groups_Help_Tour'), |
|
181 | + 'require_nonce' => false, |
|
182 | + ), |
|
183 | + |
|
184 | + 'edit_question' => array( |
|
185 | + 'nav' => array( |
|
186 | + 'label' => esc_html__('Edit Question', 'event_espresso'), |
|
187 | + 'order' => 15, |
|
188 | + 'persistent' => false, |
|
189 | + 'url' => isset($this->_req_data['question_id']) ? add_query_arg(array('question_id' => $this->_req_data['question_id']), |
|
190 | + $this->_current_page_view_url) : $this->_admin_base_url, |
|
191 | + ), |
|
192 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
193 | + 'help_tabs' => array( |
|
194 | + 'registration_form_edit_question_group_help_tab' => array( |
|
195 | + 'title' => esc_html__('Edit Question', 'event_espresso'), |
|
196 | + 'filename' => 'registration_form_edit_question', |
|
197 | + ), |
|
198 | + ), |
|
199 | + 'help_tour' => array('Registration_Form_Edit_Question_Help_Tour'), |
|
200 | + 'require_nonce' => false, |
|
201 | + ), |
|
202 | + ); |
|
203 | + } |
|
204 | + |
|
205 | + |
|
206 | + protected function _add_screen_options() |
|
207 | + { |
|
208 | + //todo |
|
209 | + } |
|
210 | + |
|
211 | + protected function _add_screen_options_default() |
|
212 | + { |
|
213 | + $page_title = $this->_admin_page_title; |
|
214 | + $this->_admin_page_title = esc_html__('Questions', 'event_espresso'); |
|
215 | + $this->_per_page_screen_option(); |
|
216 | + $this->_admin_page_title = $page_title; |
|
217 | + } |
|
218 | + |
|
219 | + protected function _add_screen_options_question_groups() |
|
220 | + { |
|
221 | + $page_title = $this->_admin_page_title; |
|
222 | + $this->_admin_page_title = esc_html__('Question Groups', 'event_espresso'); |
|
223 | + $this->_per_page_screen_option(); |
|
224 | + $this->_admin_page_title = $page_title; |
|
225 | + } |
|
226 | + |
|
227 | + //none of the below group are currently used for Event Categories |
|
228 | + protected function _add_feature_pointers() |
|
229 | + { |
|
230 | + } |
|
231 | + |
|
232 | + public function load_scripts_styles() |
|
233 | + { |
|
234 | + wp_register_style('espresso_registration', |
|
235 | + REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
236 | + wp_enqueue_style('espresso_registration'); |
|
237 | + } |
|
238 | + |
|
239 | + public function admin_init() |
|
240 | + { |
|
241 | + } |
|
242 | + |
|
243 | + public function admin_notices() |
|
244 | + { |
|
245 | + } |
|
246 | + |
|
247 | + public function admin_footer_scripts() |
|
248 | + { |
|
249 | + } |
|
250 | + |
|
251 | + |
|
252 | + public function load_scripts_styles_default() |
|
253 | + { |
|
254 | + } |
|
255 | + |
|
256 | + |
|
257 | + public function load_scripts_styles_add_question() |
|
258 | + { |
|
259 | + $this->load_scripts_styles_forms(); |
|
260 | + wp_register_script('espresso_registration_form_single', |
|
261 | + REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), |
|
262 | + EVENT_ESPRESSO_VERSION, true); |
|
263 | + wp_enqueue_script('espresso_registration_form_single'); |
|
264 | + } |
|
265 | + |
|
266 | + public function load_scripts_styles_edit_question() |
|
267 | + { |
|
268 | + $this->load_scripts_styles_forms(); |
|
269 | + wp_register_script('espresso_registration_form_single', |
|
270 | + REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), |
|
271 | + EVENT_ESPRESSO_VERSION, true); |
|
272 | + wp_enqueue_script('espresso_registration_form_single'); |
|
273 | + } |
|
274 | + |
|
275 | + |
|
276 | + public function recaptcha_info_help_tab() |
|
277 | + { |
|
278 | + $template = REGISTRATION_FORM_TEMPLATE_PATH . 'recaptcha_info_help_tab.template.php'; |
|
279 | + EEH_Template::display_template($template, array()); |
|
280 | + } |
|
281 | + |
|
282 | + |
|
283 | + public function load_scripts_styles_forms() |
|
284 | + { |
|
285 | + //styles |
|
286 | + wp_enqueue_style('espresso-ui-theme'); |
|
287 | + //scripts |
|
288 | + wp_enqueue_script('ee_admin_js'); |
|
289 | + } |
|
290 | + |
|
291 | + |
|
292 | + protected function _set_list_table_views_default() |
|
293 | + { |
|
294 | + $this->_views = array( |
|
295 | + 'all' => array( |
|
296 | + 'slug' => 'all', |
|
297 | + 'label' => esc_html__('View All Questions', 'event_espresso'), |
|
298 | + 'count' => 0, |
|
299 | 299 | // 'bulk_action' => array( |
300 | 300 | // 'trash_questions' => esc_html__('Trash', 'event_espresso'), |
301 | 301 | // ) |
302 | - ), |
|
303 | - ); |
|
304 | - |
|
305 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', |
|
306 | - 'espresso_registration_form_trash_questions') |
|
307 | - ) { |
|
308 | - $this->_views['trash'] = array( |
|
309 | - 'slug' => 'trash', |
|
310 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
311 | - 'count' => 0, |
|
302 | + ), |
|
303 | + ); |
|
304 | + |
|
305 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', |
|
306 | + 'espresso_registration_form_trash_questions') |
|
307 | + ) { |
|
308 | + $this->_views['trash'] = array( |
|
309 | + 'slug' => 'trash', |
|
310 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
311 | + 'count' => 0, |
|
312 | 312 | // 'bulk_action' => array( |
313 | 313 | // 'delete_questions' => esc_html__('Delete Permanently', 'event_espresso'), |
314 | 314 | // 'restore_questions' => esc_html__('Restore', 'event_espresso'), |
315 | - ); |
|
316 | - } |
|
317 | - } |
|
318 | - |
|
319 | - /** |
|
320 | - * This just previews the question groups tab that comes in caffeinated. |
|
321 | - * |
|
322 | - * @return string html |
|
323 | - */ |
|
324 | - protected function _questions_groups_preview() |
|
325 | - { |
|
326 | - $this->_admin_page_title = esc_html__('Question Groups (Preview)', 'event_espresso'); |
|
327 | - $this->_template_args['preview_img'] = '<img src="' . REGISTRATION_FORM_ASSETS_URL . 'caf_reg_form_preview.jpg" alt="' . esc_attr__('Preview Question Groups Overview List Table screenshot', |
|
328 | - 'event_espresso') . '" />'; |
|
329 | - $this->_template_args['preview_text'] = '<strong>' . esc_html__('Question Groups is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. With the Question Groups feature you are able to create new question groups, edit existing question groups, and create and edit new questions and add them to question groups.', |
|
330 | - 'event_espresso') . '</strong>'; |
|
331 | - $this->display_admin_caf_preview_page('question_groups_tab'); |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - /** |
|
336 | - * Extracts the question field's values from the POST request to update or insert them |
|
337 | - * |
|
338 | - * @param \EEM_Base $model |
|
339 | - * @return array where each key is the name of a model's field/db column, and each value is its value. |
|
340 | - */ |
|
341 | - protected function _set_column_values_for(EEM_Base $model) |
|
342 | - { |
|
343 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
344 | - $set_column_values = array(); |
|
345 | - |
|
346 | - //some initial checks for proper values. |
|
347 | - //if QST_admin_only, then no matter what QST_required is we disable. |
|
348 | - if (! empty($this->_req_data['QST_admin_only'])) { |
|
349 | - $this->_req_data['QST_required'] = 0; |
|
350 | - } |
|
351 | - foreach ($model->field_settings() as $fieldName => $settings) { |
|
352 | - // basically if QSG_identifier is empty or not set |
|
353 | - if ($fieldName === 'QSG_identifier' && (isset($this->_req_data['QSG_identifier']) && empty($this->_req_data['QSG_identifier']))) { |
|
354 | - $QSG_name = isset($this->_req_data['QSG_name']) ? $this->_req_data['QSG_name'] : ''; |
|
355 | - $set_column_values[$fieldName] = sanitize_title($QSG_name) . '-' . uniqid('', true); |
|
315 | + ); |
|
316 | + } |
|
317 | + } |
|
318 | + |
|
319 | + /** |
|
320 | + * This just previews the question groups tab that comes in caffeinated. |
|
321 | + * |
|
322 | + * @return string html |
|
323 | + */ |
|
324 | + protected function _questions_groups_preview() |
|
325 | + { |
|
326 | + $this->_admin_page_title = esc_html__('Question Groups (Preview)', 'event_espresso'); |
|
327 | + $this->_template_args['preview_img'] = '<img src="' . REGISTRATION_FORM_ASSETS_URL . 'caf_reg_form_preview.jpg" alt="' . esc_attr__('Preview Question Groups Overview List Table screenshot', |
|
328 | + 'event_espresso') . '" />'; |
|
329 | + $this->_template_args['preview_text'] = '<strong>' . esc_html__('Question Groups is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. With the Question Groups feature you are able to create new question groups, edit existing question groups, and create and edit new questions and add them to question groups.', |
|
330 | + 'event_espresso') . '</strong>'; |
|
331 | + $this->display_admin_caf_preview_page('question_groups_tab'); |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + /** |
|
336 | + * Extracts the question field's values from the POST request to update or insert them |
|
337 | + * |
|
338 | + * @param \EEM_Base $model |
|
339 | + * @return array where each key is the name of a model's field/db column, and each value is its value. |
|
340 | + */ |
|
341 | + protected function _set_column_values_for(EEM_Base $model) |
|
342 | + { |
|
343 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
344 | + $set_column_values = array(); |
|
345 | + |
|
346 | + //some initial checks for proper values. |
|
347 | + //if QST_admin_only, then no matter what QST_required is we disable. |
|
348 | + if (! empty($this->_req_data['QST_admin_only'])) { |
|
349 | + $this->_req_data['QST_required'] = 0; |
|
350 | + } |
|
351 | + foreach ($model->field_settings() as $fieldName => $settings) { |
|
352 | + // basically if QSG_identifier is empty or not set |
|
353 | + if ($fieldName === 'QSG_identifier' && (isset($this->_req_data['QSG_identifier']) && empty($this->_req_data['QSG_identifier']))) { |
|
354 | + $QSG_name = isset($this->_req_data['QSG_name']) ? $this->_req_data['QSG_name'] : ''; |
|
355 | + $set_column_values[$fieldName] = sanitize_title($QSG_name) . '-' . uniqid('', true); |
|
356 | 356 | // dd($set_column_values); |
357 | - } //if the admin label is blank, use a slug version of the question text |
|
358 | - else if ($fieldName === 'QST_admin_label' && (isset($this->_req_data['QST_admin_label']) && empty($this->_req_data['QST_admin_label']))) { |
|
359 | - $QST_text = isset($this->_req_data['QST_display_text']) ? $this->_req_data['QST_display_text'] : ''; |
|
360 | - $set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text, 10)); |
|
361 | - } else if ($fieldName === 'QST_admin_only' && (! isset($this->_req_data['QST_admin_only']))) { |
|
362 | - $set_column_values[$fieldName] = 0; |
|
363 | - } else if ($fieldName === 'QST_max') { |
|
364 | - $qst_system = EEM_Question::instance()->get_var( |
|
365 | - array( |
|
366 | - array( |
|
367 | - 'QST_ID' => isset($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0, |
|
368 | - ), |
|
369 | - ), |
|
370 | - 'QST_system'); |
|
371 | - $max_max = EEM_Question::instance()->absolute_max_for_system_question($qst_system); |
|
372 | - if (empty($this->_req_data['QST_max']) || |
|
373 | - $this->_req_data['QST_max'] > $max_max |
|
374 | - ) { |
|
375 | - $set_column_values[$fieldName] = $max_max; |
|
376 | - } |
|
377 | - } |
|
378 | - |
|
379 | - |
|
380 | - //only add a property to the array if it's not null (otherwise the model should just use the default value) |
|
381 | - if ( |
|
382 | - ! isset($set_column_values[$fieldName]) && |
|
383 | - isset($this->_req_data[$fieldName]) |
|
384 | - ) { |
|
385 | - $set_column_values[$fieldName] = $this->_req_data[$fieldName]; |
|
386 | - } |
|
387 | - |
|
388 | - } |
|
389 | - return $set_column_values;//validation fo this data to be performed by the model before insertion. |
|
390 | - } |
|
391 | - |
|
392 | - |
|
393 | - /** |
|
394 | - *_questions_overview_list_table |
|
395 | - */ |
|
396 | - protected function _questions_overview_list_table() |
|
397 | - { |
|
398 | - $this->_search_btn_label = esc_html__('Questions', 'event_espresso'); |
|
399 | - $this->display_admin_list_table_page_with_sidebar(); |
|
400 | - } |
|
401 | - |
|
402 | - |
|
403 | - /** |
|
404 | - * _edit_question |
|
405 | - */ |
|
406 | - protected function _edit_question() |
|
407 | - { |
|
408 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
409 | - $ID = isset($this->_req_data['QST_ID']) && ! empty($this->_req_data['QST_ID']) ? absint($this->_req_data['QST_ID']) : false; |
|
410 | - |
|
411 | - switch ($this->_req_action) { |
|
412 | - case 'add_question' : |
|
413 | - $this->_admin_page_title = esc_html__('Add Question', 'event_espresso'); |
|
414 | - break; |
|
415 | - case 'edit_question' : |
|
416 | - $this->_admin_page_title = esc_html__('Edit Question', 'event_espresso'); |
|
417 | - break; |
|
418 | - default : |
|
419 | - $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
420 | - } |
|
421 | - |
|
422 | - // add PRC_ID to title if editing |
|
423 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
424 | - if ($ID) { |
|
425 | - $question = $this->_question_model->get_one_by_ID($ID); |
|
426 | - $additional_hidden_fields = array('QST_ID' => array('type' => 'hidden', 'value' => $ID)); |
|
427 | - $this->_set_add_edit_form_tags('update_question', $additional_hidden_fields); |
|
428 | - } else { |
|
429 | - $question = EE_Question::new_instance(); |
|
430 | - $question->set_order_to_latest(); |
|
431 | - $this->_set_add_edit_form_tags('insert_question'); |
|
432 | - } |
|
433 | - if( $question->system_ID() === EEM_Attendee::system_question_phone ){ |
|
434 | - $question_types = array_intersect_key( |
|
435 | - EEM_Question::instance()->allowed_question_types(), |
|
436 | - array_flip( |
|
437 | - array( |
|
438 | - EEM_Question::QST_type_text, |
|
439 | - EEM_Question::QST_type_us_phone |
|
440 | - ) |
|
441 | - ) |
|
442 | - ); |
|
443 | - } else { |
|
444 | - $question_types = $question->has_answers() ? $this->_question_model->question_types_in_same_category($question->type()) : $this->_question_model->allowed_question_types(); |
|
445 | - } |
|
446 | - $this->_template_args['QST_ID'] = $ID; |
|
447 | - $this->_template_args['question'] = $question; |
|
448 | - $this->_template_args['question_types'] = $question_types; |
|
449 | - $this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question( |
|
450 | - $question->system_ID() |
|
451 | - ); |
|
452 | - $this->_template_args['question_type_descriptions'] = $this->_get_question_type_descriptions(); |
|
453 | - $this->_set_publish_post_box_vars('id', $ID); |
|
454 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
455 | - REGISTRATION_FORM_TEMPLATE_PATH . 'questions_main_meta_box.template.php', |
|
456 | - $this->_template_args, true |
|
457 | - ); |
|
458 | - |
|
459 | - // the details template wrapper |
|
460 | - $this->display_admin_page_with_sidebar(); |
|
461 | - } |
|
462 | - |
|
463 | - |
|
464 | - /** |
|
465 | - * @return string |
|
466 | - */ |
|
467 | - protected function _get_question_type_descriptions() |
|
468 | - { |
|
469 | - EE_Registry::instance()->load_helper('HTML'); |
|
470 | - $descriptions = ''; |
|
471 | - $question_type_descriptions = EEM_Question::instance()->question_descriptions(); |
|
472 | - foreach ($question_type_descriptions as $type => $question_type_description) { |
|
473 | - if ($type == 'HTML_TEXTAREA') { |
|
474 | - $html = new EE_Simple_HTML_Validation_Strategy(); |
|
475 | - $question_type_description .= sprintf( |
|
476 | - esc_html__('%1$s(allowed tags: %2$s)', 'event_espresso'), |
|
477 | - '<br/>', |
|
478 | - $html->get_list_of_allowed_tags() |
|
479 | - ); |
|
480 | - } |
|
481 | - $descriptions .= EEH_HTML::p( |
|
482 | - $question_type_description, |
|
483 | - 'question_type_description-' . $type, |
|
484 | - 'question_type_description description', |
|
485 | - 'display:none;' |
|
486 | - ); |
|
487 | - } |
|
488 | - return $descriptions; |
|
489 | - } |
|
490 | - |
|
491 | - |
|
492 | - /** |
|
493 | - * @param bool|true $new_question |
|
494 | - * @throws \EE_Error |
|
495 | - */ |
|
496 | - protected function _insert_or_update_question($new_question = true) |
|
497 | - { |
|
498 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
499 | - $set_column_values = $this->_set_column_values_for($this->_question_model); |
|
500 | - if ($new_question) { |
|
501 | - $ID = $this->_question_model->insert($set_column_values); |
|
502 | - $success = $ID ? true : false; |
|
503 | - $action_desc = 'added'; |
|
504 | - } else { |
|
505 | - $ID = absint($this->_req_data['QST_ID']); |
|
506 | - $pk = $this->_question_model->primary_key_name(); |
|
507 | - $wheres = array($pk => $ID); |
|
508 | - unset($set_column_values[$pk]); |
|
509 | - $success = $this->_question_model->update($set_column_values, array($wheres)); |
|
510 | - $action_desc = 'updated'; |
|
511 | - } |
|
512 | - |
|
513 | - if ($ID) { |
|
514 | - //save the related options |
|
515 | - //trash removed options, save old ones |
|
516 | - //get list of all options |
|
517 | - /** @type EE_Question $question */ |
|
518 | - $question = $this->_question_model->get_one_by_ID($ID); |
|
519 | - $options = $question->options(); |
|
520 | - if (! empty($options)) { |
|
521 | - foreach ($options as $option_ID => $option) { |
|
522 | - $option_req_index = $this->_get_option_req_data_index($option_ID); |
|
523 | - if ($option_req_index !== false) { |
|
524 | - $option->save($this->_req_data['question_options'][$option_req_index]); |
|
525 | - } else { |
|
526 | - //not found, remove it |
|
527 | - $option->delete(); |
|
528 | - } |
|
529 | - } |
|
530 | - } |
|
531 | - //save new related options |
|
532 | - foreach ($this->_req_data['question_options'] as $index => $option_req_data) { |
|
533 | - //skip $index that is from our sample |
|
534 | - if ( $index === 'xxcountxx' ) { |
|
535 | - continue; |
|
536 | - } |
|
537 | - //note we allow saving blank options. |
|
538 | - if (empty($option_req_data['QSO_ID']) |
|
539 | - ) {//no ID! save it! |
|
540 | - $new_option = EE_Question_Option::new_instance(array( |
|
541 | - 'QSO_value' => $option_req_data['QSO_value'], |
|
542 | - 'QSO_desc' => $option_req_data['QSO_desc'], |
|
543 | - 'QSO_order' => $option_req_data['QSO_order'], |
|
544 | - 'QST_ID' => $question->ID(), |
|
545 | - )); |
|
546 | - $new_option->save(); |
|
547 | - } |
|
548 | - } |
|
549 | - } |
|
550 | - $query_args = array('action' => 'edit_question', 'QST_ID' => $ID); |
|
551 | - if ($success !== false) { |
|
552 | - $msg = $new_question ? sprintf(esc_html__('The %s has been created', 'event_espresso'), |
|
553 | - $this->_question_model->item_name()) : sprintf(esc_html__('The %s has been updated', 'event_espresso'), |
|
554 | - $this->_question_model->item_name()); |
|
555 | - EE_Error::add_success($msg); |
|
556 | - } |
|
557 | - |
|
558 | - $this->_redirect_after_action(false, '', $action_desc, $query_args, true); |
|
559 | - } |
|
560 | - |
|
561 | - |
|
562 | - /** |
|
563 | - * Upon saving a question, there should be an array of 'question_options'. This array is index numerically, but not |
|
564 | - * by ID |
|
565 | - * (this is done because new question options don't have an ID, but we may want to add multiple simultaneously). |
|
566 | - * So, this function gets the index in that request data array called question_options. Returns FALSE if not found. |
|
567 | - * |
|
568 | - * @param int $ID of the question option to find |
|
569 | - * @return int index in question_options array if successful, FALSE if unsuccessful |
|
570 | - */ |
|
571 | - protected function _get_option_req_data_index($ID) |
|
572 | - { |
|
573 | - $req_data_for_question_options = $this->_req_data['question_options']; |
|
574 | - foreach ($req_data_for_question_options as $num => $option_data) { |
|
575 | - if (array_key_exists('QSO_ID', $option_data) && (int)$option_data['QSO_ID'] === $ID) { |
|
576 | - return $num; |
|
577 | - } |
|
578 | - } |
|
579 | - return false; |
|
580 | - } |
|
581 | - |
|
582 | - |
|
583 | - |
|
584 | - |
|
585 | - /***********/ |
|
586 | - /* QUERIES */ |
|
587 | - /** |
|
588 | - * For internal use in getting all the query parameters |
|
589 | - * (because it's pretty well the same between question, question groups, |
|
590 | - * and for both when searching for trashed and untrashed ones) |
|
591 | - * |
|
592 | - * @param EEM_Base $model either EEM_Question or EEM_Question_Group |
|
593 | - * @param int $per_page |
|
594 | - * @param int $current_page |
|
595 | - * @return array lik EEM_Base::get_all's $query_params parameter |
|
596 | - */ |
|
597 | - protected function get_query_params($model, $per_page = 10, $current_page = 10) |
|
598 | - { |
|
599 | - $query_params = array(); |
|
600 | - $offset = ($current_page - 1) * $per_page; |
|
601 | - $query_params['limit'] = array($offset, $per_page); |
|
602 | - $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
603 | - $orderby_field = $model instanceof EEM_Question ? 'QST_ID' : 'QSG_order'; |
|
604 | - $field_to_order_by = empty($this->_req_data['orderby']) ? $orderby_field : $this->_req_data['orderby']; |
|
605 | - $query_params['order_by'] = array($field_to_order_by => $order); |
|
606 | - $search_string = array_key_exists('s', $this->_req_data) ? $this->_req_data['s'] : null; |
|
607 | - if (! empty($search_string)) { |
|
608 | - if ($model instanceof EEM_Question_Group) { |
|
609 | - $query_params[0] = array( |
|
610 | - 'OR' => array( |
|
611 | - 'QSG_name' => array('LIKE', "%$search_string%"), |
|
612 | - 'QSG_desc' => array('LIKE', "%$search_string%"), |
|
613 | - ), |
|
614 | - ); |
|
615 | - } else { |
|
616 | - $query_params[0] = array( |
|
617 | - 'QST_display_text' => array('LIKE', "%$search_string%"), |
|
618 | - ); |
|
619 | - } |
|
620 | - } |
|
621 | - |
|
622 | - //capability checks (just leaving this commented out for reference because it illustrates some complicated query params that could be useful when fully implemented) |
|
623 | - /*if ( $model instanceof EEM_Question_Group ) { |
|
357 | + } //if the admin label is blank, use a slug version of the question text |
|
358 | + else if ($fieldName === 'QST_admin_label' && (isset($this->_req_data['QST_admin_label']) && empty($this->_req_data['QST_admin_label']))) { |
|
359 | + $QST_text = isset($this->_req_data['QST_display_text']) ? $this->_req_data['QST_display_text'] : ''; |
|
360 | + $set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text, 10)); |
|
361 | + } else if ($fieldName === 'QST_admin_only' && (! isset($this->_req_data['QST_admin_only']))) { |
|
362 | + $set_column_values[$fieldName] = 0; |
|
363 | + } else if ($fieldName === 'QST_max') { |
|
364 | + $qst_system = EEM_Question::instance()->get_var( |
|
365 | + array( |
|
366 | + array( |
|
367 | + 'QST_ID' => isset($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0, |
|
368 | + ), |
|
369 | + ), |
|
370 | + 'QST_system'); |
|
371 | + $max_max = EEM_Question::instance()->absolute_max_for_system_question($qst_system); |
|
372 | + if (empty($this->_req_data['QST_max']) || |
|
373 | + $this->_req_data['QST_max'] > $max_max |
|
374 | + ) { |
|
375 | + $set_column_values[$fieldName] = $max_max; |
|
376 | + } |
|
377 | + } |
|
378 | + |
|
379 | + |
|
380 | + //only add a property to the array if it's not null (otherwise the model should just use the default value) |
|
381 | + if ( |
|
382 | + ! isset($set_column_values[$fieldName]) && |
|
383 | + isset($this->_req_data[$fieldName]) |
|
384 | + ) { |
|
385 | + $set_column_values[$fieldName] = $this->_req_data[$fieldName]; |
|
386 | + } |
|
387 | + |
|
388 | + } |
|
389 | + return $set_column_values;//validation fo this data to be performed by the model before insertion. |
|
390 | + } |
|
391 | + |
|
392 | + |
|
393 | + /** |
|
394 | + *_questions_overview_list_table |
|
395 | + */ |
|
396 | + protected function _questions_overview_list_table() |
|
397 | + { |
|
398 | + $this->_search_btn_label = esc_html__('Questions', 'event_espresso'); |
|
399 | + $this->display_admin_list_table_page_with_sidebar(); |
|
400 | + } |
|
401 | + |
|
402 | + |
|
403 | + /** |
|
404 | + * _edit_question |
|
405 | + */ |
|
406 | + protected function _edit_question() |
|
407 | + { |
|
408 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
409 | + $ID = isset($this->_req_data['QST_ID']) && ! empty($this->_req_data['QST_ID']) ? absint($this->_req_data['QST_ID']) : false; |
|
410 | + |
|
411 | + switch ($this->_req_action) { |
|
412 | + case 'add_question' : |
|
413 | + $this->_admin_page_title = esc_html__('Add Question', 'event_espresso'); |
|
414 | + break; |
|
415 | + case 'edit_question' : |
|
416 | + $this->_admin_page_title = esc_html__('Edit Question', 'event_espresso'); |
|
417 | + break; |
|
418 | + default : |
|
419 | + $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
420 | + } |
|
421 | + |
|
422 | + // add PRC_ID to title if editing |
|
423 | + $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
424 | + if ($ID) { |
|
425 | + $question = $this->_question_model->get_one_by_ID($ID); |
|
426 | + $additional_hidden_fields = array('QST_ID' => array('type' => 'hidden', 'value' => $ID)); |
|
427 | + $this->_set_add_edit_form_tags('update_question', $additional_hidden_fields); |
|
428 | + } else { |
|
429 | + $question = EE_Question::new_instance(); |
|
430 | + $question->set_order_to_latest(); |
|
431 | + $this->_set_add_edit_form_tags('insert_question'); |
|
432 | + } |
|
433 | + if( $question->system_ID() === EEM_Attendee::system_question_phone ){ |
|
434 | + $question_types = array_intersect_key( |
|
435 | + EEM_Question::instance()->allowed_question_types(), |
|
436 | + array_flip( |
|
437 | + array( |
|
438 | + EEM_Question::QST_type_text, |
|
439 | + EEM_Question::QST_type_us_phone |
|
440 | + ) |
|
441 | + ) |
|
442 | + ); |
|
443 | + } else { |
|
444 | + $question_types = $question->has_answers() ? $this->_question_model->question_types_in_same_category($question->type()) : $this->_question_model->allowed_question_types(); |
|
445 | + } |
|
446 | + $this->_template_args['QST_ID'] = $ID; |
|
447 | + $this->_template_args['question'] = $question; |
|
448 | + $this->_template_args['question_types'] = $question_types; |
|
449 | + $this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question( |
|
450 | + $question->system_ID() |
|
451 | + ); |
|
452 | + $this->_template_args['question_type_descriptions'] = $this->_get_question_type_descriptions(); |
|
453 | + $this->_set_publish_post_box_vars('id', $ID); |
|
454 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
455 | + REGISTRATION_FORM_TEMPLATE_PATH . 'questions_main_meta_box.template.php', |
|
456 | + $this->_template_args, true |
|
457 | + ); |
|
458 | + |
|
459 | + // the details template wrapper |
|
460 | + $this->display_admin_page_with_sidebar(); |
|
461 | + } |
|
462 | + |
|
463 | + |
|
464 | + /** |
|
465 | + * @return string |
|
466 | + */ |
|
467 | + protected function _get_question_type_descriptions() |
|
468 | + { |
|
469 | + EE_Registry::instance()->load_helper('HTML'); |
|
470 | + $descriptions = ''; |
|
471 | + $question_type_descriptions = EEM_Question::instance()->question_descriptions(); |
|
472 | + foreach ($question_type_descriptions as $type => $question_type_description) { |
|
473 | + if ($type == 'HTML_TEXTAREA') { |
|
474 | + $html = new EE_Simple_HTML_Validation_Strategy(); |
|
475 | + $question_type_description .= sprintf( |
|
476 | + esc_html__('%1$s(allowed tags: %2$s)', 'event_espresso'), |
|
477 | + '<br/>', |
|
478 | + $html->get_list_of_allowed_tags() |
|
479 | + ); |
|
480 | + } |
|
481 | + $descriptions .= EEH_HTML::p( |
|
482 | + $question_type_description, |
|
483 | + 'question_type_description-' . $type, |
|
484 | + 'question_type_description description', |
|
485 | + 'display:none;' |
|
486 | + ); |
|
487 | + } |
|
488 | + return $descriptions; |
|
489 | + } |
|
490 | + |
|
491 | + |
|
492 | + /** |
|
493 | + * @param bool|true $new_question |
|
494 | + * @throws \EE_Error |
|
495 | + */ |
|
496 | + protected function _insert_or_update_question($new_question = true) |
|
497 | + { |
|
498 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
499 | + $set_column_values = $this->_set_column_values_for($this->_question_model); |
|
500 | + if ($new_question) { |
|
501 | + $ID = $this->_question_model->insert($set_column_values); |
|
502 | + $success = $ID ? true : false; |
|
503 | + $action_desc = 'added'; |
|
504 | + } else { |
|
505 | + $ID = absint($this->_req_data['QST_ID']); |
|
506 | + $pk = $this->_question_model->primary_key_name(); |
|
507 | + $wheres = array($pk => $ID); |
|
508 | + unset($set_column_values[$pk]); |
|
509 | + $success = $this->_question_model->update($set_column_values, array($wheres)); |
|
510 | + $action_desc = 'updated'; |
|
511 | + } |
|
512 | + |
|
513 | + if ($ID) { |
|
514 | + //save the related options |
|
515 | + //trash removed options, save old ones |
|
516 | + //get list of all options |
|
517 | + /** @type EE_Question $question */ |
|
518 | + $question = $this->_question_model->get_one_by_ID($ID); |
|
519 | + $options = $question->options(); |
|
520 | + if (! empty($options)) { |
|
521 | + foreach ($options as $option_ID => $option) { |
|
522 | + $option_req_index = $this->_get_option_req_data_index($option_ID); |
|
523 | + if ($option_req_index !== false) { |
|
524 | + $option->save($this->_req_data['question_options'][$option_req_index]); |
|
525 | + } else { |
|
526 | + //not found, remove it |
|
527 | + $option->delete(); |
|
528 | + } |
|
529 | + } |
|
530 | + } |
|
531 | + //save new related options |
|
532 | + foreach ($this->_req_data['question_options'] as $index => $option_req_data) { |
|
533 | + //skip $index that is from our sample |
|
534 | + if ( $index === 'xxcountxx' ) { |
|
535 | + continue; |
|
536 | + } |
|
537 | + //note we allow saving blank options. |
|
538 | + if (empty($option_req_data['QSO_ID']) |
|
539 | + ) {//no ID! save it! |
|
540 | + $new_option = EE_Question_Option::new_instance(array( |
|
541 | + 'QSO_value' => $option_req_data['QSO_value'], |
|
542 | + 'QSO_desc' => $option_req_data['QSO_desc'], |
|
543 | + 'QSO_order' => $option_req_data['QSO_order'], |
|
544 | + 'QST_ID' => $question->ID(), |
|
545 | + )); |
|
546 | + $new_option->save(); |
|
547 | + } |
|
548 | + } |
|
549 | + } |
|
550 | + $query_args = array('action' => 'edit_question', 'QST_ID' => $ID); |
|
551 | + if ($success !== false) { |
|
552 | + $msg = $new_question ? sprintf(esc_html__('The %s has been created', 'event_espresso'), |
|
553 | + $this->_question_model->item_name()) : sprintf(esc_html__('The %s has been updated', 'event_espresso'), |
|
554 | + $this->_question_model->item_name()); |
|
555 | + EE_Error::add_success($msg); |
|
556 | + } |
|
557 | + |
|
558 | + $this->_redirect_after_action(false, '', $action_desc, $query_args, true); |
|
559 | + } |
|
560 | + |
|
561 | + |
|
562 | + /** |
|
563 | + * Upon saving a question, there should be an array of 'question_options'. This array is index numerically, but not |
|
564 | + * by ID |
|
565 | + * (this is done because new question options don't have an ID, but we may want to add multiple simultaneously). |
|
566 | + * So, this function gets the index in that request data array called question_options. Returns FALSE if not found. |
|
567 | + * |
|
568 | + * @param int $ID of the question option to find |
|
569 | + * @return int index in question_options array if successful, FALSE if unsuccessful |
|
570 | + */ |
|
571 | + protected function _get_option_req_data_index($ID) |
|
572 | + { |
|
573 | + $req_data_for_question_options = $this->_req_data['question_options']; |
|
574 | + foreach ($req_data_for_question_options as $num => $option_data) { |
|
575 | + if (array_key_exists('QSO_ID', $option_data) && (int)$option_data['QSO_ID'] === $ID) { |
|
576 | + return $num; |
|
577 | + } |
|
578 | + } |
|
579 | + return false; |
|
580 | + } |
|
581 | + |
|
582 | + |
|
583 | + |
|
584 | + |
|
585 | + /***********/ |
|
586 | + /* QUERIES */ |
|
587 | + /** |
|
588 | + * For internal use in getting all the query parameters |
|
589 | + * (because it's pretty well the same between question, question groups, |
|
590 | + * and for both when searching for trashed and untrashed ones) |
|
591 | + * |
|
592 | + * @param EEM_Base $model either EEM_Question or EEM_Question_Group |
|
593 | + * @param int $per_page |
|
594 | + * @param int $current_page |
|
595 | + * @return array lik EEM_Base::get_all's $query_params parameter |
|
596 | + */ |
|
597 | + protected function get_query_params($model, $per_page = 10, $current_page = 10) |
|
598 | + { |
|
599 | + $query_params = array(); |
|
600 | + $offset = ($current_page - 1) * $per_page; |
|
601 | + $query_params['limit'] = array($offset, $per_page); |
|
602 | + $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
603 | + $orderby_field = $model instanceof EEM_Question ? 'QST_ID' : 'QSG_order'; |
|
604 | + $field_to_order_by = empty($this->_req_data['orderby']) ? $orderby_field : $this->_req_data['orderby']; |
|
605 | + $query_params['order_by'] = array($field_to_order_by => $order); |
|
606 | + $search_string = array_key_exists('s', $this->_req_data) ? $this->_req_data['s'] : null; |
|
607 | + if (! empty($search_string)) { |
|
608 | + if ($model instanceof EEM_Question_Group) { |
|
609 | + $query_params[0] = array( |
|
610 | + 'OR' => array( |
|
611 | + 'QSG_name' => array('LIKE', "%$search_string%"), |
|
612 | + 'QSG_desc' => array('LIKE', "%$search_string%"), |
|
613 | + ), |
|
614 | + ); |
|
615 | + } else { |
|
616 | + $query_params[0] = array( |
|
617 | + 'QST_display_text' => array('LIKE', "%$search_string%"), |
|
618 | + ); |
|
619 | + } |
|
620 | + } |
|
621 | + |
|
622 | + //capability checks (just leaving this commented out for reference because it illustrates some complicated query params that could be useful when fully implemented) |
|
623 | + /*if ( $model instanceof EEM_Question_Group ) { |
|
624 | 624 | if ( ! EE_Registry::instance()->CAP->current_user_can( 'edit_others_question_groups', 'espresso_registration_form_edit_question_group' ) ) { |
625 | 625 | $query_params[0] = array( |
626 | 626 | 'AND' => array( |
@@ -650,62 +650,62 @@ discard block |
||
650 | 650 | } |
651 | 651 | }/**/ |
652 | 652 | |
653 | - return $query_params; |
|
654 | - |
|
655 | - } |
|
656 | - |
|
657 | - |
|
658 | - /** |
|
659 | - * @param int $per_page |
|
660 | - * @param int $current_page |
|
661 | - * @param bool|false $count |
|
662 | - * @return \EE_Soft_Delete_Base_Class[]|int |
|
663 | - */ |
|
664 | - public function get_questions($per_page = 10, $current_page = 1, $count = false) |
|
665 | - { |
|
666 | - $QST = EEM_Question::instance(); |
|
667 | - $query_params = $this->get_query_params($QST, $per_page, $current_page); |
|
668 | - if ($count) { |
|
669 | - $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
670 | - $results = $QST->count($where); |
|
671 | - } else { |
|
672 | - $results = $QST->get_all($query_params); |
|
673 | - } |
|
674 | - return $results; |
|
675 | - |
|
676 | - } |
|
677 | - |
|
678 | - |
|
679 | - /** |
|
680 | - * @param $per_page |
|
681 | - * @param int $current_page |
|
682 | - * @param bool|false $count |
|
683 | - * @return \EE_Soft_Delete_Base_Class[]|int |
|
684 | - */ |
|
685 | - public function get_trashed_questions($per_page, $current_page = 1, $count = false) |
|
686 | - { |
|
687 | - $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
|
688 | - $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
689 | - $questions = $count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params); |
|
690 | - return $questions; |
|
691 | - } |
|
692 | - |
|
693 | - |
|
694 | - /** |
|
695 | - * @param $per_page |
|
696 | - * @param int $current_page |
|
697 | - * @param bool|false $count |
|
698 | - * @return \EE_Soft_Delete_Base_Class[] |
|
699 | - */ |
|
700 | - public function get_question_groups($per_page, $current_page = 1, $count = false) |
|
701 | - { |
|
702 | - /** @type EEM_Question_Group $questionGroupModel */ |
|
703 | - $questionGroupModel = EEM_Question_Group::instance(); |
|
704 | - //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
705 | - return $questionGroupModel->get_all( |
|
706 | - $this->get_query_params($questionGroupModel, $per_page, $current_page) |
|
707 | - ); |
|
708 | - } |
|
653 | + return $query_params; |
|
654 | + |
|
655 | + } |
|
656 | + |
|
657 | + |
|
658 | + /** |
|
659 | + * @param int $per_page |
|
660 | + * @param int $current_page |
|
661 | + * @param bool|false $count |
|
662 | + * @return \EE_Soft_Delete_Base_Class[]|int |
|
663 | + */ |
|
664 | + public function get_questions($per_page = 10, $current_page = 1, $count = false) |
|
665 | + { |
|
666 | + $QST = EEM_Question::instance(); |
|
667 | + $query_params = $this->get_query_params($QST, $per_page, $current_page); |
|
668 | + if ($count) { |
|
669 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
670 | + $results = $QST->count($where); |
|
671 | + } else { |
|
672 | + $results = $QST->get_all($query_params); |
|
673 | + } |
|
674 | + return $results; |
|
675 | + |
|
676 | + } |
|
677 | + |
|
678 | + |
|
679 | + /** |
|
680 | + * @param $per_page |
|
681 | + * @param int $current_page |
|
682 | + * @param bool|false $count |
|
683 | + * @return \EE_Soft_Delete_Base_Class[]|int |
|
684 | + */ |
|
685 | + public function get_trashed_questions($per_page, $current_page = 1, $count = false) |
|
686 | + { |
|
687 | + $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
|
688 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
689 | + $questions = $count ? EEM_Question::instance()->count_deleted($where) : EEM_Question::instance()->get_all_deleted($query_params); |
|
690 | + return $questions; |
|
691 | + } |
|
692 | + |
|
693 | + |
|
694 | + /** |
|
695 | + * @param $per_page |
|
696 | + * @param int $current_page |
|
697 | + * @param bool|false $count |
|
698 | + * @return \EE_Soft_Delete_Base_Class[] |
|
699 | + */ |
|
700 | + public function get_question_groups($per_page, $current_page = 1, $count = false) |
|
701 | + { |
|
702 | + /** @type EEM_Question_Group $questionGroupModel */ |
|
703 | + $questionGroupModel = EEM_Question_Group::instance(); |
|
704 | + //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
705 | + return $questionGroupModel->get_all( |
|
706 | + $this->get_query_params($questionGroupModel, $per_page, $current_page) |
|
707 | + ); |
|
708 | + } |
|
709 | 709 | |
710 | 710 | |
711 | 711 | } //ends Registration_Form_Admin_Page class |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | } |
5 | 5 | |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function __construct($routing = true) |
68 | 68 | { |
69 | - require_once(EE_MODELS . 'EEM_Question.model.php'); |
|
70 | - require_once(EE_MODELS . 'EEM_Question_Group.model.php'); |
|
69 | + require_once(EE_MODELS.'EEM_Question.model.php'); |
|
70 | + require_once(EE_MODELS.'EEM_Question_Group.model.php'); |
|
71 | 71 | $this->_question_model = EEM_Question::instance(); |
72 | 72 | $this->_question_group_model = EEM_Question_Group::instance(); |
73 | 73 | parent::__construct($routing); |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | public function load_scripts_styles() |
233 | 233 | { |
234 | 234 | wp_register_style('espresso_registration', |
235 | - REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
235 | + REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
236 | 236 | wp_enqueue_style('espresso_registration'); |
237 | 237 | } |
238 | 238 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | { |
259 | 259 | $this->load_scripts_styles_forms(); |
260 | 260 | wp_register_script('espresso_registration_form_single', |
261 | - REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), |
|
261 | + REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.js', array('jquery-ui-sortable'), |
|
262 | 262 | EVENT_ESPRESSO_VERSION, true); |
263 | 263 | wp_enqueue_script('espresso_registration_form_single'); |
264 | 264 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | { |
268 | 268 | $this->load_scripts_styles_forms(); |
269 | 269 | wp_register_script('espresso_registration_form_single', |
270 | - REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js', array('jquery-ui-sortable'), |
|
270 | + REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.js', array('jquery-ui-sortable'), |
|
271 | 271 | EVENT_ESPRESSO_VERSION, true); |
272 | 272 | wp_enqueue_script('espresso_registration_form_single'); |
273 | 273 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | |
276 | 276 | public function recaptcha_info_help_tab() |
277 | 277 | { |
278 | - $template = REGISTRATION_FORM_TEMPLATE_PATH . 'recaptcha_info_help_tab.template.php'; |
|
278 | + $template = REGISTRATION_FORM_TEMPLATE_PATH.'recaptcha_info_help_tab.template.php'; |
|
279 | 279 | EEH_Template::display_template($template, array()); |
280 | 280 | } |
281 | 281 | |
@@ -324,10 +324,10 @@ discard block |
||
324 | 324 | protected function _questions_groups_preview() |
325 | 325 | { |
326 | 326 | $this->_admin_page_title = esc_html__('Question Groups (Preview)', 'event_espresso'); |
327 | - $this->_template_args['preview_img'] = '<img src="' . REGISTRATION_FORM_ASSETS_URL . 'caf_reg_form_preview.jpg" alt="' . esc_attr__('Preview Question Groups Overview List Table screenshot', |
|
328 | - 'event_espresso') . '" />'; |
|
329 | - $this->_template_args['preview_text'] = '<strong>' . esc_html__('Question Groups is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. With the Question Groups feature you are able to create new question groups, edit existing question groups, and create and edit new questions and add them to question groups.', |
|
330 | - 'event_espresso') . '</strong>'; |
|
327 | + $this->_template_args['preview_img'] = '<img src="'.REGISTRATION_FORM_ASSETS_URL.'caf_reg_form_preview.jpg" alt="'.esc_attr__('Preview Question Groups Overview List Table screenshot', |
|
328 | + 'event_espresso').'" />'; |
|
329 | + $this->_template_args['preview_text'] = '<strong>'.esc_html__('Question Groups is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. With the Question Groups feature you are able to create new question groups, edit existing question groups, and create and edit new questions and add them to question groups.', |
|
330 | + 'event_espresso').'</strong>'; |
|
331 | 331 | $this->display_admin_caf_preview_page('question_groups_tab'); |
332 | 332 | } |
333 | 333 | |
@@ -345,20 +345,20 @@ discard block |
||
345 | 345 | |
346 | 346 | //some initial checks for proper values. |
347 | 347 | //if QST_admin_only, then no matter what QST_required is we disable. |
348 | - if (! empty($this->_req_data['QST_admin_only'])) { |
|
348 | + if ( ! empty($this->_req_data['QST_admin_only'])) { |
|
349 | 349 | $this->_req_data['QST_required'] = 0; |
350 | 350 | } |
351 | 351 | foreach ($model->field_settings() as $fieldName => $settings) { |
352 | 352 | // basically if QSG_identifier is empty or not set |
353 | 353 | if ($fieldName === 'QSG_identifier' && (isset($this->_req_data['QSG_identifier']) && empty($this->_req_data['QSG_identifier']))) { |
354 | 354 | $QSG_name = isset($this->_req_data['QSG_name']) ? $this->_req_data['QSG_name'] : ''; |
355 | - $set_column_values[$fieldName] = sanitize_title($QSG_name) . '-' . uniqid('', true); |
|
355 | + $set_column_values[$fieldName] = sanitize_title($QSG_name).'-'.uniqid('', true); |
|
356 | 356 | // dd($set_column_values); |
357 | 357 | } //if the admin label is blank, use a slug version of the question text |
358 | 358 | else if ($fieldName === 'QST_admin_label' && (isset($this->_req_data['QST_admin_label']) && empty($this->_req_data['QST_admin_label']))) { |
359 | 359 | $QST_text = isset($this->_req_data['QST_display_text']) ? $this->_req_data['QST_display_text'] : ''; |
360 | 360 | $set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text, 10)); |
361 | - } else if ($fieldName === 'QST_admin_only' && (! isset($this->_req_data['QST_admin_only']))) { |
|
361 | + } else if ($fieldName === 'QST_admin_only' && ( ! isset($this->_req_data['QST_admin_only']))) { |
|
362 | 362 | $set_column_values[$fieldName] = 0; |
363 | 363 | } else if ($fieldName === 'QST_max') { |
364 | 364 | $qst_system = EEM_Question::instance()->get_var( |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | ), |
369 | 369 | ), |
370 | 370 | 'QST_system'); |
371 | - $max_max = EEM_Question::instance()->absolute_max_for_system_question($qst_system); |
|
371 | + $max_max = EEM_Question::instance()->absolute_max_for_system_question($qst_system); |
|
372 | 372 | if (empty($this->_req_data['QST_max']) || |
373 | 373 | $this->_req_data['QST_max'] > $max_max |
374 | 374 | ) { |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | } |
387 | 387 | |
388 | 388 | } |
389 | - return $set_column_values;//validation fo this data to be performed by the model before insertion. |
|
389 | + return $set_column_values; //validation fo this data to be performed by the model before insertion. |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | } |
421 | 421 | |
422 | 422 | // add PRC_ID to title if editing |
423 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
423 | + $this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title; |
|
424 | 424 | if ($ID) { |
425 | 425 | $question = $this->_question_model->get_one_by_ID($ID); |
426 | 426 | $additional_hidden_fields = array('QST_ID' => array('type' => 'hidden', 'value' => $ID)); |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | $question->set_order_to_latest(); |
431 | 431 | $this->_set_add_edit_form_tags('insert_question'); |
432 | 432 | } |
433 | - if( $question->system_ID() === EEM_Attendee::system_question_phone ){ |
|
433 | + if ($question->system_ID() === EEM_Attendee::system_question_phone) { |
|
434 | 434 | $question_types = array_intersect_key( |
435 | 435 | EEM_Question::instance()->allowed_question_types(), |
436 | 436 | array_flip( |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | $this->_template_args['question_type_descriptions'] = $this->_get_question_type_descriptions(); |
453 | 453 | $this->_set_publish_post_box_vars('id', $ID); |
454 | 454 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
455 | - REGISTRATION_FORM_TEMPLATE_PATH . 'questions_main_meta_box.template.php', |
|
455 | + REGISTRATION_FORM_TEMPLATE_PATH.'questions_main_meta_box.template.php', |
|
456 | 456 | $this->_template_args, true |
457 | 457 | ); |
458 | 458 | |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | } |
481 | 481 | $descriptions .= EEH_HTML::p( |
482 | 482 | $question_type_description, |
483 | - 'question_type_description-' . $type, |
|
483 | + 'question_type_description-'.$type, |
|
484 | 484 | 'question_type_description description', |
485 | 485 | 'display:none;' |
486 | 486 | ); |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | /** @type EE_Question $question */ |
518 | 518 | $question = $this->_question_model->get_one_by_ID($ID); |
519 | 519 | $options = $question->options(); |
520 | - if (! empty($options)) { |
|
520 | + if ( ! empty($options)) { |
|
521 | 521 | foreach ($options as $option_ID => $option) { |
522 | 522 | $option_req_index = $this->_get_option_req_data_index($option_ID); |
523 | 523 | if ($option_req_index !== false) { |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | //save new related options |
532 | 532 | foreach ($this->_req_data['question_options'] as $index => $option_req_data) { |
533 | 533 | //skip $index that is from our sample |
534 | - if ( $index === 'xxcountxx' ) { |
|
534 | + if ($index === 'xxcountxx') { |
|
535 | 535 | continue; |
536 | 536 | } |
537 | 537 | //note we allow saving blank options. |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | { |
573 | 573 | $req_data_for_question_options = $this->_req_data['question_options']; |
574 | 574 | foreach ($req_data_for_question_options as $num => $option_data) { |
575 | - if (array_key_exists('QSO_ID', $option_data) && (int)$option_data['QSO_ID'] === $ID) { |
|
575 | + if (array_key_exists('QSO_ID', $option_data) && (int) $option_data['QSO_ID'] === $ID) { |
|
576 | 576 | return $num; |
577 | 577 | } |
578 | 578 | } |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | $field_to_order_by = empty($this->_req_data['orderby']) ? $orderby_field : $this->_req_data['orderby']; |
605 | 605 | $query_params['order_by'] = array($field_to_order_by => $order); |
606 | 606 | $search_string = array_key_exists('s', $this->_req_data) ? $this->_req_data['s'] : null; |
607 | - if (! empty($search_string)) { |
|
607 | + if ( ! empty($search_string)) { |
|
608 | 608 | if ($model instanceof EEM_Question_Group) { |
609 | 609 | $query_params[0] = array( |
610 | 610 | 'OR' => array( |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('NO direct script access allowed'); |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * Event Espresso |
@@ -16,35 +16,35 @@ discard block |
||
16 | 16 | |
17 | 17 | |
18 | 18 | if ( ! function_exists('espresso_get_template_part')) { |
19 | - /** |
|
20 | - * espresso_get_template_part |
|
21 | - * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files |
|
22 | - * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name |
|
23 | - * |
|
24 | - * @param string $slug The slug name for the generic template. |
|
25 | - * @param string $name The name of the specialised template. |
|
26 | - * @return string the html output for the formatted money value |
|
27 | - */ |
|
28 | - function espresso_get_template_part($slug = null, $name = null) |
|
29 | - { |
|
30 | - EEH_Template::get_template_part($slug, $name); |
|
31 | - } |
|
19 | + /** |
|
20 | + * espresso_get_template_part |
|
21 | + * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files |
|
22 | + * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name |
|
23 | + * |
|
24 | + * @param string $slug The slug name for the generic template. |
|
25 | + * @param string $name The name of the specialised template. |
|
26 | + * @return string the html output for the formatted money value |
|
27 | + */ |
|
28 | + function espresso_get_template_part($slug = null, $name = null) |
|
29 | + { |
|
30 | + EEH_Template::get_template_part($slug, $name); |
|
31 | + } |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
35 | 35 | if ( ! function_exists('espresso_get_object_css_class')) { |
36 | - /** |
|
37 | - * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed |
|
38 | - * |
|
39 | - * @param EE_Base_Class $object the EE object the css class is being generated for |
|
40 | - * @param string $prefix added to the beginning of the generated class |
|
41 | - * @param string $suffix added to the end of the generated class |
|
42 | - * @return string |
|
43 | - */ |
|
44 | - function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '') |
|
45 | - { |
|
46 | - return EEH_Template::get_object_css_class($object, $prefix, $suffix); |
|
47 | - } |
|
36 | + /** |
|
37 | + * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed |
|
38 | + * |
|
39 | + * @param EE_Base_Class $object the EE object the css class is being generated for |
|
40 | + * @param string $prefix added to the beginning of the generated class |
|
41 | + * @param string $suffix added to the end of the generated class |
|
42 | + * @return string |
|
43 | + */ |
|
44 | + function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '') |
|
45 | + { |
|
46 | + return EEH_Template::get_object_css_class($object, $prefix, $suffix); |
|
47 | + } |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | |
@@ -59,650 +59,650 @@ discard block |
||
59 | 59 | class EEH_Template |
60 | 60 | { |
61 | 61 | |
62 | - private static $_espresso_themes = array(); |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme |
|
67 | - * |
|
68 | - * @return boolean |
|
69 | - */ |
|
70 | - public static function is_espresso_theme() |
|
71 | - { |
|
72 | - return wp_get_theme()->get('TextDomain') == 'event_espresso' ? true : false; |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then |
|
77 | - * load it's functions.php file ( if not already loaded ) |
|
78 | - * |
|
79 | - * @return void |
|
80 | - */ |
|
81 | - public static function load_espresso_theme_functions() |
|
82 | - { |
|
83 | - if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
|
84 | - if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) { |
|
85 | - require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php'); |
|
86 | - } |
|
87 | - } |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory |
|
93 | - * |
|
94 | - * @return array |
|
95 | - */ |
|
96 | - public static function get_espresso_themes() |
|
97 | - { |
|
98 | - if (empty(EEH_Template::$_espresso_themes)) { |
|
99 | - $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR); |
|
100 | - if (empty($espresso_themes)) { |
|
101 | - return array(); |
|
102 | - } |
|
103 | - if (($key = array_search('global_assets', $espresso_themes)) !== false) { |
|
104 | - unset($espresso_themes[$key]); |
|
105 | - } |
|
106 | - EEH_Template::$_espresso_themes = array(); |
|
107 | - foreach ($espresso_themes as $espresso_theme) { |
|
108 | - EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme; |
|
109 | - } |
|
110 | - } |
|
111 | - return EEH_Template::$_espresso_themes; |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * EEH_Template::get_template_part |
|
117 | - * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, |
|
118 | - * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS |
|
119 | - * filtering based off of the entire template part name |
|
120 | - * |
|
121 | - * @param string $slug The slug name for the generic template. |
|
122 | - * @param string $name The name of the specialised template. |
|
123 | - * @param array $template_args |
|
124 | - * @param bool $return_string |
|
125 | - * @return string the html output for the formatted money value |
|
126 | - */ |
|
127 | - public static function get_template_part( |
|
128 | - $slug = null, |
|
129 | - $name = null, |
|
130 | - $template_args = array(), |
|
131 | - $return_string = false |
|
132 | - ) { |
|
133 | - do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
|
134 | - $templates = array(); |
|
135 | - $name = (string)$name; |
|
136 | - if ($name != '') { |
|
137 | - $templates[] = "{$slug}-{$name}.php"; |
|
138 | - } |
|
139 | - // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' ); |
|
140 | - if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) { |
|
141 | - EEH_Template::locate_template($templates, $template_args, true, $return_string); |
|
142 | - } |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * locate_template |
|
148 | - * locate a template file by looking in the following places, in the following order: |
|
149 | - * <server path up to>/wp-content/themes/<current active WordPress theme>/ |
|
150 | - * <assumed full absolute server path> |
|
151 | - * <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/ |
|
152 | - * <server path up to>/wp-content/uploads/espresso/templates/ |
|
153 | - * <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/ |
|
154 | - * <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/ |
|
155 | - * <server path up to>/wp-content/plugins/<EE4 folder>/ |
|
156 | - * as soon as the template is found in one of these locations, it will be returned or loaded |
|
157 | - * Example: |
|
158 | - * You are using the WordPress Twenty Sixteen theme, |
|
159 | - * and you want to customize the "some-event.template.php" template, |
|
160 | - * which is located in the "/relative/path/to/" folder relative to the main EE plugin folder. |
|
161 | - * Assuming WP is installed on your server in the "/home/public_html/" folder, |
|
162 | - * EEH_Template::locate_template() will look at the following paths in order until the template is found: |
|
163 | - * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php |
|
164 | - * /relative/path/to/some-event.template.php |
|
165 | - * /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
166 | - * /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php |
|
167 | - * /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
168 | - * /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
169 | - * /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php |
|
170 | - * Had you passed an absolute path to your template that was in some other location, |
|
171 | - * ie: "/absolute/path/to/some-event.template.php" |
|
172 | - * then the search would have been : |
|
173 | - * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php |
|
174 | - * /absolute/path/to/some-event.template.php |
|
175 | - * and stopped there upon finding it in the second location |
|
176 | - * |
|
177 | - * @param array|string $templates array of template file names including extension (or just a single string) |
|
178 | - * @param array $template_args an array of arguments to be extracted for use in the template |
|
179 | - * @param boolean $load whether to pass the located template path on to the |
|
180 | - * EEH_Template::display_template() method or simply return it |
|
181 | - * @param boolean $return_string whether to send output immediately to screen, or capture and return as a |
|
182 | - * string |
|
183 | - * @param boolean $check_if_custom If TRUE, this flags this method to return boolean for whether this will |
|
184 | - * generate a custom template or not. Used in places where you don't actually |
|
185 | - * load the template, you just want to know if there's a custom version of it. |
|
186 | - * @return mixed |
|
187 | - */ |
|
188 | - public static function locate_template( |
|
189 | - $templates = array(), |
|
190 | - $template_args = array(), |
|
191 | - $load = true, |
|
192 | - $return_string = true, |
|
193 | - $check_if_custom = false |
|
194 | - ) { |
|
195 | - // first use WP locate_template to check for template in the current theme folder |
|
196 | - $template_path = locate_template($templates); |
|
197 | - |
|
198 | - if ($check_if_custom && ! empty($template_path)) { |
|
199 | - return true; |
|
200 | - } |
|
201 | - |
|
202 | - // not in the theme |
|
203 | - if (empty($template_path)) { |
|
204 | - // not even a template to look for ? |
|
205 | - if (empty($templates)) { |
|
206 | - // get post_type |
|
207 | - $post_type = EE_Registry::instance()->REQ->get('post_type'); |
|
208 | - // get array of EE Custom Post Types |
|
209 | - $EE_CPTs = EE_Register_CPTs::get_CPTs(); |
|
210 | - // build template name based on request |
|
211 | - if (isset($EE_CPTs[$post_type])) { |
|
212 | - $archive_or_single = is_archive() ? 'archive' : ''; |
|
213 | - $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
214 | - $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
215 | - } |
|
216 | - } |
|
217 | - // currently active EE template theme |
|
218 | - $current_theme = EE_Config::get_current_theme(); |
|
219 | - |
|
220 | - // array of paths to folders that may contain templates |
|
221 | - $template_folder_paths = array( |
|
222 | - // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
|
223 | - EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
224 | - // then in the root of the /wp-content/uploads/espresso/templates/ folder |
|
225 | - EVENT_ESPRESSO_TEMPLATE_DIR, |
|
226 | - ); |
|
227 | - |
|
228 | - //add core plugin folders for checking only if we're not $check_if_custom |
|
229 | - if ( ! $check_if_custom) { |
|
230 | - $core_paths = array( |
|
231 | - // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
|
232 | - EE_PUBLIC . $current_theme, |
|
233 | - // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
|
234 | - EE_TEMPLATES . $current_theme, |
|
235 | - // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
|
236 | - EE_PLUGIN_DIR_PATH, |
|
237 | - ); |
|
238 | - $template_folder_paths = array_merge($template_folder_paths, $core_paths); |
|
239 | - } |
|
240 | - |
|
241 | - // now filter that array |
|
242 | - $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', |
|
243 | - $template_folder_paths); |
|
244 | - $templates = is_array($templates) ? $templates : array($templates); |
|
245 | - $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths); |
|
246 | - // array to hold all possible template paths |
|
247 | - $full_template_paths = array(); |
|
248 | - |
|
249 | - // loop through $templates |
|
250 | - foreach ($templates as $template) { |
|
251 | - // normalize directory separators |
|
252 | - $template = EEH_File::standardise_directory_separators($template); |
|
253 | - $file_name = basename($template); |
|
254 | - $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1)); |
|
255 | - // while looping through all template folder paths |
|
256 | - foreach ($template_folder_paths as $template_folder_path) { |
|
257 | - // normalize directory separators |
|
258 | - $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path); |
|
259 | - // determine if any common base path exists between the two paths |
|
260 | - $common_base_path = EEH_Template::_find_common_base_path( |
|
261 | - array($template_folder_path, $template_path_minus_file_name) |
|
262 | - ); |
|
263 | - if ($common_base_path !== '') { |
|
264 | - // both paths have a common base, so just tack the filename onto our search path |
|
265 | - $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name; |
|
266 | - } else { |
|
267 | - // no common base path, so let's just concatenate |
|
268 | - $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template; |
|
269 | - } |
|
270 | - // build up our template locations array by adding our resolved paths |
|
271 | - $full_template_paths[] = $resolved_path; |
|
272 | - } |
|
273 | - // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
|
274 | - array_unshift($full_template_paths, $template); |
|
275 | - // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
|
276 | - array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name); |
|
277 | - } |
|
278 | - // filter final array of full template paths |
|
279 | - $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', |
|
280 | - $full_template_paths, $file_name); |
|
281 | - // now loop through our final array of template location paths and check each location |
|
282 | - foreach ((array)$full_template_paths as $full_template_path) { |
|
283 | - if (is_readable($full_template_path)) { |
|
284 | - $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
|
285 | - break; |
|
286 | - } |
|
287 | - } |
|
288 | - } |
|
289 | - |
|
290 | - // hook that can be used to display the full template path that will be used |
|
291 | - do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path); |
|
292 | - |
|
293 | - // if we got it and you want to see it... |
|
294 | - if ($template_path && $load && ! $check_if_custom) { |
|
295 | - if ($return_string) { |
|
296 | - return EEH_Template::display_template($template_path, $template_args, true); |
|
297 | - } else { |
|
298 | - EEH_Template::display_template($template_path, $template_args, false); |
|
299 | - } |
|
300 | - } |
|
301 | - return $check_if_custom && ! empty($template_path) ? true : $template_path; |
|
302 | - } |
|
303 | - |
|
304 | - |
|
305 | - /** |
|
306 | - * _find_common_base_path |
|
307 | - * given two paths, this determines if there is a common base path between the two |
|
308 | - * |
|
309 | - * @param array $paths |
|
310 | - * @return string |
|
311 | - */ |
|
312 | - protected static function _find_common_base_path($paths) |
|
313 | - { |
|
314 | - $last_offset = 0; |
|
315 | - $common_base_path = ''; |
|
316 | - while (($index = strpos($paths[0], DS, $last_offset)) !== false) { |
|
317 | - $dir_length = $index - $last_offset + 1; |
|
318 | - $directory = substr($paths[0], $last_offset, $dir_length); |
|
319 | - foreach ($paths as $path) { |
|
320 | - if (substr($path, $last_offset, $dir_length) != $directory) { |
|
321 | - return $common_base_path; |
|
322 | - } |
|
323 | - } |
|
324 | - $common_base_path .= $directory; |
|
325 | - $last_offset = $index + 1; |
|
326 | - } |
|
327 | - return substr($common_base_path, 0, -1); |
|
328 | - } |
|
329 | - |
|
330 | - |
|
331 | - /** |
|
332 | - * load and display a template |
|
333 | - * |
|
334 | - * @param bool|string $template_path server path to the file to be loaded, including file name and extension |
|
335 | - * @param array $template_args an array of arguments to be extracted for use in the template |
|
336 | - * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
|
337 | - * @param bool $throw_exceptions if set to true, will throw an exception if the template is either |
|
338 | - * not found or is not readable |
|
339 | - * @return mixed string |
|
340 | - * @throws \DomainException |
|
341 | - */ |
|
62 | + private static $_espresso_themes = array(); |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme |
|
67 | + * |
|
68 | + * @return boolean |
|
69 | + */ |
|
70 | + public static function is_espresso_theme() |
|
71 | + { |
|
72 | + return wp_get_theme()->get('TextDomain') == 'event_espresso' ? true : false; |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then |
|
77 | + * load it's functions.php file ( if not already loaded ) |
|
78 | + * |
|
79 | + * @return void |
|
80 | + */ |
|
81 | + public static function load_espresso_theme_functions() |
|
82 | + { |
|
83 | + if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
|
84 | + if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) { |
|
85 | + require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php'); |
|
86 | + } |
|
87 | + } |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory |
|
93 | + * |
|
94 | + * @return array |
|
95 | + */ |
|
96 | + public static function get_espresso_themes() |
|
97 | + { |
|
98 | + if (empty(EEH_Template::$_espresso_themes)) { |
|
99 | + $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR); |
|
100 | + if (empty($espresso_themes)) { |
|
101 | + return array(); |
|
102 | + } |
|
103 | + if (($key = array_search('global_assets', $espresso_themes)) !== false) { |
|
104 | + unset($espresso_themes[$key]); |
|
105 | + } |
|
106 | + EEH_Template::$_espresso_themes = array(); |
|
107 | + foreach ($espresso_themes as $espresso_theme) { |
|
108 | + EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme; |
|
109 | + } |
|
110 | + } |
|
111 | + return EEH_Template::$_espresso_themes; |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * EEH_Template::get_template_part |
|
117 | + * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, |
|
118 | + * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS |
|
119 | + * filtering based off of the entire template part name |
|
120 | + * |
|
121 | + * @param string $slug The slug name for the generic template. |
|
122 | + * @param string $name The name of the specialised template. |
|
123 | + * @param array $template_args |
|
124 | + * @param bool $return_string |
|
125 | + * @return string the html output for the formatted money value |
|
126 | + */ |
|
127 | + public static function get_template_part( |
|
128 | + $slug = null, |
|
129 | + $name = null, |
|
130 | + $template_args = array(), |
|
131 | + $return_string = false |
|
132 | + ) { |
|
133 | + do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
|
134 | + $templates = array(); |
|
135 | + $name = (string)$name; |
|
136 | + if ($name != '') { |
|
137 | + $templates[] = "{$slug}-{$name}.php"; |
|
138 | + } |
|
139 | + // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' ); |
|
140 | + if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) { |
|
141 | + EEH_Template::locate_template($templates, $template_args, true, $return_string); |
|
142 | + } |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * locate_template |
|
148 | + * locate a template file by looking in the following places, in the following order: |
|
149 | + * <server path up to>/wp-content/themes/<current active WordPress theme>/ |
|
150 | + * <assumed full absolute server path> |
|
151 | + * <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/ |
|
152 | + * <server path up to>/wp-content/uploads/espresso/templates/ |
|
153 | + * <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/ |
|
154 | + * <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/ |
|
155 | + * <server path up to>/wp-content/plugins/<EE4 folder>/ |
|
156 | + * as soon as the template is found in one of these locations, it will be returned or loaded |
|
157 | + * Example: |
|
158 | + * You are using the WordPress Twenty Sixteen theme, |
|
159 | + * and you want to customize the "some-event.template.php" template, |
|
160 | + * which is located in the "/relative/path/to/" folder relative to the main EE plugin folder. |
|
161 | + * Assuming WP is installed on your server in the "/home/public_html/" folder, |
|
162 | + * EEH_Template::locate_template() will look at the following paths in order until the template is found: |
|
163 | + * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php |
|
164 | + * /relative/path/to/some-event.template.php |
|
165 | + * /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
166 | + * /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php |
|
167 | + * /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
168 | + * /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
169 | + * /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php |
|
170 | + * Had you passed an absolute path to your template that was in some other location, |
|
171 | + * ie: "/absolute/path/to/some-event.template.php" |
|
172 | + * then the search would have been : |
|
173 | + * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php |
|
174 | + * /absolute/path/to/some-event.template.php |
|
175 | + * and stopped there upon finding it in the second location |
|
176 | + * |
|
177 | + * @param array|string $templates array of template file names including extension (or just a single string) |
|
178 | + * @param array $template_args an array of arguments to be extracted for use in the template |
|
179 | + * @param boolean $load whether to pass the located template path on to the |
|
180 | + * EEH_Template::display_template() method or simply return it |
|
181 | + * @param boolean $return_string whether to send output immediately to screen, or capture and return as a |
|
182 | + * string |
|
183 | + * @param boolean $check_if_custom If TRUE, this flags this method to return boolean for whether this will |
|
184 | + * generate a custom template or not. Used in places where you don't actually |
|
185 | + * load the template, you just want to know if there's a custom version of it. |
|
186 | + * @return mixed |
|
187 | + */ |
|
188 | + public static function locate_template( |
|
189 | + $templates = array(), |
|
190 | + $template_args = array(), |
|
191 | + $load = true, |
|
192 | + $return_string = true, |
|
193 | + $check_if_custom = false |
|
194 | + ) { |
|
195 | + // first use WP locate_template to check for template in the current theme folder |
|
196 | + $template_path = locate_template($templates); |
|
197 | + |
|
198 | + if ($check_if_custom && ! empty($template_path)) { |
|
199 | + return true; |
|
200 | + } |
|
201 | + |
|
202 | + // not in the theme |
|
203 | + if (empty($template_path)) { |
|
204 | + // not even a template to look for ? |
|
205 | + if (empty($templates)) { |
|
206 | + // get post_type |
|
207 | + $post_type = EE_Registry::instance()->REQ->get('post_type'); |
|
208 | + // get array of EE Custom Post Types |
|
209 | + $EE_CPTs = EE_Register_CPTs::get_CPTs(); |
|
210 | + // build template name based on request |
|
211 | + if (isset($EE_CPTs[$post_type])) { |
|
212 | + $archive_or_single = is_archive() ? 'archive' : ''; |
|
213 | + $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
214 | + $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
215 | + } |
|
216 | + } |
|
217 | + // currently active EE template theme |
|
218 | + $current_theme = EE_Config::get_current_theme(); |
|
219 | + |
|
220 | + // array of paths to folders that may contain templates |
|
221 | + $template_folder_paths = array( |
|
222 | + // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
|
223 | + EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
224 | + // then in the root of the /wp-content/uploads/espresso/templates/ folder |
|
225 | + EVENT_ESPRESSO_TEMPLATE_DIR, |
|
226 | + ); |
|
227 | + |
|
228 | + //add core plugin folders for checking only if we're not $check_if_custom |
|
229 | + if ( ! $check_if_custom) { |
|
230 | + $core_paths = array( |
|
231 | + // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
|
232 | + EE_PUBLIC . $current_theme, |
|
233 | + // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
|
234 | + EE_TEMPLATES . $current_theme, |
|
235 | + // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
|
236 | + EE_PLUGIN_DIR_PATH, |
|
237 | + ); |
|
238 | + $template_folder_paths = array_merge($template_folder_paths, $core_paths); |
|
239 | + } |
|
240 | + |
|
241 | + // now filter that array |
|
242 | + $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', |
|
243 | + $template_folder_paths); |
|
244 | + $templates = is_array($templates) ? $templates : array($templates); |
|
245 | + $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths); |
|
246 | + // array to hold all possible template paths |
|
247 | + $full_template_paths = array(); |
|
248 | + |
|
249 | + // loop through $templates |
|
250 | + foreach ($templates as $template) { |
|
251 | + // normalize directory separators |
|
252 | + $template = EEH_File::standardise_directory_separators($template); |
|
253 | + $file_name = basename($template); |
|
254 | + $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1)); |
|
255 | + // while looping through all template folder paths |
|
256 | + foreach ($template_folder_paths as $template_folder_path) { |
|
257 | + // normalize directory separators |
|
258 | + $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path); |
|
259 | + // determine if any common base path exists between the two paths |
|
260 | + $common_base_path = EEH_Template::_find_common_base_path( |
|
261 | + array($template_folder_path, $template_path_minus_file_name) |
|
262 | + ); |
|
263 | + if ($common_base_path !== '') { |
|
264 | + // both paths have a common base, so just tack the filename onto our search path |
|
265 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name; |
|
266 | + } else { |
|
267 | + // no common base path, so let's just concatenate |
|
268 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template; |
|
269 | + } |
|
270 | + // build up our template locations array by adding our resolved paths |
|
271 | + $full_template_paths[] = $resolved_path; |
|
272 | + } |
|
273 | + // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
|
274 | + array_unshift($full_template_paths, $template); |
|
275 | + // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
|
276 | + array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name); |
|
277 | + } |
|
278 | + // filter final array of full template paths |
|
279 | + $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', |
|
280 | + $full_template_paths, $file_name); |
|
281 | + // now loop through our final array of template location paths and check each location |
|
282 | + foreach ((array)$full_template_paths as $full_template_path) { |
|
283 | + if (is_readable($full_template_path)) { |
|
284 | + $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
|
285 | + break; |
|
286 | + } |
|
287 | + } |
|
288 | + } |
|
289 | + |
|
290 | + // hook that can be used to display the full template path that will be used |
|
291 | + do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path); |
|
292 | + |
|
293 | + // if we got it and you want to see it... |
|
294 | + if ($template_path && $load && ! $check_if_custom) { |
|
295 | + if ($return_string) { |
|
296 | + return EEH_Template::display_template($template_path, $template_args, true); |
|
297 | + } else { |
|
298 | + EEH_Template::display_template($template_path, $template_args, false); |
|
299 | + } |
|
300 | + } |
|
301 | + return $check_if_custom && ! empty($template_path) ? true : $template_path; |
|
302 | + } |
|
303 | + |
|
304 | + |
|
305 | + /** |
|
306 | + * _find_common_base_path |
|
307 | + * given two paths, this determines if there is a common base path between the two |
|
308 | + * |
|
309 | + * @param array $paths |
|
310 | + * @return string |
|
311 | + */ |
|
312 | + protected static function _find_common_base_path($paths) |
|
313 | + { |
|
314 | + $last_offset = 0; |
|
315 | + $common_base_path = ''; |
|
316 | + while (($index = strpos($paths[0], DS, $last_offset)) !== false) { |
|
317 | + $dir_length = $index - $last_offset + 1; |
|
318 | + $directory = substr($paths[0], $last_offset, $dir_length); |
|
319 | + foreach ($paths as $path) { |
|
320 | + if (substr($path, $last_offset, $dir_length) != $directory) { |
|
321 | + return $common_base_path; |
|
322 | + } |
|
323 | + } |
|
324 | + $common_base_path .= $directory; |
|
325 | + $last_offset = $index + 1; |
|
326 | + } |
|
327 | + return substr($common_base_path, 0, -1); |
|
328 | + } |
|
329 | + |
|
330 | + |
|
331 | + /** |
|
332 | + * load and display a template |
|
333 | + * |
|
334 | + * @param bool|string $template_path server path to the file to be loaded, including file name and extension |
|
335 | + * @param array $template_args an array of arguments to be extracted for use in the template |
|
336 | + * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
|
337 | + * @param bool $throw_exceptions if set to true, will throw an exception if the template is either |
|
338 | + * not found or is not readable |
|
339 | + * @return mixed string |
|
340 | + * @throws \DomainException |
|
341 | + */ |
|
342 | 342 | public static function display_template( |
343 | - $template_path = false, |
|
344 | - $template_args = array(), |
|
345 | - $return_string = false, |
|
346 | - $throw_exceptions = false |
|
347 | - ) { |
|
348 | - |
|
349 | - /** |
|
350 | - * These two filters are intended for last minute changes to templates being loaded and/or template arg |
|
351 | - * modifications. NOTE... modifying these things can cause breakage as most templates running through |
|
352 | - * the display_template method are templates we DON'T want modified (usually because of js |
|
353 | - * dependencies etc). So unless you know what you are doing, do NOT filter templates or template args |
|
354 | - * using this. |
|
355 | - * |
|
356 | - * @since 4.6.0 |
|
357 | - */ |
|
358 | - $template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
359 | - $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
360 | - |
|
361 | - // you gimme nuttin - YOU GET NUTTIN !! |
|
362 | - if ( ! $template_path || ! is_readable($template_path)) { |
|
363 | - return ''; |
|
364 | - } |
|
365 | - // if $template_args are not in an array, then make it so |
|
366 | - if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
367 | - $template_args = array($template_args); |
|
368 | - } |
|
369 | - extract( $template_args, EXTR_SKIP ); |
|
370 | - // ignore whether template is accessible ? |
|
371 | - if ( $throw_exceptions && ! is_readable( $template_path ) ) { |
|
372 | - throw new \DomainException( |
|
373 | - esc_html__( |
|
374 | - 'Invalid, unreadable, or missing file.', |
|
375 | - 'event_espresso' |
|
376 | - ) |
|
377 | - ); |
|
378 | - } |
|
379 | - |
|
380 | - |
|
381 | - if ($return_string) { |
|
382 | - // because we want to return a string, we are going to capture the output |
|
383 | - ob_start(); |
|
384 | - include($template_path); |
|
385 | - return ob_get_clean(); |
|
386 | - } else { |
|
387 | - include($template_path); |
|
388 | - } |
|
389 | - return ''; |
|
390 | - } |
|
391 | - |
|
392 | - |
|
393 | - /** |
|
394 | - * get_object_css_class - attempts to generate a css class based on the type of EE object passed |
|
395 | - * |
|
396 | - * @param EE_Base_Class $object the EE object the css class is being generated for |
|
397 | - * @param string $prefix added to the beginning of the generated class |
|
398 | - * @param string $suffix added to the end of the generated class |
|
399 | - * @return string |
|
400 | - */ |
|
401 | - public static function get_object_css_class($object = null, $prefix = '', $suffix = '') |
|
402 | - { |
|
403 | - // in the beginning... |
|
404 | - $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : ''; |
|
405 | - // da muddle |
|
406 | - $class = ''; |
|
407 | - // the end |
|
408 | - $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : ''; |
|
409 | - // is the passed object an EE object ? |
|
410 | - if ($object instanceof EE_Base_Class) { |
|
411 | - // grab the exact type of object |
|
412 | - $obj_class = get_class($object); |
|
413 | - // depending on the type of object... |
|
414 | - switch ($obj_class) { |
|
415 | - // no specifics just yet... |
|
416 | - default : |
|
417 | - $class = strtolower(str_replace('_', '-', $obj_class)); |
|
418 | - $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : ''; |
|
419 | - |
|
420 | - } |
|
421 | - } |
|
422 | - return $prefix . $class . $suffix; |
|
423 | - } |
|
424 | - |
|
425 | - |
|
426 | - |
|
427 | - /** |
|
428 | - * EEH_Template::format_currency |
|
429 | - * This helper takes a raw float value and formats it according to the default config country currency settings, or |
|
430 | - * the country currency settings from the supplied country ISO code |
|
431 | - * |
|
432 | - * @param float $amount raw money value |
|
433 | - * @param boolean $return_raw whether to return the formatted float value only with no currency sign or code |
|
434 | - * @param boolean $display_code whether to display the country code (USD). Default = TRUE |
|
435 | - * @param string $CNT_ISO 2 letter ISO code for a country |
|
436 | - * @param string $cur_code_span_class |
|
437 | - * @return string the html output for the formatted money value |
|
438 | - * @throws \EE_Error |
|
439 | - */ |
|
440 | - public static function format_currency( |
|
441 | - $amount = null, |
|
442 | - $return_raw = false, |
|
443 | - $display_code = true, |
|
444 | - $CNT_ISO = '', |
|
445 | - $cur_code_span_class = 'currency-code' |
|
446 | - ) { |
|
447 | - // ensure amount was received |
|
448 | - if ($amount === null) { |
|
449 | - $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
450 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
451 | - return ''; |
|
452 | - } |
|
453 | - //ensure amount is float |
|
454 | - $amount = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float)$amount); |
|
455 | - $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount); |
|
456 | - // filter raw amount (allows 0.00 to be changed to "free" for example) |
|
457 | - $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
458 | - // still a number or was amount converted to a string like "free" ? |
|
459 | - if (is_float($amount_formatted)) { |
|
460 | - // was a country ISO code passed ? if so generate currency config object for that country |
|
461 | - $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null; |
|
462 | - // verify results |
|
463 | - if ( ! $mny instanceof EE_Currency_Config) { |
|
464 | - // set default config country currency settings |
|
465 | - $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
|
466 | - ? EE_Registry::instance()->CFG->currency |
|
467 | - : new EE_Currency_Config(); |
|
468 | - } |
|
469 | - // format float |
|
470 | - $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
471 | - // add formatting ? |
|
472 | - if ( ! $return_raw) { |
|
473 | - // add currency sign |
|
474 | - if ($mny->sign_b4) { |
|
475 | - if ($amount >= 0) { |
|
476 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
477 | - } else { |
|
478 | - $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted); |
|
479 | - } |
|
480 | - |
|
481 | - } else { |
|
482 | - $amount_formatted = $amount_formatted . $mny->sign; |
|
483 | - } |
|
484 | - |
|
485 | - // filter to allow global setting of display_code |
|
486 | - $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code); |
|
487 | - |
|
488 | - // add currency code ? |
|
489 | - $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
490 | - } |
|
491 | - // filter results |
|
492 | - $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', |
|
493 | - $amount_formatted, $mny, $return_raw); |
|
494 | - } |
|
495 | - // clean up vars |
|
496 | - unset($mny); |
|
497 | - // return formatted currency amount |
|
498 | - return $amount_formatted; |
|
499 | - } |
|
500 | - |
|
501 | - |
|
502 | - /** |
|
503 | - * This function is used for outputting the localized label for a given status id in the schema requested (and |
|
504 | - * possibly plural). The intended use of this function is only for cases where wanting a label outside of a |
|
505 | - * related status model or model object (i.e. in documentation etc.) |
|
506 | - * |
|
507 | - * @param string $status_id Status ID matching a registered status in the esp_status table. If there is no |
|
508 | - * match, then 'Unknown' will be returned. |
|
509 | - * @param boolean $plural Whether to return plural or not |
|
510 | - * @param string $schema 'UPPER', 'lower', or 'Sentence' |
|
511 | - * @return string The localized label for the status id. |
|
512 | - */ |
|
513 | - public static function pretty_status($status_id, $plural = false, $schema = 'upper') |
|
514 | - { |
|
515 | - /** @type EEM_Status $EEM_Status */ |
|
516 | - $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
517 | - $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, |
|
518 | - $schema); |
|
519 | - return $status[$status_id]; |
|
520 | - } |
|
521 | - |
|
522 | - |
|
523 | - /** |
|
524 | - * This helper just returns a button or link for the given parameters |
|
525 | - * |
|
526 | - * @param string $url the url for the link |
|
527 | - * @param string $label What is the label you want displayed for the button |
|
528 | - * @param string $class what class is used for the button (defaults to 'button-primary') |
|
529 | - * @param string $icon |
|
530 | - * @param string $title |
|
531 | - * @return string the html output for the button |
|
532 | - */ |
|
533 | - public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '') |
|
534 | - { |
|
535 | - $icon_html = ''; |
|
536 | - if ( ! empty($icon)) { |
|
537 | - $dashicons = preg_split("(ee-icon |dashicons )", $icon); |
|
538 | - $dashicons = array_filter($dashicons); |
|
539 | - $count = count($dashicons); |
|
540 | - $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : ''; |
|
541 | - foreach ($dashicons as $dashicon) { |
|
542 | - $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons '; |
|
543 | - $icon_html .= '<span class="' . $type . $dashicon . '"></span>'; |
|
544 | - } |
|
545 | - $icon_html .= $count > 1 ? '</span>' : ''; |
|
546 | - } |
|
547 | - $label = ! empty($icon) ? $icon_html . $label : $label; |
|
548 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>'; |
|
549 | - return $button; |
|
550 | - } |
|
551 | - |
|
552 | - |
|
553 | - /** |
|
554 | - * This returns a generated link that will load the related help tab on admin pages. |
|
555 | - * |
|
556 | - * @param string $help_tab_id the id for the connected help tab |
|
557 | - * @param bool|string $page The page identifier for the page the help tab is on |
|
558 | - * @param bool|string $action The action (route) for the admin page the help tab is on. |
|
559 | - * @param bool|string $icon_style (optional) include css class for the style you want to use for the help icon. |
|
560 | - * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
|
561 | - * @return string generated link |
|
562 | - */ |
|
563 | - public static function get_help_tab_link( |
|
564 | - $help_tab_id, |
|
565 | - $page = false, |
|
566 | - $action = false, |
|
567 | - $icon_style = false, |
|
568 | - $help_text = false |
|
569 | - ) { |
|
570 | - |
|
571 | - if ( ! $page) { |
|
572 | - $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
573 | - } |
|
574 | - |
|
575 | - if ( ! $action) { |
|
576 | - $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
577 | - } |
|
578 | - |
|
579 | - $action = empty($action) ? 'default' : $action; |
|
580 | - |
|
581 | - |
|
582 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
583 | - $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
584 | - $help_text = ! $help_text ? '' : $help_text; |
|
585 | - return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', |
|
586 | - 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
587 | - } |
|
588 | - |
|
589 | - |
|
590 | - /** |
|
591 | - * This helper generates the html structure for the jquery joyride plugin with the given params. |
|
592 | - * |
|
593 | - * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin |
|
594 | - * @see EE_Admin_Page->_stop_callback() for the construct expected for the $stops param. |
|
595 | - * @param EE_Help_Tour |
|
596 | - * @return string html |
|
597 | - */ |
|
598 | - public static function help_tour_stops_generator(EE_Help_Tour $tour) |
|
599 | - { |
|
600 | - $id = $tour->get_slug(); |
|
601 | - $stops = $tour->get_stops(); |
|
602 | - |
|
603 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
604 | - |
|
605 | - foreach ($stops as $stop) { |
|
606 | - $data_id = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
607 | - $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
608 | - |
|
609 | - //if container is set to modal then let's make sure we set the options accordingly |
|
610 | - if (empty($data_id) && empty($data_class)) { |
|
611 | - $stop['options']['modal'] = true; |
|
612 | - $stop['options']['expose'] = true; |
|
613 | - } |
|
614 | - |
|
615 | - $custom_class = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
616 | - $button_text = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
617 | - $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
|
618 | - |
|
619 | - //options |
|
620 | - if (isset($stop['options']) && is_array($stop['options'])) { |
|
621 | - $options = ' data-options="'; |
|
622 | - foreach ($stop['options'] as $option => $value) { |
|
623 | - $options .= $option . ':' . $value . ';'; |
|
624 | - } |
|
625 | - $options .= '"'; |
|
626 | - } else { |
|
627 | - $options = ''; |
|
628 | - } |
|
629 | - |
|
630 | - //let's put all together |
|
631 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
632 | - } |
|
633 | - |
|
634 | - $content .= '</ol>'; |
|
635 | - return $content; |
|
636 | - } |
|
637 | - |
|
638 | - |
|
639 | - /** |
|
640 | - * This is a helper method to generate a status legend for a given status array. |
|
641 | - * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods |
|
642 | - * status_array. |
|
643 | - * |
|
644 | - * @param array $status_array array of statuses that will make up the legend. In format: |
|
645 | - * array( |
|
646 | - * 'status_item' => 'status_name' |
|
647 | - * ) |
|
648 | - * @param string $active_status This is used to indicate what the active status is IF that is to be highlighted in |
|
649 | - * the legend. |
|
650 | - * @throws EE_Error |
|
651 | - * @return string html structure for status. |
|
652 | - */ |
|
653 | - public static function status_legend($status_array, $active_status = '') |
|
654 | - { |
|
655 | - if ( ! is_array($status_array)) { |
|
656 | - throw new EE_Error(esc_html__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', |
|
657 | - 'event_espresso')); |
|
658 | - } |
|
659 | - |
|
660 | - $setup_array = array(); |
|
661 | - foreach ($status_array as $item => $status) { |
|
662 | - $setup_array[$item] = array( |
|
663 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
664 | - 'desc' => EEH_Template::pretty_status($status, false, 'sentence'), |
|
665 | - 'status' => $status, |
|
666 | - ); |
|
667 | - } |
|
668 | - |
|
669 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
670 | - $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n"; |
|
671 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
672 | - foreach ($setup_array as $item => $details) { |
|
673 | - $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
|
674 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
675 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
676 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
677 | - $content .= '</dt>' . "\n"; |
|
678 | - } |
|
679 | - $content .= '</dl>' . "\n"; |
|
680 | - $content .= '</div>' . "\n"; |
|
681 | - return $content; |
|
682 | - } |
|
683 | - |
|
684 | - |
|
685 | - /** |
|
686 | - * Gets HTML for laying out a deeply-nested array (and objects) in a format |
|
687 | - * that's nice for presenting in the wp admin |
|
688 | - * |
|
689 | - * @param mixed $data |
|
690 | - * @return string |
|
691 | - */ |
|
692 | - public static function layout_array_as_table($data) |
|
693 | - { |
|
694 | - if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
695 | - $data = (array)$data; |
|
696 | - } |
|
697 | - ob_start(); |
|
698 | - if (is_array($data)) { |
|
699 | - if (EEH_Array::is_associative_array($data)) { |
|
700 | - ?> |
|
343 | + $template_path = false, |
|
344 | + $template_args = array(), |
|
345 | + $return_string = false, |
|
346 | + $throw_exceptions = false |
|
347 | + ) { |
|
348 | + |
|
349 | + /** |
|
350 | + * These two filters are intended for last minute changes to templates being loaded and/or template arg |
|
351 | + * modifications. NOTE... modifying these things can cause breakage as most templates running through |
|
352 | + * the display_template method are templates we DON'T want modified (usually because of js |
|
353 | + * dependencies etc). So unless you know what you are doing, do NOT filter templates or template args |
|
354 | + * using this. |
|
355 | + * |
|
356 | + * @since 4.6.0 |
|
357 | + */ |
|
358 | + $template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
359 | + $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
360 | + |
|
361 | + // you gimme nuttin - YOU GET NUTTIN !! |
|
362 | + if ( ! $template_path || ! is_readable($template_path)) { |
|
363 | + return ''; |
|
364 | + } |
|
365 | + // if $template_args are not in an array, then make it so |
|
366 | + if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
367 | + $template_args = array($template_args); |
|
368 | + } |
|
369 | + extract( $template_args, EXTR_SKIP ); |
|
370 | + // ignore whether template is accessible ? |
|
371 | + if ( $throw_exceptions && ! is_readable( $template_path ) ) { |
|
372 | + throw new \DomainException( |
|
373 | + esc_html__( |
|
374 | + 'Invalid, unreadable, or missing file.', |
|
375 | + 'event_espresso' |
|
376 | + ) |
|
377 | + ); |
|
378 | + } |
|
379 | + |
|
380 | + |
|
381 | + if ($return_string) { |
|
382 | + // because we want to return a string, we are going to capture the output |
|
383 | + ob_start(); |
|
384 | + include($template_path); |
|
385 | + return ob_get_clean(); |
|
386 | + } else { |
|
387 | + include($template_path); |
|
388 | + } |
|
389 | + return ''; |
|
390 | + } |
|
391 | + |
|
392 | + |
|
393 | + /** |
|
394 | + * get_object_css_class - attempts to generate a css class based on the type of EE object passed |
|
395 | + * |
|
396 | + * @param EE_Base_Class $object the EE object the css class is being generated for |
|
397 | + * @param string $prefix added to the beginning of the generated class |
|
398 | + * @param string $suffix added to the end of the generated class |
|
399 | + * @return string |
|
400 | + */ |
|
401 | + public static function get_object_css_class($object = null, $prefix = '', $suffix = '') |
|
402 | + { |
|
403 | + // in the beginning... |
|
404 | + $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : ''; |
|
405 | + // da muddle |
|
406 | + $class = ''; |
|
407 | + // the end |
|
408 | + $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : ''; |
|
409 | + // is the passed object an EE object ? |
|
410 | + if ($object instanceof EE_Base_Class) { |
|
411 | + // grab the exact type of object |
|
412 | + $obj_class = get_class($object); |
|
413 | + // depending on the type of object... |
|
414 | + switch ($obj_class) { |
|
415 | + // no specifics just yet... |
|
416 | + default : |
|
417 | + $class = strtolower(str_replace('_', '-', $obj_class)); |
|
418 | + $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : ''; |
|
419 | + |
|
420 | + } |
|
421 | + } |
|
422 | + return $prefix . $class . $suffix; |
|
423 | + } |
|
424 | + |
|
425 | + |
|
426 | + |
|
427 | + /** |
|
428 | + * EEH_Template::format_currency |
|
429 | + * This helper takes a raw float value and formats it according to the default config country currency settings, or |
|
430 | + * the country currency settings from the supplied country ISO code |
|
431 | + * |
|
432 | + * @param float $amount raw money value |
|
433 | + * @param boolean $return_raw whether to return the formatted float value only with no currency sign or code |
|
434 | + * @param boolean $display_code whether to display the country code (USD). Default = TRUE |
|
435 | + * @param string $CNT_ISO 2 letter ISO code for a country |
|
436 | + * @param string $cur_code_span_class |
|
437 | + * @return string the html output for the formatted money value |
|
438 | + * @throws \EE_Error |
|
439 | + */ |
|
440 | + public static function format_currency( |
|
441 | + $amount = null, |
|
442 | + $return_raw = false, |
|
443 | + $display_code = true, |
|
444 | + $CNT_ISO = '', |
|
445 | + $cur_code_span_class = 'currency-code' |
|
446 | + ) { |
|
447 | + // ensure amount was received |
|
448 | + if ($amount === null) { |
|
449 | + $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
450 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
451 | + return ''; |
|
452 | + } |
|
453 | + //ensure amount is float |
|
454 | + $amount = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float)$amount); |
|
455 | + $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount); |
|
456 | + // filter raw amount (allows 0.00 to be changed to "free" for example) |
|
457 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
458 | + // still a number or was amount converted to a string like "free" ? |
|
459 | + if (is_float($amount_formatted)) { |
|
460 | + // was a country ISO code passed ? if so generate currency config object for that country |
|
461 | + $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null; |
|
462 | + // verify results |
|
463 | + if ( ! $mny instanceof EE_Currency_Config) { |
|
464 | + // set default config country currency settings |
|
465 | + $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
|
466 | + ? EE_Registry::instance()->CFG->currency |
|
467 | + : new EE_Currency_Config(); |
|
468 | + } |
|
469 | + // format float |
|
470 | + $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
471 | + // add formatting ? |
|
472 | + if ( ! $return_raw) { |
|
473 | + // add currency sign |
|
474 | + if ($mny->sign_b4) { |
|
475 | + if ($amount >= 0) { |
|
476 | + $amount_formatted = $mny->sign . $amount_formatted; |
|
477 | + } else { |
|
478 | + $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted); |
|
479 | + } |
|
480 | + |
|
481 | + } else { |
|
482 | + $amount_formatted = $amount_formatted . $mny->sign; |
|
483 | + } |
|
484 | + |
|
485 | + // filter to allow global setting of display_code |
|
486 | + $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code); |
|
487 | + |
|
488 | + // add currency code ? |
|
489 | + $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
490 | + } |
|
491 | + // filter results |
|
492 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', |
|
493 | + $amount_formatted, $mny, $return_raw); |
|
494 | + } |
|
495 | + // clean up vars |
|
496 | + unset($mny); |
|
497 | + // return formatted currency amount |
|
498 | + return $amount_formatted; |
|
499 | + } |
|
500 | + |
|
501 | + |
|
502 | + /** |
|
503 | + * This function is used for outputting the localized label for a given status id in the schema requested (and |
|
504 | + * possibly plural). The intended use of this function is only for cases where wanting a label outside of a |
|
505 | + * related status model or model object (i.e. in documentation etc.) |
|
506 | + * |
|
507 | + * @param string $status_id Status ID matching a registered status in the esp_status table. If there is no |
|
508 | + * match, then 'Unknown' will be returned. |
|
509 | + * @param boolean $plural Whether to return plural or not |
|
510 | + * @param string $schema 'UPPER', 'lower', or 'Sentence' |
|
511 | + * @return string The localized label for the status id. |
|
512 | + */ |
|
513 | + public static function pretty_status($status_id, $plural = false, $schema = 'upper') |
|
514 | + { |
|
515 | + /** @type EEM_Status $EEM_Status */ |
|
516 | + $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
517 | + $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, |
|
518 | + $schema); |
|
519 | + return $status[$status_id]; |
|
520 | + } |
|
521 | + |
|
522 | + |
|
523 | + /** |
|
524 | + * This helper just returns a button or link for the given parameters |
|
525 | + * |
|
526 | + * @param string $url the url for the link |
|
527 | + * @param string $label What is the label you want displayed for the button |
|
528 | + * @param string $class what class is used for the button (defaults to 'button-primary') |
|
529 | + * @param string $icon |
|
530 | + * @param string $title |
|
531 | + * @return string the html output for the button |
|
532 | + */ |
|
533 | + public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '') |
|
534 | + { |
|
535 | + $icon_html = ''; |
|
536 | + if ( ! empty($icon)) { |
|
537 | + $dashicons = preg_split("(ee-icon |dashicons )", $icon); |
|
538 | + $dashicons = array_filter($dashicons); |
|
539 | + $count = count($dashicons); |
|
540 | + $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : ''; |
|
541 | + foreach ($dashicons as $dashicon) { |
|
542 | + $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons '; |
|
543 | + $icon_html .= '<span class="' . $type . $dashicon . '"></span>'; |
|
544 | + } |
|
545 | + $icon_html .= $count > 1 ? '</span>' : ''; |
|
546 | + } |
|
547 | + $label = ! empty($icon) ? $icon_html . $label : $label; |
|
548 | + $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>'; |
|
549 | + return $button; |
|
550 | + } |
|
551 | + |
|
552 | + |
|
553 | + /** |
|
554 | + * This returns a generated link that will load the related help tab on admin pages. |
|
555 | + * |
|
556 | + * @param string $help_tab_id the id for the connected help tab |
|
557 | + * @param bool|string $page The page identifier for the page the help tab is on |
|
558 | + * @param bool|string $action The action (route) for the admin page the help tab is on. |
|
559 | + * @param bool|string $icon_style (optional) include css class for the style you want to use for the help icon. |
|
560 | + * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
|
561 | + * @return string generated link |
|
562 | + */ |
|
563 | + public static function get_help_tab_link( |
|
564 | + $help_tab_id, |
|
565 | + $page = false, |
|
566 | + $action = false, |
|
567 | + $icon_style = false, |
|
568 | + $help_text = false |
|
569 | + ) { |
|
570 | + |
|
571 | + if ( ! $page) { |
|
572 | + $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
573 | + } |
|
574 | + |
|
575 | + if ( ! $action) { |
|
576 | + $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
577 | + } |
|
578 | + |
|
579 | + $action = empty($action) ? 'default' : $action; |
|
580 | + |
|
581 | + |
|
582 | + $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
583 | + $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
584 | + $help_text = ! $help_text ? '' : $help_text; |
|
585 | + return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', |
|
586 | + 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
587 | + } |
|
588 | + |
|
589 | + |
|
590 | + /** |
|
591 | + * This helper generates the html structure for the jquery joyride plugin with the given params. |
|
592 | + * |
|
593 | + * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin |
|
594 | + * @see EE_Admin_Page->_stop_callback() for the construct expected for the $stops param. |
|
595 | + * @param EE_Help_Tour |
|
596 | + * @return string html |
|
597 | + */ |
|
598 | + public static function help_tour_stops_generator(EE_Help_Tour $tour) |
|
599 | + { |
|
600 | + $id = $tour->get_slug(); |
|
601 | + $stops = $tour->get_stops(); |
|
602 | + |
|
603 | + $content = '<ol style="display:none" id="' . $id . '">'; |
|
604 | + |
|
605 | + foreach ($stops as $stop) { |
|
606 | + $data_id = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
607 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
608 | + |
|
609 | + //if container is set to modal then let's make sure we set the options accordingly |
|
610 | + if (empty($data_id) && empty($data_class)) { |
|
611 | + $stop['options']['modal'] = true; |
|
612 | + $stop['options']['expose'] = true; |
|
613 | + } |
|
614 | + |
|
615 | + $custom_class = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
616 | + $button_text = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
617 | + $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
|
618 | + |
|
619 | + //options |
|
620 | + if (isset($stop['options']) && is_array($stop['options'])) { |
|
621 | + $options = ' data-options="'; |
|
622 | + foreach ($stop['options'] as $option => $value) { |
|
623 | + $options .= $option . ':' . $value . ';'; |
|
624 | + } |
|
625 | + $options .= '"'; |
|
626 | + } else { |
|
627 | + $options = ''; |
|
628 | + } |
|
629 | + |
|
630 | + //let's put all together |
|
631 | + $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
632 | + } |
|
633 | + |
|
634 | + $content .= '</ol>'; |
|
635 | + return $content; |
|
636 | + } |
|
637 | + |
|
638 | + |
|
639 | + /** |
|
640 | + * This is a helper method to generate a status legend for a given status array. |
|
641 | + * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods |
|
642 | + * status_array. |
|
643 | + * |
|
644 | + * @param array $status_array array of statuses that will make up the legend. In format: |
|
645 | + * array( |
|
646 | + * 'status_item' => 'status_name' |
|
647 | + * ) |
|
648 | + * @param string $active_status This is used to indicate what the active status is IF that is to be highlighted in |
|
649 | + * the legend. |
|
650 | + * @throws EE_Error |
|
651 | + * @return string html structure for status. |
|
652 | + */ |
|
653 | + public static function status_legend($status_array, $active_status = '') |
|
654 | + { |
|
655 | + if ( ! is_array($status_array)) { |
|
656 | + throw new EE_Error(esc_html__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', |
|
657 | + 'event_espresso')); |
|
658 | + } |
|
659 | + |
|
660 | + $setup_array = array(); |
|
661 | + foreach ($status_array as $item => $status) { |
|
662 | + $setup_array[$item] = array( |
|
663 | + 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
664 | + 'desc' => EEH_Template::pretty_status($status, false, 'sentence'), |
|
665 | + 'status' => $status, |
|
666 | + ); |
|
667 | + } |
|
668 | + |
|
669 | + $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
670 | + $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n"; |
|
671 | + $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
672 | + foreach ($setup_array as $item => $details) { |
|
673 | + $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
|
674 | + $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
675 | + $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
676 | + $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
677 | + $content .= '</dt>' . "\n"; |
|
678 | + } |
|
679 | + $content .= '</dl>' . "\n"; |
|
680 | + $content .= '</div>' . "\n"; |
|
681 | + return $content; |
|
682 | + } |
|
683 | + |
|
684 | + |
|
685 | + /** |
|
686 | + * Gets HTML for laying out a deeply-nested array (and objects) in a format |
|
687 | + * that's nice for presenting in the wp admin |
|
688 | + * |
|
689 | + * @param mixed $data |
|
690 | + * @return string |
|
691 | + */ |
|
692 | + public static function layout_array_as_table($data) |
|
693 | + { |
|
694 | + if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
695 | + $data = (array)$data; |
|
696 | + } |
|
697 | + ob_start(); |
|
698 | + if (is_array($data)) { |
|
699 | + if (EEH_Array::is_associative_array($data)) { |
|
700 | + ?> |
|
701 | 701 | <table class="widefat"> |
702 | 702 | <tbody> |
703 | 703 | <?php |
704 | - foreach ($data as $data_key => $data_values) { |
|
705 | - ?> |
|
704 | + foreach ($data as $data_key => $data_values) { |
|
705 | + ?> |
|
706 | 706 | <tr> |
707 | 707 | <td> |
708 | 708 | <?php echo $data_key; ?> |
@@ -712,248 +712,248 @@ discard block |
||
712 | 712 | </td> |
713 | 713 | </tr> |
714 | 714 | <?php |
715 | - } ?> |
|
715 | + } ?> |
|
716 | 716 | </tbody> |
717 | 717 | </table> |
718 | 718 | <?php |
719 | - } else { |
|
720 | - ?> |
|
719 | + } else { |
|
720 | + ?> |
|
721 | 721 | <ul> |
722 | 722 | <?php |
723 | - foreach ($data as $datum) { |
|
724 | - echo "<li>"; |
|
725 | - echo self::layout_array_as_table($datum); |
|
726 | - echo "</li>"; |
|
727 | - } ?> |
|
723 | + foreach ($data as $datum) { |
|
724 | + echo "<li>"; |
|
725 | + echo self::layout_array_as_table($datum); |
|
726 | + echo "</li>"; |
|
727 | + } ?> |
|
728 | 728 | </ul> |
729 | 729 | <?php |
730 | - } |
|
731 | - } else { |
|
732 | - //simple value |
|
733 | - echo esc_html($data); |
|
734 | - } |
|
735 | - return ob_get_clean(); |
|
736 | - } |
|
737 | - |
|
738 | - |
|
739 | - /** |
|
740 | - * wrapper for self::get_paging_html() that simply echos the generated paging html |
|
741 | - * |
|
742 | - * @since 4.4.0 |
|
743 | - * @see self:get_paging_html() for argument docs. |
|
744 | - * @param $total_items |
|
745 | - * @param $current |
|
746 | - * @param $per_page |
|
747 | - * @param $url |
|
748 | - * @param bool $show_num_field |
|
749 | - * @param string $paged_arg_name |
|
750 | - * @param array $items_label |
|
751 | - * @return string |
|
752 | - */ |
|
753 | - public static function paging_html( |
|
754 | - $total_items, |
|
755 | - $current, |
|
756 | - $per_page, |
|
757 | - $url, |
|
758 | - $show_num_field = true, |
|
759 | - $paged_arg_name = 'paged', |
|
760 | - $items_label = array() |
|
761 | - ) { |
|
762 | - echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, |
|
763 | - $items_label); |
|
764 | - } |
|
765 | - |
|
766 | - |
|
767 | - /** |
|
768 | - * A method for generating paging similar to WP_List_Table |
|
769 | - * |
|
770 | - * @since 4.4.0 |
|
771 | - * @see wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination() |
|
772 | - * @param integer $total_items How many total items there are to page. |
|
773 | - * @param integer $current What the current page is. |
|
774 | - * @param integer $per_page How many items per page. |
|
775 | - * @param string $url What the base url for page links is. |
|
776 | - * @param boolean $show_num_field Whether to show the input for changing page number. |
|
777 | - * @param string $paged_arg_name The name of the key for the paged query argument. |
|
778 | - * @param array $items_label An array of singular/plural values for the items label: |
|
779 | - * array( |
|
780 | - * 'single' => 'item', |
|
781 | - * 'plural' => 'items' |
|
782 | - * ) |
|
783 | - * @return string |
|
784 | - */ |
|
785 | - public static function get_paging_html( |
|
786 | - $total_items, |
|
787 | - $current, |
|
788 | - $per_page, |
|
789 | - $url, |
|
790 | - $show_num_field = true, |
|
791 | - $paged_arg_name = 'paged', |
|
792 | - $items_label = array() |
|
793 | - ) { |
|
794 | - $page_links = array(); |
|
795 | - $disable_first = $disable_last = ''; |
|
796 | - $total_items = (int)$total_items; |
|
797 | - $per_page = (int)$per_page; |
|
798 | - $current = (int)$current; |
|
799 | - $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
800 | - |
|
801 | - //filter items_label |
|
802 | - $items_label = apply_filters( |
|
803 | - 'FHEE__EEH_Template__get_paging_html__items_label', |
|
804 | - $items_label |
|
805 | - ); |
|
806 | - |
|
807 | - if (empty($items_label) |
|
808 | - || ! is_array($items_label) |
|
809 | - || ! isset($items_label['single']) |
|
810 | - || ! isset($items_label['plural']) |
|
811 | - ) { |
|
812 | - $items_label = array( |
|
813 | - 'single' => __('1 item', 'event_espresso'), |
|
814 | - 'plural' => __('%s items', 'event_espresso'), |
|
815 | - ); |
|
816 | - } else { |
|
817 | - $items_label = array( |
|
818 | - 'single' => '1 ' . esc_html($items_label['single']), |
|
819 | - 'plural' => '%s ' . esc_html($items_label['plural']), |
|
820 | - ); |
|
821 | - } |
|
822 | - |
|
823 | - $total_pages = ceil($total_items / $per_page); |
|
824 | - |
|
825 | - if ($total_pages <= 1) { |
|
826 | - return ''; |
|
827 | - } |
|
828 | - |
|
829 | - $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
830 | - |
|
831 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
832 | - |
|
833 | - if ($current === 1) { |
|
834 | - $disable_first = ' disabled'; |
|
835 | - } |
|
836 | - if ($current == $total_pages) { |
|
837 | - $disable_last = ' disabled'; |
|
838 | - } |
|
839 | - |
|
840 | - $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
841 | - 'first-page' . $disable_first, |
|
842 | - esc_attr__('Go to the first page'), |
|
843 | - esc_url(remove_query_arg($paged_arg_name, $url)), |
|
844 | - '«' |
|
845 | - ); |
|
846 | - |
|
847 | - $page_links[] = sprintf( |
|
848 | - '<a class="%s" title="%s" href="%s">%s</a>', |
|
849 | - 'prev-page' . $disable_first, |
|
850 | - esc_attr__('Go to the previous page'), |
|
851 | - esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
852 | - '‹' |
|
853 | - ); |
|
854 | - |
|
855 | - if ( ! $show_num_field) { |
|
856 | - $html_current_page = $current; |
|
857 | - } else { |
|
858 | - $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
859 | - esc_attr__('Current page'), |
|
860 | - $current, |
|
861 | - strlen($total_pages) |
|
862 | - ); |
|
863 | - } |
|
864 | - |
|
865 | - $html_total_pages = sprintf( |
|
866 | - '<span class="total-pages">%s</span>', |
|
867 | - number_format_i18n($total_pages) |
|
868 | - ); |
|
869 | - $page_links[] = sprintf( |
|
870 | - _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
871 | - $html_current_page, |
|
872 | - $html_total_pages, |
|
873 | - '<span class="paging-input">', |
|
874 | - '</span>' |
|
875 | - ); |
|
876 | - |
|
877 | - $page_links[] = sprintf( |
|
878 | - '<a class="%s" title="%s" href="%s">%s</a>', |
|
879 | - 'next-page' . $disable_last, |
|
880 | - esc_attr__('Go to the next page'), |
|
881 | - esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
882 | - '›' |
|
883 | - ); |
|
884 | - |
|
885 | - $page_links[] = sprintf( |
|
886 | - '<a class="%s" title="%s" href="%s">%s</a>', |
|
887 | - 'last-page' . $disable_last, |
|
888 | - esc_attr__('Go to the last page'), |
|
889 | - esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
890 | - '»' |
|
891 | - ); |
|
892 | - |
|
893 | - $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>'; |
|
894 | - // set page class |
|
895 | - if ($total_pages) { |
|
896 | - $page_class = $total_pages < 2 ? ' one-page' : ''; |
|
897 | - } else { |
|
898 | - $page_class = ' no-pages'; |
|
899 | - } |
|
900 | - |
|
901 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
902 | - } |
|
903 | - |
|
904 | - |
|
905 | - /** |
|
906 | - * @param string $wrap_class |
|
907 | - * @param string $wrap_id |
|
908 | - * @return string |
|
909 | - */ |
|
910 | - public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = array()) |
|
911 | - { |
|
912 | - $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX); |
|
913 | - if ( |
|
914 | - ! $admin && |
|
915 | - ! apply_filters( |
|
916 | - 'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer', |
|
917 | - EE_Registry::instance()->CFG->admin->show_reg_footer |
|
918 | - ) |
|
919 | - ) { |
|
920 | - return ''; |
|
921 | - } |
|
922 | - $tag = $admin ? 'span' : 'div'; |
|
923 | - $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : ''; |
|
924 | - $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class; |
|
925 | - $attributes .= ! empty($wrap_class) |
|
926 | - ? " class=\"{$wrap_class} powered-by-event-espresso-credit\"" |
|
927 | - : ' class="powered-by-event-espresso-credit"'; |
|
928 | - $query_args = array_merge( |
|
929 | - array( |
|
930 | - 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id(), |
|
931 | - 'utm_source' => 'powered_by_event_espresso', |
|
932 | - 'utm_medium' => 'link', |
|
933 | - 'utm_campaign' => 'powered_by', |
|
934 | - ), |
|
935 | - $query_args |
|
936 | - ); |
|
937 | - $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text', |
|
938 | - $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'); |
|
939 | - $url = add_query_arg($query_args, 'https://eventespresso.com/'); |
|
940 | - $url = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url); |
|
941 | - return (string)apply_filters( |
|
942 | - 'FHEE__EEH_Template__powered_by_event_espresso__html', |
|
943 | - sprintf( |
|
944 | - esc_html_x( |
|
945 | - '%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s', |
|
946 | - 'Online event registration and ticketing powered by [link to eventespresso.com]', |
|
947 | - 'event_espresso' |
|
948 | - ), |
|
949 | - "<{$tag}{$attributes}>", |
|
950 | - "<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>", |
|
951 | - $admin ? '' : '<br />' |
|
952 | - ), |
|
953 | - $wrap_class, |
|
954 | - $wrap_id |
|
955 | - ); |
|
956 | - } |
|
730 | + } |
|
731 | + } else { |
|
732 | + //simple value |
|
733 | + echo esc_html($data); |
|
734 | + } |
|
735 | + return ob_get_clean(); |
|
736 | + } |
|
737 | + |
|
738 | + |
|
739 | + /** |
|
740 | + * wrapper for self::get_paging_html() that simply echos the generated paging html |
|
741 | + * |
|
742 | + * @since 4.4.0 |
|
743 | + * @see self:get_paging_html() for argument docs. |
|
744 | + * @param $total_items |
|
745 | + * @param $current |
|
746 | + * @param $per_page |
|
747 | + * @param $url |
|
748 | + * @param bool $show_num_field |
|
749 | + * @param string $paged_arg_name |
|
750 | + * @param array $items_label |
|
751 | + * @return string |
|
752 | + */ |
|
753 | + public static function paging_html( |
|
754 | + $total_items, |
|
755 | + $current, |
|
756 | + $per_page, |
|
757 | + $url, |
|
758 | + $show_num_field = true, |
|
759 | + $paged_arg_name = 'paged', |
|
760 | + $items_label = array() |
|
761 | + ) { |
|
762 | + echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, |
|
763 | + $items_label); |
|
764 | + } |
|
765 | + |
|
766 | + |
|
767 | + /** |
|
768 | + * A method for generating paging similar to WP_List_Table |
|
769 | + * |
|
770 | + * @since 4.4.0 |
|
771 | + * @see wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination() |
|
772 | + * @param integer $total_items How many total items there are to page. |
|
773 | + * @param integer $current What the current page is. |
|
774 | + * @param integer $per_page How many items per page. |
|
775 | + * @param string $url What the base url for page links is. |
|
776 | + * @param boolean $show_num_field Whether to show the input for changing page number. |
|
777 | + * @param string $paged_arg_name The name of the key for the paged query argument. |
|
778 | + * @param array $items_label An array of singular/plural values for the items label: |
|
779 | + * array( |
|
780 | + * 'single' => 'item', |
|
781 | + * 'plural' => 'items' |
|
782 | + * ) |
|
783 | + * @return string |
|
784 | + */ |
|
785 | + public static function get_paging_html( |
|
786 | + $total_items, |
|
787 | + $current, |
|
788 | + $per_page, |
|
789 | + $url, |
|
790 | + $show_num_field = true, |
|
791 | + $paged_arg_name = 'paged', |
|
792 | + $items_label = array() |
|
793 | + ) { |
|
794 | + $page_links = array(); |
|
795 | + $disable_first = $disable_last = ''; |
|
796 | + $total_items = (int)$total_items; |
|
797 | + $per_page = (int)$per_page; |
|
798 | + $current = (int)$current; |
|
799 | + $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
800 | + |
|
801 | + //filter items_label |
|
802 | + $items_label = apply_filters( |
|
803 | + 'FHEE__EEH_Template__get_paging_html__items_label', |
|
804 | + $items_label |
|
805 | + ); |
|
806 | + |
|
807 | + if (empty($items_label) |
|
808 | + || ! is_array($items_label) |
|
809 | + || ! isset($items_label['single']) |
|
810 | + || ! isset($items_label['plural']) |
|
811 | + ) { |
|
812 | + $items_label = array( |
|
813 | + 'single' => __('1 item', 'event_espresso'), |
|
814 | + 'plural' => __('%s items', 'event_espresso'), |
|
815 | + ); |
|
816 | + } else { |
|
817 | + $items_label = array( |
|
818 | + 'single' => '1 ' . esc_html($items_label['single']), |
|
819 | + 'plural' => '%s ' . esc_html($items_label['plural']), |
|
820 | + ); |
|
821 | + } |
|
822 | + |
|
823 | + $total_pages = ceil($total_items / $per_page); |
|
824 | + |
|
825 | + if ($total_pages <= 1) { |
|
826 | + return ''; |
|
827 | + } |
|
828 | + |
|
829 | + $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
830 | + |
|
831 | + $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
832 | + |
|
833 | + if ($current === 1) { |
|
834 | + $disable_first = ' disabled'; |
|
835 | + } |
|
836 | + if ($current == $total_pages) { |
|
837 | + $disable_last = ' disabled'; |
|
838 | + } |
|
839 | + |
|
840 | + $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
841 | + 'first-page' . $disable_first, |
|
842 | + esc_attr__('Go to the first page'), |
|
843 | + esc_url(remove_query_arg($paged_arg_name, $url)), |
|
844 | + '«' |
|
845 | + ); |
|
846 | + |
|
847 | + $page_links[] = sprintf( |
|
848 | + '<a class="%s" title="%s" href="%s">%s</a>', |
|
849 | + 'prev-page' . $disable_first, |
|
850 | + esc_attr__('Go to the previous page'), |
|
851 | + esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
852 | + '‹' |
|
853 | + ); |
|
854 | + |
|
855 | + if ( ! $show_num_field) { |
|
856 | + $html_current_page = $current; |
|
857 | + } else { |
|
858 | + $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
859 | + esc_attr__('Current page'), |
|
860 | + $current, |
|
861 | + strlen($total_pages) |
|
862 | + ); |
|
863 | + } |
|
864 | + |
|
865 | + $html_total_pages = sprintf( |
|
866 | + '<span class="total-pages">%s</span>', |
|
867 | + number_format_i18n($total_pages) |
|
868 | + ); |
|
869 | + $page_links[] = sprintf( |
|
870 | + _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
871 | + $html_current_page, |
|
872 | + $html_total_pages, |
|
873 | + '<span class="paging-input">', |
|
874 | + '</span>' |
|
875 | + ); |
|
876 | + |
|
877 | + $page_links[] = sprintf( |
|
878 | + '<a class="%s" title="%s" href="%s">%s</a>', |
|
879 | + 'next-page' . $disable_last, |
|
880 | + esc_attr__('Go to the next page'), |
|
881 | + esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
882 | + '›' |
|
883 | + ); |
|
884 | + |
|
885 | + $page_links[] = sprintf( |
|
886 | + '<a class="%s" title="%s" href="%s">%s</a>', |
|
887 | + 'last-page' . $disable_last, |
|
888 | + esc_attr__('Go to the last page'), |
|
889 | + esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
890 | + '»' |
|
891 | + ); |
|
892 | + |
|
893 | + $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>'; |
|
894 | + // set page class |
|
895 | + if ($total_pages) { |
|
896 | + $page_class = $total_pages < 2 ? ' one-page' : ''; |
|
897 | + } else { |
|
898 | + $page_class = ' no-pages'; |
|
899 | + } |
|
900 | + |
|
901 | + return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
902 | + } |
|
903 | + |
|
904 | + |
|
905 | + /** |
|
906 | + * @param string $wrap_class |
|
907 | + * @param string $wrap_id |
|
908 | + * @return string |
|
909 | + */ |
|
910 | + public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = array()) |
|
911 | + { |
|
912 | + $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX); |
|
913 | + if ( |
|
914 | + ! $admin && |
|
915 | + ! apply_filters( |
|
916 | + 'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer', |
|
917 | + EE_Registry::instance()->CFG->admin->show_reg_footer |
|
918 | + ) |
|
919 | + ) { |
|
920 | + return ''; |
|
921 | + } |
|
922 | + $tag = $admin ? 'span' : 'div'; |
|
923 | + $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : ''; |
|
924 | + $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class; |
|
925 | + $attributes .= ! empty($wrap_class) |
|
926 | + ? " class=\"{$wrap_class} powered-by-event-espresso-credit\"" |
|
927 | + : ' class="powered-by-event-espresso-credit"'; |
|
928 | + $query_args = array_merge( |
|
929 | + array( |
|
930 | + 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id(), |
|
931 | + 'utm_source' => 'powered_by_event_espresso', |
|
932 | + 'utm_medium' => 'link', |
|
933 | + 'utm_campaign' => 'powered_by', |
|
934 | + ), |
|
935 | + $query_args |
|
936 | + ); |
|
937 | + $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text', |
|
938 | + $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'); |
|
939 | + $url = add_query_arg($query_args, 'https://eventespresso.com/'); |
|
940 | + $url = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url); |
|
941 | + return (string)apply_filters( |
|
942 | + 'FHEE__EEH_Template__powered_by_event_espresso__html', |
|
943 | + sprintf( |
|
944 | + esc_html_x( |
|
945 | + '%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s', |
|
946 | + 'Online event registration and ticketing powered by [link to eventespresso.com]', |
|
947 | + 'event_espresso' |
|
948 | + ), |
|
949 | + "<{$tag}{$attributes}>", |
|
950 | + "<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>", |
|
951 | + $admin ? '' : '<br />' |
|
952 | + ), |
|
953 | + $wrap_class, |
|
954 | + $wrap_id |
|
955 | + ); |
|
956 | + } |
|
957 | 957 | |
958 | 958 | |
959 | 959 | } //end EEH_Template class |
@@ -962,33 +962,33 @@ discard block |
||
962 | 962 | |
963 | 963 | |
964 | 964 | if ( ! function_exists('espresso_pagination')) { |
965 | - /** |
|
966 | - * espresso_pagination |
|
967 | - * |
|
968 | - * @access public |
|
969 | - * @return void |
|
970 | - */ |
|
971 | - function espresso_pagination() |
|
972 | - { |
|
973 | - global $wp_query; |
|
974 | - $big = 999999999; // need an unlikely integer |
|
975 | - $pagination = paginate_links( |
|
976 | - array( |
|
977 | - 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
978 | - 'format' => '?paged=%#%', |
|
979 | - 'current' => max(1, get_query_var('paged')), |
|
980 | - 'total' => $wp_query->max_num_pages, |
|
981 | - 'show_all' => true, |
|
982 | - 'end_size' => 10, |
|
983 | - 'mid_size' => 6, |
|
984 | - 'prev_next' => true, |
|
985 | - 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
986 | - 'next_text' => __('NEXT ›', 'event_espresso'), |
|
987 | - 'type' => 'plain', |
|
988 | - 'add_args' => false, |
|
989 | - 'add_fragment' => '', |
|
990 | - ) |
|
991 | - ); |
|
992 | - echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : ''; |
|
993 | - } |
|
965 | + /** |
|
966 | + * espresso_pagination |
|
967 | + * |
|
968 | + * @access public |
|
969 | + * @return void |
|
970 | + */ |
|
971 | + function espresso_pagination() |
|
972 | + { |
|
973 | + global $wp_query; |
|
974 | + $big = 999999999; // need an unlikely integer |
|
975 | + $pagination = paginate_links( |
|
976 | + array( |
|
977 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
978 | + 'format' => '?paged=%#%', |
|
979 | + 'current' => max(1, get_query_var('paged')), |
|
980 | + 'total' => $wp_query->max_num_pages, |
|
981 | + 'show_all' => true, |
|
982 | + 'end_size' => 10, |
|
983 | + 'mid_size' => 6, |
|
984 | + 'prev_next' => true, |
|
985 | + 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
986 | + 'next_text' => __('NEXT ›', 'event_espresso'), |
|
987 | + 'type' => 'plain', |
|
988 | + 'add_args' => false, |
|
989 | + 'add_fragment' => '', |
|
990 | + ) |
|
991 | + ); |
|
992 | + echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : ''; |
|
993 | + } |
|
994 | 994 | } |
995 | 995 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | } |
5 | 5 | /** |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | public static function load_espresso_theme_functions() |
82 | 82 | { |
83 | 83 | if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
84 | - if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) { |
|
85 | - require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php'); |
|
84 | + if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php')) { |
|
85 | + require_once(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php'); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | public static function get_espresso_themes() |
97 | 97 | { |
98 | 98 | if (empty(EEH_Template::$_espresso_themes)) { |
99 | - $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR); |
|
99 | + $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR); |
|
100 | 100 | if (empty($espresso_themes)) { |
101 | 101 | return array(); |
102 | 102 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | ) { |
133 | 133 | do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
134 | 134 | $templates = array(); |
135 | - $name = (string)$name; |
|
135 | + $name = (string) $name; |
|
136 | 136 | if ($name != '') { |
137 | 137 | $templates[] = "{$slug}-{$name}.php"; |
138 | 138 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | if (isset($EE_CPTs[$post_type])) { |
212 | 212 | $archive_or_single = is_archive() ? 'archive' : ''; |
213 | 213 | $archive_or_single = is_single() ? 'single' : $archive_or_single; |
214 | - $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
214 | + $templates = $archive_or_single.'-'.$post_type.'.php'; |
|
215 | 215 | } |
216 | 216 | } |
217 | 217 | // currently active EE template theme |
@@ -220,18 +220,18 @@ discard block |
||
220 | 220 | // array of paths to folders that may contain templates |
221 | 221 | $template_folder_paths = array( |
222 | 222 | // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
223 | - EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
223 | + EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme, |
|
224 | 224 | // then in the root of the /wp-content/uploads/espresso/templates/ folder |
225 | 225 | EVENT_ESPRESSO_TEMPLATE_DIR, |
226 | 226 | ); |
227 | 227 | |
228 | 228 | //add core plugin folders for checking only if we're not $check_if_custom |
229 | 229 | if ( ! $check_if_custom) { |
230 | - $core_paths = array( |
|
230 | + $core_paths = array( |
|
231 | 231 | // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
232 | - EE_PUBLIC . $current_theme, |
|
232 | + EE_PUBLIC.$current_theme, |
|
233 | 233 | // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
234 | - EE_TEMPLATES . $current_theme, |
|
234 | + EE_TEMPLATES.$current_theme, |
|
235 | 235 | // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
236 | 236 | EE_PLUGIN_DIR_PATH, |
237 | 237 | ); |
@@ -262,10 +262,10 @@ discard block |
||
262 | 262 | ); |
263 | 263 | if ($common_base_path !== '') { |
264 | 264 | // both paths have a common base, so just tack the filename onto our search path |
265 | - $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name; |
|
265 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name; |
|
266 | 266 | } else { |
267 | 267 | // no common base path, so let's just concatenate |
268 | - $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template; |
|
268 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template; |
|
269 | 269 | } |
270 | 270 | // build up our template locations array by adding our resolved paths |
271 | 271 | $full_template_paths[] = $resolved_path; |
@@ -273,13 +273,13 @@ discard block |
||
273 | 273 | // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
274 | 274 | array_unshift($full_template_paths, $template); |
275 | 275 | // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
276 | - array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name); |
|
276 | + array_unshift($full_template_paths, get_stylesheet_directory().DS.$file_name); |
|
277 | 277 | } |
278 | 278 | // filter final array of full template paths |
279 | 279 | $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', |
280 | 280 | $full_template_paths, $file_name); |
281 | 281 | // now loop through our final array of template location paths and check each location |
282 | - foreach ((array)$full_template_paths as $full_template_path) { |
|
282 | + foreach ((array) $full_template_paths as $full_template_path) { |
|
283 | 283 | if (is_readable($full_template_path)) { |
284 | 284 | $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
285 | 285 | break; |
@@ -366,9 +366,9 @@ discard block |
||
366 | 366 | if ( ! is_array($template_args) && ! is_object($template_args)) { |
367 | 367 | $template_args = array($template_args); |
368 | 368 | } |
369 | - extract( $template_args, EXTR_SKIP ); |
|
369 | + extract($template_args, EXTR_SKIP); |
|
370 | 370 | // ignore whether template is accessible ? |
371 | - if ( $throw_exceptions && ! is_readable( $template_path ) ) { |
|
371 | + if ($throw_exceptions && ! is_readable($template_path)) { |
|
372 | 372 | throw new \DomainException( |
373 | 373 | esc_html__( |
374 | 374 | 'Invalid, unreadable, or missing file.', |
@@ -401,11 +401,11 @@ discard block |
||
401 | 401 | public static function get_object_css_class($object = null, $prefix = '', $suffix = '') |
402 | 402 | { |
403 | 403 | // in the beginning... |
404 | - $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : ''; |
|
404 | + $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : ''; |
|
405 | 405 | // da muddle |
406 | 406 | $class = ''; |
407 | 407 | // the end |
408 | - $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : ''; |
|
408 | + $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : ''; |
|
409 | 409 | // is the passed object an EE object ? |
410 | 410 | if ($object instanceof EE_Base_Class) { |
411 | 411 | // grab the exact type of object |
@@ -415,11 +415,11 @@ discard block |
||
415 | 415 | // no specifics just yet... |
416 | 416 | default : |
417 | 417 | $class = strtolower(str_replace('_', '-', $obj_class)); |
418 | - $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : ''; |
|
418 | + $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : ''; |
|
419 | 419 | |
420 | 420 | } |
421 | 421 | } |
422 | - return $prefix . $class . $suffix; |
|
422 | + return $prefix.$class.$suffix; |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | return ''; |
452 | 452 | } |
453 | 453 | //ensure amount is float |
454 | - $amount = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float)$amount); |
|
454 | + $amount = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount); |
|
455 | 455 | $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount); |
456 | 456 | // filter raw amount (allows 0.00 to be changed to "free" for example) |
457 | 457 | $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
@@ -473,20 +473,20 @@ discard block |
||
473 | 473 | // add currency sign |
474 | 474 | if ($mny->sign_b4) { |
475 | 475 | if ($amount >= 0) { |
476 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
476 | + $amount_formatted = $mny->sign.$amount_formatted; |
|
477 | 477 | } else { |
478 | - $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted); |
|
478 | + $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | } else { |
482 | - $amount_formatted = $amount_formatted . $mny->sign; |
|
482 | + $amount_formatted = $amount_formatted.$mny->sign; |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | // filter to allow global setting of display_code |
486 | 486 | $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code); |
487 | 487 | |
488 | 488 | // add currency code ? |
489 | - $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
489 | + $amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted; |
|
490 | 490 | } |
491 | 491 | // filter results |
492 | 492 | $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', |
@@ -540,12 +540,12 @@ discard block |
||
540 | 540 | $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : ''; |
541 | 541 | foreach ($dashicons as $dashicon) { |
542 | 542 | $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons '; |
543 | - $icon_html .= '<span class="' . $type . $dashicon . '"></span>'; |
|
543 | + $icon_html .= '<span class="'.$type.$dashicon.'"></span>'; |
|
544 | 544 | } |
545 | 545 | $icon_html .= $count > 1 ? '</span>' : ''; |
546 | 546 | } |
547 | - $label = ! empty($icon) ? $icon_html . $label : $label; |
|
548 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>'; |
|
547 | + $label = ! empty($icon) ? $icon_html.$label : $label; |
|
548 | + $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.$url.'" class="'.$class.'" title="'.$title.'">'.$label.'</a>'; |
|
549 | 549 | return $button; |
550 | 550 | } |
551 | 551 | |
@@ -579,11 +579,11 @@ discard block |
||
579 | 579 | $action = empty($action) ? 'default' : $action; |
580 | 580 | |
581 | 581 | |
582 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
582 | + $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id; |
|
583 | 583 | $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
584 | 584 | $help_text = ! $help_text ? '' : $help_text; |
585 | - return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', |
|
586 | - 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
585 | + return '<a id="'.$help_tab_lnk.'" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'.$icon.'" title="'.esc_attr__('Click to open the \'Help\' tab for more information about this feature.', |
|
586 | + 'event_espresso').'" > '.$help_text.' </a>'; |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | |
@@ -600,11 +600,11 @@ discard block |
||
600 | 600 | $id = $tour->get_slug(); |
601 | 601 | $stops = $tour->get_stops(); |
602 | 602 | |
603 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
603 | + $content = '<ol style="display:none" id="'.$id.'">'; |
|
604 | 604 | |
605 | 605 | foreach ($stops as $stop) { |
606 | - $data_id = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
607 | - $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
606 | + $data_id = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : ''; |
|
607 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : ''; |
|
608 | 608 | |
609 | 609 | //if container is set to modal then let's make sure we set the options accordingly |
610 | 610 | if (empty($data_id) && empty($data_class)) { |
@@ -612,15 +612,15 @@ discard block |
||
612 | 612 | $stop['options']['expose'] = true; |
613 | 613 | } |
614 | 614 | |
615 | - $custom_class = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
616 | - $button_text = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
615 | + $custom_class = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : ''; |
|
616 | + $button_text = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : ''; |
|
617 | 617 | $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
618 | 618 | |
619 | 619 | //options |
620 | 620 | if (isset($stop['options']) && is_array($stop['options'])) { |
621 | 621 | $options = ' data-options="'; |
622 | 622 | foreach ($stop['options'] as $option => $value) { |
623 | - $options .= $option . ':' . $value . ';'; |
|
623 | + $options .= $option.':'.$value.';'; |
|
624 | 624 | } |
625 | 625 | $options .= '"'; |
626 | 626 | } else { |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | } |
629 | 629 | |
630 | 630 | //let's put all together |
631 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
631 | + $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>'; |
|
632 | 632 | } |
633 | 633 | |
634 | 634 | $content .= '</ol>'; |
@@ -660,24 +660,24 @@ discard block |
||
660 | 660 | $setup_array = array(); |
661 | 661 | foreach ($status_array as $item => $status) { |
662 | 662 | $setup_array[$item] = array( |
663 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
663 | + 'class' => 'ee-status-legend ee-status-legend-'.$status, |
|
664 | 664 | 'desc' => EEH_Template::pretty_status($status, false, 'sentence'), |
665 | 665 | 'status' => $status, |
666 | 666 | ); |
667 | 667 | } |
668 | 668 | |
669 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
670 | - $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n"; |
|
671 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
669 | + $content = '<div class="ee-list-table-legend-container">'."\n"; |
|
670 | + $content .= '<h4 class="status-legend-title">'.esc_html__('Status Legend', 'event_espresso').'</h4>'."\n"; |
|
671 | + $content .= '<dl class="ee-list-table-legend">'."\n\t"; |
|
672 | 672 | foreach ($setup_array as $item => $details) { |
673 | 673 | $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
674 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
675 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
676 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
677 | - $content .= '</dt>' . "\n"; |
|
674 | + $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t"; |
|
675 | + $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t"; |
|
676 | + $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t"; |
|
677 | + $content .= '</dt>'."\n"; |
|
678 | 678 | } |
679 | - $content .= '</dl>' . "\n"; |
|
680 | - $content .= '</div>' . "\n"; |
|
679 | + $content .= '</dl>'."\n"; |
|
680 | + $content .= '</div>'."\n"; |
|
681 | 681 | return $content; |
682 | 682 | } |
683 | 683 | |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | public static function layout_array_as_table($data) |
693 | 693 | { |
694 | 694 | if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
695 | - $data = (array)$data; |
|
695 | + $data = (array) $data; |
|
696 | 696 | } |
697 | 697 | ob_start(); |
698 | 698 | if (is_array($data)) { |
@@ -793,9 +793,9 @@ discard block |
||
793 | 793 | ) { |
794 | 794 | $page_links = array(); |
795 | 795 | $disable_first = $disable_last = ''; |
796 | - $total_items = (int)$total_items; |
|
797 | - $per_page = (int)$per_page; |
|
798 | - $current = (int)$current; |
|
796 | + $total_items = (int) $total_items; |
|
797 | + $per_page = (int) $per_page; |
|
798 | + $current = (int) $current; |
|
799 | 799 | $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
800 | 800 | |
801 | 801 | //filter items_label |
@@ -815,8 +815,8 @@ discard block |
||
815 | 815 | ); |
816 | 816 | } else { |
817 | 817 | $items_label = array( |
818 | - 'single' => '1 ' . esc_html($items_label['single']), |
|
819 | - 'plural' => '%s ' . esc_html($items_label['plural']), |
|
818 | + 'single' => '1 '.esc_html($items_label['single']), |
|
819 | + 'plural' => '%s '.esc_html($items_label['plural']), |
|
820 | 820 | ); |
821 | 821 | } |
822 | 822 | |
@@ -828,7 +828,7 @@ discard block |
||
828 | 828 | |
829 | 829 | $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
830 | 830 | |
831 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
831 | + $output = '<span class="displaying-num">'.$item_label.'</span>'; |
|
832 | 832 | |
833 | 833 | if ($current === 1) { |
834 | 834 | $disable_first = ' disabled'; |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | } |
839 | 839 | |
840 | 840 | $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
841 | - 'first-page' . $disable_first, |
|
841 | + 'first-page'.$disable_first, |
|
842 | 842 | esc_attr__('Go to the first page'), |
843 | 843 | esc_url(remove_query_arg($paged_arg_name, $url)), |
844 | 844 | '«' |
@@ -846,7 +846,7 @@ discard block |
||
846 | 846 | |
847 | 847 | $page_links[] = sprintf( |
848 | 848 | '<a class="%s" title="%s" href="%s">%s</a>', |
849 | - 'prev-page' . $disable_first, |
|
849 | + 'prev-page'.$disable_first, |
|
850 | 850 | esc_attr__('Go to the previous page'), |
851 | 851 | esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
852 | 852 | '‹' |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | '<span class="total-pages">%s</span>', |
867 | 867 | number_format_i18n($total_pages) |
868 | 868 | ); |
869 | - $page_links[] = sprintf( |
|
869 | + $page_links[] = sprintf( |
|
870 | 870 | _x('%3$s%1$s of %2$s%4$s', 'paging'), |
871 | 871 | $html_current_page, |
872 | 872 | $html_total_pages, |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | |
877 | 877 | $page_links[] = sprintf( |
878 | 878 | '<a class="%s" title="%s" href="%s">%s</a>', |
879 | - 'next-page' . $disable_last, |
|
879 | + 'next-page'.$disable_last, |
|
880 | 880 | esc_attr__('Go to the next page'), |
881 | 881 | esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
882 | 882 | '›' |
@@ -884,13 +884,13 @@ discard block |
||
884 | 884 | |
885 | 885 | $page_links[] = sprintf( |
886 | 886 | '<a class="%s" title="%s" href="%s">%s</a>', |
887 | - 'last-page' . $disable_last, |
|
887 | + 'last-page'.$disable_last, |
|
888 | 888 | esc_attr__('Go to the last page'), |
889 | 889 | esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
890 | 890 | '»' |
891 | 891 | ); |
892 | 892 | |
893 | - $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>'; |
|
893 | + $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>'; |
|
894 | 894 | // set page class |
895 | 895 | if ($total_pages) { |
896 | 896 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | $page_class = ' no-pages'; |
899 | 899 | } |
900 | 900 | |
901 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
901 | + return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>'; |
|
902 | 902 | } |
903 | 903 | |
904 | 904 | |
@@ -935,10 +935,10 @@ discard block |
||
935 | 935 | $query_args |
936 | 936 | ); |
937 | 937 | $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text', |
938 | - $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'); |
|
938 | + $admin ? 'Event Espresso - '.EVENT_ESPRESSO_VERSION : 'Event Espresso'); |
|
939 | 939 | $url = add_query_arg($query_args, 'https://eventespresso.com/'); |
940 | 940 | $url = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url); |
941 | - return (string)apply_filters( |
|
941 | + return (string) apply_filters( |
|
942 | 942 | 'FHEE__EEH_Template__powered_by_event_espresso__html', |
943 | 943 | sprintf( |
944 | 944 | esc_html_x( |
@@ -989,6 +989,6 @@ discard block |
||
989 | 989 | 'add_fragment' => '', |
990 | 990 | ) |
991 | 991 | ); |
992 | - echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : ''; |
|
992 | + echo ! empty($pagination) ? '<div class="ee-pagination-dv clear">'.$pagination.'</div>' : ''; |
|
993 | 993 | } |
994 | 994 | } |
995 | 995 | \ No newline at end of file |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | //unfortunately, this needs to be done upon INCLUSION of this file, |
10 | 10 | //instead of construction, because it only gets constructed on first page load |
11 | 11 | //(all other times it gets resurrected from a wordpress option) |
12 | -$stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*'); |
|
12 | +$stages = glob(EE_CORE.'data_migration_scripts/4_9_0_stages/*'); |
|
13 | 13 | $class_to_filepath = array(); |
14 | 14 | foreach ($stages as $filepath) { |
15 | 15 | $matches = array(); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | } elseif ( ! $version_string) { |
68 | 68 | // echo "no version string provided: $version_string"; |
69 | 69 | //no version string provided... this must be pre 4.3 |
70 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
70 | + return false; //changed mind. dont want people thinking they should migrate yet because they cant |
|
71 | 71 | } else { |
72 | 72 | // echo "$version_string doesnt apply"; |
73 | 73 | return false; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function schema_changes_before_migration() |
83 | 83 | { |
84 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
84 | + require_once(EE_HELPERS.'EEH_Activation.helper.php'); |
|
85 | 85 | $now_in_mysql = current_time('mysql', true); |
86 | 86 | $table_name = 'esp_answer'; |
87 | 87 | $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | //ok and now let's remember this was done (without needing to check the db schemas all over again) |
677 | 677 | add_option('ee_verified_db_collations', true, null, 'no'); |
678 | 678 | //seeing how this ran with the fix from 10435, no need to check again |
679 | - add_option('ee_verified_db_collations_again',true,null,'no'); |
|
679 | + add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | * which meant some DB collations might not have been updated |
687 | 687 | * @return void |
688 | 688 | */ |
689 | - public function verify_db_collations_again(){ |
|
689 | + public function verify_db_collations_again() { |
|
690 | 690 | if (get_option('ee_verified_db_collations_again', false)) { |
691 | 691 | return; |
692 | 692 | } |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | 'esp_message' |
696 | 696 | ); |
697 | 697 | $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
698 | - add_option('ee_verified_db_collations_again',true,null,'no'); |
|
698 | + add_option('ee_verified_db_collations_again', true, null, 'no'); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | { |
710 | 710 | foreach ($tables_to_check as $table_name) { |
711 | 711 | $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
712 | - if ( ! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name ) |
|
712 | + if ( ! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name) |
|
713 | 713 | && $this->_get_table_analysis()->tableExists($table_name) |
714 | 714 | ) { |
715 | 715 | maybe_convert_table_to_utf8mb4($table_name); |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | $stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*'); |
13 | 13 | $class_to_filepath = array(); |
14 | 14 | foreach ($stages as $filepath) { |
15 | - $matches = array(); |
|
16 | - preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
17 | - $class_to_filepath[$matches[1]] = $filepath; |
|
15 | + $matches = array(); |
|
16 | + preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches); |
|
17 | + $class_to_filepath[$matches[1]] = $filepath; |
|
18 | 18 | } |
19 | 19 | //give addons a chance to autoload their stages too |
20 | 20 | $class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath); |
@@ -33,68 +33,68 @@ discard block |
||
33 | 33 | class EE_DMS_Core_4_9_0 extends EE_Data_Migration_Script_Base |
34 | 34 | { |
35 | 35 | |
36 | - /** |
|
37 | - * return EE_DMS_Core_4_9_0 |
|
38 | - * |
|
39 | - * @param TableManager $table_manager |
|
40 | - * @param TableAnalysis $table_analysis |
|
41 | - */ |
|
42 | - public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
43 | - { |
|
44 | - $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso"); |
|
45 | - $this->_priority = 10; |
|
46 | - $this->_migration_stages = array( |
|
47 | - new EE_DMS_4_9_0_Email_System_Question(), |
|
48 | - new EE_DMS_4_9_0_Answers_With_No_Registration(), |
|
49 | - ); |
|
50 | - parent::__construct($table_manager, $table_analysis); |
|
51 | - } |
|
36 | + /** |
|
37 | + * return EE_DMS_Core_4_9_0 |
|
38 | + * |
|
39 | + * @param TableManager $table_manager |
|
40 | + * @param TableAnalysis $table_analysis |
|
41 | + */ |
|
42 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) |
|
43 | + { |
|
44 | + $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso"); |
|
45 | + $this->_priority = 10; |
|
46 | + $this->_migration_stages = array( |
|
47 | + new EE_DMS_4_9_0_Email_System_Question(), |
|
48 | + new EE_DMS_4_9_0_Answers_With_No_Registration(), |
|
49 | + ); |
|
50 | + parent::__construct($table_manager, $table_analysis); |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Whether to migrate or not. |
|
57 | - * |
|
58 | - * @param array $version_array |
|
59 | - * @return bool |
|
60 | - */ |
|
61 | - public function can_migrate_from_version($version_array) |
|
62 | - { |
|
63 | - $version_string = $version_array['Core']; |
|
64 | - if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) { |
|
65 | - // echo "$version_string can be migrated from"; |
|
66 | - return true; |
|
67 | - } elseif ( ! $version_string) { |
|
68 | - // echo "no version string provided: $version_string"; |
|
69 | - //no version string provided... this must be pre 4.3 |
|
70 | - return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
71 | - } else { |
|
72 | - // echo "$version_string doesnt apply"; |
|
73 | - return false; |
|
74 | - } |
|
75 | - } |
|
55 | + /** |
|
56 | + * Whether to migrate or not. |
|
57 | + * |
|
58 | + * @param array $version_array |
|
59 | + * @return bool |
|
60 | + */ |
|
61 | + public function can_migrate_from_version($version_array) |
|
62 | + { |
|
63 | + $version_string = $version_array['Core']; |
|
64 | + if (version_compare($version_string, '4.9.0', '<=') && version_compare($version_string, '4.8.0', '>=')) { |
|
65 | + // echo "$version_string can be migrated from"; |
|
66 | + return true; |
|
67 | + } elseif ( ! $version_string) { |
|
68 | + // echo "no version string provided: $version_string"; |
|
69 | + //no version string provided... this must be pre 4.3 |
|
70 | + return false;//changed mind. dont want people thinking they should migrate yet because they cant |
|
71 | + } else { |
|
72 | + // echo "$version_string doesnt apply"; |
|
73 | + return false; |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | 78 | |
79 | - /** |
|
80 | - * @return bool |
|
81 | - */ |
|
82 | - public function schema_changes_before_migration() |
|
83 | - { |
|
84 | - require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
85 | - $now_in_mysql = current_time('mysql', true); |
|
86 | - $table_name = 'esp_answer'; |
|
87 | - $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
79 | + /** |
|
80 | + * @return bool |
|
81 | + */ |
|
82 | + public function schema_changes_before_migration() |
|
83 | + { |
|
84 | + require_once(EE_HELPERS . 'EEH_Activation.helper.php'); |
|
85 | + $now_in_mysql = current_time('mysql', true); |
|
86 | + $table_name = 'esp_answer'; |
|
87 | + $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
88 | 88 | REG_ID int(10) unsigned NOT NULL, |
89 | 89 | QST_ID int(10) unsigned NOT NULL, |
90 | 90 | ANS_value text NOT NULL, |
91 | 91 | PRIMARY KEY (ANS_ID), |
92 | 92 | KEY REG_ID (REG_ID), |
93 | 93 | KEY QST_ID (QST_ID)"; |
94 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
95 | - $table_name = 'esp_attendee_meta'; |
|
96 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email'); |
|
97 | - $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
94 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
95 | + $table_name = 'esp_attendee_meta'; |
|
96 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email'); |
|
97 | + $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
98 | 98 | ATT_ID bigint(20) unsigned NOT NULL, |
99 | 99 | ATT_fname varchar(45) NOT NULL, |
100 | 100 | ATT_lname varchar(45) NOT NULL, |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | KEY ATT_email (ATT_email(191)), |
112 | 112 | KEY ATT_lname (ATT_lname), |
113 | 113 | KEY ATT_fname (ATT_fname)"; |
114 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
115 | - $table_name = 'esp_checkin'; |
|
116 | - $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
114 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
115 | + $table_name = 'esp_checkin'; |
|
116 | + $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
117 | 117 | REG_ID int(10) unsigned NOT NULL, |
118 | 118 | DTT_ID int(10) unsigned NOT NULL, |
119 | 119 | CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | PRIMARY KEY (CHK_ID), |
122 | 122 | KEY REG_ID (REG_ID), |
123 | 123 | KEY DTT_ID (DTT_ID)"; |
124 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
125 | - $table_name = 'esp_country'; |
|
126 | - $sql = "CNT_ISO varchar(2) NOT NULL, |
|
124 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
125 | + $table_name = 'esp_country'; |
|
126 | + $sql = "CNT_ISO varchar(2) NOT NULL, |
|
127 | 127 | CNT_ISO3 varchar(3) NOT NULL, |
128 | 128 | RGN_ID tinyint(3) unsigned DEFAULT NULL, |
129 | 129 | CNT_name varchar(45) NOT NULL, |
@@ -139,25 +139,25 @@ discard block |
||
139 | 139 | CNT_is_EU tinyint(1) DEFAULT '0', |
140 | 140 | CNT_active tinyint(1) DEFAULT '0', |
141 | 141 | PRIMARY KEY (CNT_ISO)"; |
142 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
143 | - $table_name = 'esp_currency'; |
|
144 | - $sql = "CUR_code varchar(6) NOT NULL, |
|
142 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
143 | + $table_name = 'esp_currency'; |
|
144 | + $sql = "CUR_code varchar(6) NOT NULL, |
|
145 | 145 | CUR_single varchar(45) DEFAULT 'dollar', |
146 | 146 | CUR_plural varchar(45) DEFAULT 'dollars', |
147 | 147 | CUR_sign varchar(45) DEFAULT '$', |
148 | 148 | CUR_dec_plc varchar(1) NOT NULL DEFAULT '2', |
149 | 149 | CUR_active tinyint(1) DEFAULT '0', |
150 | 150 | PRIMARY KEY (CUR_code)"; |
151 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
152 | - $table_name = 'esp_currency_payment_method'; |
|
153 | - $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
151 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
152 | + $table_name = 'esp_currency_payment_method'; |
|
153 | + $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
154 | 154 | CUR_code varchar(6) NOT NULL, |
155 | 155 | PMD_ID int(11) NOT NULL, |
156 | 156 | PRIMARY KEY (CPM_ID), |
157 | 157 | KEY PMD_ID (PMD_ID)"; |
158 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
159 | - $table_name = 'esp_datetime'; |
|
160 | - $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
158 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
159 | + $table_name = 'esp_datetime'; |
|
160 | + $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
161 | 161 | EVT_ID bigint(20) unsigned NOT NULL, |
162 | 162 | DTT_name varchar(255) NOT NULL DEFAULT '', |
163 | 163 | DTT_description text NOT NULL, |
@@ -174,25 +174,25 @@ discard block |
||
174 | 174 | KEY DTT_EVT_start (DTT_EVT_start), |
175 | 175 | KEY EVT_ID (EVT_ID), |
176 | 176 | KEY DTT_is_primary (DTT_is_primary)"; |
177 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
178 | - $table_name = "esp_datetime_ticket"; |
|
179 | - $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
177 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
178 | + $table_name = "esp_datetime_ticket"; |
|
179 | + $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
180 | 180 | DTT_ID int(10) unsigned NOT NULL, |
181 | 181 | TKT_ID int(10) unsigned NOT NULL, |
182 | 182 | PRIMARY KEY (DTK_ID), |
183 | 183 | KEY DTT_ID (DTT_ID), |
184 | 184 | KEY TKT_ID (TKT_ID)"; |
185 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
186 | - $table_name = 'esp_event_message_template'; |
|
187 | - $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
185 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
186 | + $table_name = 'esp_event_message_template'; |
|
187 | + $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
188 | 188 | EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
189 | 189 | GRP_ID int(10) unsigned NOT NULL DEFAULT 0, |
190 | 190 | PRIMARY KEY (EMT_ID), |
191 | 191 | KEY EVT_ID (EVT_ID), |
192 | 192 | KEY GRP_ID (GRP_ID)"; |
193 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
194 | - $table_name = 'esp_event_meta'; |
|
195 | - $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
193 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
194 | + $table_name = 'esp_event_meta'; |
|
195 | + $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT, |
|
196 | 196 | EVT_ID bigint(20) unsigned NOT NULL, |
197 | 197 | EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1, |
198 | 198 | EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1, |
@@ -207,34 +207,34 @@ discard block |
||
207 | 207 | EVT_donations tinyint(1) NULL, |
208 | 208 | PRIMARY KEY (EVTM_ID), |
209 | 209 | KEY EVT_ID (EVT_ID)"; |
210 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
211 | - $table_name = 'esp_event_question_group'; |
|
212 | - $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
210 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
211 | + $table_name = 'esp_event_question_group'; |
|
212 | + $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
213 | 213 | EVT_ID bigint(20) unsigned NOT NULL, |
214 | 214 | QSG_ID int(10) unsigned NOT NULL, |
215 | 215 | EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
216 | 216 | PRIMARY KEY (EQG_ID), |
217 | 217 | KEY EVT_ID (EVT_ID), |
218 | 218 | KEY QSG_ID (QSG_ID)"; |
219 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
220 | - $table_name = 'esp_event_venue'; |
|
221 | - $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
219 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
220 | + $table_name = 'esp_event_venue'; |
|
221 | + $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT, |
|
222 | 222 | EVT_ID bigint(20) unsigned NOT NULL, |
223 | 223 | VNU_ID bigint(20) unsigned NOT NULL, |
224 | 224 | EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0, |
225 | 225 | PRIMARY KEY (EVV_ID)"; |
226 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
227 | - $table_name = 'esp_extra_meta'; |
|
228 | - $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
226 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
227 | + $table_name = 'esp_extra_meta'; |
|
228 | + $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
229 | 229 | OBJ_ID int(11) DEFAULT NULL, |
230 | 230 | EXM_type varchar(45) DEFAULT NULL, |
231 | 231 | EXM_key varchar(45) DEFAULT NULL, |
232 | 232 | EXM_value text, |
233 | 233 | PRIMARY KEY (EXM_ID), |
234 | 234 | KEY EXM_type (EXM_type,OBJ_ID,EXM_key)"; |
235 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
236 | - $table_name = 'esp_extra_join'; |
|
237 | - $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
235 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
236 | + $table_name = 'esp_extra_join'; |
|
237 | + $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT, |
|
238 | 238 | EXJ_first_model_id varchar(6) NOT NULL, |
239 | 239 | EXJ_first_model_name varchar(20) NOT NULL, |
240 | 240 | EXJ_second_model_id varchar(6) NOT NULL, |
@@ -242,9 +242,9 @@ discard block |
||
242 | 242 | PRIMARY KEY (EXJ_ID), |
243 | 243 | KEY first_model (EXJ_first_model_name,EXJ_first_model_id), |
244 | 244 | KEY second_model (EXJ_second_model_name,EXJ_second_model_id)"; |
245 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
246 | - $table_name = 'esp_line_item'; |
|
247 | - $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
245 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
246 | + $table_name = 'esp_line_item'; |
|
247 | + $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT, |
|
248 | 248 | LIN_code varchar(245) NOT NULL DEFAULT '', |
249 | 249 | TXN_ID int(11) DEFAULT NULL, |
250 | 250 | LIN_name varchar(245) NOT NULL DEFAULT '', |
@@ -263,9 +263,9 @@ discard block |
||
263 | 263 | PRIMARY KEY (LIN_ID), |
264 | 264 | KEY LIN_code (LIN_code(191)), |
265 | 265 | KEY TXN_ID (TXN_ID)"; |
266 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
267 | - $table_name = 'esp_log'; |
|
268 | - $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
266 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
267 | + $table_name = 'esp_log'; |
|
268 | + $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT, |
|
269 | 269 | LOG_time datetime DEFAULT NULL, |
270 | 270 | OBJ_ID varchar(45) DEFAULT NULL, |
271 | 271 | OBJ_type varchar(45) DEFAULT NULL, |
@@ -276,12 +276,12 @@ discard block |
||
276 | 276 | KEY LOG_time (LOG_time), |
277 | 277 | KEY OBJ (OBJ_type,OBJ_ID), |
278 | 278 | KEY LOG_type (LOG_type)"; |
279 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
280 | - $table_name = 'esp_message'; |
|
281 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to'); |
|
282 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from'); |
|
283 | - $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject'); |
|
284 | - $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
279 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
280 | + $table_name = 'esp_message'; |
|
281 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to'); |
|
282 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from'); |
|
283 | + $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject'); |
|
284 | + $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
|
285 | 285 | GRP_ID int(10) unsigned NULL, |
286 | 286 | MSG_token varchar(255) NULL, |
287 | 287 | TXN_ID int(10) unsigned NULL, |
@@ -313,18 +313,18 @@ discard block |
||
313 | 313 | KEY STS_ID (STS_ID), |
314 | 314 | KEY MSG_created (MSG_created), |
315 | 315 | KEY MSG_modified (MSG_modified)"; |
316 | - $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
317 | - $table_name = 'esp_message_template'; |
|
318 | - $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
316 | + $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
317 | + $table_name = 'esp_message_template'; |
|
318 | + $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
319 | 319 | GRP_ID int(10) unsigned NOT NULL, |
320 | 320 | MTP_context varchar(50) NOT NULL, |
321 | 321 | MTP_template_field varchar(30) NOT NULL, |
322 | 322 | MTP_content text NOT NULL, |
323 | 323 | PRIMARY KEY (MTP_ID), |
324 | 324 | KEY GRP_ID (GRP_ID)"; |
325 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
326 | - $table_name = 'esp_message_template_group'; |
|
327 | - $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
325 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
326 | + $table_name = 'esp_message_template_group'; |
|
327 | + $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
328 | 328 | MTP_user_id int(10) NOT NULL DEFAULT '1', |
329 | 329 | MTP_name varchar(245) NOT NULL DEFAULT '', |
330 | 330 | MTP_description varchar(245) NOT NULL DEFAULT '', |
@@ -336,9 +336,9 @@ discard block |
||
336 | 336 | MTP_is_active tinyint(1) NOT NULL DEFAULT '1', |
337 | 337 | PRIMARY KEY (GRP_ID), |
338 | 338 | KEY MTP_user_id (MTP_user_id)"; |
339 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
340 | - $table_name = 'esp_payment'; |
|
341 | - $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
339 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
340 | + $table_name = 'esp_payment'; |
|
341 | + $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
342 | 342 | TXN_ID int(10) unsigned DEFAULT NULL, |
343 | 343 | STS_ID varchar(3) DEFAULT NULL, |
344 | 344 | PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
@@ -355,9 +355,9 @@ discard block |
||
355 | 355 | PRIMARY KEY (PAY_ID), |
356 | 356 | KEY PAY_timestamp (PAY_timestamp), |
357 | 357 | KEY TXN_ID (TXN_ID)"; |
358 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
359 | - $table_name = 'esp_payment_method'; |
|
360 | - $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
358 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
359 | + $table_name = 'esp_payment_method'; |
|
360 | + $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT, |
|
361 | 361 | PMD_type varchar(124) DEFAULT NULL, |
362 | 362 | PMD_name varchar(255) DEFAULT NULL, |
363 | 363 | PMD_desc text, |
@@ -373,24 +373,24 @@ discard block |
||
373 | 373 | PRIMARY KEY (PMD_ID), |
374 | 374 | UNIQUE KEY PMD_slug_UNIQUE (PMD_slug), |
375 | 375 | KEY PMD_type (PMD_type)"; |
376 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
377 | - $table_name = "esp_ticket_price"; |
|
378 | - $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
376 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
377 | + $table_name = "esp_ticket_price"; |
|
378 | + $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
379 | 379 | TKT_ID int(10) unsigned NOT NULL, |
380 | 380 | PRC_ID int(10) unsigned NOT NULL, |
381 | 381 | PRIMARY KEY (TKP_ID), |
382 | 382 | KEY TKT_ID (TKT_ID), |
383 | 383 | KEY PRC_ID (PRC_ID)"; |
384 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
385 | - $table_name = "esp_ticket_template"; |
|
386 | - $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
384 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
385 | + $table_name = "esp_ticket_template"; |
|
386 | + $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
387 | 387 | TTM_name varchar(45) NOT NULL, |
388 | 388 | TTM_description text, |
389 | 389 | TTM_file varchar(45), |
390 | 390 | PRIMARY KEY (TTM_ID)"; |
391 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
392 | - $table_name = 'esp_question'; |
|
393 | - $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
391 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
392 | + $table_name = 'esp_question'; |
|
393 | + $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
394 | 394 | QST_display_text text NOT NULL, |
395 | 395 | QST_admin_label varchar(255) NOT NULL, |
396 | 396 | QST_system varchar(25) DEFAULT NULL, |
@@ -404,18 +404,18 @@ discard block |
||
404 | 404 | QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0, |
405 | 405 | PRIMARY KEY (QST_ID), |
406 | 406 | KEY QST_order (QST_order)'; |
407 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
408 | - $table_name = 'esp_question_group_question'; |
|
409 | - $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
407 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
408 | + $table_name = 'esp_question_group_question'; |
|
409 | + $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
410 | 410 | QSG_ID int(10) unsigned NOT NULL, |
411 | 411 | QST_ID int(10) unsigned NOT NULL, |
412 | 412 | QGQ_order int(10) unsigned NOT NULL DEFAULT 0, |
413 | 413 | PRIMARY KEY (QGQ_ID), |
414 | 414 | KEY QST_ID (QST_ID), |
415 | 415 | KEY QSG_ID_order (QSG_ID,QGQ_order)"; |
416 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
417 | - $table_name = 'esp_question_option'; |
|
418 | - $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
416 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
417 | + $table_name = 'esp_question_option'; |
|
418 | + $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
419 | 419 | QSO_value varchar(255) NOT NULL, |
420 | 420 | QSO_desc text NOT NULL, |
421 | 421 | QST_ID int(10) unsigned NOT NULL, |
@@ -425,9 +425,9 @@ discard block |
||
425 | 425 | PRIMARY KEY (QSO_ID), |
426 | 426 | KEY QST_ID (QST_ID), |
427 | 427 | KEY QSO_order (QSO_order)"; |
428 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
429 | - $table_name = 'esp_registration'; |
|
430 | - $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
428 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
429 | + $table_name = 'esp_registration'; |
|
430 | + $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
431 | 431 | EVT_ID bigint(20) unsigned NOT NULL, |
432 | 432 | ATT_ID bigint(20) unsigned NOT NULL, |
433 | 433 | TXN_ID int(10) unsigned NOT NULL, |
@@ -451,18 +451,18 @@ discard block |
||
451 | 451 | KEY TKT_ID (TKT_ID), |
452 | 452 | KEY EVT_ID (EVT_ID), |
453 | 453 | KEY STS_ID (STS_ID)"; |
454 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
455 | - $table_name = 'esp_registration_payment'; |
|
456 | - $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
454 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
455 | + $table_name = 'esp_registration_payment'; |
|
456 | + $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
457 | 457 | REG_ID int(10) unsigned NOT NULL, |
458 | 458 | PAY_ID int(10) unsigned NULL, |
459 | 459 | RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
460 | 460 | PRIMARY KEY (RPY_ID), |
461 | 461 | KEY REG_ID (REG_ID), |
462 | 462 | KEY PAY_ID (PAY_ID)"; |
463 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
464 | - $table_name = 'esp_state'; |
|
465 | - $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
463 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB '); |
|
464 | + $table_name = 'esp_state'; |
|
465 | + $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
|
466 | 466 | CNT_ISO varchar(2) NOT NULL, |
467 | 467 | STA_abbrev varchar(24) NOT NULL, |
468 | 468 | STA_name varchar(100) NOT NULL, |
@@ -470,9 +470,9 @@ discard block |
||
470 | 470 | PRIMARY KEY (STA_ID), |
471 | 471 | KEY STA_abbrev (STA_abbrev), |
472 | 472 | KEY CNT_ISO (CNT_ISO)"; |
473 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
474 | - $table_name = 'esp_status'; |
|
475 | - $sql = "STS_ID varchar(3) NOT NULL, |
|
473 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
474 | + $table_name = 'esp_status'; |
|
475 | + $sql = "STS_ID varchar(3) NOT NULL, |
|
476 | 476 | STS_code varchar(45) NOT NULL, |
477 | 477 | STS_type varchar(45) NOT NULL, |
478 | 478 | STS_can_edit tinyint(1) NOT NULL DEFAULT 0, |
@@ -480,9 +480,9 @@ discard block |
||
480 | 480 | STS_open tinyint(1) NOT NULL DEFAULT 1, |
481 | 481 | UNIQUE KEY STS_ID_UNIQUE (STS_ID), |
482 | 482 | KEY STS_type (STS_type)"; |
483 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
484 | - $table_name = 'esp_transaction'; |
|
485 | - $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
483 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
484 | + $table_name = 'esp_transaction'; |
|
485 | + $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
486 | 486 | TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00', |
487 | 487 | TXN_total decimal(12,3) DEFAULT '0.00', |
488 | 488 | TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00', |
@@ -494,9 +494,9 @@ discard block |
||
494 | 494 | PRIMARY KEY (TXN_ID), |
495 | 495 | KEY TXN_timestamp (TXN_timestamp), |
496 | 496 | KEY STS_ID (STS_ID)"; |
497 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
498 | - $table_name = 'esp_venue_meta'; |
|
499 | - $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
497 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
498 | + $table_name = 'esp_venue_meta'; |
|
499 | + $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT, |
|
500 | 500 | VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0, |
501 | 501 | VNU_address varchar(255) DEFAULT NULL, |
502 | 502 | VNU_address2 varchar(255) DEFAULT NULL, |
@@ -515,10 +515,10 @@ discard block |
||
515 | 515 | KEY VNU_ID (VNU_ID), |
516 | 516 | KEY STA_ID (STA_ID), |
517 | 517 | KEY CNT_ISO (CNT_ISO)"; |
518 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
519 | - //modified tables |
|
520 | - $table_name = "esp_price"; |
|
521 | - $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
518 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
519 | + //modified tables |
|
520 | + $table_name = "esp_price"; |
|
521 | + $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
522 | 522 | PRT_ID tinyint(3) unsigned NOT NULL, |
523 | 523 | PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00', |
524 | 524 | PRC_name varchar(245) NOT NULL, |
@@ -531,9 +531,9 @@ discard block |
||
531 | 531 | PRC_parent int(10) unsigned DEFAULT 0, |
532 | 532 | PRIMARY KEY (PRC_ID), |
533 | 533 | KEY PRT_ID (PRT_ID)"; |
534 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
535 | - $table_name = "esp_price_type"; |
|
536 | - $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
534 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
535 | + $table_name = "esp_price_type"; |
|
536 | + $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT, |
|
537 | 537 | PRT_name varchar(45) NOT NULL, |
538 | 538 | PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1', |
539 | 539 | PRT_is_percent tinyint(1) NOT NULL DEFAULT '0', |
@@ -542,9 +542,9 @@ discard block |
||
542 | 542 | PRT_deleted tinyint(1) NOT NULL DEFAULT '0', |
543 | 543 | UNIQUE KEY PRT_name_UNIQUE (PRT_name), |
544 | 544 | PRIMARY KEY (PRT_ID)"; |
545 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
546 | - $table_name = "esp_ticket"; |
|
547 | - $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
545 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB '); |
|
546 | + $table_name = "esp_ticket"; |
|
547 | + $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
548 | 548 | TTM_ID int(10) unsigned NOT NULL, |
549 | 549 | TKT_name varchar(245) NOT NULL DEFAULT '', |
550 | 550 | TKT_description text NOT NULL, |
@@ -567,9 +567,9 @@ discard block |
||
567 | 567 | TKT_deleted tinyint(1) NOT NULL DEFAULT '0', |
568 | 568 | PRIMARY KEY (TKT_ID), |
569 | 569 | KEY TKT_start_date (TKT_start_date)"; |
570 | - $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
571 | - $table_name = 'esp_question_group'; |
|
572 | - $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
570 | + $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB'); |
|
571 | + $table_name = 'esp_question_group'; |
|
572 | + $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT, |
|
573 | 573 | QSG_name varchar(255) NOT NULL, |
574 | 574 | QSG_identifier varchar(100) NOT NULL, |
575 | 575 | QSG_desc text NULL, |
@@ -582,138 +582,138 @@ discard block |
||
582 | 582 | PRIMARY KEY (QSG_ID), |
583 | 583 | UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier), |
584 | 584 | KEY QSG_order (QSG_order)'; |
585 | - $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
586 | - /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
587 | - $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
588 | - //(because many need to convert old string states to foreign keys into the states table) |
|
589 | - $script_4_1_defaults->insert_default_states(); |
|
590 | - $script_4_1_defaults->insert_default_countries(); |
|
591 | - /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
592 | - $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
593 | - $script_4_5_defaults->insert_default_price_types(); |
|
594 | - $script_4_5_defaults->insert_default_prices(); |
|
595 | - $script_4_5_defaults->insert_default_tickets(); |
|
596 | - /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
597 | - $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
598 | - $script_4_6_defaults->add_default_admin_only_payments(); |
|
599 | - $script_4_6_defaults->insert_default_currencies(); |
|
600 | - /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
601 | - $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
602 | - $script_4_8_defaults->verify_new_countries(); |
|
603 | - $script_4_8_defaults->verify_new_currencies(); |
|
604 | - $this->verify_db_collations(); |
|
605 | - $this->verify_db_collations_again(); |
|
606 | - return true; |
|
607 | - } |
|
585 | + $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB'); |
|
586 | + /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */ |
|
587 | + $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0'); |
|
588 | + //(because many need to convert old string states to foreign keys into the states table) |
|
589 | + $script_4_1_defaults->insert_default_states(); |
|
590 | + $script_4_1_defaults->insert_default_countries(); |
|
591 | + /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */ |
|
592 | + $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0'); |
|
593 | + $script_4_5_defaults->insert_default_price_types(); |
|
594 | + $script_4_5_defaults->insert_default_prices(); |
|
595 | + $script_4_5_defaults->insert_default_tickets(); |
|
596 | + /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */ |
|
597 | + $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0'); |
|
598 | + $script_4_6_defaults->add_default_admin_only_payments(); |
|
599 | + $script_4_6_defaults->insert_default_currencies(); |
|
600 | + /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */ |
|
601 | + $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0'); |
|
602 | + $script_4_8_defaults->verify_new_countries(); |
|
603 | + $script_4_8_defaults->verify_new_currencies(); |
|
604 | + $this->verify_db_collations(); |
|
605 | + $this->verify_db_collations_again(); |
|
606 | + return true; |
|
607 | + } |
|
608 | 608 | |
609 | 609 | |
610 | 610 | |
611 | - /** |
|
612 | - * @return boolean |
|
613 | - */ |
|
614 | - public function schema_changes_after_migration() |
|
615 | - { |
|
616 | - return true; |
|
617 | - } |
|
611 | + /** |
|
612 | + * @return boolean |
|
613 | + */ |
|
614 | + public function schema_changes_after_migration() |
|
615 | + { |
|
616 | + return true; |
|
617 | + } |
|
618 | 618 | |
619 | 619 | |
620 | 620 | |
621 | - public function migration_page_hooks() |
|
622 | - { |
|
623 | - } |
|
621 | + public function migration_page_hooks() |
|
622 | + { |
|
623 | + } |
|
624 | 624 | |
625 | 625 | |
626 | 626 | |
627 | - /** |
|
628 | - * Verify all EE4 models' tables use utf8mb4 collation |
|
629 | - * |
|
630 | - * @return void |
|
631 | - */ |
|
632 | - public function verify_db_collations() |
|
633 | - { |
|
634 | - if (get_option('ee_verified_db_collations', false)) { |
|
635 | - return; |
|
636 | - } |
|
637 | - // grab tables from each model |
|
638 | - $tables_to_check = array(); |
|
639 | - foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
640 | - if (method_exists($model_name, 'instance')) { |
|
641 | - $model_obj = call_user_func(array($model_name, 'instance')); |
|
642 | - if ($model_obj instanceof EEM_Base) { |
|
643 | - foreach ($model_obj->get_tables() as $table) { |
|
644 | - if ( |
|
645 | - strpos($table->get_table_name(), 'esp_') |
|
646 | - && (is_main_site()//for main tables, verify global tables |
|
647 | - || ! $table->is_global()//if not the main site, then only verify non-global tables (avoid doubling up) |
|
648 | - ) |
|
649 | - && function_exists('maybe_convert_table_to_utf8mb4') |
|
650 | - ) { |
|
651 | - $tables_to_check[] = $table->get_table_name(); |
|
652 | - } |
|
653 | - } |
|
654 | - } |
|
655 | - } |
|
656 | - } |
|
657 | - //and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active |
|
658 | - //when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead |
|
659 | - //of hard-coding this |
|
660 | - $addon_tables = array( |
|
661 | - //mailchimp |
|
662 | - 'esp_event_mailchimp_list_group', |
|
663 | - 'esp_event_question_mailchimp_field', |
|
664 | - //multisite |
|
665 | - 'esp_blog_meta', |
|
666 | - //people |
|
667 | - 'esp_people_to_post', |
|
668 | - //promotions |
|
669 | - 'esp_promotion', |
|
670 | - 'esp_promotion_object', |
|
671 | - ); |
|
672 | - foreach ($addon_tables as $table_name) { |
|
673 | - $tables_to_check[] = $table_name; |
|
674 | - } |
|
675 | - $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
676 | - //ok and now let's remember this was done (without needing to check the db schemas all over again) |
|
677 | - add_option('ee_verified_db_collations', true, null, 'no'); |
|
678 | - //seeing how this ran with the fix from 10435, no need to check again |
|
679 | - add_option('ee_verified_db_collations_again',true,null,'no'); |
|
680 | - } |
|
627 | + /** |
|
628 | + * Verify all EE4 models' tables use utf8mb4 collation |
|
629 | + * |
|
630 | + * @return void |
|
631 | + */ |
|
632 | + public function verify_db_collations() |
|
633 | + { |
|
634 | + if (get_option('ee_verified_db_collations', false)) { |
|
635 | + return; |
|
636 | + } |
|
637 | + // grab tables from each model |
|
638 | + $tables_to_check = array(); |
|
639 | + foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) { |
|
640 | + if (method_exists($model_name, 'instance')) { |
|
641 | + $model_obj = call_user_func(array($model_name, 'instance')); |
|
642 | + if ($model_obj instanceof EEM_Base) { |
|
643 | + foreach ($model_obj->get_tables() as $table) { |
|
644 | + if ( |
|
645 | + strpos($table->get_table_name(), 'esp_') |
|
646 | + && (is_main_site()//for main tables, verify global tables |
|
647 | + || ! $table->is_global()//if not the main site, then only verify non-global tables (avoid doubling up) |
|
648 | + ) |
|
649 | + && function_exists('maybe_convert_table_to_utf8mb4') |
|
650 | + ) { |
|
651 | + $tables_to_check[] = $table->get_table_name(); |
|
652 | + } |
|
653 | + } |
|
654 | + } |
|
655 | + } |
|
656 | + } |
|
657 | + //and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active |
|
658 | + //when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead |
|
659 | + //of hard-coding this |
|
660 | + $addon_tables = array( |
|
661 | + //mailchimp |
|
662 | + 'esp_event_mailchimp_list_group', |
|
663 | + 'esp_event_question_mailchimp_field', |
|
664 | + //multisite |
|
665 | + 'esp_blog_meta', |
|
666 | + //people |
|
667 | + 'esp_people_to_post', |
|
668 | + //promotions |
|
669 | + 'esp_promotion', |
|
670 | + 'esp_promotion_object', |
|
671 | + ); |
|
672 | + foreach ($addon_tables as $table_name) { |
|
673 | + $tables_to_check[] = $table_name; |
|
674 | + } |
|
675 | + $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
676 | + //ok and now let's remember this was done (without needing to check the db schemas all over again) |
|
677 | + add_option('ee_verified_db_collations', true, null, 'no'); |
|
678 | + //seeing how this ran with the fix from 10435, no need to check again |
|
679 | + add_option('ee_verified_db_collations_again',true,null,'no'); |
|
680 | + } |
|
681 | 681 | |
682 | 682 | |
683 | 683 | |
684 | - /** |
|
685 | - * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435 |
|
686 | - * which meant some DB collations might not have been updated |
|
687 | - * @return void |
|
688 | - */ |
|
689 | - public function verify_db_collations_again(){ |
|
690 | - if (get_option('ee_verified_db_collations_again', false)) { |
|
691 | - return; |
|
692 | - } |
|
693 | - $tables_to_check = array( |
|
694 | - 'esp_attendee_meta', |
|
695 | - 'esp_message' |
|
696 | - ); |
|
697 | - $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
698 | - add_option('ee_verified_db_collations_again',true,null,'no'); |
|
699 | - } |
|
684 | + /** |
|
685 | + * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435 |
|
686 | + * which meant some DB collations might not have been updated |
|
687 | + * @return void |
|
688 | + */ |
|
689 | + public function verify_db_collations_again(){ |
|
690 | + if (get_option('ee_verified_db_collations_again', false)) { |
|
691 | + return; |
|
692 | + } |
|
693 | + $tables_to_check = array( |
|
694 | + 'esp_attendee_meta', |
|
695 | + 'esp_message' |
|
696 | + ); |
|
697 | + $this->_verify_db_collations_for_tables(array_unique($tables_to_check)); |
|
698 | + add_option('ee_verified_db_collations_again',true,null,'no'); |
|
699 | + } |
|
700 | 700 | |
701 | 701 | |
702 | 702 | |
703 | - /** |
|
704 | - * Runs maybe_convert_table_to_utf8mb4 on the specified tables |
|
705 | - * @param $tables_to_check |
|
706 | - * @return boolean true if logic ran, false if it didn't |
|
707 | - */ |
|
708 | - protected function _verify_db_collations_for_tables($tables_to_check) |
|
709 | - { |
|
710 | - foreach ($tables_to_check as $table_name) { |
|
711 | - $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
|
712 | - if ( ! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name ) |
|
713 | - && $this->_get_table_analysis()->tableExists($table_name) |
|
714 | - ) { |
|
715 | - maybe_convert_table_to_utf8mb4($table_name); |
|
716 | - } |
|
717 | - } |
|
718 | - } |
|
703 | + /** |
|
704 | + * Runs maybe_convert_table_to_utf8mb4 on the specified tables |
|
705 | + * @param $tables_to_check |
|
706 | + * @return boolean true if logic ran, false if it didn't |
|
707 | + */ |
|
708 | + protected function _verify_db_collations_for_tables($tables_to_check) |
|
709 | + { |
|
710 | + foreach ($tables_to_check as $table_name) { |
|
711 | + $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name); |
|
712 | + if ( ! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name ) |
|
713 | + && $this->_get_table_analysis()->tableExists($table_name) |
|
714 | + ) { |
|
715 | + maybe_convert_table_to_utf8mb4($table_name); |
|
716 | + } |
|
717 | + } |
|
718 | + } |
|
719 | 719 | } |
720 | 720 | \ No newline at end of file |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * You can specify $default is case you haven't found the extra meta |
61 | 61 | * @param string $meta_key |
62 | 62 | * @param boolean $single |
63 | - * @param mixed $default if we don't find anything, what should we return? |
|
63 | + * @param boolean $default if we don't find anything, what should we return? |
|
64 | 64 | * @return mixed single value if $single; array if ! $single |
65 | 65 | */ |
66 | 66 | public function get_extra_meta($meta_key,$single = FALSE,$default = NULL); |
@@ -72,9 +72,7 @@ discard block |
||
72 | 72 | * The $extra_cache_ref will be passed to the model field's prepare_for_pretty_echoing, so consult the field's class |
73 | 73 | * to see what options are available. |
74 | 74 | * @param string $field_name |
75 | - * @param string $format This allows the user to specify an extra cache ref for the given property |
|
76 | - * (in cases where the same property may be used for different outputs |
|
77 | - * - i.e. datetime, money etc.) |
|
75 | + * @param string|null $extra_cache_ref |
|
78 | 76 | * @return mixed |
79 | 77 | * @throws \EE_Error |
80 | 78 | */ |
@@ -120,6 +118,7 @@ discard block |
||
120 | 118 | * |
121 | 119 | * @param EE_Request $request |
122 | 120 | * @param EE_Response $response |
121 | + * @return void |
|
123 | 122 | */ |
124 | 123 | public function handle_response( EE_Request $request, EE_Response $response ); |
125 | 124 | } |
@@ -203,26 +202,78 @@ discard block |
||
203 | 202 | * Interface EEI_Attendee |
204 | 203 | */ |
205 | 204 | interface EEI_Attendee { |
205 | + |
|
206 | + /** |
|
207 | + * @return string |
|
208 | + */ |
|
206 | 209 | public function fname(); |
210 | + |
|
211 | + /** |
|
212 | + * @return string |
|
213 | + */ |
|
207 | 214 | public function lname(); |
215 | + |
|
216 | + /** |
|
217 | + * @return string |
|
218 | + */ |
|
208 | 219 | public function full_name(); |
220 | + |
|
221 | + /** |
|
222 | + * @return string |
|
223 | + */ |
|
209 | 224 | public function email(); |
225 | + |
|
226 | + /** |
|
227 | + * @return string |
|
228 | + */ |
|
210 | 229 | public function phone(); |
230 | + |
|
231 | + /** |
|
232 | + * @return string |
|
233 | + */ |
|
211 | 234 | public function address(); |
235 | + |
|
236 | + /** |
|
237 | + * @return string |
|
238 | + */ |
|
212 | 239 | public function address2(); |
240 | + |
|
241 | + /** |
|
242 | + * @return string |
|
243 | + */ |
|
213 | 244 | public function city(); |
245 | + |
|
246 | + /** |
|
247 | + * @return string |
|
248 | + */ |
|
214 | 249 | public function state_ID(); |
250 | + |
|
251 | + /** |
|
252 | + * @return string |
|
253 | + */ |
|
215 | 254 | public function state_name(); |
216 | 255 | /** |
217 | 256 | * @return EE_State |
218 | 257 | */ |
219 | 258 | public function state_obj(); |
259 | + |
|
260 | + /** |
|
261 | + * @return string |
|
262 | + */ |
|
220 | 263 | public function country_ID(); |
264 | + |
|
265 | + /** |
|
266 | + * @return string |
|
267 | + */ |
|
221 | 268 | public function country_name(); |
222 | 269 | /** |
223 | 270 | * @return EE_Country |
224 | 271 | */ |
225 | 272 | public function country_obj(); |
273 | + |
|
274 | + /** |
|
275 | + * @return string |
|
276 | + */ |
|
226 | 277 | public function zip(); |
227 | 278 | } |
228 | 279 | |
@@ -234,9 +285,25 @@ discard block |
||
234 | 285 | * Interface EEI_Contact |
235 | 286 | */ |
236 | 287 | interface EEI_Contact { |
288 | + |
|
289 | + /** |
|
290 | + * @return string |
|
291 | + */ |
|
237 | 292 | public function fname(); |
293 | + |
|
294 | + /** |
|
295 | + * @return string |
|
296 | + */ |
|
238 | 297 | public function lname(); |
298 | + |
|
299 | + /** |
|
300 | + * @return string |
|
301 | + */ |
|
239 | 302 | public function email(); |
303 | + |
|
304 | + /** |
|
305 | + * @return string |
|
306 | + */ |
|
240 | 307 | public function phone(); |
241 | 308 | } |
242 | 309 | |
@@ -263,24 +330,64 @@ discard block |
||
263 | 330 | * Interface EEI_Address |
264 | 331 | */ |
265 | 332 | interface EEI_Address { |
333 | + |
|
334 | + /** |
|
335 | + * @return string |
|
336 | + */ |
|
266 | 337 | public function address(); |
338 | + |
|
339 | + /** |
|
340 | + * @return string |
|
341 | + */ |
|
267 | 342 | public function address2(); |
343 | + |
|
344 | + /** |
|
345 | + * @return string |
|
346 | + */ |
|
268 | 347 | public function city(); |
269 | 348 | /** |
270 | 349 | * @return EE_State |
271 | 350 | */ |
272 | 351 | public function state_obj(); |
273 | 352 | public function state_ID(); |
353 | + |
|
354 | + /** |
|
355 | + * @return string |
|
356 | + */ |
|
274 | 357 | public function state_name(); |
358 | + |
|
359 | + /** |
|
360 | + * @return string |
|
361 | + */ |
|
275 | 362 | public function state_abbrev(); |
363 | + |
|
364 | + /** |
|
365 | + * @return string |
|
366 | + */ |
|
276 | 367 | public function state(); |
277 | 368 | /** |
278 | 369 | * @return EE_Country |
279 | 370 | */ |
280 | 371 | public function country_obj(); |
372 | + |
|
373 | + /** |
|
374 | + * @return string |
|
375 | + */ |
|
281 | 376 | public function country_ID(); |
377 | + |
|
378 | + /** |
|
379 | + * @return string |
|
380 | + */ |
|
282 | 381 | public function country_name(); |
382 | + |
|
383 | + /** |
|
384 | + * @return string |
|
385 | + */ |
|
283 | 386 | public function country(); |
387 | + |
|
388 | + /** |
|
389 | + * @return string |
|
390 | + */ |
|
284 | 391 | public function zip(); |
285 | 392 | } |
286 | 393 | |
@@ -301,6 +408,7 @@ discard block |
||
301 | 408 | * @param string $zip |
302 | 409 | * @param string $country |
303 | 410 | * @param string $CNT_ISO |
411 | + * @return string|null |
|
304 | 412 | */ |
305 | 413 | public function format( $address, $address2, $city, $state, $zip, $country, $CNT_ISO ); |
306 | 414 | } |
@@ -413,7 +521,7 @@ discard block |
||
413 | 521 | /** |
414 | 522 | * @param EE_Line_Item $line_item |
415 | 523 | * @param array $options |
416 | - * @return mixed |
|
524 | + * @return string |
|
417 | 525 | */ |
418 | 526 | public function display_line_item( EE_Line_Item $line_item, $options = array() ); |
419 | 527 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | /** |
6 | 6 | * Interface EEI_Base |
7 | 7 | */ |
8 | -interface EEI_Base{ |
|
8 | +interface EEI_Base { |
|
9 | 9 | /** |
10 | 10 | * gets the unique ID of the model object. If it hasn't been saved yet |
11 | 11 | * to the database, this should be 0 or NULL |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @return int records updated (or BOOLEAN if we actually ended up inserting the extra meta row) |
33 | 33 | * NOTE: if the values haven't changed, returns 0 |
34 | 34 | */ |
35 | - public function update_extra_meta($meta_key,$meta_value,$previous_value = NULL); |
|
35 | + public function update_extra_meta($meta_key, $meta_value, $previous_value = NULL); |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * Adds a new extra meta record. If $unique is set to TRUE, we'll first double-check |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param boolean $unique |
44 | 44 | * @return boolean |
45 | 45 | */ |
46 | - public function add_extra_meta($meta_key,$meta_value,$unique = false); |
|
46 | + public function add_extra_meta($meta_key, $meta_value, $unique = false); |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Deletes all the extra meta rows for this record as specified by key. If $meta_value |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param string $meta_value |
53 | 53 | * @return int number of extra meta rows deleted |
54 | 54 | */ |
55 | - public function delete_extra_meta($meta_key,$meta_value = NULL); |
|
55 | + public function delete_extra_meta($meta_key, $meta_value = NULL); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Gets the extra meta with the given meta key. If you specify "single" we just return 1, otherwise |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param mixed $default if we don't find anything, what should we return? |
64 | 64 | * @return mixed single value if $single; array if ! $single |
65 | 65 | */ |
66 | - public function get_extra_meta($meta_key,$single = FALSE,$default = NULL); |
|
66 | + public function get_extra_meta($meta_key, $single = FALSE, $default = NULL); |
|
67 | 67 | |
68 | 68 | |
69 | 69 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @param EE_Response $response |
106 | 106 | * @return EE_Response |
107 | 107 | */ |
108 | - public function handle_request( EE_Request $request, EE_Response $response ); |
|
108 | + public function handle_request(EE_Request $request, EE_Response $response); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @param EE_Request $request |
122 | 122 | * @param EE_Response $response |
123 | 123 | */ |
124 | - public function handle_response( EE_Request $request, EE_Response $response ); |
|
124 | + public function handle_response(EE_Request $request, EE_Response $response); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @param string $country |
303 | 303 | * @param string $CNT_ISO |
304 | 304 | */ |
305 | - public function format( $address, $address2, $city, $state, $zip, $country, $CNT_ISO ); |
|
305 | + public function format($address, $address2, $city, $state, $zip, $country, $CNT_ISO); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | |
@@ -312,13 +312,13 @@ discard block |
||
312 | 312 | /** |
313 | 313 | * Interface EEHI_Line_Item |
314 | 314 | */ |
315 | -interface EEHI_Line_Item{ |
|
315 | +interface EEHI_Line_Item { |
|
316 | 316 | /** |
317 | 317 | * Adds an item to the purchase in the right spot |
318 | 318 | * @param EE_Line_Item $total_line_item |
319 | 319 | * @param EE_Line_Item $line_item |
320 | 320 | */ |
321 | - public function add_item( EE_Line_Item $total_line_item, EE_Line_Item $line_item ); |
|
321 | + public function add_item(EE_Line_Item $total_line_item, EE_Line_Item $line_item); |
|
322 | 322 | /** |
323 | 323 | * Overwrites the previous tax by clearing out the old taxes, and creates a new |
324 | 324 | * tax and updates the total line item accordingly |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | * set the taxes to match $amount |
333 | 333 | * @return EE_Line_Item the new tax created |
334 | 334 | */ |
335 | - public function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false ); |
|
335 | + public function set_total_tax_to(EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false); |
|
336 | 336 | |
337 | 337 | /** |
338 | 338 | * Makes all the line items which are children of $line_item taxable (or not). |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | * @param string $code_substring_for_whitelist if this string is part of the line item's code |
343 | 343 | * it will be whitelisted (ie, except from becoming taxable) |
344 | 344 | */ |
345 | - public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null ); |
|
345 | + public static function set_line_items_taxable(EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null); |
|
346 | 346 | |
347 | 347 | /** |
348 | 348 | * Adds a simple item ( unrelated to any other model object) to the total line item, |
@@ -356,21 +356,21 @@ discard block |
||
356 | 356 | * @param boolean $code if set to a value, ensures there is only one line item with that code |
357 | 357 | * @return boolean success |
358 | 358 | */ |
359 | - public function add_unrelated_item( EE_Line_Item $total_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = null ); |
|
359 | + public function add_unrelated_item(EE_Line_Item $total_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = null); |
|
360 | 360 | |
361 | 361 | /** |
362 | 362 | * Gets the line item for the taxes subtotal |
363 | 363 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
364 | 364 | * @return \EE_Line_Item |
365 | 365 | */ |
366 | - public static function get_taxes_subtotal( EE_Line_Item $total_line_item ); |
|
366 | + public static function get_taxes_subtotal(EE_Line_Item $total_line_item); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | |
370 | 370 | /** |
371 | 371 | * Money-related helper |
372 | 372 | */ |
373 | -interface EEHI_Money{ |
|
373 | +interface EEHI_Money { |
|
374 | 374 | /** |
375 | 375 | * For comparing floats. Default operator is '=', but see the $operator below for all options. |
376 | 376 | * This should be used to compare floats instead of normal '==' because floats |
@@ -381,13 +381,13 @@ discard block |
||
381 | 381 | * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne |
382 | 382 | * @return boolean whether the equation is true or false |
383 | 383 | */ |
384 | - public function compare_floats( $float1, $float2, $operator='=' ); |
|
384 | + public function compare_floats($float1, $float2, $operator = '='); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | /** |
388 | 388 | * Interface EEHI_Template |
389 | 389 | */ |
390 | -interface EEHI_Template{ |
|
390 | +interface EEHI_Template { |
|
391 | 391 | |
392 | 392 | /** |
393 | 393 | * EEH_Template::format_currency |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | * @param string $cur_code_span_class |
401 | 401 | * @return string the html output for the formatted money value |
402 | 402 | */ |
403 | - public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' ); |
|
403 | + public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code'); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | * @param array $options |
416 | 416 | * @return mixed |
417 | 417 | */ |
418 | - public function display_line_item( EE_Line_Item $line_item, $options = array() ); |
|
418 | + public function display_line_item(EE_Line_Item $line_item, $options = array()); |
|
419 | 419 | |
420 | 420 | } |
421 | 421 | |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | * @throws EE_Error |
433 | 433 | * @return bool |
434 | 434 | */ |
435 | - public static function ensure_file_exists_and_is_writable( $full_file_path = '' ); |
|
435 | + public static function ensure_file_exists_and_is_writable($full_file_path = ''); |
|
436 | 436 | |
437 | 437 | /** |
438 | 438 | * ensure_folder_exists_and_is_writable |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | * @throws EE_Error |
442 | 442 | * @return bool |
443 | 443 | */ |
444 | - public static function ensure_folder_exists_and_is_writable( $folder = '' ); |
|
444 | + public static function ensure_folder_exists_and_is_writable($folder = ''); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | // End of file EEI_Interfaces.php |
@@ -67,18 +67,18 @@ discard block |
||
67 | 67 | |
68 | 68 | |
69 | 69 | |
70 | - /** |
|
71 | - * Gets a pretty view of the field's value. $extra_cache_ref can specify different formats for this. |
|
72 | - * The $extra_cache_ref will be passed to the model field's prepare_for_pretty_echoing, so consult the field's class |
|
73 | - * to see what options are available. |
|
74 | - * @param string $field_name |
|
75 | - * @param string $format This allows the user to specify an extra cache ref for the given property |
|
76 | - * (in cases where the same property may be used for different outputs |
|
77 | - * - i.e. datetime, money etc.) |
|
78 | - * @return mixed |
|
79 | - * @throws \EE_Error |
|
80 | - */ |
|
81 | - public function get_pretty($field_name, $extra_cache_ref); |
|
70 | + /** |
|
71 | + * Gets a pretty view of the field's value. $extra_cache_ref can specify different formats for this. |
|
72 | + * The $extra_cache_ref will be passed to the model field's prepare_for_pretty_echoing, so consult the field's class |
|
73 | + * to see what options are available. |
|
74 | + * @param string $field_name |
|
75 | + * @param string $format This allows the user to specify an extra cache ref for the given property |
|
76 | + * (in cases where the same property may be used for different outputs |
|
77 | + * - i.e. datetime, money etc.) |
|
78 | + * @return mixed |
|
79 | + * @throws \EE_Error |
|
80 | + */ |
|
81 | + public function get_pretty($field_name, $extra_cache_ref); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
@@ -168,11 +168,11 @@ discard block |
||
168 | 168 | |
169 | 169 | |
170 | 170 | |
171 | - /** |
|
172 | - * Retrieves all the pending payments on this transaction |
|
173 | - * @return EEI_Payment[] |
|
174 | - */ |
|
175 | - public function pending_payments(); |
|
171 | + /** |
|
172 | + * Retrieves all the pending payments on this transaction |
|
173 | + * @return EEI_Payment[] |
|
174 | + */ |
|
175 | + public function pending_payments(); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | interface EEI_Attendee { |
214 | 214 | public function fname(); |
215 | 215 | public function lname(); |
216 | - public function full_name(); |
|
216 | + public function full_name(); |
|
217 | 217 | public function email(); |
218 | 218 | public function phone(); |
219 | 219 | public function address(); |
@@ -334,23 +334,23 @@ discard block |
||
334 | 334 | * @param float $amount |
335 | 335 | * @param string $name |
336 | 336 | * @param string $description |
337 | - * @param string $code |
|
338 | - * @param boolean $add_to_existing_line_item if true and a duplicate line item with |
|
339 | - * the same code is found, $amount will be added onto it; otherwise will simply |
|
340 | - * set the taxes to match $amount |
|
337 | + * @param string $code |
|
338 | + * @param boolean $add_to_existing_line_item if true and a duplicate line item with |
|
339 | + * the same code is found, $amount will be added onto it; otherwise will simply |
|
340 | + * set the taxes to match $amount |
|
341 | 341 | * @return EE_Line_Item the new tax created |
342 | 342 | */ |
343 | 343 | public function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false ); |
344 | 344 | |
345 | - /** |
|
346 | - * Makes all the line items which are children of $line_item taxable (or not). |
|
347 | - * Does NOT save the line items |
|
348 | - * @param EE_Line_Item $line_item |
|
349 | - * @param boolean $taxable |
|
350 | - * @param string $code_substring_for_whitelist if this string is part of the line item's code |
|
351 | - * it will be whitelisted (ie, except from becoming taxable) |
|
352 | - */ |
|
353 | - public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null ); |
|
345 | + /** |
|
346 | + * Makes all the line items which are children of $line_item taxable (or not). |
|
347 | + * Does NOT save the line items |
|
348 | + * @param EE_Line_Item $line_item |
|
349 | + * @param boolean $taxable |
|
350 | + * @param string $code_substring_for_whitelist if this string is part of the line item's code |
|
351 | + * it will be whitelisted (ie, except from becoming taxable) |
|
352 | + */ |
|
353 | + public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null ); |
|
354 | 354 | |
355 | 355 | /** |
356 | 356 | * Adds a simple item ( unrelated to any other model object) to the total line item, |
@@ -380,15 +380,15 @@ discard block |
||
380 | 380 | */ |
381 | 381 | interface EEHI_Money{ |
382 | 382 | /** |
383 | - * For comparing floats. Default operator is '=', but see the $operator below for all options. |
|
384 | - * This should be used to compare floats instead of normal '==' because floats |
|
385 | - * are inherently imprecise, and so you can sometimes have two floats that appear to be identical |
|
386 | - * but actually differ by 0.00000001. |
|
387 | - * @param float $float1 |
|
388 | - * @param float $float2 |
|
389 | - * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne |
|
390 | - * @return boolean whether the equation is true or false |
|
391 | - */ |
|
383 | + * For comparing floats. Default operator is '=', but see the $operator below for all options. |
|
384 | + * This should be used to compare floats instead of normal '==' because floats |
|
385 | + * are inherently imprecise, and so you can sometimes have two floats that appear to be identical |
|
386 | + * but actually differ by 0.00000001. |
|
387 | + * @param float $float1 |
|
388 | + * @param float $float2 |
|
389 | + * @param string $operator The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne |
|
390 | + * @return boolean whether the equation is true or false |
|
391 | + */ |
|
392 | 392 | public function compare_floats( $float1, $float2, $operator='=' ); |
393 | 393 | } |
394 | 394 |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | /** |
370 | 370 | * Gets the first event for this payment (it's possible that it could be for multiple) |
371 | 371 | * @param EEI_Payment $payment |
372 | - * @return EEI_Event|null |
|
372 | + * @return EE_Event|null |
|
373 | 373 | * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event() |
374 | 374 | */ |
375 | 375 | protected function _get_first_event_for_payment( EEI_Payment $payment ) { |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | * Gets the order description that should generlly be sent to gateways |
431 | 431 | * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatOrderDescription($payment) |
432 | 432 | * @param EEI_Payment $payment |
433 | - * @return type |
|
433 | + * @return string |
|
434 | 434 | */ |
435 | 435 | protected function _format_order_description( EEI_Payment $payment ) { |
436 | 436 | return $this->_get_gateway_formatter()->formatOrderDescription($payment); |
@@ -74,15 +74,15 @@ discard block |
||
74 | 74 | */ |
75 | 75 | protected $_line_item; |
76 | 76 | |
77 | - /** |
|
78 | - * @var GatewayDataFormatterInterface |
|
79 | - */ |
|
80 | - protected $_gateway_data_formatter; |
|
77 | + /** |
|
78 | + * @var GatewayDataFormatterInterface |
|
79 | + */ |
|
80 | + protected $_gateway_data_formatter; |
|
81 | 81 | |
82 | - /** |
|
83 | - * @var FormatterInterface |
|
84 | - */ |
|
85 | - protected $_unsupported_character_remover; |
|
82 | + /** |
|
83 | + * @var FormatterInterface |
|
84 | + */ |
|
85 | + protected $_unsupported_character_remover; |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * The ID of the payment method using this gateway |
@@ -211,75 +211,75 @@ discard block |
||
211 | 211 | |
212 | 212 | |
213 | 213 | |
214 | - /** |
|
215 | - * Sets the gateway data formatter helper |
|
216 | - * @param GatewayDataFormatterInterface $gateway_data_formatter |
|
217 | - * @throws InvalidEntityException if it's not set properly |
|
218 | - */ |
|
214 | + /** |
|
215 | + * Sets the gateway data formatter helper |
|
216 | + * @param GatewayDataFormatterInterface $gateway_data_formatter |
|
217 | + * @throws InvalidEntityException if it's not set properly |
|
218 | + */ |
|
219 | 219 | public function set_gateway_data_formatter( GatewayDataFormatterInterface $gateway_data_formatter){ |
220 | - if( ! $gateway_data_formatter instanceof GatewayDataFormatterInterface){ |
|
221 | - throw new InvalidEntityException( |
|
222 | - is_object($gateway_data_formatter) |
|
223 | - ? get_class($gateway_data_formatter) |
|
224 | - : esc_html__('Not an object','event_espresso'), |
|
225 | - '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
|
226 | - ); |
|
227 | - } |
|
228 | - $this->_gateway_data_formatter = $gateway_data_formatter; |
|
229 | - } |
|
230 | - |
|
231 | - /** |
|
232 | - * Gets the gateway data formatter |
|
233 | - * @return GatewayDataFormatterInterface |
|
234 | - * @throws InvalidEntityException if it's not set properly |
|
235 | - */ |
|
236 | - protected function _get_gateway_formatter(){ |
|
237 | - if( ! $this->_gateway_data_formatter instanceof GatewayDataFormatterInterface){ |
|
238 | - throw new InvalidEntityException( |
|
239 | - is_object($this->_gateway_data_formatter) |
|
240 | - ? get_class($this->_gateway_data_formatter) |
|
241 | - : esc_html__('Not an object','event_espresso'), |
|
242 | - '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
|
243 | - ); |
|
244 | - } |
|
245 | - return $this->_gateway_data_formatter; |
|
246 | - } |
|
247 | - |
|
248 | - |
|
249 | - |
|
250 | - /** |
|
251 | - * Sets the helper which will remove unsupported characters for most gateways |
|
252 | - * @param FormatterInterface $formatter |
|
253 | - * @return FormatterInterface |
|
254 | - * @throws InvalidEntityException |
|
255 | - */ |
|
256 | - public function set_unsupported_character_remover( FormatterInterface $formatter){ |
|
257 | - if( ! $formatter instanceof FormatterInterface){ |
|
258 | - throw new InvalidEntityException( |
|
259 | - is_object($formatter) |
|
260 | - ? get_class($formatter) |
|
261 | - : esc_html__('Not an object','event_espresso'), |
|
262 | - '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
|
263 | - ); |
|
264 | - } |
|
265 | - $this->_unsupported_character_remover = $formatter; |
|
266 | - } |
|
267 | - /** |
|
268 | - * Gets the helper which removes characters which gateways might not support, like emojis etc. |
|
269 | - * @return FormatterInterface |
|
270 | - * @throws InvalidEntityException |
|
271 | - */ |
|
272 | - protected function _get_unsupported_character_remover(){ |
|
273 | - if( ! $this->_unsupported_character_remover instanceof FormatterInterface){ |
|
274 | - throw new InvalidEntityException( |
|
275 | - is_object($this->_unsupported_character_remover) |
|
276 | - ? get_class($this->_unsupported_character_remover) |
|
277 | - : esc_html__('Not an object','event_espresso'), |
|
278 | - '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
|
279 | - ); |
|
280 | - } |
|
281 | - return $this->_unsupported_character_remover; |
|
282 | - } |
|
220 | + if( ! $gateway_data_formatter instanceof GatewayDataFormatterInterface){ |
|
221 | + throw new InvalidEntityException( |
|
222 | + is_object($gateway_data_formatter) |
|
223 | + ? get_class($gateway_data_formatter) |
|
224 | + : esc_html__('Not an object','event_espresso'), |
|
225 | + '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
|
226 | + ); |
|
227 | + } |
|
228 | + $this->_gateway_data_formatter = $gateway_data_formatter; |
|
229 | + } |
|
230 | + |
|
231 | + /** |
|
232 | + * Gets the gateway data formatter |
|
233 | + * @return GatewayDataFormatterInterface |
|
234 | + * @throws InvalidEntityException if it's not set properly |
|
235 | + */ |
|
236 | + protected function _get_gateway_formatter(){ |
|
237 | + if( ! $this->_gateway_data_formatter instanceof GatewayDataFormatterInterface){ |
|
238 | + throw new InvalidEntityException( |
|
239 | + is_object($this->_gateway_data_formatter) |
|
240 | + ? get_class($this->_gateway_data_formatter) |
|
241 | + : esc_html__('Not an object','event_espresso'), |
|
242 | + '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
|
243 | + ); |
|
244 | + } |
|
245 | + return $this->_gateway_data_formatter; |
|
246 | + } |
|
247 | + |
|
248 | + |
|
249 | + |
|
250 | + /** |
|
251 | + * Sets the helper which will remove unsupported characters for most gateways |
|
252 | + * @param FormatterInterface $formatter |
|
253 | + * @return FormatterInterface |
|
254 | + * @throws InvalidEntityException |
|
255 | + */ |
|
256 | + public function set_unsupported_character_remover( FormatterInterface $formatter){ |
|
257 | + if( ! $formatter instanceof FormatterInterface){ |
|
258 | + throw new InvalidEntityException( |
|
259 | + is_object($formatter) |
|
260 | + ? get_class($formatter) |
|
261 | + : esc_html__('Not an object','event_espresso'), |
|
262 | + '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
|
263 | + ); |
|
264 | + } |
|
265 | + $this->_unsupported_character_remover = $formatter; |
|
266 | + } |
|
267 | + /** |
|
268 | + * Gets the helper which removes characters which gateways might not support, like emojis etc. |
|
269 | + * @return FormatterInterface |
|
270 | + * @throws InvalidEntityException |
|
271 | + */ |
|
272 | + protected function _get_unsupported_character_remover(){ |
|
273 | + if( ! $this->_unsupported_character_remover instanceof FormatterInterface){ |
|
274 | + throw new InvalidEntityException( |
|
275 | + is_object($this->_unsupported_character_remover) |
|
276 | + ? get_class($this->_unsupported_character_remover) |
|
277 | + : esc_html__('Not an object','event_espresso'), |
|
278 | + '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
|
279 | + ); |
|
280 | + } |
|
281 | + return $this->_unsupported_character_remover; |
|
282 | + } |
|
283 | 283 | |
284 | 284 | |
285 | 285 | /** |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * Formats the amount so it can generally be sent to gateways |
301 | 301 | * @param float $amount |
302 | 302 | * @return string |
303 | - * @deprecated since 4.9.31 insetad use EventEspresso\core\services\payment_methods\gateways\GatewayDataFormatter::format_currency() |
|
303 | + * @deprecated since 4.9.31 insetad use EventEspresso\core\services\payment_methods\gateways\GatewayDataFormatter::format_currency() |
|
304 | 304 | */ |
305 | 305 | public function format_currency($amount){ |
306 | 306 | return $this->_get_gateway_formatter()->formatCurrency($amount); |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | * Gets the first event for this payment (it's possible that it could be for multiple) |
371 | 371 | * @param EEI_Payment $payment |
372 | 372 | * @return EEI_Event|null |
373 | - * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event() |
|
373 | + * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event() |
|
374 | 374 | */ |
375 | 375 | protected function _get_first_event_for_payment( EEI_Payment $payment ) { |
376 | 376 | return $payment->get_first_event(); |
@@ -380,14 +380,14 @@ discard block |
||
380 | 380 | * Gets the name of the first event for which is being paid |
381 | 381 | * @param EEI_Payment $payment |
382 | 382 | * @return string |
383 | - * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event_name() |
|
383 | + * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event_name() |
|
384 | 384 | */ |
385 | 385 | protected function _get_first_event_name_for_payment( EEI_Payment $payment ) { |
386 | 386 | return $payment->get_first_event_name(); |
387 | 387 | } |
388 | 388 | /** |
389 | 389 | * Gets the text to use for a gateway's line item name when this is a partial payment |
390 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatPartialPaymentLineItemName($payment) |
|
390 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatPartialPaymentLineItemName($payment) |
|
391 | 391 | * @param EE_Payment $payment |
392 | 392 | * @return string |
393 | 393 | */ |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | } |
397 | 397 | /** |
398 | 398 | * Gets the text to use for a gateway's line item description when this is a partial payment |
399 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatPartialPaymentLineItemDesc() |
|
399 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatPartialPaymentLineItemDesc() |
|
400 | 400 | * @param EEI_Payment $payment |
401 | 401 | * @return string |
402 | 402 | */ |
@@ -405,9 +405,9 @@ discard block |
||
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
408 | - * Gets the name to use for a line item when sending line items to the gateway |
|
409 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatLineItemName($line_item,$payment) |
|
410 | - * @param EEI_Line_Item $line_item |
|
408 | + * Gets the name to use for a line item when sending line items to the gateway |
|
409 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatLineItemName($line_item,$payment) |
|
410 | + * @param EEI_Line_Item $line_item |
|
411 | 411 | * @param EEI_Payment $payment |
412 | 412 | * @return string |
413 | 413 | */ |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | |
418 | 418 | /** |
419 | 419 | * Gets the description to use for a line item when sending line items to the gateway |
420 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatLineItemDesc($line_item, $payment)) |
|
420 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatLineItemDesc($line_item, $payment)) |
|
421 | 421 | * @param EEI_Line_Item $line_item |
422 | 422 | * @param EEI_Payment $payment |
423 | 423 | * @return string |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | |
429 | 429 | /** |
430 | 430 | * Gets the order description that should generlly be sent to gateways |
431 | - * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatOrderDescription($payment) |
|
431 | + * @deprecated since 4.9.31 instead use $this->_get_gateway_formatter()->formatOrderDescription($payment) |
|
432 | 432 | * @param EEI_Payment $payment |
433 | 433 | * @return type |
434 | 434 | */ |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @subpackage core/libraries/payment_methods |
21 | 21 | * @author Mike Nelson |
22 | 22 | */ |
23 | -abstract class EE_Gateway{ |
|
23 | +abstract class EE_Gateway { |
|
24 | 24 | /** |
25 | 25 | * a constant used as a possible value for $_currencies_supported to indicate |
26 | 26 | * that ALL currencies are supported by this gateway |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | /** |
109 | 109 | * @return EE_Gateway |
110 | 110 | */ |
111 | - public function __construct(){ |
|
111 | + public function __construct() { |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | * beginning again) |
121 | 121 | * @return array |
122 | 122 | */ |
123 | - public function __sleep(){ |
|
123 | + public function __sleep() { |
|
124 | 124 | $properties = get_object_vars($this); |
125 | - unset( $properties[ '_pay_model' ], $properties[ '_pay_log' ] ); |
|
125 | + unset($properties['_pay_model'], $properties['_pay_log']); |
|
126 | 126 | return array_keys($properties); |
127 | 127 | } |
128 | 128 | /** |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * see $_supports_sending_refunds |
131 | 131 | * @return boolean |
132 | 132 | */ |
133 | - public function supports_sending_refunds(){ |
|
133 | + public function supports_sending_refunds() { |
|
134 | 134 | return $this->_supports_sending_refunds; |
135 | 135 | } |
136 | 136 | /** |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * see $_supports_receiving_refunds |
139 | 139 | * @return boolean |
140 | 140 | */ |
141 | - public function supports_receiving_refunds(){ |
|
141 | + public function supports_receiving_refunds() { |
|
142 | 142 | return $this->_supports_receiving_refunds; |
143 | 143 | } |
144 | 144 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @return EE_Payment for the refund |
154 | 154 | * @throws EE_Error |
155 | 155 | */ |
156 | - public function do_direct_refund( EE_Payment $payment, $refund_info = null ) { |
|
156 | + public function do_direct_refund(EE_Payment $payment, $refund_info = null) { |
|
157 | 157 | return NULL; |
158 | 158 | } |
159 | 159 | |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | * etc |
165 | 165 | * @param array $settings_array |
166 | 166 | */ |
167 | - public function set_settings($settings_array){ |
|
168 | - foreach($settings_array as $name => $value){ |
|
167 | + public function set_settings($settings_array) { |
|
168 | + foreach ($settings_array as $name => $value) { |
|
169 | 169 | $property_name = "_".$name; |
170 | 170 | $this->{$property_name} = $value; |
171 | 171 | } |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | * See this class description |
175 | 175 | * @param EEMI_Payment $payment_model |
176 | 176 | */ |
177 | - public function set_payment_model($payment_model){ |
|
177 | + public function set_payment_model($payment_model) { |
|
178 | 178 | $this->_pay_model = $payment_model; |
179 | 179 | } |
180 | 180 | /** |
181 | 181 | * See this class description |
182 | 182 | * @param EEMI_Payment_Log $payment_log_model |
183 | 183 | */ |
184 | - public function set_payment_log($payment_log_model){ |
|
184 | + public function set_payment_log($payment_log_model) { |
|
185 | 185 | $this->_pay_log = $payment_log_model; |
186 | 186 | } |
187 | 187 | |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | * See this class description |
190 | 190 | * @param EEHI_Template $template_helper |
191 | 191 | */ |
192 | - public function set_template_helper($template_helper){ |
|
192 | + public function set_template_helper($template_helper) { |
|
193 | 193 | $this->_template = $template_helper; |
194 | 194 | } |
195 | 195 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * See this class description |
198 | 198 | * @param EEHI_Line_Item $line_item_helper |
199 | 199 | */ |
200 | - public function set_line_item_helper( $line_item_helper ){ |
|
200 | + public function set_line_item_helper($line_item_helper) { |
|
201 | 201 | $this->_line_item = $line_item_helper; |
202 | 202 | } |
203 | 203 | |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * See this class description |
206 | 206 | * @param EEHI_Money $money_helper |
207 | 207 | */ |
208 | - public function set_money_helper( $money_helper ){ |
|
208 | + public function set_money_helper($money_helper) { |
|
209 | 209 | $this->_money = $money_helper; |
210 | 210 | } |
211 | 211 | |
@@ -216,12 +216,12 @@ discard block |
||
216 | 216 | * @param GatewayDataFormatterInterface $gateway_data_formatter |
217 | 217 | * @throws InvalidEntityException if it's not set properly |
218 | 218 | */ |
219 | - public function set_gateway_data_formatter( GatewayDataFormatterInterface $gateway_data_formatter){ |
|
220 | - if( ! $gateway_data_formatter instanceof GatewayDataFormatterInterface){ |
|
219 | + public function set_gateway_data_formatter(GatewayDataFormatterInterface $gateway_data_formatter) { |
|
220 | + if ( ! $gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
221 | 221 | throw new InvalidEntityException( |
222 | 222 | is_object($gateway_data_formatter) |
223 | 223 | ? get_class($gateway_data_formatter) |
224 | - : esc_html__('Not an object','event_espresso'), |
|
224 | + : esc_html__('Not an object', 'event_espresso'), |
|
225 | 225 | '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
226 | 226 | ); |
227 | 227 | } |
@@ -233,12 +233,12 @@ discard block |
||
233 | 233 | * @return GatewayDataFormatterInterface |
234 | 234 | * @throws InvalidEntityException if it's not set properly |
235 | 235 | */ |
236 | - protected function _get_gateway_formatter(){ |
|
237 | - if( ! $this->_gateway_data_formatter instanceof GatewayDataFormatterInterface){ |
|
236 | + protected function _get_gateway_formatter() { |
|
237 | + if ( ! $this->_gateway_data_formatter instanceof GatewayDataFormatterInterface) { |
|
238 | 238 | throw new InvalidEntityException( |
239 | 239 | is_object($this->_gateway_data_formatter) |
240 | 240 | ? get_class($this->_gateway_data_formatter) |
241 | - : esc_html__('Not an object','event_espresso'), |
|
241 | + : esc_html__('Not an object', 'event_espresso'), |
|
242 | 242 | '\\EventEspresso\\core\\services\\payment_methods\\gateways\\GatewayDataFormatterInterface' |
243 | 243 | ); |
244 | 244 | } |
@@ -253,12 +253,12 @@ discard block |
||
253 | 253 | * @return FormatterInterface |
254 | 254 | * @throws InvalidEntityException |
255 | 255 | */ |
256 | - public function set_unsupported_character_remover( FormatterInterface $formatter){ |
|
257 | - if( ! $formatter instanceof FormatterInterface){ |
|
256 | + public function set_unsupported_character_remover(FormatterInterface $formatter) { |
|
257 | + if ( ! $formatter instanceof FormatterInterface) { |
|
258 | 258 | throw new InvalidEntityException( |
259 | 259 | is_object($formatter) |
260 | 260 | ? get_class($formatter) |
261 | - : esc_html__('Not an object','event_espresso'), |
|
261 | + : esc_html__('Not an object', 'event_espresso'), |
|
262 | 262 | '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
263 | 263 | ); |
264 | 264 | } |
@@ -269,12 +269,12 @@ discard block |
||
269 | 269 | * @return FormatterInterface |
270 | 270 | * @throws InvalidEntityException |
271 | 271 | */ |
272 | - protected function _get_unsupported_character_remover(){ |
|
273 | - if( ! $this->_unsupported_character_remover instanceof FormatterInterface){ |
|
272 | + protected function _get_unsupported_character_remover() { |
|
273 | + if ( ! $this->_unsupported_character_remover instanceof FormatterInterface) { |
|
274 | 274 | throw new InvalidEntityException( |
275 | 275 | is_object($this->_unsupported_character_remover) |
276 | 276 | ? get_class($this->_unsupported_character_remover) |
277 | - : esc_html__('Not an object','event_espresso'), |
|
277 | + : esc_html__('Not an object', 'event_espresso'), |
|
278 | 278 | '\\EventEspresso\\core\\services\\formatters\\FormatterInterface' |
279 | 279 | ); |
280 | 280 | } |
@@ -286,15 +286,15 @@ discard block |
||
286 | 286 | * @param $message |
287 | 287 | * @param $payment |
288 | 288 | */ |
289 | - public function log($message,$payment){ |
|
290 | - if($payment instanceof EEI_Payment){ |
|
291 | - $type='Payment'; |
|
289 | + public function log($message, $payment) { |
|
290 | + if ($payment instanceof EEI_Payment) { |
|
291 | + $type = 'Payment'; |
|
292 | 292 | $id = $payment->ID(); |
293 | - }else{ |
|
293 | + } else { |
|
294 | 294 | $type = 'Payment_Method'; |
295 | 295 | $id = $this->_ID; |
296 | 296 | } |
297 | - $this->_pay_log->gateway_log($message,$id,$type); |
|
297 | + $this->_pay_log->gateway_log($message, $id, $type); |
|
298 | 298 | } |
299 | 299 | /** |
300 | 300 | * Formats the amount so it can generally be sent to gateways |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @return string |
303 | 303 | * @deprecated since 4.9.31 insetad use EventEspresso\core\services\payment_methods\gateways\GatewayDataFormatter::format_currency() |
304 | 304 | */ |
305 | - public function format_currency($amount){ |
|
305 | + public function format_currency($amount) { |
|
306 | 306 | return $this->_get_gateway_formatter()->formatCurrency($amount); |
307 | 307 | } |
308 | 308 | |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * or a string indicating they're all supported (EE_gateway::all_currencies_supported) |
312 | 312 | * @return mixed array or string |
313 | 313 | */ |
314 | - public function currencies_supported(){ |
|
314 | + public function currencies_supported() { |
|
315 | 315 | return $this->_currencies_supported; |
316 | 316 | } |
317 | 317 | |
@@ -323,14 +323,14 @@ discard block |
||
323 | 323 | * @param EE_Transaction $transaction |
324 | 324 | * @return float |
325 | 325 | */ |
326 | - protected function _sum_items_and_taxes( EE_Transaction $transaction){ |
|
326 | + protected function _sum_items_and_taxes(EE_Transaction $transaction) { |
|
327 | 327 | $total_line_item = $transaction->total_line_item(); |
328 | 328 | $total = 0; |
329 | - foreach($total_line_item->get_items() as $item_line_item ){ |
|
330 | - $total += max( $item_line_item->total(), 0 ); |
|
329 | + foreach ($total_line_item->get_items() as $item_line_item) { |
|
330 | + $total += max($item_line_item->total(), 0); |
|
331 | 331 | } |
332 | - foreach($total_line_item->tax_descendants() as $tax_line_item ){ |
|
333 | - $total += max( $tax_line_item->total(), 0 ); |
|
332 | + foreach ($total_line_item->tax_descendants() as $tax_line_item) { |
|
333 | + $total += max($tax_line_item->total(), 0); |
|
334 | 334 | } |
335 | 335 | return $total; |
336 | 336 | } |
@@ -341,9 +341,9 @@ discard block |
||
341 | 341 | * @param EEI_Payment $payment |
342 | 342 | * @return boolean |
343 | 343 | */ |
344 | - protected function _can_easily_itemize_transaction_for( EEI_Payment $payment ){ |
|
344 | + protected function _can_easily_itemize_transaction_for(EEI_Payment $payment) { |
|
345 | 345 | return $this->_money->compare_floats( |
346 | - $this->_sum_items_and_taxes( $payment->transaction() ), |
|
346 | + $this->_sum_items_and_taxes($payment->transaction()), |
|
347 | 347 | $payment->transaction()->total() ) && |
348 | 348 | $this->_money->compare_floats( |
349 | 349 | $payment->amount(), |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | * @param EE_Payment $payment |
362 | 362 | * @return void |
363 | 363 | */ |
364 | - public function update_txn_based_on_payment( $payment ){ |
|
364 | + public function update_txn_based_on_payment($payment) { |
|
365 | 365 | //maybe update the transaction or line items or registrations |
366 | 366 | //but most gateways don't need to do this, because they only update the payment |
367 | 367 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | * @return EEI_Event|null |
373 | 373 | * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event() |
374 | 374 | */ |
375 | - protected function _get_first_event_for_payment( EEI_Payment $payment ) { |
|
375 | + protected function _get_first_event_for_payment(EEI_Payment $payment) { |
|
376 | 376 | return $payment->get_first_event(); |
377 | 377 | } |
378 | 378 | |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | * @return string |
383 | 383 | * @deprecated since 4.9.31 instead use EEI_Payment::get_first_event_name() |
384 | 384 | */ |
385 | - protected function _get_first_event_name_for_payment( EEI_Payment $payment ) { |
|
385 | + protected function _get_first_event_name_for_payment(EEI_Payment $payment) { |
|
386 | 386 | return $payment->get_first_event_name(); |
387 | 387 | } |
388 | 388 | /** |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | * @param EE_Payment $payment |
392 | 392 | * @return string |
393 | 393 | */ |
394 | - protected function _format_partial_payment_line_item_name( EEI_Payment $payment ){ |
|
394 | + protected function _format_partial_payment_line_item_name(EEI_Payment $payment) { |
|
395 | 395 | return $this->_get_gateway_formatter()->formatPartialPaymentLineItemName($payment); |
396 | 396 | } |
397 | 397 | /** |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | * @param EEI_Payment $payment |
401 | 401 | * @return string |
402 | 402 | */ |
403 | - protected function _format_partial_payment_line_item_desc( EEI_Payment $payment ) { |
|
403 | + protected function _format_partial_payment_line_item_desc(EEI_Payment $payment) { |
|
404 | 404 | return $this->_get_gateway_formatter()->formatPartialPaymentLineItemDesc($payment); |
405 | 405 | } |
406 | 406 | |
@@ -411,8 +411,8 @@ discard block |
||
411 | 411 | * @param EEI_Payment $payment |
412 | 412 | * @return string |
413 | 413 | */ |
414 | - protected function _format_line_item_name( EEI_Line_Item $line_item, EEI_Payment $payment ) { |
|
415 | - return $this->_get_gateway_formatter()->formatLineItemName($line_item,$payment); |
|
414 | + protected function _format_line_item_name(EEI_Line_Item $line_item, EEI_Payment $payment) { |
|
415 | + return $this->_get_gateway_formatter()->formatLineItemName($line_item, $payment); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | /** |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * @param EEI_Payment $payment |
423 | 423 | * @return string |
424 | 424 | */ |
425 | - protected function _format_line_item_desc( EEI_Line_Item $line_item, EEI_Payment $payment ) { |
|
425 | + protected function _format_line_item_desc(EEI_Line_Item $line_item, EEI_Payment $payment) { |
|
426 | 426 | return $this->_get_gateway_formatter()->formatLineItemDesc($line_item, $payment); |
427 | 427 | } |
428 | 428 | |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | * @param EEI_Payment $payment |
433 | 433 | * @return type |
434 | 434 | */ |
435 | - protected function _format_order_description( EEI_Payment $payment ) { |
|
435 | + protected function _format_order_description(EEI_Payment $payment) { |
|
436 | 436 | return $this->_get_gateway_formatter()->formatOrderDescription($payment); |
437 | 437 | } |
438 | 438 | } |
439 | 439 | \ No newline at end of file |