@@ -177,7 +177,7 @@ |
||
177 | 177 | |
178 | 178 | /** |
179 | 179 | * @since 4.1.0 |
180 | - * @return int |
|
180 | + * @return string |
|
181 | 181 | */ |
182 | 182 | public function get_permissions() |
183 | 183 | { |
@@ -14,328 +14,328 @@ |
||
14 | 14 | class EEH_Sideloader extends EEH_Base |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * @since 4.1.0 |
|
19 | - * @var string |
|
20 | - */ |
|
21 | - private $_upload_to; |
|
22 | - |
|
23 | - /** |
|
24 | - * @since $VID:$ |
|
25 | - * @var string |
|
26 | - */ |
|
27 | - private $_download_from; |
|
28 | - |
|
29 | - /** |
|
30 | - * @since 4.1.0 |
|
31 | - * @var string |
|
32 | - */ |
|
33 | - private $_permissions; |
|
34 | - |
|
35 | - /** |
|
36 | - * @since 4.1.0 |
|
37 | - * @var string |
|
38 | - */ |
|
39 | - private $_new_file_name; |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * constructor allows the user to set the properties on the sideloader on construct. However, there are also setters for doing so. |
|
44 | - * |
|
45 | - * @since 4.1.0 |
|
46 | - * @param array $init array fo initializing the sideloader if keys match the properties. |
|
47 | - */ |
|
48 | - public function __construct($init = array()) |
|
49 | - { |
|
50 | - $this->_init($init); |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * sets the properties for class either to defaults or using incoming initialization array |
|
56 | - * |
|
57 | - * @since 4.1.0 |
|
58 | - * @param array $init array on init (keys match properties others ignored) |
|
59 | - * @return void |
|
60 | - */ |
|
61 | - private function _init($init) |
|
62 | - { |
|
63 | - $defaults = array( |
|
64 | - '_upload_to' => $this->_get_wp_uploads_dir(), |
|
65 | - '_download_from' => '', |
|
66 | - '_permissions' => 0644, |
|
67 | - '_new_file_name' => 'EE_Sideloader_' . uniqid() . '.default' |
|
68 | - ); |
|
69 | - |
|
70 | - $props = array_merge($defaults, $init); |
|
71 | - |
|
72 | - foreach ($props as $property => $val) { |
|
73 | - $setter = 'set' . $property; |
|
74 | - if (method_exists($this, $setter)) { |
|
75 | - $this->$setter($val); |
|
76 | - } else { |
|
77 | - // No setter found. |
|
78 | - EE_Error::add_error( |
|
79 | - sprintf( |
|
80 | - esc_html__( |
|
81 | - 'EEH_Sideloader::%1$s not found. There is no setter for the %2$s property.', |
|
82 | - 'event_espresso' |
|
83 | - ), |
|
84 | - $setter, |
|
85 | - $property |
|
86 | - ), |
|
87 | - __FILE__, |
|
88 | - __FUNCTION__, |
|
89 | - __LINE__ |
|
90 | - ); |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - // make sure we include the required wp file for needed functions |
|
95 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - // utilities |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * @since 4.1.0 |
|
104 | - * @return void |
|
105 | - */ |
|
106 | - private function _get_wp_uploads_dir() |
|
107 | - { |
|
108 | - } |
|
109 | - |
|
110 | - // setters |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * sets the _upload_to property to the directory to upload to. |
|
115 | - * |
|
116 | - * @since 4.1.0 |
|
117 | - * @param $upload_to_folder |
|
118 | - * @return void |
|
119 | - */ |
|
120 | - public function set_upload_to($upload_to_folder) |
|
121 | - { |
|
122 | - $this->_upload_to = $upload_to_folder; |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * sets the _download_from property to the location we should download the file from. |
|
128 | - * |
|
129 | - * @since $VID:$ |
|
130 | - * @param string $download_from The full path to the file we should sideload. |
|
131 | - * @return void |
|
132 | - */ |
|
133 | - public function set_download_from($download_from) |
|
134 | - { |
|
135 | - $this->_download_from = $download_from; |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * sets the _permissions property used on the sideloaded file. |
|
141 | - * |
|
142 | - * @since 4.1.0 |
|
143 | - * @param int $permissions |
|
144 | - * @return void |
|
145 | - */ |
|
146 | - public function set_permissions($permissions) |
|
147 | - { |
|
148 | - $this->_permissions = $permissions; |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * sets the _new_file_name property used on the sideloaded file. |
|
154 | - * |
|
155 | - * @since 4.1.0 |
|
156 | - * @param string $new_file_name |
|
157 | - * @return void |
|
158 | - */ |
|
159 | - public function set_new_file_name($new_file_name) |
|
160 | - { |
|
161 | - $this->_new_file_name = $new_file_name; |
|
162 | - } |
|
163 | - |
|
164 | - // getters |
|
165 | - |
|
166 | - |
|
167 | - /** |
|
168 | - * @since 4.1.0 |
|
169 | - * @return string |
|
170 | - */ |
|
171 | - public function get_upload_to() |
|
172 | - { |
|
173 | - return $this->_upload_to; |
|
174 | - } |
|
175 | - |
|
176 | - |
|
177 | - /** |
|
178 | - * @since $VID:$ |
|
179 | - * @return string |
|
180 | - */ |
|
181 | - public function get_download_from() |
|
182 | - { |
|
183 | - return $this->_download_from; |
|
184 | - } |
|
185 | - |
|
186 | - |
|
187 | - /** |
|
188 | - * @since 4.1.0 |
|
189 | - * @return int |
|
190 | - */ |
|
191 | - public function get_permissions() |
|
192 | - { |
|
193 | - return $this->_permissions; |
|
194 | - } |
|
195 | - |
|
196 | - |
|
197 | - /** |
|
198 | - * @since 4.1.0 |
|
199 | - * @return string |
|
200 | - */ |
|
201 | - public function get_new_file_name() |
|
202 | - { |
|
203 | - return $this->_new_file_name; |
|
204 | - } |
|
205 | - |
|
206 | - |
|
207 | - // upload methods |
|
208 | - |
|
209 | - |
|
210 | - /** |
|
211 | - * Downloads the file using the WordPress HTTP API. |
|
212 | - * |
|
213 | - * @since 4.1.0 |
|
214 | - * @return bool |
|
215 | - */ |
|
216 | - public function sideload() |
|
217 | - { |
|
218 | - // setup temp dir |
|
219 | - $temp_file = wp_tempnam($this->_download_from); |
|
220 | - |
|
221 | - if (!$temp_file) { |
|
222 | - EE_Error::add_error( |
|
223 | - esc_html__('Something went wrong with the upload. Unable to create a tmp file for the uploaded file on the server', 'event_espresso'), |
|
224 | - __FILE__, |
|
225 | - __FUNCTION__, |
|
226 | - __LINE__ |
|
227 | - ); |
|
228 | - return false; |
|
229 | - } |
|
230 | - |
|
231 | - do_action('AHEE__EEH_Sideloader__sideload__before', $this, $temp_file); |
|
232 | - |
|
233 | - $wp_remote_args = apply_filters('FHEE__EEH_Sideloader__sideload__wp_remote_args', array( 'timeout' => 500, 'stream' => true, 'filename' => $temp_file ), $this, $temp_file); |
|
234 | - |
|
235 | - $response = wp_safe_remote_get($this->_download_from, $wp_remote_args); |
|
236 | - |
|
237 | - if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) { |
|
238 | - unlink($temp_file); |
|
239 | - if (defined('WP_DEBUG') && WP_DEBUG) { |
|
240 | - EE_Error::add_error( |
|
241 | - sprintf( |
|
242 | - esc_html__('Unable to upload the file. Either the path given to upload from is incorrect, or something else happened. Here is the path given: %s', 'event_espresso'), |
|
243 | - $this->_download_from |
|
244 | - ), |
|
245 | - __FILE__, |
|
246 | - __FUNCTION__, |
|
247 | - __LINE__ |
|
248 | - ); |
|
249 | - } |
|
250 | - return false; |
|
251 | - } |
|
252 | - |
|
253 | - // possible md5 check |
|
254 | - $content_md5 = wp_remote_retrieve_header($response, 'content-md5'); |
|
255 | - if ($content_md5) { |
|
256 | - $md5_check = verify_file_md5($temp_file, $content_md5); |
|
257 | - if (is_wp_error($md5_check)) { |
|
258 | - unlink($temp_file); |
|
259 | - EE_Error::add_error( |
|
260 | - $md5_check->get_error_message(), |
|
261 | - __FILE__, |
|
262 | - __FUNCTION__, |
|
263 | - __LINE__ |
|
264 | - ); |
|
265 | - return false; |
|
266 | - } |
|
267 | - } |
|
268 | - |
|
269 | - $file = $temp_file; |
|
270 | - |
|
271 | - // now we have the file, let's get it in the right directory with the right name. |
|
272 | - $path = apply_filters('FHEE__EEH_Sideloader__sideload__new_path', $this->_upload_to . $this->_new_file_name, $this); |
|
273 | - |
|
274 | - // move file in |
|
275 | - if (false === @ rename($file, $path)) { |
|
276 | - unlink($temp_file); |
|
277 | - EE_Error::add_error( |
|
278 | - sprintf( |
|
279 | - esc_html__('Unable to move the file to new location (possible permissions errors). This is the path the class attempted to move the file to: %s', 'event_espresso'), |
|
280 | - $path |
|
281 | - ), |
|
282 | - __FILE__, |
|
283 | - __FUNCTION__, |
|
284 | - __LINE__ |
|
285 | - ); |
|
286 | - return false; |
|
287 | - } |
|
288 | - |
|
289 | - // set permissions |
|
290 | - $permissions = apply_filters('FHEE__EEH_Sideloader__sideload__permissions_applied', $this->_permissions, $this); |
|
291 | - chmod($path, $permissions); |
|
292 | - |
|
293 | - // that's it. let's allow for actions after file uploaded. |
|
294 | - do_action('AHEE__EE_Sideloader__sideload_after', $this, $path); |
|
295 | - |
|
296 | - // unlink tempfile |
|
297 | - @unlink($temp_file); |
|
298 | - return true; |
|
299 | - } |
|
300 | - |
|
301 | - // deprecated |
|
302 | - |
|
303 | - /** |
|
304 | - * sets the _upload_from property to the location we should download the file from. |
|
305 | - * |
|
306 | - * @param string $upload_from The full path to the file we should sideload. |
|
307 | - * @return void |
|
308 | - * @deprecated since version $VID:$ |
|
309 | - */ |
|
310 | - public function set_upload_from($upload_from) |
|
311 | - { |
|
312 | - EE_Error::doing_it_wrong( |
|
313 | - __CLASS__ . '::' . __FUNCTION__, |
|
314 | - __( |
|
315 | - 'EEH_Sideloader::set_upload_from was renamed to EEH_Sideloader::set_download_from', |
|
316 | - 'event_espresso' |
|
317 | - ), |
|
318 | - '$VID:$' |
|
319 | - ); |
|
320 | - $this->set_download_from($upload_from); |
|
321 | - } |
|
322 | - |
|
323 | - |
|
324 | - /** |
|
325 | - * @since 4.1.0 |
|
326 | - * @return string |
|
327 | - * @deprecated since version $VID:$ |
|
328 | - */ |
|
329 | - public function get_upload_from() |
|
330 | - { |
|
331 | - EE_Error::doing_it_wrong( |
|
332 | - __CLASS__ . '::' . __FUNCTION__, |
|
333 | - __( |
|
334 | - 'EEH_Sideloader::get_upload_from was renamed to EEH_Sideloader::get_download_from', |
|
335 | - 'event_espresso' |
|
336 | - ), |
|
337 | - '$VID:$' |
|
338 | - ); |
|
339 | - return $this->_download_from; |
|
340 | - } |
|
17 | + /** |
|
18 | + * @since 4.1.0 |
|
19 | + * @var string |
|
20 | + */ |
|
21 | + private $_upload_to; |
|
22 | + |
|
23 | + /** |
|
24 | + * @since $VID:$ |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + private $_download_from; |
|
28 | + |
|
29 | + /** |
|
30 | + * @since 4.1.0 |
|
31 | + * @var string |
|
32 | + */ |
|
33 | + private $_permissions; |
|
34 | + |
|
35 | + /** |
|
36 | + * @since 4.1.0 |
|
37 | + * @var string |
|
38 | + */ |
|
39 | + private $_new_file_name; |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * constructor allows the user to set the properties on the sideloader on construct. However, there are also setters for doing so. |
|
44 | + * |
|
45 | + * @since 4.1.0 |
|
46 | + * @param array $init array fo initializing the sideloader if keys match the properties. |
|
47 | + */ |
|
48 | + public function __construct($init = array()) |
|
49 | + { |
|
50 | + $this->_init($init); |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * sets the properties for class either to defaults or using incoming initialization array |
|
56 | + * |
|
57 | + * @since 4.1.0 |
|
58 | + * @param array $init array on init (keys match properties others ignored) |
|
59 | + * @return void |
|
60 | + */ |
|
61 | + private function _init($init) |
|
62 | + { |
|
63 | + $defaults = array( |
|
64 | + '_upload_to' => $this->_get_wp_uploads_dir(), |
|
65 | + '_download_from' => '', |
|
66 | + '_permissions' => 0644, |
|
67 | + '_new_file_name' => 'EE_Sideloader_' . uniqid() . '.default' |
|
68 | + ); |
|
69 | + |
|
70 | + $props = array_merge($defaults, $init); |
|
71 | + |
|
72 | + foreach ($props as $property => $val) { |
|
73 | + $setter = 'set' . $property; |
|
74 | + if (method_exists($this, $setter)) { |
|
75 | + $this->$setter($val); |
|
76 | + } else { |
|
77 | + // No setter found. |
|
78 | + EE_Error::add_error( |
|
79 | + sprintf( |
|
80 | + esc_html__( |
|
81 | + 'EEH_Sideloader::%1$s not found. There is no setter for the %2$s property.', |
|
82 | + 'event_espresso' |
|
83 | + ), |
|
84 | + $setter, |
|
85 | + $property |
|
86 | + ), |
|
87 | + __FILE__, |
|
88 | + __FUNCTION__, |
|
89 | + __LINE__ |
|
90 | + ); |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + // make sure we include the required wp file for needed functions |
|
95 | + require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + // utilities |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * @since 4.1.0 |
|
104 | + * @return void |
|
105 | + */ |
|
106 | + private function _get_wp_uploads_dir() |
|
107 | + { |
|
108 | + } |
|
109 | + |
|
110 | + // setters |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * sets the _upload_to property to the directory to upload to. |
|
115 | + * |
|
116 | + * @since 4.1.0 |
|
117 | + * @param $upload_to_folder |
|
118 | + * @return void |
|
119 | + */ |
|
120 | + public function set_upload_to($upload_to_folder) |
|
121 | + { |
|
122 | + $this->_upload_to = $upload_to_folder; |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * sets the _download_from property to the location we should download the file from. |
|
128 | + * |
|
129 | + * @since $VID:$ |
|
130 | + * @param string $download_from The full path to the file we should sideload. |
|
131 | + * @return void |
|
132 | + */ |
|
133 | + public function set_download_from($download_from) |
|
134 | + { |
|
135 | + $this->_download_from = $download_from; |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * sets the _permissions property used on the sideloaded file. |
|
141 | + * |
|
142 | + * @since 4.1.0 |
|
143 | + * @param int $permissions |
|
144 | + * @return void |
|
145 | + */ |
|
146 | + public function set_permissions($permissions) |
|
147 | + { |
|
148 | + $this->_permissions = $permissions; |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * sets the _new_file_name property used on the sideloaded file. |
|
154 | + * |
|
155 | + * @since 4.1.0 |
|
156 | + * @param string $new_file_name |
|
157 | + * @return void |
|
158 | + */ |
|
159 | + public function set_new_file_name($new_file_name) |
|
160 | + { |
|
161 | + $this->_new_file_name = $new_file_name; |
|
162 | + } |
|
163 | + |
|
164 | + // getters |
|
165 | + |
|
166 | + |
|
167 | + /** |
|
168 | + * @since 4.1.0 |
|
169 | + * @return string |
|
170 | + */ |
|
171 | + public function get_upload_to() |
|
172 | + { |
|
173 | + return $this->_upload_to; |
|
174 | + } |
|
175 | + |
|
176 | + |
|
177 | + /** |
|
178 | + * @since $VID:$ |
|
179 | + * @return string |
|
180 | + */ |
|
181 | + public function get_download_from() |
|
182 | + { |
|
183 | + return $this->_download_from; |
|
184 | + } |
|
185 | + |
|
186 | + |
|
187 | + /** |
|
188 | + * @since 4.1.0 |
|
189 | + * @return int |
|
190 | + */ |
|
191 | + public function get_permissions() |
|
192 | + { |
|
193 | + return $this->_permissions; |
|
194 | + } |
|
195 | + |
|
196 | + |
|
197 | + /** |
|
198 | + * @since 4.1.0 |
|
199 | + * @return string |
|
200 | + */ |
|
201 | + public function get_new_file_name() |
|
202 | + { |
|
203 | + return $this->_new_file_name; |
|
204 | + } |
|
205 | + |
|
206 | + |
|
207 | + // upload methods |
|
208 | + |
|
209 | + |
|
210 | + /** |
|
211 | + * Downloads the file using the WordPress HTTP API. |
|
212 | + * |
|
213 | + * @since 4.1.0 |
|
214 | + * @return bool |
|
215 | + */ |
|
216 | + public function sideload() |
|
217 | + { |
|
218 | + // setup temp dir |
|
219 | + $temp_file = wp_tempnam($this->_download_from); |
|
220 | + |
|
221 | + if (!$temp_file) { |
|
222 | + EE_Error::add_error( |
|
223 | + esc_html__('Something went wrong with the upload. Unable to create a tmp file for the uploaded file on the server', 'event_espresso'), |
|
224 | + __FILE__, |
|
225 | + __FUNCTION__, |
|
226 | + __LINE__ |
|
227 | + ); |
|
228 | + return false; |
|
229 | + } |
|
230 | + |
|
231 | + do_action('AHEE__EEH_Sideloader__sideload__before', $this, $temp_file); |
|
232 | + |
|
233 | + $wp_remote_args = apply_filters('FHEE__EEH_Sideloader__sideload__wp_remote_args', array( 'timeout' => 500, 'stream' => true, 'filename' => $temp_file ), $this, $temp_file); |
|
234 | + |
|
235 | + $response = wp_safe_remote_get($this->_download_from, $wp_remote_args); |
|
236 | + |
|
237 | + if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) { |
|
238 | + unlink($temp_file); |
|
239 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
240 | + EE_Error::add_error( |
|
241 | + sprintf( |
|
242 | + esc_html__('Unable to upload the file. Either the path given to upload from is incorrect, or something else happened. Here is the path given: %s', 'event_espresso'), |
|
243 | + $this->_download_from |
|
244 | + ), |
|
245 | + __FILE__, |
|
246 | + __FUNCTION__, |
|
247 | + __LINE__ |
|
248 | + ); |
|
249 | + } |
|
250 | + return false; |
|
251 | + } |
|
252 | + |
|
253 | + // possible md5 check |
|
254 | + $content_md5 = wp_remote_retrieve_header($response, 'content-md5'); |
|
255 | + if ($content_md5) { |
|
256 | + $md5_check = verify_file_md5($temp_file, $content_md5); |
|
257 | + if (is_wp_error($md5_check)) { |
|
258 | + unlink($temp_file); |
|
259 | + EE_Error::add_error( |
|
260 | + $md5_check->get_error_message(), |
|
261 | + __FILE__, |
|
262 | + __FUNCTION__, |
|
263 | + __LINE__ |
|
264 | + ); |
|
265 | + return false; |
|
266 | + } |
|
267 | + } |
|
268 | + |
|
269 | + $file = $temp_file; |
|
270 | + |
|
271 | + // now we have the file, let's get it in the right directory with the right name. |
|
272 | + $path = apply_filters('FHEE__EEH_Sideloader__sideload__new_path', $this->_upload_to . $this->_new_file_name, $this); |
|
273 | + |
|
274 | + // move file in |
|
275 | + if (false === @ rename($file, $path)) { |
|
276 | + unlink($temp_file); |
|
277 | + EE_Error::add_error( |
|
278 | + sprintf( |
|
279 | + esc_html__('Unable to move the file to new location (possible permissions errors). This is the path the class attempted to move the file to: %s', 'event_espresso'), |
|
280 | + $path |
|
281 | + ), |
|
282 | + __FILE__, |
|
283 | + __FUNCTION__, |
|
284 | + __LINE__ |
|
285 | + ); |
|
286 | + return false; |
|
287 | + } |
|
288 | + |
|
289 | + // set permissions |
|
290 | + $permissions = apply_filters('FHEE__EEH_Sideloader__sideload__permissions_applied', $this->_permissions, $this); |
|
291 | + chmod($path, $permissions); |
|
292 | + |
|
293 | + // that's it. let's allow for actions after file uploaded. |
|
294 | + do_action('AHEE__EE_Sideloader__sideload_after', $this, $path); |
|
295 | + |
|
296 | + // unlink tempfile |
|
297 | + @unlink($temp_file); |
|
298 | + return true; |
|
299 | + } |
|
300 | + |
|
301 | + // deprecated |
|
302 | + |
|
303 | + /** |
|
304 | + * sets the _upload_from property to the location we should download the file from. |
|
305 | + * |
|
306 | + * @param string $upload_from The full path to the file we should sideload. |
|
307 | + * @return void |
|
308 | + * @deprecated since version $VID:$ |
|
309 | + */ |
|
310 | + public function set_upload_from($upload_from) |
|
311 | + { |
|
312 | + EE_Error::doing_it_wrong( |
|
313 | + __CLASS__ . '::' . __FUNCTION__, |
|
314 | + __( |
|
315 | + 'EEH_Sideloader::set_upload_from was renamed to EEH_Sideloader::set_download_from', |
|
316 | + 'event_espresso' |
|
317 | + ), |
|
318 | + '$VID:$' |
|
319 | + ); |
|
320 | + $this->set_download_from($upload_from); |
|
321 | + } |
|
322 | + |
|
323 | + |
|
324 | + /** |
|
325 | + * @since 4.1.0 |
|
326 | + * @return string |
|
327 | + * @deprecated since version $VID:$ |
|
328 | + */ |
|
329 | + public function get_upload_from() |
|
330 | + { |
|
331 | + EE_Error::doing_it_wrong( |
|
332 | + __CLASS__ . '::' . __FUNCTION__, |
|
333 | + __( |
|
334 | + 'EEH_Sideloader::get_upload_from was renamed to EEH_Sideloader::get_download_from', |
|
335 | + 'event_espresso' |
|
336 | + ), |
|
337 | + '$VID:$' |
|
338 | + ); |
|
339 | + return $this->_download_from; |
|
340 | + } |
|
341 | 341 | } //end EEH_Sideloader class |
@@ -64,13 +64,13 @@ discard block |
||
64 | 64 | '_upload_to' => $this->_get_wp_uploads_dir(), |
65 | 65 | '_download_from' => '', |
66 | 66 | '_permissions' => 0644, |
67 | - '_new_file_name' => 'EE_Sideloader_' . uniqid() . '.default' |
|
67 | + '_new_file_name' => 'EE_Sideloader_'.uniqid().'.default' |
|
68 | 68 | ); |
69 | 69 | |
70 | 70 | $props = array_merge($defaults, $init); |
71 | 71 | |
72 | 72 | foreach ($props as $property => $val) { |
73 | - $setter = 'set' . $property; |
|
73 | + $setter = 'set'.$property; |
|
74 | 74 | if (method_exists($this, $setter)) { |
75 | 75 | $this->$setter($val); |
76 | 76 | } else { |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | } |
93 | 93 | |
94 | 94 | // make sure we include the required wp file for needed functions |
95 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
95 | + require_once(ABSPATH.'wp-admin/includes/file.php'); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | // setup temp dir |
219 | 219 | $temp_file = wp_tempnam($this->_download_from); |
220 | 220 | |
221 | - if (!$temp_file) { |
|
221 | + if ( ! $temp_file) { |
|
222 | 222 | EE_Error::add_error( |
223 | 223 | esc_html__('Something went wrong with the upload. Unable to create a tmp file for the uploaded file on the server', 'event_espresso'), |
224 | 224 | __FILE__, |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | |
231 | 231 | do_action('AHEE__EEH_Sideloader__sideload__before', $this, $temp_file); |
232 | 232 | |
233 | - $wp_remote_args = apply_filters('FHEE__EEH_Sideloader__sideload__wp_remote_args', array( 'timeout' => 500, 'stream' => true, 'filename' => $temp_file ), $this, $temp_file); |
|
233 | + $wp_remote_args = apply_filters('FHEE__EEH_Sideloader__sideload__wp_remote_args', array('timeout' => 500, 'stream' => true, 'filename' => $temp_file), $this, $temp_file); |
|
234 | 234 | |
235 | 235 | $response = wp_safe_remote_get($this->_download_from, $wp_remote_args); |
236 | 236 | |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | $file = $temp_file; |
270 | 270 | |
271 | 271 | // now we have the file, let's get it in the right directory with the right name. |
272 | - $path = apply_filters('FHEE__EEH_Sideloader__sideload__new_path', $this->_upload_to . $this->_new_file_name, $this); |
|
272 | + $path = apply_filters('FHEE__EEH_Sideloader__sideload__new_path', $this->_upload_to.$this->_new_file_name, $this); |
|
273 | 273 | |
274 | 274 | // move file in |
275 | 275 | if (false === @ rename($file, $path)) { |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | public function set_upload_from($upload_from) |
311 | 311 | { |
312 | 312 | EE_Error::doing_it_wrong( |
313 | - __CLASS__ . '::' . __FUNCTION__, |
|
313 | + __CLASS__.'::'.__FUNCTION__, |
|
314 | 314 | __( |
315 | 315 | 'EEH_Sideloader::set_upload_from was renamed to EEH_Sideloader::set_download_from', |
316 | 316 | 'event_espresso' |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | public function get_upload_from() |
330 | 330 | { |
331 | 331 | EE_Error::doing_it_wrong( |
332 | - __CLASS__ . '::' . __FUNCTION__, |
|
332 | + __CLASS__.'::'.__FUNCTION__, |
|
333 | 333 | __( |
334 | 334 | 'EEH_Sideloader::get_upload_from was renamed to EEH_Sideloader::get_download_from', |
335 | 335 | 'event_espresso' |
@@ -12,566 +12,566 @@ |
||
12 | 12 | class EE_Event_Registrations_List_Table extends EE_Admin_List_Table |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * This property will hold the related Datetimes on an event IF the event id is included in the request. |
|
17 | - * |
|
18 | - * @var EE_Datetime[] |
|
19 | - */ |
|
20 | - protected $_dtts_for_event = array(); |
|
21 | - |
|
22 | - |
|
23 | - /** |
|
24 | - * The event if one is specified in the request |
|
25 | - * |
|
26 | - * @var EE_Event |
|
27 | - */ |
|
28 | - protected $_evt = null; |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * The DTT_ID if the current view has a specified datetime. |
|
33 | - * |
|
34 | - * @var int $_cur_dtt_id |
|
35 | - */ |
|
36 | - protected $_cur_dtt_id = 0; |
|
37 | - |
|
38 | - |
|
39 | - /** |
|
40 | - * EE_Event_Registrations_List_Table constructor. |
|
41 | - * |
|
42 | - * @param \Registrations_Admin_Page $admin_page |
|
43 | - */ |
|
44 | - public function __construct($admin_page) |
|
45 | - { |
|
46 | - parent::__construct($admin_page); |
|
47 | - $this->_status = $this->_admin_page->get_registration_status_array(); |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - protected function _setup_data() |
|
52 | - { |
|
53 | - $this->_data = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees($this->_per_page) |
|
54 | - : $this->_admin_page->get_event_attendees($this->_per_page, false, true); |
|
55 | - $this->_all_data_count = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees( |
|
56 | - $this->_per_page, |
|
57 | - true |
|
58 | - ) : $this->_admin_page->get_event_attendees($this->_per_page, true, true); |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - protected function _set_properties() |
|
63 | - { |
|
64 | - $evt_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
65 | - $this->_wp_list_args = array( |
|
66 | - 'singular' => __('registrant', 'event_espresso'), |
|
67 | - 'plural' => __('registrants', 'event_espresso'), |
|
68 | - 'ajax' => true, |
|
69 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
70 | - ); |
|
71 | - $columns = array(); |
|
72 | - // $columns['_Reg_Status'] = ''; |
|
73 | - $this->_columns = array( |
|
74 | - '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>', |
|
75 | - 'ATT_name' => __('Registrant', 'event_espresso'), |
|
76 | - 'ATT_email' => __('Email Address', 'event_espresso'), |
|
77 | - 'Event' => __('Event', 'event_espresso'), |
|
78 | - 'PRC_name' => __('TKT Option', 'event_espresso'), |
|
79 | - '_REG_final_price' => __('Price', 'event_espresso'), |
|
80 | - 'TXN_paid' => __('Paid', 'event_espresso'), |
|
81 | - 'TXN_total' => __('Total', 'event_espresso'), |
|
82 | - ); |
|
83 | - // Add/remove columns when an event has been selected |
|
84 | - if (! empty($evt_id)) { |
|
85 | - // Render a checkbox column |
|
86 | - $columns['cb'] = '<input type="checkbox" />'; |
|
87 | - $this->_has_checkbox_column = true; |
|
88 | - // Remove the 'Event' column |
|
89 | - unset($this->_columns['Event']); |
|
90 | - } |
|
91 | - $this->_columns = array_merge($columns, $this->_columns); |
|
92 | - $this->_primary_column = '_REG_att_checked_in'; |
|
93 | - if (! empty($evt_id) |
|
94 | - && EE_Registry::instance()->CAP->current_user_can( |
|
95 | - 'ee_read_registrations', |
|
96 | - 'espresso_registrations_registrations_reports', |
|
97 | - $evt_id |
|
98 | - ) |
|
99 | - ) { |
|
100 | - $this->_bottom_buttons = array( |
|
101 | - 'report' => array( |
|
102 | - 'route' => 'registrations_report', |
|
103 | - 'extra_request' => |
|
104 | - array( |
|
105 | - 'EVT_ID' => $evt_id, |
|
106 | - 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
107 | - ), |
|
108 | - ), |
|
109 | - ); |
|
110 | - } |
|
111 | - $this->_bottom_buttons['report_filtered'] = array( |
|
112 | - 'route' => 'registrations_checkin_report', |
|
113 | - 'extra_request' => array( |
|
114 | - 'use_filters' => true, |
|
115 | - 'filters' => array_merge( |
|
116 | - array( |
|
117 | - 'EVT_ID' => $evt_id, |
|
118 | - ), |
|
119 | - array_diff_key( |
|
120 | - $this->_req_data, |
|
121 | - array_flip( |
|
122 | - array( |
|
123 | - 'page', |
|
124 | - 'action', |
|
125 | - 'default_nonce', |
|
126 | - ) |
|
127 | - ) |
|
128 | - ) |
|
129 | - ), |
|
130 | - 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
131 | - ), |
|
132 | - ); |
|
133 | - $this->_sortable_columns = array( |
|
134 | - /** |
|
135 | - * Allows users to change the default sort if they wish. |
|
136 | - * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name. |
|
137 | - * |
|
138 | - * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to |
|
139 | - * change the sorts on any list table involving registration contacts. If you want to only change the filter |
|
140 | - * for a specific list table you can use the provided reference to this object instance. |
|
141 | - */ |
|
142 | - 'ATT_name' => array( |
|
143 | - 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
144 | - true, |
|
145 | - $this, |
|
146 | - ) |
|
147 | - ? array('ATT_lname' => true) |
|
148 | - : array('ATT_fname' => true), |
|
149 | - 'Event' => array('Event.EVT_name' => false), |
|
150 | - ); |
|
151 | - $this->_hidden_columns = array(); |
|
152 | - $this->_evt = EEM_Event::instance()->get_one_by_ID($evt_id); |
|
153 | - $this->_dtts_for_event = $this->_evt instanceof EE_Event ? $this->_evt->datetimes_ordered() : array(); |
|
154 | - } |
|
155 | - |
|
156 | - |
|
157 | - /** |
|
158 | - * @param \EE_Registration $item |
|
159 | - * @return string |
|
160 | - */ |
|
161 | - protected function _get_row_class($item) |
|
162 | - { |
|
163 | - $class = parent::_get_row_class($item); |
|
164 | - // add status class |
|
165 | - $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
166 | - if ($this->_has_checkbox_column) { |
|
167 | - $class .= ' has-checkbox-column'; |
|
168 | - } |
|
169 | - return $class; |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - /** |
|
174 | - * @return array |
|
175 | - * @throws \EE_Error |
|
176 | - */ |
|
177 | - protected function _get_table_filters() |
|
178 | - { |
|
179 | - $filters = $where = array(); |
|
180 | - $current_EVT_ID = isset($this->_req_data['event_id']) ? (int) $this->_req_data['event_id'] : 0; |
|
181 | - if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) { |
|
182 | - // this means we don't have an event so let's setup a filter dropdown for all the events to select |
|
183 | - // note possible capability restrictions |
|
184 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
185 | - $where['status**'] = array('!=', 'private'); |
|
186 | - } |
|
187 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
188 | - $where['EVT_wp_user'] = get_current_user_id(); |
|
189 | - } |
|
190 | - $events = EEM_Event::instance()->get_all( |
|
191 | - array( |
|
192 | - $where, |
|
193 | - 'order_by' => array('Datetime.DTT_EVT_start' => 'DESC'), |
|
194 | - ) |
|
195 | - ); |
|
196 | - $evts[] = array( |
|
197 | - 'id' => 0, |
|
198 | - 'text' => __('To toggle Check-in status, select an event', 'event_espresso'), |
|
199 | - ); |
|
200 | - $checked = 'checked'; |
|
201 | - /** @var EE_Event $evt */ |
|
202 | - foreach ($events as $evt) { |
|
203 | - // any registrations for this event? |
|
204 | - if (! $evt->get_count_of_all_registrations()) { |
|
205 | - continue; |
|
206 | - } |
|
207 | - $evts[] = array( |
|
208 | - 'id' => $evt->ID(), |
|
209 | - 'text' => apply_filters( |
|
210 | - 'FHEE__EE_Event_Registrations___get_table_filters__event_name', |
|
211 | - $evt->get('EVT_name'), |
|
212 | - $evt |
|
213 | - ), |
|
214 | - 'class' => $evt->is_expired() ? 'ee-expired-event' : '', |
|
215 | - ); |
|
216 | - if ($evt->ID() === $current_EVT_ID && $evt->is_expired()) { |
|
217 | - $checked = ''; |
|
218 | - } |
|
219 | - } |
|
220 | - $event_filter = '<div class="ee-event-filter">'; |
|
221 | - $event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID); |
|
222 | - $event_filter .= '<span class="ee-event-filter-toggle">'; |
|
223 | - $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> '; |
|
224 | - $event_filter .= __('Hide Expired Events', 'event_espresso'); |
|
225 | - $event_filter .= '</span>'; |
|
226 | - $event_filter .= '</div>'; |
|
227 | - $filters[] = $event_filter; |
|
228 | - } |
|
229 | - if (! empty($this->_dtts_for_event)) { |
|
230 | - // DTT datetimes filter |
|
231 | - $this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0; |
|
232 | - if (count($this->_dtts_for_event) > 1) { |
|
233 | - $dtts[0] = __('To toggle check-in status, select a datetime.', 'event_espresso'); |
|
234 | - foreach ($this->_dtts_for_event as $dtt) { |
|
235 | - $datetime_string = $dtt->name(); |
|
236 | - $datetime_string = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : ''; |
|
237 | - $datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string; |
|
238 | - $dtts[ $dtt->ID() ] = $datetime_string; |
|
239 | - } |
|
240 | - $input = new EE_Select_Input( |
|
241 | - $dtts, |
|
242 | - array( |
|
243 | - 'html_name' => 'DTT_ID', |
|
244 | - 'html_id' => 'DTT_ID', |
|
245 | - 'default' => $this->_cur_dtt_id, |
|
246 | - ) |
|
247 | - ); |
|
248 | - $filters[] = $input->get_html_for_input(); |
|
249 | - $filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">'; |
|
250 | - } |
|
251 | - } |
|
252 | - return $filters; |
|
253 | - } |
|
254 | - |
|
255 | - |
|
256 | - protected function _add_view_counts() |
|
257 | - { |
|
258 | - $this->_views['all']['count'] = $this->_get_total_event_attendees(); |
|
259 | - } |
|
260 | - |
|
261 | - |
|
262 | - /** |
|
263 | - * @return int |
|
264 | - * @throws \EE_Error |
|
265 | - */ |
|
266 | - protected function _get_total_event_attendees() |
|
267 | - { |
|
268 | - $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
269 | - $DTT_ID = $this->_cur_dtt_id; |
|
270 | - $query_params = array(); |
|
271 | - if ($EVT_ID) { |
|
272 | - $query_params[0]['EVT_ID'] = $EVT_ID; |
|
273 | - } |
|
274 | - // if DTT is included we only show for that datetime. Otherwise we're showing for all datetimes (the event). |
|
275 | - if ($DTT_ID) { |
|
276 | - $query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID; |
|
277 | - } |
|
278 | - $status_ids_array = apply_filters( |
|
279 | - 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
280 | - array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
281 | - ); |
|
282 | - $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
283 | - return EEM_Registration::instance()->count($query_params); |
|
284 | - } |
|
285 | - |
|
286 | - |
|
287 | - /** |
|
288 | - * @param \EE_Registration $item |
|
289 | - * @return string |
|
290 | - */ |
|
291 | - public function column__Reg_Status(EE_Registration $item) |
|
292 | - { |
|
293 | - return '<span class="ee-status-strip ee-status-strip-td reg-status-' . $item->status_ID() . '"></span>'; |
|
294 | - } |
|
295 | - |
|
296 | - |
|
297 | - /** |
|
298 | - * @param \EE_Registration $item |
|
299 | - * @return string |
|
300 | - * @throws \EE_Error |
|
301 | - */ |
|
302 | - public function column_cb($item) |
|
303 | - { |
|
304 | - return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID()); |
|
305 | - } |
|
306 | - |
|
307 | - |
|
308 | - /** |
|
309 | - * column_REG_att_checked_in |
|
310 | - * |
|
311 | - * @param EE_Registration $item |
|
312 | - * @return string |
|
313 | - * @throws EE_Error |
|
314 | - * @throws InvalidArgumentException |
|
315 | - * @throws InvalidDataTypeException |
|
316 | - * @throws InvalidInterfaceException |
|
317 | - */ |
|
318 | - public function column__REG_att_checked_in(EE_Registration $item) |
|
319 | - { |
|
320 | - $attendee = $item->attendee(); |
|
321 | - $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
322 | - |
|
323 | - if ($this->_cur_dtt_id === 0 && count($this->_dtts_for_event) === 1) { |
|
324 | - $latest_related_datetime = $item->get_latest_related_datetime(); |
|
325 | - if ($latest_related_datetime instanceof EE_Datetime) { |
|
326 | - $this->_cur_dtt_id = $latest_related_datetime->ID(); |
|
327 | - } |
|
328 | - } |
|
329 | - $checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId( |
|
330 | - $item, |
|
331 | - $this->_cur_dtt_id |
|
332 | - ); |
|
333 | - $nonce = wp_create_nonce('checkin_nonce'); |
|
334 | - $toggle_active = ! empty($this->_cur_dtt_id) |
|
335 | - && EE_Registry::instance()->CAP->current_user_can( |
|
336 | - 'ee_edit_checkin', |
|
337 | - 'espresso_registrations_toggle_checkin_status', |
|
338 | - $item->ID() |
|
339 | - ) |
|
340 | - ? ' clickable trigger-checkin' |
|
341 | - : ''; |
|
342 | - $mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
|
343 | - return '<span class="' . $checkin_status_dashicon->cssClasses() . $toggle_active . '"' |
|
344 | - . ' data-_regid="' . $item->ID() . '"' |
|
345 | - . ' data-dttid="' . $this->_cur_dtt_id . '"' |
|
346 | - . ' data-nonce="' . $nonce . '">' |
|
347 | - . '</span>' |
|
348 | - . $mobile_view_content; |
|
349 | - } |
|
350 | - |
|
351 | - |
|
352 | - /** |
|
353 | - * @param \EE_Registration $item |
|
354 | - * @return mixed|string|void |
|
355 | - * @throws \EE_Error |
|
356 | - */ |
|
357 | - public function column_ATT_name(EE_Registration $item) |
|
358 | - { |
|
359 | - $attendee = $item->attendee(); |
|
360 | - if (! $attendee instanceof EE_Attendee) { |
|
361 | - return __('No contact record for this registration.', 'event_espresso'); |
|
362 | - } |
|
363 | - // edit attendee link |
|
364 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
365 | - array('action' => 'view_registration', '_REG_ID' => $item->ID()), |
|
366 | - REG_ADMIN_URL |
|
367 | - ); |
|
368 | - $name_link = EE_Registry::instance()->CAP->current_user_can( |
|
369 | - 'ee_edit_contacts', |
|
370 | - 'espresso_registrations_edit_attendee' |
|
371 | - ) |
|
372 | - ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
373 | - . $item->attendee()->full_name() |
|
374 | - . '</a>' |
|
375 | - : $item->attendee()->full_name(); |
|
376 | - $name_link .= $item->count() === 1 |
|
377 | - ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup> ' |
|
378 | - : ''; |
|
379 | - // add group details |
|
380 | - $name_link .= ' ' . sprintf(__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
381 | - // add regcode |
|
382 | - $link = EE_Admin_Page::add_query_args_and_nonce( |
|
383 | - array('action' => 'view_registration', '_REG_ID' => $item->ID()), |
|
384 | - REG_ADMIN_URL |
|
385 | - ); |
|
386 | - $name_link .= '<br>'; |
|
387 | - $name_link .= EE_Registry::instance()->instance()->CAP->current_user_can( |
|
388 | - 'ee_read_registration', |
|
389 | - 'view_registration', |
|
390 | - $item->ID() |
|
391 | - ) |
|
392 | - ? '<a href="' . $link . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
393 | - . $item->reg_code() |
|
394 | - . '</a>' |
|
395 | - : $item->reg_code(); |
|
396 | - // status |
|
397 | - $name_link .= '<br><span class="ee-status-text-small">'; |
|
398 | - $name_link .= EEH_Template::pretty_status($item->status_ID(), false, 'sentence'); |
|
399 | - $name_link .= '</span>'; |
|
400 | - $actions = array(); |
|
401 | - $DTT_ID = $this->_cur_dtt_id; |
|
402 | - $latest_related_datetime = empty($DTT_ID) && ! empty($this->_req_data['event_id']) && $item instanceof EE_Registration |
|
403 | - ? $item->get_latest_related_datetime() |
|
404 | - : null; |
|
405 | - $DTT_ID = $latest_related_datetime instanceof EE_Datetime |
|
406 | - ? $latest_related_datetime->ID() |
|
407 | - : $DTT_ID; |
|
408 | - if (! empty($DTT_ID) |
|
409 | - && EE_Registry::instance()->CAP->current_user_can( |
|
410 | - 'ee_read_checkins', |
|
411 | - 'espresso_registrations_registration_checkins' |
|
412 | - ) |
|
413 | - ) { |
|
414 | - $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce( |
|
415 | - array('action' => 'registration_checkins', '_REG_ID' => $item->ID(), 'DTT_ID' => $DTT_ID), |
|
416 | - REG_ADMIN_URL |
|
417 | - ); |
|
418 | - // get the timestamps for this registration's checkins, related to the selected datetime |
|
419 | - $timestamps = $item->get_many_related('Checkin', array(array('DTT_ID' => $DTT_ID))); |
|
420 | - if (! empty($timestamps)) { |
|
421 | - // get the last timestamp |
|
422 | - $last_timestamp = end($timestamps); |
|
423 | - // checked in or checked out? |
|
424 | - $checkin_status = $last_timestamp->get('CHK_in') |
|
425 | - ? esc_html__('Checked In', 'event_espresso') |
|
426 | - : esc_html__('Checked Out', 'event_espresso'); |
|
427 | - // get timestamp string |
|
428 | - $timestamp_string = $last_timestamp->get_datetime('CHK_timestamp'); |
|
429 | - $actions['checkin'] = '<a href="' . $checkin_list_url . '" title="' |
|
430 | - . esc_attr__( |
|
431 | - 'View this registrant\'s check-ins/checkouts for the datetime', |
|
432 | - 'event_espresso' |
|
433 | - ) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>'; |
|
434 | - } |
|
435 | - } |
|
436 | - return (! empty($DTT_ID) && ! empty($timestamps)) |
|
437 | - ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true)) |
|
438 | - : $name_link; |
|
439 | - } |
|
440 | - |
|
441 | - |
|
442 | - /** |
|
443 | - * @param \EE_Registration $item |
|
444 | - * @return string |
|
445 | - */ |
|
446 | - public function column_ATT_email(EE_Registration $item) |
|
447 | - { |
|
448 | - $attendee = $item->attendee(); |
|
449 | - return $attendee instanceof EE_Attendee ? $attendee->email() : ''; |
|
450 | - } |
|
451 | - |
|
452 | - |
|
453 | - /** |
|
454 | - * @param \EE_Registration $item |
|
455 | - * @return bool|string |
|
456 | - * @throws \EE_Error |
|
457 | - */ |
|
458 | - public function column_Event(EE_Registration $item) |
|
459 | - { |
|
460 | - try { |
|
461 | - $event = $this->_evt instanceof EE_Event ? $this->_evt : $item->event(); |
|
462 | - $chkin_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
463 | - array('action' => 'event_registrations', 'event_id' => $event->ID()), |
|
464 | - REG_ADMIN_URL |
|
465 | - ); |
|
466 | - $event_label = EE_Registry::instance()->CAP->current_user_can( |
|
467 | - 'ee_read_checkins', |
|
468 | - 'espresso_registrations_registration_checkins' |
|
469 | - ) ? '<a href="' . $chkin_lnk_url . '" title="' |
|
470 | - . esc_attr__( |
|
471 | - 'View Checkins for this Event', |
|
472 | - 'event_espresso' |
|
473 | - ) . '">' . $event->name() . '</a>' : $event->name(); |
|
474 | - } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) { |
|
475 | - $event_label = esc_html__('Unknown', 'event_espresso'); |
|
476 | - } |
|
477 | - return $event_label; |
|
478 | - } |
|
479 | - |
|
480 | - |
|
481 | - /** |
|
482 | - * @param \EE_Registration $item |
|
483 | - * @return mixed|string|void |
|
484 | - */ |
|
485 | - public function column_PRC_name(EE_Registration $item) |
|
486 | - { |
|
487 | - return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : __("Unknown", "event_espresso"); |
|
488 | - } |
|
489 | - |
|
490 | - |
|
491 | - /** |
|
492 | - * column_REG_final_price |
|
493 | - * |
|
494 | - * @param \EE_Registration $item |
|
495 | - * @return string |
|
496 | - */ |
|
497 | - public function column__REG_final_price(EE_Registration $item) |
|
498 | - { |
|
499 | - return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>'; |
|
500 | - } |
|
501 | - |
|
502 | - |
|
503 | - /** |
|
504 | - * column_TXN_paid |
|
505 | - * |
|
506 | - * @param \EE_Registration $item |
|
507 | - * @return string |
|
508 | - * @throws \EE_Error |
|
509 | - */ |
|
510 | - public function column_TXN_paid(EE_Registration $item) |
|
511 | - { |
|
512 | - if ($item->count() === 1) { |
|
513 | - if ($item->transaction()->paid() >= $item->transaction()->total()) { |
|
514 | - return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>'; |
|
515 | - } else { |
|
516 | - $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
517 | - array('action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID()), |
|
518 | - TXN_ADMIN_URL |
|
519 | - ); |
|
520 | - return EE_Registry::instance()->CAP->current_user_can( |
|
521 | - 'ee_read_transaction', |
|
522 | - 'espresso_transactions_view_transaction' |
|
523 | - ) ? ' |
|
15 | + /** |
|
16 | + * This property will hold the related Datetimes on an event IF the event id is included in the request. |
|
17 | + * |
|
18 | + * @var EE_Datetime[] |
|
19 | + */ |
|
20 | + protected $_dtts_for_event = array(); |
|
21 | + |
|
22 | + |
|
23 | + /** |
|
24 | + * The event if one is specified in the request |
|
25 | + * |
|
26 | + * @var EE_Event |
|
27 | + */ |
|
28 | + protected $_evt = null; |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * The DTT_ID if the current view has a specified datetime. |
|
33 | + * |
|
34 | + * @var int $_cur_dtt_id |
|
35 | + */ |
|
36 | + protected $_cur_dtt_id = 0; |
|
37 | + |
|
38 | + |
|
39 | + /** |
|
40 | + * EE_Event_Registrations_List_Table constructor. |
|
41 | + * |
|
42 | + * @param \Registrations_Admin_Page $admin_page |
|
43 | + */ |
|
44 | + public function __construct($admin_page) |
|
45 | + { |
|
46 | + parent::__construct($admin_page); |
|
47 | + $this->_status = $this->_admin_page->get_registration_status_array(); |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + protected function _setup_data() |
|
52 | + { |
|
53 | + $this->_data = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees($this->_per_page) |
|
54 | + : $this->_admin_page->get_event_attendees($this->_per_page, false, true); |
|
55 | + $this->_all_data_count = $this->_view !== 'trash' ? $this->_admin_page->get_event_attendees( |
|
56 | + $this->_per_page, |
|
57 | + true |
|
58 | + ) : $this->_admin_page->get_event_attendees($this->_per_page, true, true); |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + protected function _set_properties() |
|
63 | + { |
|
64 | + $evt_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
65 | + $this->_wp_list_args = array( |
|
66 | + 'singular' => __('registrant', 'event_espresso'), |
|
67 | + 'plural' => __('registrants', 'event_espresso'), |
|
68 | + 'ajax' => true, |
|
69 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
70 | + ); |
|
71 | + $columns = array(); |
|
72 | + // $columns['_Reg_Status'] = ''; |
|
73 | + $this->_columns = array( |
|
74 | + '_REG_att_checked_in' => '<span class="dashicons dashicons-yes ee-icon-size-18"></span>', |
|
75 | + 'ATT_name' => __('Registrant', 'event_espresso'), |
|
76 | + 'ATT_email' => __('Email Address', 'event_espresso'), |
|
77 | + 'Event' => __('Event', 'event_espresso'), |
|
78 | + 'PRC_name' => __('TKT Option', 'event_espresso'), |
|
79 | + '_REG_final_price' => __('Price', 'event_espresso'), |
|
80 | + 'TXN_paid' => __('Paid', 'event_espresso'), |
|
81 | + 'TXN_total' => __('Total', 'event_espresso'), |
|
82 | + ); |
|
83 | + // Add/remove columns when an event has been selected |
|
84 | + if (! empty($evt_id)) { |
|
85 | + // Render a checkbox column |
|
86 | + $columns['cb'] = '<input type="checkbox" />'; |
|
87 | + $this->_has_checkbox_column = true; |
|
88 | + // Remove the 'Event' column |
|
89 | + unset($this->_columns['Event']); |
|
90 | + } |
|
91 | + $this->_columns = array_merge($columns, $this->_columns); |
|
92 | + $this->_primary_column = '_REG_att_checked_in'; |
|
93 | + if (! empty($evt_id) |
|
94 | + && EE_Registry::instance()->CAP->current_user_can( |
|
95 | + 'ee_read_registrations', |
|
96 | + 'espresso_registrations_registrations_reports', |
|
97 | + $evt_id |
|
98 | + ) |
|
99 | + ) { |
|
100 | + $this->_bottom_buttons = array( |
|
101 | + 'report' => array( |
|
102 | + 'route' => 'registrations_report', |
|
103 | + 'extra_request' => |
|
104 | + array( |
|
105 | + 'EVT_ID' => $evt_id, |
|
106 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
107 | + ), |
|
108 | + ), |
|
109 | + ); |
|
110 | + } |
|
111 | + $this->_bottom_buttons['report_filtered'] = array( |
|
112 | + 'route' => 'registrations_checkin_report', |
|
113 | + 'extra_request' => array( |
|
114 | + 'use_filters' => true, |
|
115 | + 'filters' => array_merge( |
|
116 | + array( |
|
117 | + 'EVT_ID' => $evt_id, |
|
118 | + ), |
|
119 | + array_diff_key( |
|
120 | + $this->_req_data, |
|
121 | + array_flip( |
|
122 | + array( |
|
123 | + 'page', |
|
124 | + 'action', |
|
125 | + 'default_nonce', |
|
126 | + ) |
|
127 | + ) |
|
128 | + ) |
|
129 | + ), |
|
130 | + 'return_url' => urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"), |
|
131 | + ), |
|
132 | + ); |
|
133 | + $this->_sortable_columns = array( |
|
134 | + /** |
|
135 | + * Allows users to change the default sort if they wish. |
|
136 | + * Returning a falsey on this filter will result in the default sort to be by firstname rather than last name. |
|
137 | + * |
|
138 | + * Note: usual naming conventions for filters aren't followed here so that just one filter can be used to |
|
139 | + * change the sorts on any list table involving registration contacts. If you want to only change the filter |
|
140 | + * for a specific list table you can use the provided reference to this object instance. |
|
141 | + */ |
|
142 | + 'ATT_name' => array( |
|
143 | + 'FHEE__EE_Registrations_List_Table___set_properties__default_sort_by_registration_last_name', |
|
144 | + true, |
|
145 | + $this, |
|
146 | + ) |
|
147 | + ? array('ATT_lname' => true) |
|
148 | + : array('ATT_fname' => true), |
|
149 | + 'Event' => array('Event.EVT_name' => false), |
|
150 | + ); |
|
151 | + $this->_hidden_columns = array(); |
|
152 | + $this->_evt = EEM_Event::instance()->get_one_by_ID($evt_id); |
|
153 | + $this->_dtts_for_event = $this->_evt instanceof EE_Event ? $this->_evt->datetimes_ordered() : array(); |
|
154 | + } |
|
155 | + |
|
156 | + |
|
157 | + /** |
|
158 | + * @param \EE_Registration $item |
|
159 | + * @return string |
|
160 | + */ |
|
161 | + protected function _get_row_class($item) |
|
162 | + { |
|
163 | + $class = parent::_get_row_class($item); |
|
164 | + // add status class |
|
165 | + $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
166 | + if ($this->_has_checkbox_column) { |
|
167 | + $class .= ' has-checkbox-column'; |
|
168 | + } |
|
169 | + return $class; |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + /** |
|
174 | + * @return array |
|
175 | + * @throws \EE_Error |
|
176 | + */ |
|
177 | + protected function _get_table_filters() |
|
178 | + { |
|
179 | + $filters = $where = array(); |
|
180 | + $current_EVT_ID = isset($this->_req_data['event_id']) ? (int) $this->_req_data['event_id'] : 0; |
|
181 | + if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) { |
|
182 | + // this means we don't have an event so let's setup a filter dropdown for all the events to select |
|
183 | + // note possible capability restrictions |
|
184 | + if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
185 | + $where['status**'] = array('!=', 'private'); |
|
186 | + } |
|
187 | + if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
188 | + $where['EVT_wp_user'] = get_current_user_id(); |
|
189 | + } |
|
190 | + $events = EEM_Event::instance()->get_all( |
|
191 | + array( |
|
192 | + $where, |
|
193 | + 'order_by' => array('Datetime.DTT_EVT_start' => 'DESC'), |
|
194 | + ) |
|
195 | + ); |
|
196 | + $evts[] = array( |
|
197 | + 'id' => 0, |
|
198 | + 'text' => __('To toggle Check-in status, select an event', 'event_espresso'), |
|
199 | + ); |
|
200 | + $checked = 'checked'; |
|
201 | + /** @var EE_Event $evt */ |
|
202 | + foreach ($events as $evt) { |
|
203 | + // any registrations for this event? |
|
204 | + if (! $evt->get_count_of_all_registrations()) { |
|
205 | + continue; |
|
206 | + } |
|
207 | + $evts[] = array( |
|
208 | + 'id' => $evt->ID(), |
|
209 | + 'text' => apply_filters( |
|
210 | + 'FHEE__EE_Event_Registrations___get_table_filters__event_name', |
|
211 | + $evt->get('EVT_name'), |
|
212 | + $evt |
|
213 | + ), |
|
214 | + 'class' => $evt->is_expired() ? 'ee-expired-event' : '', |
|
215 | + ); |
|
216 | + if ($evt->ID() === $current_EVT_ID && $evt->is_expired()) { |
|
217 | + $checked = ''; |
|
218 | + } |
|
219 | + } |
|
220 | + $event_filter = '<div class="ee-event-filter">'; |
|
221 | + $event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID); |
|
222 | + $event_filter .= '<span class="ee-event-filter-toggle">'; |
|
223 | + $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> '; |
|
224 | + $event_filter .= __('Hide Expired Events', 'event_espresso'); |
|
225 | + $event_filter .= '</span>'; |
|
226 | + $event_filter .= '</div>'; |
|
227 | + $filters[] = $event_filter; |
|
228 | + } |
|
229 | + if (! empty($this->_dtts_for_event)) { |
|
230 | + // DTT datetimes filter |
|
231 | + $this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0; |
|
232 | + if (count($this->_dtts_for_event) > 1) { |
|
233 | + $dtts[0] = __('To toggle check-in status, select a datetime.', 'event_espresso'); |
|
234 | + foreach ($this->_dtts_for_event as $dtt) { |
|
235 | + $datetime_string = $dtt->name(); |
|
236 | + $datetime_string = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : ''; |
|
237 | + $datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string; |
|
238 | + $dtts[ $dtt->ID() ] = $datetime_string; |
|
239 | + } |
|
240 | + $input = new EE_Select_Input( |
|
241 | + $dtts, |
|
242 | + array( |
|
243 | + 'html_name' => 'DTT_ID', |
|
244 | + 'html_id' => 'DTT_ID', |
|
245 | + 'default' => $this->_cur_dtt_id, |
|
246 | + ) |
|
247 | + ); |
|
248 | + $filters[] = $input->get_html_for_input(); |
|
249 | + $filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">'; |
|
250 | + } |
|
251 | + } |
|
252 | + return $filters; |
|
253 | + } |
|
254 | + |
|
255 | + |
|
256 | + protected function _add_view_counts() |
|
257 | + { |
|
258 | + $this->_views['all']['count'] = $this->_get_total_event_attendees(); |
|
259 | + } |
|
260 | + |
|
261 | + |
|
262 | + /** |
|
263 | + * @return int |
|
264 | + * @throws \EE_Error |
|
265 | + */ |
|
266 | + protected function _get_total_event_attendees() |
|
267 | + { |
|
268 | + $EVT_ID = isset($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : false; |
|
269 | + $DTT_ID = $this->_cur_dtt_id; |
|
270 | + $query_params = array(); |
|
271 | + if ($EVT_ID) { |
|
272 | + $query_params[0]['EVT_ID'] = $EVT_ID; |
|
273 | + } |
|
274 | + // if DTT is included we only show for that datetime. Otherwise we're showing for all datetimes (the event). |
|
275 | + if ($DTT_ID) { |
|
276 | + $query_params[0]['Ticket.Datetime.DTT_ID'] = $DTT_ID; |
|
277 | + } |
|
278 | + $status_ids_array = apply_filters( |
|
279 | + 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
280 | + array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
281 | + ); |
|
282 | + $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
283 | + return EEM_Registration::instance()->count($query_params); |
|
284 | + } |
|
285 | + |
|
286 | + |
|
287 | + /** |
|
288 | + * @param \EE_Registration $item |
|
289 | + * @return string |
|
290 | + */ |
|
291 | + public function column__Reg_Status(EE_Registration $item) |
|
292 | + { |
|
293 | + return '<span class="ee-status-strip ee-status-strip-td reg-status-' . $item->status_ID() . '"></span>'; |
|
294 | + } |
|
295 | + |
|
296 | + |
|
297 | + /** |
|
298 | + * @param \EE_Registration $item |
|
299 | + * @return string |
|
300 | + * @throws \EE_Error |
|
301 | + */ |
|
302 | + public function column_cb($item) |
|
303 | + { |
|
304 | + return sprintf('<input type="checkbox" name="checkbox[%1$s]" value="%1$s" />', $item->ID()); |
|
305 | + } |
|
306 | + |
|
307 | + |
|
308 | + /** |
|
309 | + * column_REG_att_checked_in |
|
310 | + * |
|
311 | + * @param EE_Registration $item |
|
312 | + * @return string |
|
313 | + * @throws EE_Error |
|
314 | + * @throws InvalidArgumentException |
|
315 | + * @throws InvalidDataTypeException |
|
316 | + * @throws InvalidInterfaceException |
|
317 | + */ |
|
318 | + public function column__REG_att_checked_in(EE_Registration $item) |
|
319 | + { |
|
320 | + $attendee = $item->attendee(); |
|
321 | + $attendee_name = $attendee instanceof EE_Attendee ? $attendee->full_name() : ''; |
|
322 | + |
|
323 | + if ($this->_cur_dtt_id === 0 && count($this->_dtts_for_event) === 1) { |
|
324 | + $latest_related_datetime = $item->get_latest_related_datetime(); |
|
325 | + if ($latest_related_datetime instanceof EE_Datetime) { |
|
326 | + $this->_cur_dtt_id = $latest_related_datetime->ID(); |
|
327 | + } |
|
328 | + } |
|
329 | + $checkin_status_dashicon = CheckinStatusDashicon::fromRegistrationAndDatetimeId( |
|
330 | + $item, |
|
331 | + $this->_cur_dtt_id |
|
332 | + ); |
|
333 | + $nonce = wp_create_nonce('checkin_nonce'); |
|
334 | + $toggle_active = ! empty($this->_cur_dtt_id) |
|
335 | + && EE_Registry::instance()->CAP->current_user_can( |
|
336 | + 'ee_edit_checkin', |
|
337 | + 'espresso_registrations_toggle_checkin_status', |
|
338 | + $item->ID() |
|
339 | + ) |
|
340 | + ? ' clickable trigger-checkin' |
|
341 | + : ''; |
|
342 | + $mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
|
343 | + return '<span class="' . $checkin_status_dashicon->cssClasses() . $toggle_active . '"' |
|
344 | + . ' data-_regid="' . $item->ID() . '"' |
|
345 | + . ' data-dttid="' . $this->_cur_dtt_id . '"' |
|
346 | + . ' data-nonce="' . $nonce . '">' |
|
347 | + . '</span>' |
|
348 | + . $mobile_view_content; |
|
349 | + } |
|
350 | + |
|
351 | + |
|
352 | + /** |
|
353 | + * @param \EE_Registration $item |
|
354 | + * @return mixed|string|void |
|
355 | + * @throws \EE_Error |
|
356 | + */ |
|
357 | + public function column_ATT_name(EE_Registration $item) |
|
358 | + { |
|
359 | + $attendee = $item->attendee(); |
|
360 | + if (! $attendee instanceof EE_Attendee) { |
|
361 | + return __('No contact record for this registration.', 'event_espresso'); |
|
362 | + } |
|
363 | + // edit attendee link |
|
364 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
365 | + array('action' => 'view_registration', '_REG_ID' => $item->ID()), |
|
366 | + REG_ADMIN_URL |
|
367 | + ); |
|
368 | + $name_link = EE_Registry::instance()->CAP->current_user_can( |
|
369 | + 'ee_edit_contacts', |
|
370 | + 'espresso_registrations_edit_attendee' |
|
371 | + ) |
|
372 | + ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
373 | + . $item->attendee()->full_name() |
|
374 | + . '</a>' |
|
375 | + : $item->attendee()->full_name(); |
|
376 | + $name_link .= $item->count() === 1 |
|
377 | + ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup> ' |
|
378 | + : ''; |
|
379 | + // add group details |
|
380 | + $name_link .= ' ' . sprintf(__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
381 | + // add regcode |
|
382 | + $link = EE_Admin_Page::add_query_args_and_nonce( |
|
383 | + array('action' => 'view_registration', '_REG_ID' => $item->ID()), |
|
384 | + REG_ADMIN_URL |
|
385 | + ); |
|
386 | + $name_link .= '<br>'; |
|
387 | + $name_link .= EE_Registry::instance()->instance()->CAP->current_user_can( |
|
388 | + 'ee_read_registration', |
|
389 | + 'view_registration', |
|
390 | + $item->ID() |
|
391 | + ) |
|
392 | + ? '<a href="' . $link . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
393 | + . $item->reg_code() |
|
394 | + . '</a>' |
|
395 | + : $item->reg_code(); |
|
396 | + // status |
|
397 | + $name_link .= '<br><span class="ee-status-text-small">'; |
|
398 | + $name_link .= EEH_Template::pretty_status($item->status_ID(), false, 'sentence'); |
|
399 | + $name_link .= '</span>'; |
|
400 | + $actions = array(); |
|
401 | + $DTT_ID = $this->_cur_dtt_id; |
|
402 | + $latest_related_datetime = empty($DTT_ID) && ! empty($this->_req_data['event_id']) && $item instanceof EE_Registration |
|
403 | + ? $item->get_latest_related_datetime() |
|
404 | + : null; |
|
405 | + $DTT_ID = $latest_related_datetime instanceof EE_Datetime |
|
406 | + ? $latest_related_datetime->ID() |
|
407 | + : $DTT_ID; |
|
408 | + if (! empty($DTT_ID) |
|
409 | + && EE_Registry::instance()->CAP->current_user_can( |
|
410 | + 'ee_read_checkins', |
|
411 | + 'espresso_registrations_registration_checkins' |
|
412 | + ) |
|
413 | + ) { |
|
414 | + $checkin_list_url = EE_Admin_Page::add_query_args_and_nonce( |
|
415 | + array('action' => 'registration_checkins', '_REG_ID' => $item->ID(), 'DTT_ID' => $DTT_ID), |
|
416 | + REG_ADMIN_URL |
|
417 | + ); |
|
418 | + // get the timestamps for this registration's checkins, related to the selected datetime |
|
419 | + $timestamps = $item->get_many_related('Checkin', array(array('DTT_ID' => $DTT_ID))); |
|
420 | + if (! empty($timestamps)) { |
|
421 | + // get the last timestamp |
|
422 | + $last_timestamp = end($timestamps); |
|
423 | + // checked in or checked out? |
|
424 | + $checkin_status = $last_timestamp->get('CHK_in') |
|
425 | + ? esc_html__('Checked In', 'event_espresso') |
|
426 | + : esc_html__('Checked Out', 'event_espresso'); |
|
427 | + // get timestamp string |
|
428 | + $timestamp_string = $last_timestamp->get_datetime('CHK_timestamp'); |
|
429 | + $actions['checkin'] = '<a href="' . $checkin_list_url . '" title="' |
|
430 | + . esc_attr__( |
|
431 | + 'View this registrant\'s check-ins/checkouts for the datetime', |
|
432 | + 'event_espresso' |
|
433 | + ) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>'; |
|
434 | + } |
|
435 | + } |
|
436 | + return (! empty($DTT_ID) && ! empty($timestamps)) |
|
437 | + ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true)) |
|
438 | + : $name_link; |
|
439 | + } |
|
440 | + |
|
441 | + |
|
442 | + /** |
|
443 | + * @param \EE_Registration $item |
|
444 | + * @return string |
|
445 | + */ |
|
446 | + public function column_ATT_email(EE_Registration $item) |
|
447 | + { |
|
448 | + $attendee = $item->attendee(); |
|
449 | + return $attendee instanceof EE_Attendee ? $attendee->email() : ''; |
|
450 | + } |
|
451 | + |
|
452 | + |
|
453 | + /** |
|
454 | + * @param \EE_Registration $item |
|
455 | + * @return bool|string |
|
456 | + * @throws \EE_Error |
|
457 | + */ |
|
458 | + public function column_Event(EE_Registration $item) |
|
459 | + { |
|
460 | + try { |
|
461 | + $event = $this->_evt instanceof EE_Event ? $this->_evt : $item->event(); |
|
462 | + $chkin_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
463 | + array('action' => 'event_registrations', 'event_id' => $event->ID()), |
|
464 | + REG_ADMIN_URL |
|
465 | + ); |
|
466 | + $event_label = EE_Registry::instance()->CAP->current_user_can( |
|
467 | + 'ee_read_checkins', |
|
468 | + 'espresso_registrations_registration_checkins' |
|
469 | + ) ? '<a href="' . $chkin_lnk_url . '" title="' |
|
470 | + . esc_attr__( |
|
471 | + 'View Checkins for this Event', |
|
472 | + 'event_espresso' |
|
473 | + ) . '">' . $event->name() . '</a>' : $event->name(); |
|
474 | + } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) { |
|
475 | + $event_label = esc_html__('Unknown', 'event_espresso'); |
|
476 | + } |
|
477 | + return $event_label; |
|
478 | + } |
|
479 | + |
|
480 | + |
|
481 | + /** |
|
482 | + * @param \EE_Registration $item |
|
483 | + * @return mixed|string|void |
|
484 | + */ |
|
485 | + public function column_PRC_name(EE_Registration $item) |
|
486 | + { |
|
487 | + return $item->ticket() instanceof EE_Ticket ? $item->ticket()->name() : __("Unknown", "event_espresso"); |
|
488 | + } |
|
489 | + |
|
490 | + |
|
491 | + /** |
|
492 | + * column_REG_final_price |
|
493 | + * |
|
494 | + * @param \EE_Registration $item |
|
495 | + * @return string |
|
496 | + */ |
|
497 | + public function column__REG_final_price(EE_Registration $item) |
|
498 | + { |
|
499 | + return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>'; |
|
500 | + } |
|
501 | + |
|
502 | + |
|
503 | + /** |
|
504 | + * column_TXN_paid |
|
505 | + * |
|
506 | + * @param \EE_Registration $item |
|
507 | + * @return string |
|
508 | + * @throws \EE_Error |
|
509 | + */ |
|
510 | + public function column_TXN_paid(EE_Registration $item) |
|
511 | + { |
|
512 | + if ($item->count() === 1) { |
|
513 | + if ($item->transaction()->paid() >= $item->transaction()->total()) { |
|
514 | + return '<span class="reg-pad-rght"><div class="dashicons dashicons-yes green-icon"></div></span>'; |
|
515 | + } else { |
|
516 | + $view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
517 | + array('action' => 'view_transaction', 'TXN_ID' => $item->transaction_ID()), |
|
518 | + TXN_ADMIN_URL |
|
519 | + ); |
|
520 | + return EE_Registry::instance()->CAP->current_user_can( |
|
521 | + 'ee_read_transaction', |
|
522 | + 'espresso_transactions_view_transaction' |
|
523 | + ) ? ' |
|
524 | 524 | <span class="reg-pad-rght"> |
525 | 525 | <a class="status-' |
526 | - . $item->transaction()->status_ID() |
|
527 | - . '" href="' |
|
528 | - . $view_txn_lnk_url |
|
529 | - . '" title="' |
|
530 | - . esc_attr__('View Transaction', 'event_espresso') |
|
531 | - . '"> |
|
526 | + . $item->transaction()->status_ID() |
|
527 | + . '" href="' |
|
528 | + . $view_txn_lnk_url |
|
529 | + . '" title="' |
|
530 | + . esc_attr__('View Transaction', 'event_espresso') |
|
531 | + . '"> |
|
532 | 532 | ' |
533 | - . $item->transaction()->pretty_paid() |
|
534 | - . ' |
|
533 | + . $item->transaction()->pretty_paid() |
|
534 | + . ' |
|
535 | 535 | </a> |
536 | 536 | <span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
537 | - } |
|
538 | - } else { |
|
539 | - return '<span class="reg-pad-rght"></span>'; |
|
540 | - } |
|
541 | - } |
|
542 | - |
|
543 | - |
|
544 | - /** |
|
545 | - * column_TXN_total |
|
546 | - * |
|
547 | - * @param \EE_Registration $item |
|
548 | - * @return string |
|
549 | - * @throws \EE_Error |
|
550 | - */ |
|
551 | - public function column_TXN_total(EE_Registration $item) |
|
552 | - { |
|
553 | - $txn = $item->transaction(); |
|
554 | - $view_txn_url = add_query_arg(array('action' => 'view_transaction', 'TXN_ID' => $txn->ID()), TXN_ADMIN_URL); |
|
555 | - if ($item->get('REG_count') === 1) { |
|
556 | - $line_total_obj = $txn->total_line_item(); |
|
557 | - $txn_total = $line_total_obj instanceof EE_Line_Item |
|
558 | - ? $line_total_obj->get_pretty('LIN_total') |
|
559 | - : __( |
|
560 | - 'View Transaction', |
|
561 | - 'event_espresso' |
|
562 | - ); |
|
563 | - return EE_Registry::instance()->CAP->current_user_can( |
|
564 | - 'ee_read_transaction', |
|
565 | - 'espresso_transactions_view_transaction' |
|
566 | - ) ? '<a href="' |
|
567 | - . $view_txn_url |
|
568 | - . '" title="' |
|
569 | - . esc_attr__('View Transaction', 'event_espresso') |
|
570 | - . '"><span class="reg-pad-rght">' |
|
571 | - . $txn_total |
|
572 | - . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>'; |
|
573 | - } else { |
|
574 | - return '<span class="reg-pad-rght"></span>'; |
|
575 | - } |
|
576 | - } |
|
537 | + } |
|
538 | + } else { |
|
539 | + return '<span class="reg-pad-rght"></span>'; |
|
540 | + } |
|
541 | + } |
|
542 | + |
|
543 | + |
|
544 | + /** |
|
545 | + * column_TXN_total |
|
546 | + * |
|
547 | + * @param \EE_Registration $item |
|
548 | + * @return string |
|
549 | + * @throws \EE_Error |
|
550 | + */ |
|
551 | + public function column_TXN_total(EE_Registration $item) |
|
552 | + { |
|
553 | + $txn = $item->transaction(); |
|
554 | + $view_txn_url = add_query_arg(array('action' => 'view_transaction', 'TXN_ID' => $txn->ID()), TXN_ADMIN_URL); |
|
555 | + if ($item->get('REG_count') === 1) { |
|
556 | + $line_total_obj = $txn->total_line_item(); |
|
557 | + $txn_total = $line_total_obj instanceof EE_Line_Item |
|
558 | + ? $line_total_obj->get_pretty('LIN_total') |
|
559 | + : __( |
|
560 | + 'View Transaction', |
|
561 | + 'event_espresso' |
|
562 | + ); |
|
563 | + return EE_Registry::instance()->CAP->current_user_can( |
|
564 | + 'ee_read_transaction', |
|
565 | + 'espresso_transactions_view_transaction' |
|
566 | + ) ? '<a href="' |
|
567 | + . $view_txn_url |
|
568 | + . '" title="' |
|
569 | + . esc_attr__('View Transaction', 'event_espresso') |
|
570 | + . '"><span class="reg-pad-rght">' |
|
571 | + . $txn_total |
|
572 | + . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>'; |
|
573 | + } else { |
|
574 | + return '<span class="reg-pad-rght"></span>'; |
|
575 | + } |
|
576 | + } |
|
577 | 577 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | 'TXN_total' => __('Total', 'event_espresso'), |
82 | 82 | ); |
83 | 83 | // Add/remove columns when an event has been selected |
84 | - if (! empty($evt_id)) { |
|
84 | + if ( ! empty($evt_id)) { |
|
85 | 85 | // Render a checkbox column |
86 | 86 | $columns['cb'] = '<input type="checkbox" />'; |
87 | 87 | $this->_has_checkbox_column = true; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | } |
91 | 91 | $this->_columns = array_merge($columns, $this->_columns); |
92 | 92 | $this->_primary_column = '_REG_att_checked_in'; |
93 | - if (! empty($evt_id) |
|
93 | + if ( ! empty($evt_id) |
|
94 | 94 | && EE_Registry::instance()->CAP->current_user_can( |
95 | 95 | 'ee_read_registrations', |
96 | 96 | 'espresso_registrations_registrations_reports', |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | { |
163 | 163 | $class = parent::_get_row_class($item); |
164 | 164 | // add status class |
165 | - $class .= ' ee-status-strip reg-status-' . $item->status_ID(); |
|
165 | + $class .= ' ee-status-strip reg-status-'.$item->status_ID(); |
|
166 | 166 | if ($this->_has_checkbox_column) { |
167 | 167 | $class .= ' has-checkbox-column'; |
168 | 168 | } |
@@ -181,10 +181,10 @@ discard block |
||
181 | 181 | if (empty($this->_dtts_for_event) || count($this->_dtts_for_event) === 1) { |
182 | 182 | // this means we don't have an event so let's setup a filter dropdown for all the events to select |
183 | 183 | // note possible capability restrictions |
184 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
184 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
185 | 185 | $where['status**'] = array('!=', 'private'); |
186 | 186 | } |
187 | - if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
187 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
188 | 188 | $where['EVT_wp_user'] = get_current_user_id(); |
189 | 189 | } |
190 | 190 | $events = EEM_Event::instance()->get_all( |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | /** @var EE_Event $evt */ |
202 | 202 | foreach ($events as $evt) { |
203 | 203 | // any registrations for this event? |
204 | - if (! $evt->get_count_of_all_registrations()) { |
|
204 | + if ( ! $evt->get_count_of_all_registrations()) { |
|
205 | 205 | continue; |
206 | 206 | } |
207 | 207 | $evts[] = array( |
@@ -220,22 +220,22 @@ discard block |
||
220 | 220 | $event_filter = '<div class="ee-event-filter">'; |
221 | 221 | $event_filter .= EEH_Form_Fields::select_input('event_id', $evts, $current_EVT_ID); |
222 | 222 | $event_filter .= '<span class="ee-event-filter-toggle">'; |
223 | - $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" ' . $checked . '> '; |
|
223 | + $event_filter .= '<input type="checkbox" id="js-ee-hide-expired-events" '.$checked.'> '; |
|
224 | 224 | $event_filter .= __('Hide Expired Events', 'event_espresso'); |
225 | 225 | $event_filter .= '</span>'; |
226 | 226 | $event_filter .= '</div>'; |
227 | 227 | $filters[] = $event_filter; |
228 | 228 | } |
229 | - if (! empty($this->_dtts_for_event)) { |
|
229 | + if ( ! empty($this->_dtts_for_event)) { |
|
230 | 230 | // DTT datetimes filter |
231 | 231 | $this->_cur_dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0; |
232 | 232 | if (count($this->_dtts_for_event) > 1) { |
233 | 233 | $dtts[0] = __('To toggle check-in status, select a datetime.', 'event_espresso'); |
234 | 234 | foreach ($this->_dtts_for_event as $dtt) { |
235 | 235 | $datetime_string = $dtt->name(); |
236 | - $datetime_string = ! empty($datetime_string) ? ' (' . $datetime_string . ')' : ''; |
|
237 | - $datetime_string = $dtt->start_date_and_time() . ' - ' . $dtt->end_date_and_time() . $datetime_string; |
|
238 | - $dtts[ $dtt->ID() ] = $datetime_string; |
|
236 | + $datetime_string = ! empty($datetime_string) ? ' ('.$datetime_string.')' : ''; |
|
237 | + $datetime_string = $dtt->start_date_and_time().' - '.$dtt->end_date_and_time().$datetime_string; |
|
238 | + $dtts[$dtt->ID()] = $datetime_string; |
|
239 | 239 | } |
240 | 240 | $input = new EE_Select_Input( |
241 | 241 | $dtts, |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | ) |
247 | 247 | ); |
248 | 248 | $filters[] = $input->get_html_for_input(); |
249 | - $filters[] = '<input type="hidden" name="event_id" value="' . $current_EVT_ID . '">'; |
|
249 | + $filters[] = '<input type="hidden" name="event_id" value="'.$current_EVT_ID.'">'; |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | return $filters; |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | */ |
291 | 291 | public function column__Reg_Status(EE_Registration $item) |
292 | 292 | { |
293 | - return '<span class="ee-status-strip ee-status-strip-td reg-status-' . $item->status_ID() . '"></span>'; |
|
293 | + return '<span class="ee-status-strip ee-status-strip-td reg-status-'.$item->status_ID().'"></span>'; |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | |
@@ -339,11 +339,11 @@ discard block |
||
339 | 339 | ) |
340 | 340 | ? ' clickable trigger-checkin' |
341 | 341 | : ''; |
342 | - $mobile_view_content = ' <span class="show-on-mobile-view-only">' . $attendee_name . '</span>'; |
|
343 | - return '<span class="' . $checkin_status_dashicon->cssClasses() . $toggle_active . '"' |
|
344 | - . ' data-_regid="' . $item->ID() . '"' |
|
345 | - . ' data-dttid="' . $this->_cur_dtt_id . '"' |
|
346 | - . ' data-nonce="' . $nonce . '">' |
|
342 | + $mobile_view_content = ' <span class="show-on-mobile-view-only">'.$attendee_name.'</span>'; |
|
343 | + return '<span class="'.$checkin_status_dashicon->cssClasses().$toggle_active.'"' |
|
344 | + . ' data-_regid="'.$item->ID().'"' |
|
345 | + . ' data-dttid="'.$this->_cur_dtt_id.'"' |
|
346 | + . ' data-nonce="'.$nonce.'">' |
|
347 | 347 | . '</span>' |
348 | 348 | . $mobile_view_content; |
349 | 349 | } |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | public function column_ATT_name(EE_Registration $item) |
358 | 358 | { |
359 | 359 | $attendee = $item->attendee(); |
360 | - if (! $attendee instanceof EE_Attendee) { |
|
360 | + if ( ! $attendee instanceof EE_Attendee) { |
|
361 | 361 | return __('No contact record for this registration.', 'event_espresso'); |
362 | 362 | } |
363 | 363 | // edit attendee link |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | 'ee_edit_contacts', |
370 | 370 | 'espresso_registrations_edit_attendee' |
371 | 371 | ) |
372 | - ? '<a href="' . $edit_lnk_url . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
372 | + ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">' |
|
373 | 373 | . $item->attendee()->full_name() |
374 | 374 | . '</a>' |
375 | 375 | : $item->attendee()->full_name(); |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | ? ' <sup><div class="dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8"></div></sup> ' |
378 | 378 | : ''; |
379 | 379 | // add group details |
380 | - $name_link .= ' ' . sprintf(__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
380 | + $name_link .= ' '.sprintf(__('(%s of %s)', 'event_espresso'), $item->count(), $item->group_size()); |
|
381 | 381 | // add regcode |
382 | 382 | $link = EE_Admin_Page::add_query_args_and_nonce( |
383 | 383 | array('action' => 'view_registration', '_REG_ID' => $item->ID()), |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | 'view_registration', |
390 | 390 | $item->ID() |
391 | 391 | ) |
392 | - ? '<a href="' . $link . '" title="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
392 | + ? '<a href="'.$link.'" title="'.esc_attr__('View Registration Details', 'event_espresso').'">' |
|
393 | 393 | . $item->reg_code() |
394 | 394 | . '</a>' |
395 | 395 | : $item->reg_code(); |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | $DTT_ID = $latest_related_datetime instanceof EE_Datetime |
406 | 406 | ? $latest_related_datetime->ID() |
407 | 407 | : $DTT_ID; |
408 | - if (! empty($DTT_ID) |
|
408 | + if ( ! empty($DTT_ID) |
|
409 | 409 | && EE_Registry::instance()->CAP->current_user_can( |
410 | 410 | 'ee_read_checkins', |
411 | 411 | 'espresso_registrations_registration_checkins' |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | ); |
418 | 418 | // get the timestamps for this registration's checkins, related to the selected datetime |
419 | 419 | $timestamps = $item->get_many_related('Checkin', array(array('DTT_ID' => $DTT_ID))); |
420 | - if (! empty($timestamps)) { |
|
420 | + if ( ! empty($timestamps)) { |
|
421 | 421 | // get the last timestamp |
422 | 422 | $last_timestamp = end($timestamps); |
423 | 423 | // checked in or checked out? |
@@ -426,14 +426,14 @@ discard block |
||
426 | 426 | : esc_html__('Checked Out', 'event_espresso'); |
427 | 427 | // get timestamp string |
428 | 428 | $timestamp_string = $last_timestamp->get_datetime('CHK_timestamp'); |
429 | - $actions['checkin'] = '<a href="' . $checkin_list_url . '" title="' |
|
429 | + $actions['checkin'] = '<a href="'.$checkin_list_url.'" title="' |
|
430 | 430 | . esc_attr__( |
431 | 431 | 'View this registrant\'s check-ins/checkouts for the datetime', |
432 | 432 | 'event_espresso' |
433 | - ) . '">' . $checkin_status . ': ' . $timestamp_string . '</a>'; |
|
433 | + ).'">'.$checkin_status.': '.$timestamp_string.'</a>'; |
|
434 | 434 | } |
435 | 435 | } |
436 | - return (! empty($DTT_ID) && ! empty($timestamps)) |
|
436 | + return ( ! empty($DTT_ID) && ! empty($timestamps)) |
|
437 | 437 | ? sprintf('%1$s %2$s', $name_link, $this->row_actions($actions, true)) |
438 | 438 | : $name_link; |
439 | 439 | } |
@@ -466,11 +466,11 @@ discard block |
||
466 | 466 | $event_label = EE_Registry::instance()->CAP->current_user_can( |
467 | 467 | 'ee_read_checkins', |
468 | 468 | 'espresso_registrations_registration_checkins' |
469 | - ) ? '<a href="' . $chkin_lnk_url . '" title="' |
|
469 | + ) ? '<a href="'.$chkin_lnk_url.'" title="' |
|
470 | 470 | . esc_attr__( |
471 | 471 | 'View Checkins for this Event', |
472 | 472 | 'event_espresso' |
473 | - ) . '">' . $event->name() . '</a>' : $event->name(); |
|
473 | + ).'">'.$event->name().'</a>' : $event->name(); |
|
474 | 474 | } catch (\EventEspresso\core\exceptions\EntityNotFoundException $e) { |
475 | 475 | $event_label = esc_html__('Unknown', 'event_espresso'); |
476 | 476 | } |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | */ |
497 | 497 | public function column__REG_final_price(EE_Registration $item) |
498 | 498 | { |
499 | - return '<span class="reg-pad-rght">' . ' ' . $item->pretty_final_price() . '</span>'; |
|
499 | + return '<span class="reg-pad-rght">'.' '.$item->pretty_final_price().'</span>'; |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | . $item->transaction()->pretty_paid() |
534 | 534 | . ' |
535 | 535 | </a> |
536 | - <span>' : '<span class="reg-pad-rght">' . $item->transaction()->pretty_paid() . '</span>'; |
|
536 | + <span>' : '<span class="reg-pad-rght">'.$item->transaction()->pretty_paid().'</span>'; |
|
537 | 537 | } |
538 | 538 | } else { |
539 | 539 | return '<span class="reg-pad-rght"></span>'; |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | . esc_attr__('View Transaction', 'event_espresso') |
570 | 570 | . '"><span class="reg-pad-rght">' |
571 | 571 | . $txn_total |
572 | - . '</span></a>' : '<span class="reg-pad-rght">' . $txn_total . '</span>'; |
|
572 | + . '</span></a>' : '<span class="reg-pad-rght">'.$txn_total.'</span>'; |
|
573 | 573 | } else { |
574 | 574 | return '<span class="reg-pad-rght"></span>'; |
575 | 575 | } |
@@ -38,103 +38,103 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.10.5.rc.009'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.10.5.rc.009'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | - bootstrap_espresso(); |
|
121 | - } |
|
119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | + bootstrap_espresso(); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
124 | - /** |
|
125 | - * deactivate_plugin |
|
126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | - { |
|
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | - } |
|
137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | - deactivate_plugins($plugin_basename); |
|
139 | - } |
|
124 | + /** |
|
125 | + * deactivate_plugin |
|
126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | + { |
|
134 | + if (! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | + } |
|
137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | + deactivate_plugins($plugin_basename); |
|
139 | + } |
|
140 | 140 | } |