@@ -42,354 +42,354 @@ |
||
42 | 42 | */ |
43 | 43 | class CollectionDetails implements CollectionDetailsInterface |
44 | 44 | { |
45 | - /** |
|
46 | - * if $identifier_type is set to this, |
|
47 | - * then the collection will use each object's spl_object_hash() as it's identifier |
|
48 | - */ |
|
49 | - const ID_OBJECT_HASH = 'identifier-uses-spl-object-hash'; |
|
50 | - |
|
51 | - /** |
|
52 | - * if $identifier_type is set to this, |
|
53 | - * then the collection will use each object's class name as it's identifier |
|
54 | - */ |
|
55 | - const ID_CLASS_NAME = 'identifier-uses-object-class-name'; |
|
56 | - |
|
57 | - /** |
|
58 | - * if $identifier_type is set to this, |
|
59 | - * then the collection will use the return value from a specified callback method on each object |
|
60 | - */ |
|
61 | - const ID_CALLBACK_METHOD = 'identifier-uses-callback-method'; |
|
62 | - |
|
63 | - /** |
|
64 | - * The interface used for controlling what gets added to the collection |
|
65 | - * |
|
66 | - * @var string $collection_interface |
|
67 | - */ |
|
68 | - protected $collection_interface = ''; |
|
69 | - |
|
70 | - /** |
|
71 | - * a unique name used to identify the collection in filter names |
|
72 | - * supplied value is run through sanitize_title_with_dashes(), |
|
73 | - * but then also converts dashes to underscores |
|
74 | - * |
|
75 | - * @var string $collection_name |
|
76 | - */ |
|
77 | - protected $collection_name = ''; |
|
78 | - |
|
79 | - /** |
|
80 | - * what the collection uses for the object identifier. |
|
81 | - * corresponds to one of the class constants above. |
|
82 | - * CollectionDetails::ID_OBJECT_HASH will use spl_object_hash( object ) for the identifier |
|
83 | - * CollectionDetails::ID_CLASS_NAME will use get_class( object ) for the identifier |
|
84 | - * CollectionDetails::ID_CALLBACK_METHOD will use a callback for the identifier |
|
85 | - * defaults to using spl_object_hash() so that multiple objects of the same class can be added |
|
86 | - * |
|
87 | - * @var string $identifier_type |
|
88 | - */ |
|
89 | - protected $identifier_type = CollectionDetails::ID_OBJECT_HASH; |
|
90 | - |
|
91 | - /** |
|
92 | - * the pattern applied to paths when searching for class files to add to the collection |
|
93 | - * ie: "My_Awesome_*.class.php" |
|
94 | - * computed value (setter) defaults to "*.php" |
|
95 | - * |
|
96 | - * @var string $file_mask |
|
97 | - * @see CollectionDetails::setFileMask() for details on how computed value is resolved |
|
98 | - */ |
|
99 | - protected $file_mask = ''; |
|
100 | - |
|
101 | - /** |
|
102 | - * if the $identifier_type above is set to CollectionDetails::ID_CALLBACK_METHOD, |
|
103 | - * then this specifies the method to use on each entity. |
|
104 | - * If the callback method does not exist, then an exception will be thrown |
|
105 | - * |
|
106 | - * @var string $identifier_callback |
|
107 | - */ |
|
108 | - protected $identifier_callback = ''; |
|
109 | - |
|
110 | - /** |
|
111 | - * an array of Fully Qualified Class Names |
|
112 | - * for example: |
|
113 | - * $FQCNs = array( |
|
114 | - * '/Fully/Qualified/ClassNameA' |
|
115 | - * '/Fully/Qualified/Other/ClassNameB' |
|
116 | - * ); |
|
117 | - * |
|
118 | - * @var array $collection_FQCNs |
|
119 | - */ |
|
120 | - protected $collection_FQCNs = array(); |
|
121 | - |
|
122 | - /** |
|
123 | - * an array of full server paths to folders containing files to be loaded into collection |
|
124 | - * for example: |
|
125 | - * $paths = array( |
|
126 | - * '/full/server/path/to/ClassNameA.ext.php' // for class ClassNameA |
|
127 | - * '/full/server/path/to/other/ClassNameB.php' // for class ClassNameB |
|
128 | - * ); |
|
129 | - * |
|
130 | - * @var array $collection_paths |
|
131 | - */ |
|
132 | - protected $collection_paths = array(); |
|
133 | - |
|
134 | - /** |
|
135 | - * @var LocatorInterface $file_locator |
|
136 | - */ |
|
137 | - protected $file_locator; |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * CollectionDetails constructor. |
|
142 | - * |
|
143 | - * @access public |
|
144 | - * @param string $collection_name |
|
145 | - * @param string $collection_interface |
|
146 | - * @param array $collection_FQCNs |
|
147 | - * @param array $collection_paths |
|
148 | - * @param string $file_mask |
|
149 | - * @param string $identifier_type |
|
150 | - * @param string $identifier_callback |
|
151 | - * @param LocatorInterface $file_locator |
|
152 | - * @throws CollectionDetailsException |
|
153 | - */ |
|
154 | - public function __construct( |
|
155 | - $collection_name, |
|
156 | - $collection_interface, |
|
157 | - array $collection_FQCNs = array(), |
|
158 | - array $collection_paths = array(), |
|
159 | - $file_mask = '', |
|
160 | - $identifier_type = CollectionDetails::ID_OBJECT_HASH, |
|
161 | - $identifier_callback = '', |
|
162 | - LocatorInterface $file_locator = null |
|
163 | - ) { |
|
164 | - try { |
|
165 | - $this->setCollectionName($collection_name); |
|
166 | - $this->setCollectionInterface($collection_interface); |
|
167 | - $this->setCollectionFQCNs($collection_FQCNs); |
|
168 | - $this->setCollectionPaths($collection_paths); |
|
169 | - $this->setFileMask($file_mask); |
|
170 | - $this->setIdentifierType($identifier_type); |
|
171 | - $this->setIdentifierCallback($identifier_callback); |
|
172 | - $this->file_locator = $file_locator; |
|
173 | - } catch (Exception $exception) { |
|
174 | - throw new CollectionDetailsException($exception); |
|
175 | - } |
|
176 | - } |
|
177 | - |
|
178 | - |
|
179 | - /** |
|
180 | - * @access public |
|
181 | - * @return mixed |
|
182 | - */ |
|
183 | - public function getCollectionInterface() |
|
184 | - { |
|
185 | - return $this->collection_interface; |
|
186 | - } |
|
187 | - |
|
188 | - |
|
189 | - /** |
|
190 | - * @access protected |
|
191 | - * @param string $collection_interface |
|
192 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
193 | - */ |
|
194 | - protected function setCollectionInterface($collection_interface) |
|
195 | - { |
|
196 | - if (! (interface_exists($collection_interface) || class_exists($collection_interface))) { |
|
197 | - throw new InvalidInterfaceException($collection_interface); |
|
198 | - } |
|
199 | - $this->collection_interface = $collection_interface; |
|
200 | - } |
|
201 | - |
|
202 | - |
|
203 | - /** |
|
204 | - * the collection name will be used for creating dynamic filters |
|
205 | - * |
|
206 | - * @access public |
|
207 | - * @return string |
|
208 | - */ |
|
209 | - public function collectionName() |
|
210 | - { |
|
211 | - return $this->collection_name; |
|
212 | - } |
|
213 | - |
|
214 | - |
|
215 | - /** |
|
216 | - * sanitizes collection name and converts spaces and dashes to underscores |
|
217 | - * |
|
218 | - * @access protected |
|
219 | - * @param string $collection_name |
|
220 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
221 | - */ |
|
222 | - protected function setCollectionName($collection_name) |
|
223 | - { |
|
224 | - if (! is_string($collection_name)) { |
|
225 | - throw new InvalidDataTypeException('$collection_name', $collection_name, 'string'); |
|
226 | - } |
|
227 | - $this->collection_name = str_replace( |
|
228 | - '-', |
|
229 | - '_', |
|
230 | - sanitize_title_with_dashes($collection_name, '', 'save') |
|
231 | - ); |
|
232 | - } |
|
233 | - |
|
234 | - |
|
235 | - /** |
|
236 | - * @access public |
|
237 | - * @return string |
|
238 | - */ |
|
239 | - public function identifierType() |
|
240 | - { |
|
241 | - return $this->identifier_type; |
|
242 | - } |
|
243 | - |
|
244 | - |
|
245 | - /** |
|
246 | - * @access protected |
|
247 | - * @param string $identifier_type |
|
248 | - * @throws InvalidIdentifierException |
|
249 | - */ |
|
250 | - protected function setIdentifierType($identifier_type) |
|
251 | - { |
|
252 | - if ( |
|
253 | - ! ($identifier_type === CollectionDetails::ID_CLASS_NAME |
|
254 | - || $identifier_type === CollectionDetails::ID_OBJECT_HASH |
|
255 | - || $identifier_type === CollectionDetails::ID_CALLBACK_METHOD |
|
256 | - ) |
|
257 | - ) { |
|
258 | - throw new InvalidIdentifierException( |
|
259 | - $identifier_type, |
|
260 | - 'CollectionDetails::ID_CLASS_NAME or CollectionDetails::ID_OBJECT_HASH or CollectionDetails::ID_CALLBACK_METHOD' |
|
261 | - ); |
|
262 | - } |
|
263 | - $this->identifier_type = $identifier_type; |
|
264 | - } |
|
265 | - |
|
266 | - |
|
267 | - /** |
|
268 | - * @access public |
|
269 | - * @return string |
|
270 | - */ |
|
271 | - public function identifierCallback() |
|
272 | - { |
|
273 | - return $this->identifier_callback; |
|
274 | - } |
|
275 | - |
|
276 | - |
|
277 | - /** |
|
278 | - * @access protected |
|
279 | - * @param string $identifier_callback |
|
280 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
281 | - */ |
|
282 | - protected function setIdentifierCallback($identifier_callback = 'identifier') |
|
283 | - { |
|
284 | - if (! is_string($identifier_callback)) { |
|
285 | - throw new InvalidDataTypeException('$identifier_callback', $identifier_callback, 'string'); |
|
286 | - } |
|
287 | - $this->identifier_callback = $identifier_callback; |
|
288 | - } |
|
289 | - |
|
290 | - |
|
291 | - /** |
|
292 | - * @access public |
|
293 | - * @return string |
|
294 | - */ |
|
295 | - public function getFileMask() |
|
296 | - { |
|
297 | - return $this->file_mask; |
|
298 | - } |
|
299 | - |
|
300 | - |
|
301 | - /** |
|
302 | - * sets the file mask which is then used to filter what files get loaded |
|
303 | - * when searching for classes to add to the collection. Defaults to '*.php' when parameter is an empty string |
|
304 | - * |
|
305 | - * @access protected |
|
306 | - * @param string $file_mask |
|
307 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
308 | - */ |
|
309 | - protected function setFileMask($file_mask) |
|
310 | - { |
|
311 | - $this->file_mask = ! empty($file_mask) ? $file_mask : '*.php'; |
|
312 | - // we know our default is a string, so if it's not a string now, |
|
313 | - // then that means the incoming parameter was something else |
|
314 | - if (! is_string($this->file_mask)) { |
|
315 | - throw new InvalidDataTypeException('$file_mask', $this->file_mask, 'string'); |
|
316 | - } |
|
317 | - } |
|
318 | - |
|
319 | - |
|
320 | - /** |
|
321 | - * @access public |
|
322 | - * @return array |
|
323 | - */ |
|
324 | - public function getCollectionFQCNs() |
|
325 | - { |
|
326 | - return $this->collection_FQCNs; |
|
327 | - } |
|
328 | - |
|
329 | - |
|
330 | - /** |
|
331 | - * @access public |
|
332 | - * @param string|array $collection_FQCNs |
|
333 | - * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
334 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
335 | - */ |
|
336 | - public function setCollectionFQCNs($collection_FQCNs) |
|
337 | - { |
|
338 | - foreach ((array) $collection_FQCNs as $collection_FQCN) { |
|
339 | - if (! empty($collection_FQCN)) { |
|
340 | - if (class_exists($collection_FQCN)) { |
|
341 | - $this->collection_FQCNs[] = $collection_FQCN; |
|
342 | - } else { |
|
343 | - foreach ($this->getFQCNsFromPartialNamespace($collection_FQCN) as $FQCN) { |
|
344 | - $this->collection_FQCNs[] = $FQCN; |
|
345 | - } |
|
346 | - } |
|
347 | - } |
|
348 | - } |
|
349 | - } |
|
350 | - |
|
351 | - |
|
352 | - /** |
|
353 | - * @access protected |
|
354 | - * @param string $partial_FQCN |
|
355 | - * @return array |
|
356 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
357 | - * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
358 | - */ |
|
359 | - protected function getFQCNsFromPartialNamespace($partial_FQCN) |
|
360 | - { |
|
361 | - if (! $this->file_locator instanceof FqcnLocator) { |
|
362 | - $this->file_locator = new FqcnLocator(); |
|
363 | - } |
|
364 | - $this->file_locator->locate($partial_FQCN); |
|
365 | - return $this->file_locator->getFQCNs(); |
|
366 | - } |
|
367 | - |
|
368 | - |
|
369 | - /** |
|
370 | - * @access public |
|
371 | - * @return array |
|
372 | - */ |
|
373 | - public function getCollectionPaths() |
|
374 | - { |
|
375 | - return $this->collection_paths; |
|
376 | - } |
|
377 | - |
|
378 | - |
|
379 | - /** |
|
380 | - * @access public |
|
381 | - * @param string|array $collection_paths |
|
382 | - * @throws \EventEspresso\core\exceptions\InvalidFilePathException |
|
383 | - */ |
|
384 | - public function setCollectionPaths($collection_paths) |
|
385 | - { |
|
386 | - foreach ((array) $collection_paths as $collection_path) { |
|
387 | - if (! empty($collection_path)) { |
|
388 | - if (! is_readable($collection_path)) { |
|
389 | - throw new InvalidFilePathException($collection_path); |
|
390 | - } |
|
391 | - $this->collection_paths[] = $collection_path; |
|
392 | - } |
|
393 | - } |
|
394 | - } |
|
45 | + /** |
|
46 | + * if $identifier_type is set to this, |
|
47 | + * then the collection will use each object's spl_object_hash() as it's identifier |
|
48 | + */ |
|
49 | + const ID_OBJECT_HASH = 'identifier-uses-spl-object-hash'; |
|
50 | + |
|
51 | + /** |
|
52 | + * if $identifier_type is set to this, |
|
53 | + * then the collection will use each object's class name as it's identifier |
|
54 | + */ |
|
55 | + const ID_CLASS_NAME = 'identifier-uses-object-class-name'; |
|
56 | + |
|
57 | + /** |
|
58 | + * if $identifier_type is set to this, |
|
59 | + * then the collection will use the return value from a specified callback method on each object |
|
60 | + */ |
|
61 | + const ID_CALLBACK_METHOD = 'identifier-uses-callback-method'; |
|
62 | + |
|
63 | + /** |
|
64 | + * The interface used for controlling what gets added to the collection |
|
65 | + * |
|
66 | + * @var string $collection_interface |
|
67 | + */ |
|
68 | + protected $collection_interface = ''; |
|
69 | + |
|
70 | + /** |
|
71 | + * a unique name used to identify the collection in filter names |
|
72 | + * supplied value is run through sanitize_title_with_dashes(), |
|
73 | + * but then also converts dashes to underscores |
|
74 | + * |
|
75 | + * @var string $collection_name |
|
76 | + */ |
|
77 | + protected $collection_name = ''; |
|
78 | + |
|
79 | + /** |
|
80 | + * what the collection uses for the object identifier. |
|
81 | + * corresponds to one of the class constants above. |
|
82 | + * CollectionDetails::ID_OBJECT_HASH will use spl_object_hash( object ) for the identifier |
|
83 | + * CollectionDetails::ID_CLASS_NAME will use get_class( object ) for the identifier |
|
84 | + * CollectionDetails::ID_CALLBACK_METHOD will use a callback for the identifier |
|
85 | + * defaults to using spl_object_hash() so that multiple objects of the same class can be added |
|
86 | + * |
|
87 | + * @var string $identifier_type |
|
88 | + */ |
|
89 | + protected $identifier_type = CollectionDetails::ID_OBJECT_HASH; |
|
90 | + |
|
91 | + /** |
|
92 | + * the pattern applied to paths when searching for class files to add to the collection |
|
93 | + * ie: "My_Awesome_*.class.php" |
|
94 | + * computed value (setter) defaults to "*.php" |
|
95 | + * |
|
96 | + * @var string $file_mask |
|
97 | + * @see CollectionDetails::setFileMask() for details on how computed value is resolved |
|
98 | + */ |
|
99 | + protected $file_mask = ''; |
|
100 | + |
|
101 | + /** |
|
102 | + * if the $identifier_type above is set to CollectionDetails::ID_CALLBACK_METHOD, |
|
103 | + * then this specifies the method to use on each entity. |
|
104 | + * If the callback method does not exist, then an exception will be thrown |
|
105 | + * |
|
106 | + * @var string $identifier_callback |
|
107 | + */ |
|
108 | + protected $identifier_callback = ''; |
|
109 | + |
|
110 | + /** |
|
111 | + * an array of Fully Qualified Class Names |
|
112 | + * for example: |
|
113 | + * $FQCNs = array( |
|
114 | + * '/Fully/Qualified/ClassNameA' |
|
115 | + * '/Fully/Qualified/Other/ClassNameB' |
|
116 | + * ); |
|
117 | + * |
|
118 | + * @var array $collection_FQCNs |
|
119 | + */ |
|
120 | + protected $collection_FQCNs = array(); |
|
121 | + |
|
122 | + /** |
|
123 | + * an array of full server paths to folders containing files to be loaded into collection |
|
124 | + * for example: |
|
125 | + * $paths = array( |
|
126 | + * '/full/server/path/to/ClassNameA.ext.php' // for class ClassNameA |
|
127 | + * '/full/server/path/to/other/ClassNameB.php' // for class ClassNameB |
|
128 | + * ); |
|
129 | + * |
|
130 | + * @var array $collection_paths |
|
131 | + */ |
|
132 | + protected $collection_paths = array(); |
|
133 | + |
|
134 | + /** |
|
135 | + * @var LocatorInterface $file_locator |
|
136 | + */ |
|
137 | + protected $file_locator; |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * CollectionDetails constructor. |
|
142 | + * |
|
143 | + * @access public |
|
144 | + * @param string $collection_name |
|
145 | + * @param string $collection_interface |
|
146 | + * @param array $collection_FQCNs |
|
147 | + * @param array $collection_paths |
|
148 | + * @param string $file_mask |
|
149 | + * @param string $identifier_type |
|
150 | + * @param string $identifier_callback |
|
151 | + * @param LocatorInterface $file_locator |
|
152 | + * @throws CollectionDetailsException |
|
153 | + */ |
|
154 | + public function __construct( |
|
155 | + $collection_name, |
|
156 | + $collection_interface, |
|
157 | + array $collection_FQCNs = array(), |
|
158 | + array $collection_paths = array(), |
|
159 | + $file_mask = '', |
|
160 | + $identifier_type = CollectionDetails::ID_OBJECT_HASH, |
|
161 | + $identifier_callback = '', |
|
162 | + LocatorInterface $file_locator = null |
|
163 | + ) { |
|
164 | + try { |
|
165 | + $this->setCollectionName($collection_name); |
|
166 | + $this->setCollectionInterface($collection_interface); |
|
167 | + $this->setCollectionFQCNs($collection_FQCNs); |
|
168 | + $this->setCollectionPaths($collection_paths); |
|
169 | + $this->setFileMask($file_mask); |
|
170 | + $this->setIdentifierType($identifier_type); |
|
171 | + $this->setIdentifierCallback($identifier_callback); |
|
172 | + $this->file_locator = $file_locator; |
|
173 | + } catch (Exception $exception) { |
|
174 | + throw new CollectionDetailsException($exception); |
|
175 | + } |
|
176 | + } |
|
177 | + |
|
178 | + |
|
179 | + /** |
|
180 | + * @access public |
|
181 | + * @return mixed |
|
182 | + */ |
|
183 | + public function getCollectionInterface() |
|
184 | + { |
|
185 | + return $this->collection_interface; |
|
186 | + } |
|
187 | + |
|
188 | + |
|
189 | + /** |
|
190 | + * @access protected |
|
191 | + * @param string $collection_interface |
|
192 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
193 | + */ |
|
194 | + protected function setCollectionInterface($collection_interface) |
|
195 | + { |
|
196 | + if (! (interface_exists($collection_interface) || class_exists($collection_interface))) { |
|
197 | + throw new InvalidInterfaceException($collection_interface); |
|
198 | + } |
|
199 | + $this->collection_interface = $collection_interface; |
|
200 | + } |
|
201 | + |
|
202 | + |
|
203 | + /** |
|
204 | + * the collection name will be used for creating dynamic filters |
|
205 | + * |
|
206 | + * @access public |
|
207 | + * @return string |
|
208 | + */ |
|
209 | + public function collectionName() |
|
210 | + { |
|
211 | + return $this->collection_name; |
|
212 | + } |
|
213 | + |
|
214 | + |
|
215 | + /** |
|
216 | + * sanitizes collection name and converts spaces and dashes to underscores |
|
217 | + * |
|
218 | + * @access protected |
|
219 | + * @param string $collection_name |
|
220 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
221 | + */ |
|
222 | + protected function setCollectionName($collection_name) |
|
223 | + { |
|
224 | + if (! is_string($collection_name)) { |
|
225 | + throw new InvalidDataTypeException('$collection_name', $collection_name, 'string'); |
|
226 | + } |
|
227 | + $this->collection_name = str_replace( |
|
228 | + '-', |
|
229 | + '_', |
|
230 | + sanitize_title_with_dashes($collection_name, '', 'save') |
|
231 | + ); |
|
232 | + } |
|
233 | + |
|
234 | + |
|
235 | + /** |
|
236 | + * @access public |
|
237 | + * @return string |
|
238 | + */ |
|
239 | + public function identifierType() |
|
240 | + { |
|
241 | + return $this->identifier_type; |
|
242 | + } |
|
243 | + |
|
244 | + |
|
245 | + /** |
|
246 | + * @access protected |
|
247 | + * @param string $identifier_type |
|
248 | + * @throws InvalidIdentifierException |
|
249 | + */ |
|
250 | + protected function setIdentifierType($identifier_type) |
|
251 | + { |
|
252 | + if ( |
|
253 | + ! ($identifier_type === CollectionDetails::ID_CLASS_NAME |
|
254 | + || $identifier_type === CollectionDetails::ID_OBJECT_HASH |
|
255 | + || $identifier_type === CollectionDetails::ID_CALLBACK_METHOD |
|
256 | + ) |
|
257 | + ) { |
|
258 | + throw new InvalidIdentifierException( |
|
259 | + $identifier_type, |
|
260 | + 'CollectionDetails::ID_CLASS_NAME or CollectionDetails::ID_OBJECT_HASH or CollectionDetails::ID_CALLBACK_METHOD' |
|
261 | + ); |
|
262 | + } |
|
263 | + $this->identifier_type = $identifier_type; |
|
264 | + } |
|
265 | + |
|
266 | + |
|
267 | + /** |
|
268 | + * @access public |
|
269 | + * @return string |
|
270 | + */ |
|
271 | + public function identifierCallback() |
|
272 | + { |
|
273 | + return $this->identifier_callback; |
|
274 | + } |
|
275 | + |
|
276 | + |
|
277 | + /** |
|
278 | + * @access protected |
|
279 | + * @param string $identifier_callback |
|
280 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
281 | + */ |
|
282 | + protected function setIdentifierCallback($identifier_callback = 'identifier') |
|
283 | + { |
|
284 | + if (! is_string($identifier_callback)) { |
|
285 | + throw new InvalidDataTypeException('$identifier_callback', $identifier_callback, 'string'); |
|
286 | + } |
|
287 | + $this->identifier_callback = $identifier_callback; |
|
288 | + } |
|
289 | + |
|
290 | + |
|
291 | + /** |
|
292 | + * @access public |
|
293 | + * @return string |
|
294 | + */ |
|
295 | + public function getFileMask() |
|
296 | + { |
|
297 | + return $this->file_mask; |
|
298 | + } |
|
299 | + |
|
300 | + |
|
301 | + /** |
|
302 | + * sets the file mask which is then used to filter what files get loaded |
|
303 | + * when searching for classes to add to the collection. Defaults to '*.php' when parameter is an empty string |
|
304 | + * |
|
305 | + * @access protected |
|
306 | + * @param string $file_mask |
|
307 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
308 | + */ |
|
309 | + protected function setFileMask($file_mask) |
|
310 | + { |
|
311 | + $this->file_mask = ! empty($file_mask) ? $file_mask : '*.php'; |
|
312 | + // we know our default is a string, so if it's not a string now, |
|
313 | + // then that means the incoming parameter was something else |
|
314 | + if (! is_string($this->file_mask)) { |
|
315 | + throw new InvalidDataTypeException('$file_mask', $this->file_mask, 'string'); |
|
316 | + } |
|
317 | + } |
|
318 | + |
|
319 | + |
|
320 | + /** |
|
321 | + * @access public |
|
322 | + * @return array |
|
323 | + */ |
|
324 | + public function getCollectionFQCNs() |
|
325 | + { |
|
326 | + return $this->collection_FQCNs; |
|
327 | + } |
|
328 | + |
|
329 | + |
|
330 | + /** |
|
331 | + * @access public |
|
332 | + * @param string|array $collection_FQCNs |
|
333 | + * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
334 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
335 | + */ |
|
336 | + public function setCollectionFQCNs($collection_FQCNs) |
|
337 | + { |
|
338 | + foreach ((array) $collection_FQCNs as $collection_FQCN) { |
|
339 | + if (! empty($collection_FQCN)) { |
|
340 | + if (class_exists($collection_FQCN)) { |
|
341 | + $this->collection_FQCNs[] = $collection_FQCN; |
|
342 | + } else { |
|
343 | + foreach ($this->getFQCNsFromPartialNamespace($collection_FQCN) as $FQCN) { |
|
344 | + $this->collection_FQCNs[] = $FQCN; |
|
345 | + } |
|
346 | + } |
|
347 | + } |
|
348 | + } |
|
349 | + } |
|
350 | + |
|
351 | + |
|
352 | + /** |
|
353 | + * @access protected |
|
354 | + * @param string $partial_FQCN |
|
355 | + * @return array |
|
356 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
357 | + * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
358 | + */ |
|
359 | + protected function getFQCNsFromPartialNamespace($partial_FQCN) |
|
360 | + { |
|
361 | + if (! $this->file_locator instanceof FqcnLocator) { |
|
362 | + $this->file_locator = new FqcnLocator(); |
|
363 | + } |
|
364 | + $this->file_locator->locate($partial_FQCN); |
|
365 | + return $this->file_locator->getFQCNs(); |
|
366 | + } |
|
367 | + |
|
368 | + |
|
369 | + /** |
|
370 | + * @access public |
|
371 | + * @return array |
|
372 | + */ |
|
373 | + public function getCollectionPaths() |
|
374 | + { |
|
375 | + return $this->collection_paths; |
|
376 | + } |
|
377 | + |
|
378 | + |
|
379 | + /** |
|
380 | + * @access public |
|
381 | + * @param string|array $collection_paths |
|
382 | + * @throws \EventEspresso\core\exceptions\InvalidFilePathException |
|
383 | + */ |
|
384 | + public function setCollectionPaths($collection_paths) |
|
385 | + { |
|
386 | + foreach ((array) $collection_paths as $collection_path) { |
|
387 | + if (! empty($collection_path)) { |
|
388 | + if (! is_readable($collection_path)) { |
|
389 | + throw new InvalidFilePathException($collection_path); |
|
390 | + } |
|
391 | + $this->collection_paths[] = $collection_path; |
|
392 | + } |
|
393 | + } |
|
394 | + } |
|
395 | 395 | } |
@@ -12,302 +12,302 @@ |
||
12 | 12 | */ |
13 | 13 | class AllowedTags |
14 | 14 | { |
15 | - private static array $attributes = [ |
|
16 | - 'accept-charset' => true, |
|
17 | - 'action' => true, |
|
18 | - 'align' => true, |
|
19 | - 'align-items' => true, |
|
20 | - 'allow' => true, |
|
21 | - 'allowfullscreen' => true, |
|
22 | - 'alt' => true, |
|
23 | - 'aria-controls' => true, |
|
24 | - 'aria-current' => true, |
|
25 | - 'aria-describedby' => true, |
|
26 | - 'aria-details' => true, |
|
27 | - 'aria-expanded' => true, |
|
28 | - 'aria-hidden' => true, |
|
29 | - 'aria-label' => true, |
|
30 | - 'aria-labelledby' => true, |
|
31 | - 'aria-live' => true, |
|
32 | - 'autocomplete' => true, |
|
33 | - 'bgcolor' => true, |
|
34 | - 'border' => true, |
|
35 | - 'cellpadding' => true, |
|
36 | - 'cellspacing' => true, |
|
37 | - 'checked' => true, |
|
38 | - 'class' => true, |
|
39 | - 'cols' => true, |
|
40 | - 'content' => true, |
|
41 | - 'data-*' => true, |
|
42 | - 'dir' => true, |
|
43 | - 'disabled' => true, |
|
44 | - 'display' => true, |
|
45 | - 'enctype' => true, |
|
46 | - 'extension' => true, |
|
47 | - 'for' => true, |
|
48 | - 'frameborder' => true, |
|
49 | - 'height' => true, |
|
50 | - 'href' => true, |
|
51 | - 'http-equiv' => true, |
|
52 | - 'id' => true, |
|
53 | - 'itemprop' => true, |
|
54 | - 'itemscope' => true, |
|
55 | - 'itemtype' => true, |
|
56 | - 'label' => true, |
|
57 | - 'lang' => true, |
|
58 | - 'leftmargin' => true, |
|
59 | - 'marginheight' => true, |
|
60 | - 'marginwidth' => true, |
|
61 | - 'max' => true, |
|
62 | - 'maxlength' => true, |
|
63 | - 'media' => true, |
|
64 | - 'method' => true, |
|
65 | - 'min' => true, |
|
66 | - 'multiple' => true, |
|
67 | - 'name' => true, |
|
68 | - 'novalidate' => true, |
|
69 | - 'onclick' => true, |
|
70 | - 'opacity' => true, |
|
71 | - 'placeholder' => true, |
|
72 | - 'property' => true, |
|
73 | - 'readonly' => true, |
|
74 | - 'rel' => true, |
|
75 | - 'required' => true, |
|
76 | - 'rows' => true, |
|
77 | - 'selected' => true, |
|
78 | - 'size' => true, |
|
79 | - 'src' => true, |
|
80 | - 'step' => true, |
|
81 | - 'style' => true, |
|
82 | - 'tabindex' => true, |
|
83 | - 'target' => true, |
|
84 | - 'title' => true, |
|
85 | - 'topmargin' => true, |
|
86 | - 'type' => true, |
|
87 | - 'value' => true, |
|
88 | - 'width' => true, |
|
89 | - 'z-index' => true, |
|
90 | - ]; |
|
15 | + private static array $attributes = [ |
|
16 | + 'accept-charset' => true, |
|
17 | + 'action' => true, |
|
18 | + 'align' => true, |
|
19 | + 'align-items' => true, |
|
20 | + 'allow' => true, |
|
21 | + 'allowfullscreen' => true, |
|
22 | + 'alt' => true, |
|
23 | + 'aria-controls' => true, |
|
24 | + 'aria-current' => true, |
|
25 | + 'aria-describedby' => true, |
|
26 | + 'aria-details' => true, |
|
27 | + 'aria-expanded' => true, |
|
28 | + 'aria-hidden' => true, |
|
29 | + 'aria-label' => true, |
|
30 | + 'aria-labelledby' => true, |
|
31 | + 'aria-live' => true, |
|
32 | + 'autocomplete' => true, |
|
33 | + 'bgcolor' => true, |
|
34 | + 'border' => true, |
|
35 | + 'cellpadding' => true, |
|
36 | + 'cellspacing' => true, |
|
37 | + 'checked' => true, |
|
38 | + 'class' => true, |
|
39 | + 'cols' => true, |
|
40 | + 'content' => true, |
|
41 | + 'data-*' => true, |
|
42 | + 'dir' => true, |
|
43 | + 'disabled' => true, |
|
44 | + 'display' => true, |
|
45 | + 'enctype' => true, |
|
46 | + 'extension' => true, |
|
47 | + 'for' => true, |
|
48 | + 'frameborder' => true, |
|
49 | + 'height' => true, |
|
50 | + 'href' => true, |
|
51 | + 'http-equiv' => true, |
|
52 | + 'id' => true, |
|
53 | + 'itemprop' => true, |
|
54 | + 'itemscope' => true, |
|
55 | + 'itemtype' => true, |
|
56 | + 'label' => true, |
|
57 | + 'lang' => true, |
|
58 | + 'leftmargin' => true, |
|
59 | + 'marginheight' => true, |
|
60 | + 'marginwidth' => true, |
|
61 | + 'max' => true, |
|
62 | + 'maxlength' => true, |
|
63 | + 'media' => true, |
|
64 | + 'method' => true, |
|
65 | + 'min' => true, |
|
66 | + 'multiple' => true, |
|
67 | + 'name' => true, |
|
68 | + 'novalidate' => true, |
|
69 | + 'onclick' => true, |
|
70 | + 'opacity' => true, |
|
71 | + 'placeholder' => true, |
|
72 | + 'property' => true, |
|
73 | + 'readonly' => true, |
|
74 | + 'rel' => true, |
|
75 | + 'required' => true, |
|
76 | + 'rows' => true, |
|
77 | + 'selected' => true, |
|
78 | + 'size' => true, |
|
79 | + 'src' => true, |
|
80 | + 'step' => true, |
|
81 | + 'style' => true, |
|
82 | + 'tabindex' => true, |
|
83 | + 'target' => true, |
|
84 | + 'title' => true, |
|
85 | + 'topmargin' => true, |
|
86 | + 'type' => true, |
|
87 | + 'value' => true, |
|
88 | + 'width' => true, |
|
89 | + 'z-index' => true, |
|
90 | + ]; |
|
91 | 91 | |
92 | - private static array $tags = [ |
|
93 | - 'a', |
|
94 | - 'abbr', |
|
95 | - 'b', |
|
96 | - 'br', |
|
97 | - 'code', |
|
98 | - 'div', |
|
99 | - 'em', |
|
100 | - 'h1', |
|
101 | - 'h2', |
|
102 | - 'h3', |
|
103 | - 'h4', |
|
104 | - 'h5', |
|
105 | - 'h6', |
|
106 | - 'hr', |
|
107 | - 'i', |
|
108 | - 'img', |
|
109 | - 'li', |
|
110 | - 'ol', |
|
111 | - 'p', |
|
112 | - 'pre', |
|
113 | - 'small', |
|
114 | - 'span', |
|
115 | - 'strong', |
|
116 | - 'table', |
|
117 | - 'td', |
|
118 | - 'tr', |
|
119 | - 'ul', |
|
120 | - ]; |
|
92 | + private static array $tags = [ |
|
93 | + 'a', |
|
94 | + 'abbr', |
|
95 | + 'b', |
|
96 | + 'br', |
|
97 | + 'code', |
|
98 | + 'div', |
|
99 | + 'em', |
|
100 | + 'h1', |
|
101 | + 'h2', |
|
102 | + 'h3', |
|
103 | + 'h4', |
|
104 | + 'h5', |
|
105 | + 'h6', |
|
106 | + 'hr', |
|
107 | + 'i', |
|
108 | + 'img', |
|
109 | + 'li', |
|
110 | + 'ol', |
|
111 | + 'p', |
|
112 | + 'pre', |
|
113 | + 'small', |
|
114 | + 'span', |
|
115 | + 'strong', |
|
116 | + 'table', |
|
117 | + 'td', |
|
118 | + 'tr', |
|
119 | + 'ul', |
|
120 | + ]; |
|
121 | 121 | |
122 | - private static array $allowed_tags = []; |
|
122 | + private static array $allowed_tags = []; |
|
123 | 123 | |
124 | - private static array $allowed_with_embed_tags = []; |
|
124 | + private static array $allowed_with_embed_tags = []; |
|
125 | 125 | |
126 | - private static array $allowed_with_form_tags = []; |
|
126 | + private static array $allowed_with_form_tags = []; |
|
127 | 127 | |
128 | - private static array $allowed_with_script_and_style_tags = []; |
|
128 | + private static array $allowed_with_script_and_style_tags = []; |
|
129 | 129 | |
130 | - private static array $allowed_with_full_tags = []; |
|
130 | + private static array $allowed_with_full_tags = []; |
|
131 | 131 | |
132 | 132 | |
133 | - /** |
|
134 | - * merges additional tags and attributes into the WP post tags |
|
135 | - */ |
|
136 | - private static function initializeAllowedTags() |
|
137 | - { |
|
138 | - $allowed_post_tags = wp_kses_allowed_html('post'); |
|
139 | - $allowed_tags = []; |
|
140 | - foreach (AllowedTags::$tags as $tag) { |
|
141 | - $allowed_tags[ $tag ] = AllowedTags::$attributes; |
|
142 | - } |
|
143 | - AllowedTags::$allowed_tags = array_merge_recursive($allowed_post_tags, $allowed_tags); |
|
144 | - } |
|
133 | + /** |
|
134 | + * merges additional tags and attributes into the WP post tags |
|
135 | + */ |
|
136 | + private static function initializeAllowedTags() |
|
137 | + { |
|
138 | + $allowed_post_tags = wp_kses_allowed_html('post'); |
|
139 | + $allowed_tags = []; |
|
140 | + foreach (AllowedTags::$tags as $tag) { |
|
141 | + $allowed_tags[ $tag ] = AllowedTags::$attributes; |
|
142 | + } |
|
143 | + AllowedTags::$allowed_tags = array_merge_recursive($allowed_post_tags, $allowed_tags); |
|
144 | + } |
|
145 | 145 | |
146 | 146 | |
147 | - /** |
|
148 | - * merges embed tags and attributes into the EE all tags |
|
149 | - */ |
|
150 | - private static function initializeWithEmbedTags() |
|
151 | - { |
|
152 | - $all_tags = AllowedTags::getAllowedTags(); |
|
153 | - $embed_tags = [ |
|
154 | - 'iframe' => AllowedTags::$attributes, |
|
155 | - ]; |
|
156 | - AllowedTags::$allowed_with_embed_tags = array_merge_recursive($all_tags, $embed_tags); |
|
157 | - } |
|
147 | + /** |
|
148 | + * merges embed tags and attributes into the EE all tags |
|
149 | + */ |
|
150 | + private static function initializeWithEmbedTags() |
|
151 | + { |
|
152 | + $all_tags = AllowedTags::getAllowedTags(); |
|
153 | + $embed_tags = [ |
|
154 | + 'iframe' => AllowedTags::$attributes, |
|
155 | + ]; |
|
156 | + AllowedTags::$allowed_with_embed_tags = array_merge_recursive($all_tags, $embed_tags); |
|
157 | + } |
|
158 | 158 | |
159 | 159 | |
160 | - /** |
|
161 | - * merges form tags and attributes into the EE all tags |
|
162 | - */ |
|
163 | - private static function initializeWithFormTags() |
|
164 | - { |
|
165 | - $all_tags = AllowedTags::getAllowedTags(); |
|
166 | - $form_tags = [ |
|
167 | - 'button' => AllowedTags::$attributes, |
|
168 | - 'fieldset' => AllowedTags::$attributes, |
|
169 | - 'form' => AllowedTags::$attributes, |
|
170 | - 'input' => AllowedTags::$attributes, |
|
171 | - 'label' => AllowedTags::$attributes, |
|
172 | - 'optgroup' => AllowedTags::$attributes, |
|
173 | - 'option' => AllowedTags::$attributes, |
|
174 | - 'output' => AllowedTags::$attributes, |
|
175 | - 'select' => AllowedTags::$attributes, |
|
176 | - 'textarea' => AllowedTags::$attributes, |
|
177 | - ]; |
|
178 | - AllowedTags::$allowed_with_form_tags = array_merge_recursive($all_tags, $form_tags); |
|
179 | - } |
|
160 | + /** |
|
161 | + * merges form tags and attributes into the EE all tags |
|
162 | + */ |
|
163 | + private static function initializeWithFormTags() |
|
164 | + { |
|
165 | + $all_tags = AllowedTags::getAllowedTags(); |
|
166 | + $form_tags = [ |
|
167 | + 'button' => AllowedTags::$attributes, |
|
168 | + 'fieldset' => AllowedTags::$attributes, |
|
169 | + 'form' => AllowedTags::$attributes, |
|
170 | + 'input' => AllowedTags::$attributes, |
|
171 | + 'label' => AllowedTags::$attributes, |
|
172 | + 'optgroup' => AllowedTags::$attributes, |
|
173 | + 'option' => AllowedTags::$attributes, |
|
174 | + 'output' => AllowedTags::$attributes, |
|
175 | + 'select' => AllowedTags::$attributes, |
|
176 | + 'textarea' => AllowedTags::$attributes, |
|
177 | + ]; |
|
178 | + AllowedTags::$allowed_with_form_tags = array_merge_recursive($all_tags, $form_tags); |
|
179 | + } |
|
180 | 180 | |
181 | 181 | |
182 | - /** |
|
183 | - * merges form script and style tags and attributes into the EE all tags |
|
184 | - */ |
|
185 | - private static function initializeWithScriptAndStyleTags() |
|
186 | - { |
|
187 | - $all_tags = AllowedTags::getAllowedTags(); |
|
188 | - $script_and_style_tags = [ |
|
189 | - 'link' => AllowedTags::$attributes, |
|
190 | - 'noscript' => AllowedTags::$attributes, |
|
191 | - 'script' => AllowedTags::$attributes, |
|
192 | - 'style' => AllowedTags::$attributes, |
|
193 | - ]; |
|
194 | - AllowedTags::$allowed_with_script_and_style_tags = array_merge_recursive($all_tags, $script_and_style_tags); |
|
195 | - } |
|
182 | + /** |
|
183 | + * merges form script and style tags and attributes into the EE all tags |
|
184 | + */ |
|
185 | + private static function initializeWithScriptAndStyleTags() |
|
186 | + { |
|
187 | + $all_tags = AllowedTags::getAllowedTags(); |
|
188 | + $script_and_style_tags = [ |
|
189 | + 'link' => AllowedTags::$attributes, |
|
190 | + 'noscript' => AllowedTags::$attributes, |
|
191 | + 'script' => AllowedTags::$attributes, |
|
192 | + 'style' => AllowedTags::$attributes, |
|
193 | + ]; |
|
194 | + AllowedTags::$allowed_with_script_and_style_tags = array_merge_recursive($all_tags, $script_and_style_tags); |
|
195 | + } |
|
196 | 196 | |
197 | 197 | |
198 | - /** |
|
199 | - * merges all head and body tags and attributes into the EE all tags |
|
200 | - */ |
|
201 | - private static function initializeWithFullTags() |
|
202 | - { |
|
203 | - $all_tags = AllowedTags::getAllowedTags(); |
|
204 | - $full_tags = [ |
|
205 | - 'body' => AllowedTags::$attributes, |
|
206 | - 'button' => AllowedTags::$attributes, |
|
207 | - 'circle' => [ |
|
208 | - 'cx' => true, |
|
209 | - 'cy' => true, |
|
210 | - 'fill' => true, |
|
211 | - 'r' => true, |
|
212 | - ], |
|
213 | - 'defs' => AllowedTags::$attributes, |
|
214 | - 'fieldset' => AllowedTags::$attributes, |
|
215 | - 'form' => AllowedTags::$attributes, |
|
216 | - 'g' => AllowedTags::$attributes, |
|
217 | - 'head' => AllowedTags::$attributes, |
|
218 | - 'html' => AllowedTags::$attributes, |
|
219 | - 'iframe' => AllowedTags::$attributes, |
|
220 | - 'input' => AllowedTags::$attributes, |
|
221 | - 'label' => AllowedTags::$attributes, |
|
222 | - 'link' => AllowedTags::$attributes, |
|
223 | - 'meta' => AllowedTags::$attributes, |
|
224 | - 'noscript' => AllowedTags::$attributes, |
|
225 | - 'optgroup' => AllowedTags::$attributes, |
|
226 | - 'option' => AllowedTags::$attributes, |
|
227 | - 'output' => AllowedTags::$attributes, |
|
228 | - 'path' => [ |
|
229 | - 'class' => true, |
|
230 | - 'd' => true |
|
231 | - ], |
|
232 | - 'script' => AllowedTags::$attributes, |
|
233 | - 'select' => AllowedTags::$attributes, |
|
234 | - 'style' => AllowedTags::$attributes, |
|
235 | - 'svg' => [ |
|
236 | - 'aria-hidden' => true, |
|
237 | - 'class' => true, |
|
238 | - 'display' => true, |
|
239 | - 'fill' => true, |
|
240 | - 'focusable' => true, |
|
241 | - 'height' => true, |
|
242 | - 'stroke' => true, |
|
243 | - 'stroke-width' => true, |
|
244 | - 'viewBox' => true, |
|
245 | - 'width' => true, |
|
246 | - 'xmlns' => true, |
|
247 | - ], |
|
248 | - 'textarea' => AllowedTags::$attributes, |
|
249 | - 'title' => AllowedTags::$attributes, |
|
250 | - ]; |
|
251 | - AllowedTags::$allowed_with_full_tags = array_merge_recursive($all_tags, $full_tags); |
|
252 | - } |
|
198 | + /** |
|
199 | + * merges all head and body tags and attributes into the EE all tags |
|
200 | + */ |
|
201 | + private static function initializeWithFullTags() |
|
202 | + { |
|
203 | + $all_tags = AllowedTags::getAllowedTags(); |
|
204 | + $full_tags = [ |
|
205 | + 'body' => AllowedTags::$attributes, |
|
206 | + 'button' => AllowedTags::$attributes, |
|
207 | + 'circle' => [ |
|
208 | + 'cx' => true, |
|
209 | + 'cy' => true, |
|
210 | + 'fill' => true, |
|
211 | + 'r' => true, |
|
212 | + ], |
|
213 | + 'defs' => AllowedTags::$attributes, |
|
214 | + 'fieldset' => AllowedTags::$attributes, |
|
215 | + 'form' => AllowedTags::$attributes, |
|
216 | + 'g' => AllowedTags::$attributes, |
|
217 | + 'head' => AllowedTags::$attributes, |
|
218 | + 'html' => AllowedTags::$attributes, |
|
219 | + 'iframe' => AllowedTags::$attributes, |
|
220 | + 'input' => AllowedTags::$attributes, |
|
221 | + 'label' => AllowedTags::$attributes, |
|
222 | + 'link' => AllowedTags::$attributes, |
|
223 | + 'meta' => AllowedTags::$attributes, |
|
224 | + 'noscript' => AllowedTags::$attributes, |
|
225 | + 'optgroup' => AllowedTags::$attributes, |
|
226 | + 'option' => AllowedTags::$attributes, |
|
227 | + 'output' => AllowedTags::$attributes, |
|
228 | + 'path' => [ |
|
229 | + 'class' => true, |
|
230 | + 'd' => true |
|
231 | + ], |
|
232 | + 'script' => AllowedTags::$attributes, |
|
233 | + 'select' => AllowedTags::$attributes, |
|
234 | + 'style' => AllowedTags::$attributes, |
|
235 | + 'svg' => [ |
|
236 | + 'aria-hidden' => true, |
|
237 | + 'class' => true, |
|
238 | + 'display' => true, |
|
239 | + 'fill' => true, |
|
240 | + 'focusable' => true, |
|
241 | + 'height' => true, |
|
242 | + 'stroke' => true, |
|
243 | + 'stroke-width' => true, |
|
244 | + 'viewBox' => true, |
|
245 | + 'width' => true, |
|
246 | + 'xmlns' => true, |
|
247 | + ], |
|
248 | + 'textarea' => AllowedTags::$attributes, |
|
249 | + 'title' => AllowedTags::$attributes, |
|
250 | + ]; |
|
251 | + AllowedTags::$allowed_with_full_tags = array_merge_recursive($all_tags, $full_tags); |
|
252 | + } |
|
253 | 253 | |
254 | 254 | |
255 | - /** |
|
256 | - * @return array[] |
|
257 | - */ |
|
258 | - public static function getAllowedTags(): array |
|
259 | - { |
|
260 | - if (empty(AllowedTags::$allowed_tags)) { |
|
261 | - AllowedTags::initializeAllowedTags(); |
|
262 | - } |
|
263 | - return AllowedTags::$allowed_tags; |
|
264 | - } |
|
255 | + /** |
|
256 | + * @return array[] |
|
257 | + */ |
|
258 | + public static function getAllowedTags(): array |
|
259 | + { |
|
260 | + if (empty(AllowedTags::$allowed_tags)) { |
|
261 | + AllowedTags::initializeAllowedTags(); |
|
262 | + } |
|
263 | + return AllowedTags::$allowed_tags; |
|
264 | + } |
|
265 | 265 | |
266 | 266 | |
267 | - /** |
|
268 | - * @return array[] |
|
269 | - */ |
|
270 | - public static function getWithEmbedTags(): array |
|
271 | - { |
|
272 | - if (empty(AllowedTags::$allowed_with_embed_tags)) { |
|
273 | - AllowedTags::initializeWithEmbedTags(); |
|
274 | - } |
|
275 | - return AllowedTags::$allowed_with_embed_tags; |
|
276 | - } |
|
267 | + /** |
|
268 | + * @return array[] |
|
269 | + */ |
|
270 | + public static function getWithEmbedTags(): array |
|
271 | + { |
|
272 | + if (empty(AllowedTags::$allowed_with_embed_tags)) { |
|
273 | + AllowedTags::initializeWithEmbedTags(); |
|
274 | + } |
|
275 | + return AllowedTags::$allowed_with_embed_tags; |
|
276 | + } |
|
277 | 277 | |
278 | 278 | |
279 | - /** |
|
280 | - * @return array[] |
|
281 | - */ |
|
282 | - public static function getWithFormTags(): array |
|
283 | - { |
|
284 | - if (empty(AllowedTags::$allowed_with_form_tags)) { |
|
285 | - AllowedTags::initializeWithFormTags(); |
|
286 | - } |
|
287 | - return AllowedTags::$allowed_with_form_tags; |
|
288 | - } |
|
279 | + /** |
|
280 | + * @return array[] |
|
281 | + */ |
|
282 | + public static function getWithFormTags(): array |
|
283 | + { |
|
284 | + if (empty(AllowedTags::$allowed_with_form_tags)) { |
|
285 | + AllowedTags::initializeWithFormTags(); |
|
286 | + } |
|
287 | + return AllowedTags::$allowed_with_form_tags; |
|
288 | + } |
|
289 | 289 | |
290 | 290 | |
291 | - /** |
|
292 | - * @return array[] |
|
293 | - */ |
|
294 | - public static function getWithScriptAndStyleTags(): array |
|
295 | - { |
|
296 | - if (empty(AllowedTags::$allowed_with_script_and_style_tags)) { |
|
297 | - AllowedTags::initializeWithScriptAndStyleTags(); |
|
298 | - } |
|
299 | - return AllowedTags::$allowed_with_script_and_style_tags; |
|
300 | - } |
|
291 | + /** |
|
292 | + * @return array[] |
|
293 | + */ |
|
294 | + public static function getWithScriptAndStyleTags(): array |
|
295 | + { |
|
296 | + if (empty(AllowedTags::$allowed_with_script_and_style_tags)) { |
|
297 | + AllowedTags::initializeWithScriptAndStyleTags(); |
|
298 | + } |
|
299 | + return AllowedTags::$allowed_with_script_and_style_tags; |
|
300 | + } |
|
301 | 301 | |
302 | 302 | |
303 | - /** |
|
304 | - * @return array[] |
|
305 | - */ |
|
306 | - public static function getWithFullTags(): array |
|
307 | - { |
|
308 | - if (empty(AllowedTags::$allowed_with_full_tags)) { |
|
309 | - AllowedTags::initializeWithFullTags(); |
|
310 | - } |
|
311 | - return AllowedTags::$allowed_with_full_tags; |
|
312 | - } |
|
303 | + /** |
|
304 | + * @return array[] |
|
305 | + */ |
|
306 | + public static function getWithFullTags(): array |
|
307 | + { |
|
308 | + if (empty(AllowedTags::$allowed_with_full_tags)) { |
|
309 | + AllowedTags::initializeWithFullTags(); |
|
310 | + } |
|
311 | + return AllowedTags::$allowed_with_full_tags; |
|
312 | + } |
|
313 | 313 | } |
@@ -17,42 +17,42 @@ |
||
17 | 17 | */ |
18 | 18 | class ServiceChangesManager |
19 | 19 | { |
20 | - private EE_Dependency_Map $dependency_map; |
|
21 | - |
|
22 | - private LoaderInterface $loader; |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * @param EE_Dependency_Map $dependency_map |
|
27 | - * @param LoaderInterface $loader |
|
28 | - */ |
|
29 | - public function __construct(EE_Dependency_Map $dependency_map, LoaderInterface $loader) |
|
30 | - { |
|
31 | - $this->dependency_map = $dependency_map; |
|
32 | - $this->loader = $loader; |
|
33 | - $this->registerDependencies(); |
|
34 | - $this->loadServiceChangeNotifications(); |
|
35 | - } |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * @return void |
|
40 | - */ |
|
41 | - private function registerDependencies() |
|
42 | - { |
|
43 | - $this->dependency_map->registerDependencies( |
|
44 | - 'EventEspresso\core\domain\services\service_changes\PaymentMethodDeprecations2025', |
|
45 | - [ |
|
46 | - 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
47 | - ] |
|
48 | - ); |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - public function loadServiceChangeNotifications() |
|
53 | - { |
|
54 | - /** @var PaymentMethodDeprecations2025 $pm_deps */ |
|
55 | - $pm_deps = $this->loader->getShared(PaymentMethodDeprecations2025::class); |
|
56 | - $pm_deps->setHooks(); |
|
57 | - } |
|
20 | + private EE_Dependency_Map $dependency_map; |
|
21 | + |
|
22 | + private LoaderInterface $loader; |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * @param EE_Dependency_Map $dependency_map |
|
27 | + * @param LoaderInterface $loader |
|
28 | + */ |
|
29 | + public function __construct(EE_Dependency_Map $dependency_map, LoaderInterface $loader) |
|
30 | + { |
|
31 | + $this->dependency_map = $dependency_map; |
|
32 | + $this->loader = $loader; |
|
33 | + $this->registerDependencies(); |
|
34 | + $this->loadServiceChangeNotifications(); |
|
35 | + } |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * @return void |
|
40 | + */ |
|
41 | + private function registerDependencies() |
|
42 | + { |
|
43 | + $this->dependency_map->registerDependencies( |
|
44 | + 'EventEspresso\core\domain\services\service_changes\PaymentMethodDeprecations2025', |
|
45 | + [ |
|
46 | + 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
47 | + ] |
|
48 | + ); |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + public function loadServiceChangeNotifications() |
|
53 | + { |
|
54 | + /** @var PaymentMethodDeprecations2025 $pm_deps */ |
|
55 | + $pm_deps = $this->loader->getShared(PaymentMethodDeprecations2025::class); |
|
56 | + $pm_deps->setHooks(); |
|
57 | + } |
|
58 | 58 | } |
@@ -29,415 +29,415 @@ |
||
29 | 29 | */ |
30 | 30 | class PersistentAdminNoticeManager |
31 | 31 | { |
32 | - const WP_OPTION_KEY = 'ee_pers_admin_notices'; |
|
33 | - |
|
34 | - private CapabilitiesChecker $capabilities_checker; |
|
35 | - |
|
36 | - private RequestInterface $request; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var Collection|PersistentAdminNotice[]|null $notice_collection |
|
40 | - */ |
|
41 | - private ?Collection $notice_collection = null; |
|
42 | - |
|
43 | - /** |
|
44 | - * if AJAX is not enabled, then the return URL will be used for redirecting back to the admin page where the |
|
45 | - * persistent admin notice was displayed, and ultimately dismissed from. |
|
46 | - * |
|
47 | - * @var string $return_url |
|
48 | - */ |
|
49 | - private string $return_url; |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * PersistentAdminNoticeManager constructor |
|
54 | - * |
|
55 | - * @param CapabilitiesChecker $capabilities_checker |
|
56 | - * @param RequestInterface $request |
|
57 | - * @param string $return_url where to redirect to after dismissing notices |
|
58 | - */ |
|
59 | - public function __construct( |
|
60 | - CapabilitiesChecker $capabilities_checker, |
|
61 | - RequestInterface $request, |
|
62 | - string $return_url = '' |
|
63 | - ) { |
|
64 | - $this->capabilities_checker = $capabilities_checker; |
|
65 | - $this->request = $request; |
|
66 | - $this->setReturnUrl($return_url); |
|
67 | - add_action('wp_ajax_dismiss_ee_nag_notice', [$this, 'dismissNotice']); |
|
68 | - add_action('shutdown', [$this, 'registerAndSaveNotices'], 998); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - public function loadAdminNotices() |
|
73 | - { |
|
74 | - // setup up notices at priority 9 because `EE_Admin::display_admin_notices()` runs at priority 10, |
|
75 | - // and we want to retrieve and generate any nag notices at the last possible moment |
|
76 | - add_action('admin_notices', [$this, 'displayNotices'], 9); |
|
77 | - add_action('network_admin_notices', [$this, 'displayNotices'], 9); |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * @param string $return_url |
|
83 | - */ |
|
84 | - public function setReturnUrl(string $return_url) |
|
85 | - { |
|
86 | - $this->return_url = $return_url; |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * @return Collection |
|
92 | - * @throws InvalidEntityException |
|
93 | - * @throws InvalidInterfaceException |
|
94 | - * @throws DomainException |
|
95 | - * @throws DuplicateCollectionIdentifierException |
|
96 | - */ |
|
97 | - protected function getPersistentAdminNoticeCollection(): Collection |
|
98 | - { |
|
99 | - if (! $this->notice_collection instanceof Collection) { |
|
100 | - $this->notice_collection = new Collection( |
|
101 | - 'EventEspresso\core\domain\entities\notifications\PersistentAdminNotice' |
|
102 | - ); |
|
103 | - $this->retrieveStoredNotices(); |
|
104 | - $this->registerNotices(); |
|
105 | - } |
|
106 | - return $this->notice_collection; |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * generates PersistentAdminNotice objects for all non-dismissed notices saved to the db |
|
112 | - * |
|
113 | - * @return void |
|
114 | - * @throws InvalidEntityException |
|
115 | - * @throws DomainException |
|
116 | - * @throws DuplicateCollectionIdentifierException |
|
117 | - */ |
|
118 | - protected function retrieveStoredNotices() |
|
119 | - { |
|
120 | - $persistent_admin_notices = get_option(PersistentAdminNoticeManager::WP_OPTION_KEY, []); |
|
121 | - if (! empty($persistent_admin_notices)) { |
|
122 | - foreach ($persistent_admin_notices as $name => $details) { |
|
123 | - if (is_array($details)) { |
|
124 | - if ( |
|
125 | - ! isset( |
|
126 | - $details['message'], |
|
127 | - $details['capability'], |
|
128 | - $details['cap_context'], |
|
129 | - $details['dismissed'] |
|
130 | - ) |
|
131 | - ) { |
|
132 | - throw new DomainException( |
|
133 | - sprintf( |
|
134 | - esc_html__( |
|
135 | - 'The "%1$s" PersistentAdminNotice could not be retrieved from the database.', |
|
136 | - 'event_espresso' |
|
137 | - ), |
|
138 | - $name |
|
139 | - ) |
|
140 | - ); |
|
141 | - } |
|
142 | - $notice = new PersistentAdminNotice( |
|
143 | - (string) $name, |
|
144 | - (string) $details['message'], |
|
145 | - (bool) ($details['force_update'] ?? false), |
|
146 | - (string) $details['capability'], |
|
147 | - (string) $details['cap_context'], |
|
148 | - (bool) $details['dismissed'], |
|
149 | - (string) ($details['type'] ?? 'info'), |
|
150 | - (string) ($details['extra_css'] ?? '') |
|
151 | - ); |
|
152 | - // new format for nag notices |
|
153 | - $this->notice_collection->add($notice, sanitize_key($name)); |
|
154 | - } else { |
|
155 | - try { |
|
156 | - // old nag notices, that we want to convert to the new format |
|
157 | - $this->notice_collection->add( |
|
158 | - new PersistentAdminNotice( |
|
159 | - (string) $name, |
|
160 | - (string) $details, |
|
161 | - false, |
|
162 | - '', |
|
163 | - '', |
|
164 | - empty($details) |
|
165 | - ), |
|
166 | - sanitize_key($name) |
|
167 | - ); |
|
168 | - } catch (Exception $e) { |
|
169 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
170 | - } |
|
171 | - } |
|
172 | - // each notice will self register when the action hook in registerNotices is triggered |
|
173 | - } |
|
174 | - } |
|
175 | - } |
|
176 | - |
|
177 | - |
|
178 | - /** |
|
179 | - * exposes the Persistent Admin Notice Collection via an action |
|
180 | - * so that PersistentAdminNotice objects can be added and/or removed |
|
181 | - * without compromising the actual collection like a filter would |
|
182 | - */ |
|
183 | - protected function registerNotices() |
|
184 | - { |
|
185 | - do_action( |
|
186 | - 'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices', |
|
187 | - $this->notice_collection |
|
188 | - ); |
|
189 | - } |
|
190 | - |
|
191 | - |
|
192 | - /** |
|
193 | - * @throws DomainException |
|
194 | - * @throws InvalidClassException |
|
195 | - * @throws InvalidInterfaceException |
|
196 | - * @throws InvalidEntityException |
|
197 | - * @throws DuplicateCollectionIdentifierException |
|
198 | - */ |
|
199 | - public function displayNotices() |
|
200 | - { |
|
201 | - $this->notice_collection = $this->getPersistentAdminNoticeCollection(); |
|
202 | - if ($this->notice_collection->hasObjects()) { |
|
203 | - $enqueue_assets = false; |
|
204 | - // and display notices |
|
205 | - foreach ($this->notice_collection as $persistent_admin_notice) { |
|
206 | - /** @var PersistentAdminNotice $persistent_admin_notice */ |
|
207 | - // don't display notices that have already been dismissed |
|
208 | - if ($persistent_admin_notice->getDismissed()) { |
|
209 | - continue; |
|
210 | - } |
|
211 | - try { |
|
212 | - $this->capabilities_checker->processCapCheck( |
|
213 | - $persistent_admin_notice->getCapCheck() |
|
214 | - ); |
|
215 | - } catch (InsufficientPermissionsException $e) { |
|
216 | - // user does not have required cap, so skip to next notice |
|
217 | - // and just eat the exception - nom nom nom nom |
|
218 | - continue; |
|
219 | - } |
|
220 | - if ($persistent_admin_notice->getMessage() === '') { |
|
221 | - continue; |
|
222 | - } |
|
223 | - $this->displayPersistentAdminNotice($persistent_admin_notice); |
|
224 | - $enqueue_assets = true; |
|
225 | - } |
|
226 | - if ($enqueue_assets) { |
|
227 | - $this->enqueueAssets(); |
|
228 | - } |
|
229 | - } |
|
230 | - } |
|
231 | - |
|
232 | - |
|
233 | - /** |
|
234 | - * does what it's named |
|
235 | - * |
|
236 | - * @return void |
|
237 | - */ |
|
238 | - public function enqueueAssets() |
|
239 | - { |
|
240 | - wp_register_script( |
|
241 | - 'espresso_core', |
|
242 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
243 | - ['jquery'], |
|
244 | - EVENT_ESPRESSO_VERSION, |
|
245 | - true |
|
246 | - ); |
|
247 | - wp_register_script( |
|
248 | - 'ee_error_js', |
|
249 | - EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', |
|
250 | - ['espresso_core'], |
|
251 | - EVENT_ESPRESSO_VERSION, |
|
252 | - true |
|
253 | - ); |
|
254 | - wp_localize_script( |
|
255 | - 'ee_error_js', |
|
256 | - 'ee_dismiss', |
|
257 | - [ |
|
258 | - 'return_url' => urlencode($this->return_url), |
|
259 | - 'ajax_url' => WP_AJAX_URL, |
|
260 | - 'unknown_error' => wp_strip_all_tags( |
|
261 | - __( |
|
262 | - 'An unknown error has occurred on the server while attempting to dismiss this notice.', |
|
263 | - 'event_espresso' |
|
264 | - ) |
|
265 | - ), |
|
266 | - ] |
|
267 | - ); |
|
268 | - wp_enqueue_script('ee_error_js'); |
|
269 | - } |
|
270 | - |
|
271 | - |
|
272 | - /** |
|
273 | - * displayPersistentAdminNoticeHtml |
|
274 | - * |
|
275 | - * @param PersistentAdminNotice $persistent_admin_notice |
|
276 | - */ |
|
277 | - protected function displayPersistentAdminNotice(PersistentAdminNotice $persistent_admin_notice) |
|
278 | - { |
|
279 | - // used in template |
|
280 | - $persistent_admin_notice_name = $persistent_admin_notice->getName(); |
|
281 | - $persistent_admin_notice_message = $persistent_admin_notice->getMessage(); |
|
282 | - $persistent_admin_notice_type = $persistent_admin_notice->getType(); |
|
283 | - $persistent_admin_notice_css = $persistent_admin_notice->extraCss(); |
|
284 | - $is_dismissible = $persistent_admin_notice->getForceUpdate() !== true; |
|
285 | - require EE_TEMPLATES . '/notifications/persistent_admin_notice.template.php'; |
|
286 | - } |
|
287 | - |
|
288 | - |
|
289 | - /** |
|
290 | - * dismissNotice |
|
291 | - * |
|
292 | - * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed |
|
293 | - * @param bool $purge if true, then delete it from the db |
|
294 | - * @param bool $return forget all of this AJAX or redirect nonsense, and just return |
|
295 | - * @return void |
|
296 | - * @throws InvalidEntityException |
|
297 | - * @throws InvalidInterfaceException |
|
298 | - * @throws DomainException |
|
299 | - * @throws InvalidArgumentException |
|
300 | - * @throws InvalidArgumentException |
|
301 | - * @throws InvalidArgumentException |
|
302 | - * @throws InvalidArgumentException |
|
303 | - * @throws DuplicateCollectionIdentifierException |
|
304 | - */ |
|
305 | - public function dismissNotice(string $pan_name = '', bool $purge = false, bool $return = false) |
|
306 | - { |
|
307 | - $pan_name = $this->request->getRequestParam('ee_nag_notice', $pan_name); |
|
308 | - $this->notice_collection = $this->getPersistentAdminNoticeCollection(); |
|
309 | - if (! empty($pan_name) && $this->notice_collection->has($pan_name)) { |
|
310 | - /** @var PersistentAdminNotice $persistent_admin_notice */ |
|
311 | - $persistent_admin_notice = $this->notice_collection->get($pan_name); |
|
312 | - try { |
|
313 | - $this->capabilities_checker->processCapCheck( |
|
314 | - $persistent_admin_notice->getCapCheck() |
|
315 | - ); |
|
316 | - } catch (InsufficientPermissionsException $e) { |
|
317 | - // user does not have required cap, so just eat the exception - nom nom nom nom |
|
318 | - return; |
|
319 | - } |
|
320 | - $persistent_admin_notice->setDismissed(true); |
|
321 | - $persistent_admin_notice->setPurge($purge); |
|
322 | - $this->saveNotices(); |
|
323 | - } |
|
324 | - if ($return) { |
|
325 | - return; |
|
326 | - } |
|
327 | - if ($this->request->isAjax()) { |
|
328 | - // grab any notices and concatenate into string |
|
329 | - echo wp_json_encode( |
|
330 | - [ |
|
331 | - 'errors' => implode('<br />', EE_Error::get_notices(false)), |
|
332 | - ] |
|
333 | - ); |
|
334 | - exit(); |
|
335 | - } |
|
336 | - // save errors to a transient to be displayed on next request (after redirect) |
|
337 | - EE_Error::get_notices(false, true); |
|
338 | - wp_safe_redirect( |
|
339 | - urldecode( |
|
340 | - $this->request->getRequestParam('return_url', '') |
|
341 | - ) |
|
342 | - ); |
|
343 | - } |
|
344 | - |
|
345 | - |
|
346 | - /** |
|
347 | - * saveNotices |
|
348 | - * |
|
349 | - * @throws DomainException |
|
350 | - * @throws InvalidInterfaceException |
|
351 | - * @throws InvalidEntityException |
|
352 | - * @throws DuplicateCollectionIdentifierException |
|
353 | - */ |
|
354 | - public function saveNotices() |
|
355 | - { |
|
356 | - $this->notice_collection = $this->getPersistentAdminNoticeCollection(); |
|
357 | - if ($this->notice_collection->hasObjects()) { |
|
358 | - $persistent_admin_notices = get_option(PersistentAdminNoticeManager::WP_OPTION_KEY, []); |
|
359 | - // maybe initialize persistent_admin_notices |
|
360 | - if (empty($persistent_admin_notices)) { |
|
361 | - add_option(PersistentAdminNoticeManager::WP_OPTION_KEY, [], '', 'no'); |
|
362 | - } |
|
363 | - $new_notices_array = []; |
|
364 | - foreach ($this->notice_collection as $persistent_admin_notice) { |
|
365 | - // remove this notice ? |
|
366 | - if ($persistent_admin_notice->getPurge()) { |
|
367 | - continue; |
|
368 | - } |
|
369 | - /** @var PersistentAdminNotice $persistent_admin_notice */ |
|
370 | - $new_notices_array[ $persistent_admin_notice->getName() ] = [ |
|
371 | - 'message' => $persistent_admin_notice->getMessage(), |
|
372 | - 'capability' => $persistent_admin_notice->getCapability(), |
|
373 | - 'cap_context' => $persistent_admin_notice->getCapContext(), |
|
374 | - 'dismissed' => $persistent_admin_notice->getDismissed(), |
|
375 | - 'force_update' => $persistent_admin_notice->getForceUpdate(), |
|
376 | - 'type' => $persistent_admin_notice->getType(), |
|
377 | - 'extra_css' => $persistent_admin_notice->extraCss(), |
|
378 | - ]; |
|
379 | - } |
|
380 | - update_option(PersistentAdminNoticeManager::WP_OPTION_KEY, $new_notices_array); |
|
381 | - } |
|
382 | - } |
|
383 | - |
|
384 | - |
|
385 | - /** |
|
386 | - * @throws DomainException |
|
387 | - * @throws InvalidEntityException |
|
388 | - * @throws InvalidInterfaceException |
|
389 | - * @throws DuplicateCollectionIdentifierException |
|
390 | - */ |
|
391 | - public function registerAndSaveNotices() |
|
392 | - { |
|
393 | - $this->getPersistentAdminNoticeCollection(); |
|
394 | - $this->registerNotices(); |
|
395 | - $this->saveNotices(); |
|
396 | - add_filter( |
|
397 | - 'PersistentAdminNoticeManager__registerAndSaveNotices__complete', |
|
398 | - '__return_true' |
|
399 | - ); |
|
400 | - } |
|
401 | - |
|
402 | - |
|
403 | - /** |
|
404 | - * @throws DomainException |
|
405 | - * @throws InvalidEntityException |
|
406 | - * @throws InvalidInterfaceException |
|
407 | - * @throws InvalidArgumentException |
|
408 | - * @throws DuplicateCollectionIdentifierException |
|
409 | - */ |
|
410 | - public static function loadRegisterAndSaveNotices() |
|
411 | - { |
|
412 | - /** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */ |
|
413 | - $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared( |
|
414 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
415 | - ); |
|
416 | - // if shutdown has already run, then call registerAndSaveNotices() manually |
|
417 | - if (did_action('shutdown')) { |
|
418 | - $persistent_admin_notice_manager->registerAndSaveNotices(); |
|
419 | - } |
|
420 | - } |
|
421 | - |
|
422 | - |
|
423 | - public static function dismissPersistentAdminNotice(string $notice_name) |
|
424 | - { |
|
425 | - /** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */ |
|
426 | - $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(PersistentAdminNoticeManager::class); |
|
427 | - $persistent_admin_notice_manager->dismissNotice(sanitize_key($notice_name), true, true); |
|
428 | - } |
|
429 | - |
|
430 | - |
|
431 | - public static function deletePersistentAdminNotice(string $notice_name) |
|
432 | - { |
|
433 | - /** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */ |
|
434 | - $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(PersistentAdminNoticeManager::class); |
|
435 | - $persistent_admin_notice_manager->getPersistentAdminNoticeCollection(); |
|
436 | - $notice = $persistent_admin_notice_manager->notice_collection->get(sanitize_key($notice_name)); |
|
437 | - if ($notice) { |
|
438 | - $notice->setPurge(true); |
|
439 | - $persistent_admin_notice_manager->notice_collection->remove($notice); |
|
440 | - $persistent_admin_notice_manager->saveNotices(); |
|
441 | - } |
|
442 | - } |
|
32 | + const WP_OPTION_KEY = 'ee_pers_admin_notices'; |
|
33 | + |
|
34 | + private CapabilitiesChecker $capabilities_checker; |
|
35 | + |
|
36 | + private RequestInterface $request; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var Collection|PersistentAdminNotice[]|null $notice_collection |
|
40 | + */ |
|
41 | + private ?Collection $notice_collection = null; |
|
42 | + |
|
43 | + /** |
|
44 | + * if AJAX is not enabled, then the return URL will be used for redirecting back to the admin page where the |
|
45 | + * persistent admin notice was displayed, and ultimately dismissed from. |
|
46 | + * |
|
47 | + * @var string $return_url |
|
48 | + */ |
|
49 | + private string $return_url; |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * PersistentAdminNoticeManager constructor |
|
54 | + * |
|
55 | + * @param CapabilitiesChecker $capabilities_checker |
|
56 | + * @param RequestInterface $request |
|
57 | + * @param string $return_url where to redirect to after dismissing notices |
|
58 | + */ |
|
59 | + public function __construct( |
|
60 | + CapabilitiesChecker $capabilities_checker, |
|
61 | + RequestInterface $request, |
|
62 | + string $return_url = '' |
|
63 | + ) { |
|
64 | + $this->capabilities_checker = $capabilities_checker; |
|
65 | + $this->request = $request; |
|
66 | + $this->setReturnUrl($return_url); |
|
67 | + add_action('wp_ajax_dismiss_ee_nag_notice', [$this, 'dismissNotice']); |
|
68 | + add_action('shutdown', [$this, 'registerAndSaveNotices'], 998); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + public function loadAdminNotices() |
|
73 | + { |
|
74 | + // setup up notices at priority 9 because `EE_Admin::display_admin_notices()` runs at priority 10, |
|
75 | + // and we want to retrieve and generate any nag notices at the last possible moment |
|
76 | + add_action('admin_notices', [$this, 'displayNotices'], 9); |
|
77 | + add_action('network_admin_notices', [$this, 'displayNotices'], 9); |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * @param string $return_url |
|
83 | + */ |
|
84 | + public function setReturnUrl(string $return_url) |
|
85 | + { |
|
86 | + $this->return_url = $return_url; |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * @return Collection |
|
92 | + * @throws InvalidEntityException |
|
93 | + * @throws InvalidInterfaceException |
|
94 | + * @throws DomainException |
|
95 | + * @throws DuplicateCollectionIdentifierException |
|
96 | + */ |
|
97 | + protected function getPersistentAdminNoticeCollection(): Collection |
|
98 | + { |
|
99 | + if (! $this->notice_collection instanceof Collection) { |
|
100 | + $this->notice_collection = new Collection( |
|
101 | + 'EventEspresso\core\domain\entities\notifications\PersistentAdminNotice' |
|
102 | + ); |
|
103 | + $this->retrieveStoredNotices(); |
|
104 | + $this->registerNotices(); |
|
105 | + } |
|
106 | + return $this->notice_collection; |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * generates PersistentAdminNotice objects for all non-dismissed notices saved to the db |
|
112 | + * |
|
113 | + * @return void |
|
114 | + * @throws InvalidEntityException |
|
115 | + * @throws DomainException |
|
116 | + * @throws DuplicateCollectionIdentifierException |
|
117 | + */ |
|
118 | + protected function retrieveStoredNotices() |
|
119 | + { |
|
120 | + $persistent_admin_notices = get_option(PersistentAdminNoticeManager::WP_OPTION_KEY, []); |
|
121 | + if (! empty($persistent_admin_notices)) { |
|
122 | + foreach ($persistent_admin_notices as $name => $details) { |
|
123 | + if (is_array($details)) { |
|
124 | + if ( |
|
125 | + ! isset( |
|
126 | + $details['message'], |
|
127 | + $details['capability'], |
|
128 | + $details['cap_context'], |
|
129 | + $details['dismissed'] |
|
130 | + ) |
|
131 | + ) { |
|
132 | + throw new DomainException( |
|
133 | + sprintf( |
|
134 | + esc_html__( |
|
135 | + 'The "%1$s" PersistentAdminNotice could not be retrieved from the database.', |
|
136 | + 'event_espresso' |
|
137 | + ), |
|
138 | + $name |
|
139 | + ) |
|
140 | + ); |
|
141 | + } |
|
142 | + $notice = new PersistentAdminNotice( |
|
143 | + (string) $name, |
|
144 | + (string) $details['message'], |
|
145 | + (bool) ($details['force_update'] ?? false), |
|
146 | + (string) $details['capability'], |
|
147 | + (string) $details['cap_context'], |
|
148 | + (bool) $details['dismissed'], |
|
149 | + (string) ($details['type'] ?? 'info'), |
|
150 | + (string) ($details['extra_css'] ?? '') |
|
151 | + ); |
|
152 | + // new format for nag notices |
|
153 | + $this->notice_collection->add($notice, sanitize_key($name)); |
|
154 | + } else { |
|
155 | + try { |
|
156 | + // old nag notices, that we want to convert to the new format |
|
157 | + $this->notice_collection->add( |
|
158 | + new PersistentAdminNotice( |
|
159 | + (string) $name, |
|
160 | + (string) $details, |
|
161 | + false, |
|
162 | + '', |
|
163 | + '', |
|
164 | + empty($details) |
|
165 | + ), |
|
166 | + sanitize_key($name) |
|
167 | + ); |
|
168 | + } catch (Exception $e) { |
|
169 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
170 | + } |
|
171 | + } |
|
172 | + // each notice will self register when the action hook in registerNotices is triggered |
|
173 | + } |
|
174 | + } |
|
175 | + } |
|
176 | + |
|
177 | + |
|
178 | + /** |
|
179 | + * exposes the Persistent Admin Notice Collection via an action |
|
180 | + * so that PersistentAdminNotice objects can be added and/or removed |
|
181 | + * without compromising the actual collection like a filter would |
|
182 | + */ |
|
183 | + protected function registerNotices() |
|
184 | + { |
|
185 | + do_action( |
|
186 | + 'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices', |
|
187 | + $this->notice_collection |
|
188 | + ); |
|
189 | + } |
|
190 | + |
|
191 | + |
|
192 | + /** |
|
193 | + * @throws DomainException |
|
194 | + * @throws InvalidClassException |
|
195 | + * @throws InvalidInterfaceException |
|
196 | + * @throws InvalidEntityException |
|
197 | + * @throws DuplicateCollectionIdentifierException |
|
198 | + */ |
|
199 | + public function displayNotices() |
|
200 | + { |
|
201 | + $this->notice_collection = $this->getPersistentAdminNoticeCollection(); |
|
202 | + if ($this->notice_collection->hasObjects()) { |
|
203 | + $enqueue_assets = false; |
|
204 | + // and display notices |
|
205 | + foreach ($this->notice_collection as $persistent_admin_notice) { |
|
206 | + /** @var PersistentAdminNotice $persistent_admin_notice */ |
|
207 | + // don't display notices that have already been dismissed |
|
208 | + if ($persistent_admin_notice->getDismissed()) { |
|
209 | + continue; |
|
210 | + } |
|
211 | + try { |
|
212 | + $this->capabilities_checker->processCapCheck( |
|
213 | + $persistent_admin_notice->getCapCheck() |
|
214 | + ); |
|
215 | + } catch (InsufficientPermissionsException $e) { |
|
216 | + // user does not have required cap, so skip to next notice |
|
217 | + // and just eat the exception - nom nom nom nom |
|
218 | + continue; |
|
219 | + } |
|
220 | + if ($persistent_admin_notice->getMessage() === '') { |
|
221 | + continue; |
|
222 | + } |
|
223 | + $this->displayPersistentAdminNotice($persistent_admin_notice); |
|
224 | + $enqueue_assets = true; |
|
225 | + } |
|
226 | + if ($enqueue_assets) { |
|
227 | + $this->enqueueAssets(); |
|
228 | + } |
|
229 | + } |
|
230 | + } |
|
231 | + |
|
232 | + |
|
233 | + /** |
|
234 | + * does what it's named |
|
235 | + * |
|
236 | + * @return void |
|
237 | + */ |
|
238 | + public function enqueueAssets() |
|
239 | + { |
|
240 | + wp_register_script( |
|
241 | + 'espresso_core', |
|
242 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
243 | + ['jquery'], |
|
244 | + EVENT_ESPRESSO_VERSION, |
|
245 | + true |
|
246 | + ); |
|
247 | + wp_register_script( |
|
248 | + 'ee_error_js', |
|
249 | + EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', |
|
250 | + ['espresso_core'], |
|
251 | + EVENT_ESPRESSO_VERSION, |
|
252 | + true |
|
253 | + ); |
|
254 | + wp_localize_script( |
|
255 | + 'ee_error_js', |
|
256 | + 'ee_dismiss', |
|
257 | + [ |
|
258 | + 'return_url' => urlencode($this->return_url), |
|
259 | + 'ajax_url' => WP_AJAX_URL, |
|
260 | + 'unknown_error' => wp_strip_all_tags( |
|
261 | + __( |
|
262 | + 'An unknown error has occurred on the server while attempting to dismiss this notice.', |
|
263 | + 'event_espresso' |
|
264 | + ) |
|
265 | + ), |
|
266 | + ] |
|
267 | + ); |
|
268 | + wp_enqueue_script('ee_error_js'); |
|
269 | + } |
|
270 | + |
|
271 | + |
|
272 | + /** |
|
273 | + * displayPersistentAdminNoticeHtml |
|
274 | + * |
|
275 | + * @param PersistentAdminNotice $persistent_admin_notice |
|
276 | + */ |
|
277 | + protected function displayPersistentAdminNotice(PersistentAdminNotice $persistent_admin_notice) |
|
278 | + { |
|
279 | + // used in template |
|
280 | + $persistent_admin_notice_name = $persistent_admin_notice->getName(); |
|
281 | + $persistent_admin_notice_message = $persistent_admin_notice->getMessage(); |
|
282 | + $persistent_admin_notice_type = $persistent_admin_notice->getType(); |
|
283 | + $persistent_admin_notice_css = $persistent_admin_notice->extraCss(); |
|
284 | + $is_dismissible = $persistent_admin_notice->getForceUpdate() !== true; |
|
285 | + require EE_TEMPLATES . '/notifications/persistent_admin_notice.template.php'; |
|
286 | + } |
|
287 | + |
|
288 | + |
|
289 | + /** |
|
290 | + * dismissNotice |
|
291 | + * |
|
292 | + * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed |
|
293 | + * @param bool $purge if true, then delete it from the db |
|
294 | + * @param bool $return forget all of this AJAX or redirect nonsense, and just return |
|
295 | + * @return void |
|
296 | + * @throws InvalidEntityException |
|
297 | + * @throws InvalidInterfaceException |
|
298 | + * @throws DomainException |
|
299 | + * @throws InvalidArgumentException |
|
300 | + * @throws InvalidArgumentException |
|
301 | + * @throws InvalidArgumentException |
|
302 | + * @throws InvalidArgumentException |
|
303 | + * @throws DuplicateCollectionIdentifierException |
|
304 | + */ |
|
305 | + public function dismissNotice(string $pan_name = '', bool $purge = false, bool $return = false) |
|
306 | + { |
|
307 | + $pan_name = $this->request->getRequestParam('ee_nag_notice', $pan_name); |
|
308 | + $this->notice_collection = $this->getPersistentAdminNoticeCollection(); |
|
309 | + if (! empty($pan_name) && $this->notice_collection->has($pan_name)) { |
|
310 | + /** @var PersistentAdminNotice $persistent_admin_notice */ |
|
311 | + $persistent_admin_notice = $this->notice_collection->get($pan_name); |
|
312 | + try { |
|
313 | + $this->capabilities_checker->processCapCheck( |
|
314 | + $persistent_admin_notice->getCapCheck() |
|
315 | + ); |
|
316 | + } catch (InsufficientPermissionsException $e) { |
|
317 | + // user does not have required cap, so just eat the exception - nom nom nom nom |
|
318 | + return; |
|
319 | + } |
|
320 | + $persistent_admin_notice->setDismissed(true); |
|
321 | + $persistent_admin_notice->setPurge($purge); |
|
322 | + $this->saveNotices(); |
|
323 | + } |
|
324 | + if ($return) { |
|
325 | + return; |
|
326 | + } |
|
327 | + if ($this->request->isAjax()) { |
|
328 | + // grab any notices and concatenate into string |
|
329 | + echo wp_json_encode( |
|
330 | + [ |
|
331 | + 'errors' => implode('<br />', EE_Error::get_notices(false)), |
|
332 | + ] |
|
333 | + ); |
|
334 | + exit(); |
|
335 | + } |
|
336 | + // save errors to a transient to be displayed on next request (after redirect) |
|
337 | + EE_Error::get_notices(false, true); |
|
338 | + wp_safe_redirect( |
|
339 | + urldecode( |
|
340 | + $this->request->getRequestParam('return_url', '') |
|
341 | + ) |
|
342 | + ); |
|
343 | + } |
|
344 | + |
|
345 | + |
|
346 | + /** |
|
347 | + * saveNotices |
|
348 | + * |
|
349 | + * @throws DomainException |
|
350 | + * @throws InvalidInterfaceException |
|
351 | + * @throws InvalidEntityException |
|
352 | + * @throws DuplicateCollectionIdentifierException |
|
353 | + */ |
|
354 | + public function saveNotices() |
|
355 | + { |
|
356 | + $this->notice_collection = $this->getPersistentAdminNoticeCollection(); |
|
357 | + if ($this->notice_collection->hasObjects()) { |
|
358 | + $persistent_admin_notices = get_option(PersistentAdminNoticeManager::WP_OPTION_KEY, []); |
|
359 | + // maybe initialize persistent_admin_notices |
|
360 | + if (empty($persistent_admin_notices)) { |
|
361 | + add_option(PersistentAdminNoticeManager::WP_OPTION_KEY, [], '', 'no'); |
|
362 | + } |
|
363 | + $new_notices_array = []; |
|
364 | + foreach ($this->notice_collection as $persistent_admin_notice) { |
|
365 | + // remove this notice ? |
|
366 | + if ($persistent_admin_notice->getPurge()) { |
|
367 | + continue; |
|
368 | + } |
|
369 | + /** @var PersistentAdminNotice $persistent_admin_notice */ |
|
370 | + $new_notices_array[ $persistent_admin_notice->getName() ] = [ |
|
371 | + 'message' => $persistent_admin_notice->getMessage(), |
|
372 | + 'capability' => $persistent_admin_notice->getCapability(), |
|
373 | + 'cap_context' => $persistent_admin_notice->getCapContext(), |
|
374 | + 'dismissed' => $persistent_admin_notice->getDismissed(), |
|
375 | + 'force_update' => $persistent_admin_notice->getForceUpdate(), |
|
376 | + 'type' => $persistent_admin_notice->getType(), |
|
377 | + 'extra_css' => $persistent_admin_notice->extraCss(), |
|
378 | + ]; |
|
379 | + } |
|
380 | + update_option(PersistentAdminNoticeManager::WP_OPTION_KEY, $new_notices_array); |
|
381 | + } |
|
382 | + } |
|
383 | + |
|
384 | + |
|
385 | + /** |
|
386 | + * @throws DomainException |
|
387 | + * @throws InvalidEntityException |
|
388 | + * @throws InvalidInterfaceException |
|
389 | + * @throws DuplicateCollectionIdentifierException |
|
390 | + */ |
|
391 | + public function registerAndSaveNotices() |
|
392 | + { |
|
393 | + $this->getPersistentAdminNoticeCollection(); |
|
394 | + $this->registerNotices(); |
|
395 | + $this->saveNotices(); |
|
396 | + add_filter( |
|
397 | + 'PersistentAdminNoticeManager__registerAndSaveNotices__complete', |
|
398 | + '__return_true' |
|
399 | + ); |
|
400 | + } |
|
401 | + |
|
402 | + |
|
403 | + /** |
|
404 | + * @throws DomainException |
|
405 | + * @throws InvalidEntityException |
|
406 | + * @throws InvalidInterfaceException |
|
407 | + * @throws InvalidArgumentException |
|
408 | + * @throws DuplicateCollectionIdentifierException |
|
409 | + */ |
|
410 | + public static function loadRegisterAndSaveNotices() |
|
411 | + { |
|
412 | + /** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */ |
|
413 | + $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared( |
|
414 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
415 | + ); |
|
416 | + // if shutdown has already run, then call registerAndSaveNotices() manually |
|
417 | + if (did_action('shutdown')) { |
|
418 | + $persistent_admin_notice_manager->registerAndSaveNotices(); |
|
419 | + } |
|
420 | + } |
|
421 | + |
|
422 | + |
|
423 | + public static function dismissPersistentAdminNotice(string $notice_name) |
|
424 | + { |
|
425 | + /** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */ |
|
426 | + $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(PersistentAdminNoticeManager::class); |
|
427 | + $persistent_admin_notice_manager->dismissNotice(sanitize_key($notice_name), true, true); |
|
428 | + } |
|
429 | + |
|
430 | + |
|
431 | + public static function deletePersistentAdminNotice(string $notice_name) |
|
432 | + { |
|
433 | + /** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */ |
|
434 | + $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(PersistentAdminNoticeManager::class); |
|
435 | + $persistent_admin_notice_manager->getPersistentAdminNoticeCollection(); |
|
436 | + $notice = $persistent_admin_notice_manager->notice_collection->get(sanitize_key($notice_name)); |
|
437 | + if ($notice) { |
|
438 | + $notice->setPurge(true); |
|
439 | + $persistent_admin_notice_manager->notice_collection->remove($notice); |
|
440 | + $persistent_admin_notice_manager->saveNotices(); |
|
441 | + } |
|
442 | + } |
|
443 | 443 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | protected function getPersistentAdminNoticeCollection(): Collection |
98 | 98 | { |
99 | - if (! $this->notice_collection instanceof Collection) { |
|
99 | + if ( ! $this->notice_collection instanceof Collection) { |
|
100 | 100 | $this->notice_collection = new Collection( |
101 | 101 | 'EventEspresso\core\domain\entities\notifications\PersistentAdminNotice' |
102 | 102 | ); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | protected function retrieveStoredNotices() |
119 | 119 | { |
120 | 120 | $persistent_admin_notices = get_option(PersistentAdminNoticeManager::WP_OPTION_KEY, []); |
121 | - if (! empty($persistent_admin_notices)) { |
|
121 | + if ( ! empty($persistent_admin_notices)) { |
|
122 | 122 | foreach ($persistent_admin_notices as $name => $details) { |
123 | 123 | if (is_array($details)) { |
124 | 124 | if ( |
@@ -239,14 +239,14 @@ discard block |
||
239 | 239 | { |
240 | 240 | wp_register_script( |
241 | 241 | 'espresso_core', |
242 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
242 | + EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', |
|
243 | 243 | ['jquery'], |
244 | 244 | EVENT_ESPRESSO_VERSION, |
245 | 245 | true |
246 | 246 | ); |
247 | 247 | wp_register_script( |
248 | 248 | 'ee_error_js', |
249 | - EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', |
|
249 | + EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js', |
|
250 | 250 | ['espresso_core'], |
251 | 251 | EVENT_ESPRESSO_VERSION, |
252 | 252 | true |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | $persistent_admin_notice_type = $persistent_admin_notice->getType(); |
283 | 283 | $persistent_admin_notice_css = $persistent_admin_notice->extraCss(); |
284 | 284 | $is_dismissible = $persistent_admin_notice->getForceUpdate() !== true; |
285 | - require EE_TEMPLATES . '/notifications/persistent_admin_notice.template.php'; |
|
285 | + require EE_TEMPLATES.'/notifications/persistent_admin_notice.template.php'; |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | { |
307 | 307 | $pan_name = $this->request->getRequestParam('ee_nag_notice', $pan_name); |
308 | 308 | $this->notice_collection = $this->getPersistentAdminNoticeCollection(); |
309 | - if (! empty($pan_name) && $this->notice_collection->has($pan_name)) { |
|
309 | + if ( ! empty($pan_name) && $this->notice_collection->has($pan_name)) { |
|
310 | 310 | /** @var PersistentAdminNotice $persistent_admin_notice */ |
311 | 311 | $persistent_admin_notice = $this->notice_collection->get($pan_name); |
312 | 312 | try { |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | continue; |
368 | 368 | } |
369 | 369 | /** @var PersistentAdminNotice $persistent_admin_notice */ |
370 | - $new_notices_array[ $persistent_admin_notice->getName() ] = [ |
|
370 | + $new_notices_array[$persistent_admin_notice->getName()] = [ |
|
371 | 371 | 'message' => $persistent_admin_notice->getMessage(), |
372 | 372 | 'capability' => $persistent_admin_notice->getCapability(), |
373 | 373 | 'cap_context' => $persistent_admin_notice->getCapContext(), |
@@ -12,671 +12,671 @@ |
||
12 | 12 | */ |
13 | 13 | class EE_Question extends EE_Soft_Delete_Base_Class implements EEI_Duplicatable |
14 | 14 | { |
15 | - /** |
|
16 | - * @param array $props_n_values incoming values |
|
17 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
18 | - * used.) |
|
19 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
20 | - * date_format and the second value is the time format |
|
21 | - * @return EE_Question |
|
22 | - */ |
|
23 | - public static function new_instance($props_n_values = [], $timezone = '', $date_formats = []) |
|
24 | - { |
|
25 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
26 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
27 | - } |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * @param array $props_n_values incoming values from the database |
|
32 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
33 | - * the website will be used. |
|
34 | - * @return EE_Question |
|
35 | - */ |
|
36 | - public static function new_instance_from_db($props_n_values = [], $timezone = '') |
|
37 | - { |
|
38 | - return new self($props_n_values, true, $timezone); |
|
39 | - } |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * Set Question display text |
|
44 | - * |
|
45 | - * @access public |
|
46 | - * @param string $QST_display_text |
|
47 | - */ |
|
48 | - public function set_display_text($QST_display_text = '') |
|
49 | - { |
|
50 | - $this->set('QST_display_text', $QST_display_text); |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * Set Question admin text |
|
56 | - * |
|
57 | - * @access public |
|
58 | - * @param string $QST_admin_label |
|
59 | - */ |
|
60 | - public function set_admin_label($QST_admin_label = '') |
|
61 | - { |
|
62 | - $this->set('QST_admin_label', $QST_admin_label); |
|
63 | - } |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * Set system name |
|
68 | - * |
|
69 | - * @access public |
|
70 | - * @param mixed $QST_system |
|
71 | - */ |
|
72 | - public function set_system_ID($QST_system = '') |
|
73 | - { |
|
74 | - $this->set('QST_system', $QST_system); |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * Set question's type |
|
80 | - * |
|
81 | - * @access public |
|
82 | - * @param string $QST_type |
|
83 | - */ |
|
84 | - public function set_question_type($QST_type = '') |
|
85 | - { |
|
86 | - $this->set('QST_type', $QST_type); |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * Sets whether this question must be answered when presented in a form |
|
92 | - * |
|
93 | - * @access public |
|
94 | - * @param bool $QST_required |
|
95 | - */ |
|
96 | - public function set_required($QST_required = false) |
|
97 | - { |
|
98 | - $this->set('QST_required', $QST_required); |
|
99 | - } |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * Set Question display text |
|
104 | - * |
|
105 | - * @access public |
|
106 | - * @param string $QST_required_text |
|
107 | - */ |
|
108 | - public function set_required_text($QST_required_text = '') |
|
109 | - { |
|
110 | - $this->set('QST_required_text', $QST_required_text); |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * Sets the order of this question when placed in a sequence of questions |
|
116 | - * |
|
117 | - * @access public |
|
118 | - * @param int $QST_order |
|
119 | - */ |
|
120 | - public function set_order($QST_order = 0) |
|
121 | - { |
|
122 | - $this->set('QST_order', $QST_order); |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * Sets whether the question is admin-only |
|
128 | - * |
|
129 | - * @access public |
|
130 | - * @param bool $QST_admin_only |
|
131 | - */ |
|
132 | - public function set_admin_only($QST_admin_only = false) |
|
133 | - { |
|
134 | - $this->set('QST_admin_only', $QST_admin_only); |
|
135 | - } |
|
136 | - |
|
137 | - |
|
138 | - /** |
|
139 | - * Sets the wordpress user ID on the question |
|
140 | - * |
|
141 | - * @access public |
|
142 | - * @param int $QST_wp_user |
|
143 | - */ |
|
144 | - public function set_wp_user($QST_wp_user = 1) |
|
145 | - { |
|
146 | - $this->set('QST_wp_user', $QST_wp_user); |
|
147 | - } |
|
148 | - |
|
149 | - |
|
150 | - /** |
|
151 | - * Sets whether the question has been deleted |
|
152 | - * (we use this boolean instead of actually |
|
153 | - * deleting it because when users delete this question |
|
154 | - * they really want to remove the question from future |
|
155 | - * forms, BUT keep their old answers which depend |
|
156 | - * on this record actually existing. |
|
157 | - * |
|
158 | - * @access public |
|
159 | - * @param bool $QST_deleted |
|
160 | - */ |
|
161 | - public function set_deleted($QST_deleted = false) |
|
162 | - { |
|
163 | - $this->set('QST_deleted', $QST_deleted); |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - /** |
|
168 | - * returns the text for displaying the question to users |
|
169 | - * |
|
170 | - * @access public |
|
171 | - * @return string |
|
172 | - */ |
|
173 | - public function display_text() |
|
174 | - { |
|
175 | - return $this->get('QST_display_text'); |
|
176 | - } |
|
177 | - |
|
178 | - |
|
179 | - /** |
|
180 | - * returns the text for the administrative label |
|
181 | - * |
|
182 | - * @access public |
|
183 | - * @return string |
|
184 | - */ |
|
185 | - public function admin_label() |
|
186 | - { |
|
187 | - return $this->get('QST_admin_label'); |
|
188 | - } |
|
189 | - |
|
190 | - |
|
191 | - /** |
|
192 | - * returns the attendee column name for this question |
|
193 | - * |
|
194 | - * @access public |
|
195 | - * @return string |
|
196 | - */ |
|
197 | - public function system_ID() |
|
198 | - { |
|
199 | - return $this->get('QST_system'); |
|
200 | - } |
|
201 | - |
|
202 | - |
|
203 | - /** |
|
204 | - * if question is required or not (boolean) |
|
205 | - * |
|
206 | - * @access public |
|
207 | - * @return boolean |
|
208 | - */ |
|
209 | - public function required() |
|
210 | - { |
|
211 | - return $this->get('QST_required'); |
|
212 | - } |
|
213 | - |
|
214 | - |
|
215 | - /** |
|
216 | - * returns the text which should be displayed when a user |
|
217 | - * doesn't answer this question in a form |
|
218 | - * |
|
219 | - * @access public |
|
220 | - * @return string |
|
221 | - */ |
|
222 | - public function required_text() |
|
223 | - { |
|
224 | - return $this->get('QST_required_text'); |
|
225 | - } |
|
226 | - |
|
227 | - |
|
228 | - /** |
|
229 | - * returns the type of this question |
|
230 | - * |
|
231 | - * @access public |
|
232 | - * @return string |
|
233 | - */ |
|
234 | - public function type() |
|
235 | - { |
|
236 | - return $this->get('QST_type'); |
|
237 | - } |
|
238 | - |
|
239 | - |
|
240 | - /** |
|
241 | - * returns an integer showing where this question should |
|
242 | - * be placed in a sequence of questions |
|
243 | - * |
|
244 | - * @access public |
|
245 | - * @return int |
|
246 | - */ |
|
247 | - public function order() |
|
248 | - { |
|
249 | - return $this->get('QST_order'); |
|
250 | - } |
|
251 | - |
|
252 | - |
|
253 | - /** |
|
254 | - * returns whether this question should only appears to admins, |
|
255 | - * or to everyone |
|
256 | - * |
|
257 | - * @access public |
|
258 | - * @return boolean |
|
259 | - */ |
|
260 | - public function admin_only() |
|
261 | - { |
|
262 | - return $this->get('QST_admin_only'); |
|
263 | - } |
|
264 | - |
|
265 | - |
|
266 | - /** |
|
267 | - * returns the id the wordpress user who created this question |
|
268 | - * |
|
269 | - * @access public |
|
270 | - * @return int |
|
271 | - */ |
|
272 | - public function wp_user() |
|
273 | - { |
|
274 | - return $this->get('QST_wp_user'); |
|
275 | - } |
|
276 | - |
|
277 | - |
|
278 | - /** |
|
279 | - * returns whether this question has been marked as 'deleted' |
|
280 | - * |
|
281 | - * @access public |
|
282 | - * @return boolean |
|
283 | - */ |
|
284 | - public function deleted() |
|
285 | - { |
|
286 | - return $this->get('QST_deleted'); |
|
287 | - } |
|
288 | - |
|
289 | - |
|
290 | - /** |
|
291 | - * Gets an array of related EE_Answer to this EE_Question |
|
292 | - * |
|
293 | - * @return EE_Answer[] |
|
294 | - */ |
|
295 | - public function answers() |
|
296 | - { |
|
297 | - return $this->get_many_related('Answer'); |
|
298 | - } |
|
299 | - |
|
300 | - |
|
301 | - /** |
|
302 | - * Boolean check for if there are answers on this question in th db |
|
303 | - * |
|
304 | - * @return boolean true = has answers, false = no answers. |
|
305 | - */ |
|
306 | - public function has_answers() |
|
307 | - { |
|
308 | - return $this->count_related('Answer') > 0 ? true : false; |
|
309 | - } |
|
310 | - |
|
311 | - |
|
312 | - /** |
|
313 | - * gets an array of EE_Question_Group which relate to this question |
|
314 | - * |
|
315 | - * @return EE_Question_Group[] |
|
316 | - */ |
|
317 | - public function question_groups() |
|
318 | - { |
|
319 | - return $this->get_many_related('Question_Group'); |
|
320 | - } |
|
321 | - |
|
322 | - |
|
323 | - /** |
|
324 | - * Returns all the options for this question. By default, it returns only the not-yet-deleted ones. |
|
325 | - * |
|
326 | - * @param boolean $notDeletedOptionsOnly 1 |
|
327 | - * whether to return ALL options, or only the ones which have |
|
328 | - * not yet been deleleted |
|
329 | - * @param string|array $selected_value_to_always_include , when retrieving options to an ANSWERED question, |
|
330 | - * we want to usually only show non-deleted options AND the |
|
331 | - * value that was selected for the answer, whether it was |
|
332 | - * trashed or not. |
|
333 | - * @return EE_Question_Option[] |
|
334 | - */ |
|
335 | - public function options($notDeletedOptionsOnly = true, $selected_value_to_always_include = null) |
|
336 | - { |
|
337 | - if (! $this->ID()) { |
|
338 | - return []; |
|
339 | - } |
|
340 | - $query_params = []; |
|
341 | - if ($selected_value_to_always_include) { |
|
342 | - if (is_array($selected_value_to_always_include)) { |
|
343 | - $query_params[0]['OR*options-query']['QSO_value'] = ['IN', $selected_value_to_always_include]; |
|
344 | - } else { |
|
345 | - $query_params[0]['OR*options-query']['QSO_value'] = $selected_value_to_always_include; |
|
346 | - } |
|
347 | - } |
|
348 | - if ($notDeletedOptionsOnly) { |
|
349 | - $query_params[0]['OR*options-query']['QSO_deleted'] = false; |
|
350 | - } |
|
351 | - // order by QSO_order |
|
352 | - $query_params['order_by'] = ['QSO_order' => 'ASC']; |
|
353 | - return $this->get_many_related('Question_Option', $query_params); |
|
354 | - } |
|
355 | - |
|
356 | - |
|
357 | - /** |
|
358 | - * returns an array of EE_Question_Options which relate to this question |
|
359 | - * |
|
360 | - * @return \EE_Question_Option[] |
|
361 | - */ |
|
362 | - public function temp_options() |
|
363 | - { |
|
364 | - return $this->_model_relations['Question_Option']; |
|
365 | - } |
|
366 | - |
|
367 | - |
|
368 | - /** |
|
369 | - * Adds an option for this question. Note: if the option were previously associated with a different |
|
370 | - * Question, that relationship will be overwritten. |
|
371 | - * |
|
372 | - * @param EE_Question_Option $option |
|
373 | - * @return boolean success |
|
374 | - */ |
|
375 | - public function add_option(EE_Question_Option $option) |
|
376 | - { |
|
377 | - return $this->_add_relation_to($option, 'Question_Option'); |
|
378 | - } |
|
379 | - |
|
380 | - |
|
381 | - /** |
|
382 | - * Adds an option directly to this question without saving to the db |
|
383 | - * |
|
384 | - * @param EE_Question_Option $option |
|
385 | - * @return boolean success |
|
386 | - */ |
|
387 | - public function add_temp_option(EE_Question_Option $option) |
|
388 | - { |
|
389 | - $this->_model_relations['Question_Option'][] = $option; |
|
390 | - return true; |
|
391 | - } |
|
392 | - |
|
393 | - |
|
394 | - /** |
|
395 | - * Marks the option as deleted. |
|
396 | - * |
|
397 | - * @param EE_Question_Option $option |
|
398 | - * @return boolean success |
|
399 | - */ |
|
400 | - public function remove_option(EE_Question_Option $option) |
|
401 | - { |
|
402 | - return $this->_remove_relation_to($option, 'Question_Option'); |
|
403 | - } |
|
404 | - |
|
405 | - |
|
406 | - /** |
|
407 | - * @return bool |
|
408 | - */ |
|
409 | - public function is_system_question() |
|
410 | - { |
|
411 | - $system_ID = $this->get('QST_system'); |
|
412 | - return ! empty($system_ID) ? true : false; |
|
413 | - } |
|
414 | - |
|
415 | - |
|
416 | - /** |
|
417 | - * The purpose of this method is set the question order this question order to be the max out of all questions |
|
418 | - * |
|
419 | - * @access public |
|
420 | - * @return void |
|
421 | - */ |
|
422 | - public function set_order_to_latest() |
|
423 | - { |
|
424 | - $latest_order = $this->get_model()->get_latest_question_order(); |
|
425 | - $latest_order++; |
|
426 | - $this->set('QST_order', $latest_order); |
|
427 | - } |
|
428 | - |
|
429 | - |
|
430 | - /** |
|
431 | - * Retrieves the list of allowed question types from the model. |
|
432 | - * |
|
433 | - * @return string[] |
|
434 | - */ |
|
435 | - private function _allowed_question_types() |
|
436 | - { |
|
437 | - $questionModel = $this->get_model(); |
|
438 | - /* @var $questionModel EEM_Question */ |
|
439 | - return $questionModel->allowed_question_types(); |
|
440 | - } |
|
441 | - |
|
442 | - |
|
443 | - /** |
|
444 | - * Duplicates this question and its question options |
|
445 | - * |
|
446 | - * @return \EE_Question |
|
447 | - */ |
|
448 | - public function duplicate($options = []) |
|
449 | - { |
|
450 | - $new_question = clone $this; |
|
451 | - $new_question->set('QST_ID', null); |
|
452 | - $new_question->set_display_text( |
|
453 | - sprintf(esc_html__('%s **Duplicate**', 'event_espresso'), $this->display_text()) |
|
454 | - ); |
|
455 | - $new_question->set_admin_label(sprintf(esc_html__('%s **Duplicate**', 'event_espresso'), $this->admin_label())); |
|
456 | - $new_question->set_system_ID(null); |
|
457 | - $new_question->set_wp_user(get_current_user_id()); |
|
458 | - // if we're duplicating a trashed question, assume we don't want the new one to be trashed |
|
459 | - $new_question->set_deleted(false); |
|
460 | - $success = $new_question->save(); |
|
461 | - if ($success) { |
|
462 | - // we don't totally want to duplicate the question options, because we want them to be for the NEW question |
|
463 | - foreach ($this->options() as $question_option) { |
|
464 | - $question_option->duplicate(['QST_ID' => $new_question->ID()]); |
|
465 | - } |
|
466 | - return $new_question; |
|
467 | - } else { |
|
468 | - return null; |
|
469 | - } |
|
470 | - } |
|
471 | - |
|
472 | - |
|
473 | - /** |
|
474 | - * Returns the question's maximum allowed response size |
|
475 | - * |
|
476 | - * @return int|float |
|
477 | - */ |
|
478 | - public function max() |
|
479 | - { |
|
480 | - return $this->get('QST_max'); |
|
481 | - } |
|
482 | - |
|
483 | - |
|
484 | - /** |
|
485 | - * Sets the question's maximum allowed response size |
|
486 | - * |
|
487 | - * @param int|float $new_max |
|
488 | - * @return void |
|
489 | - */ |
|
490 | - public function set_max($new_max) |
|
491 | - { |
|
492 | - $this->set('QST_max', $new_max); |
|
493 | - } |
|
494 | - |
|
495 | - |
|
496 | - /** |
|
497 | - * Creates a form input from this question which can be used in HTML forms |
|
498 | - * |
|
499 | - * @param EE_Registration $registration |
|
500 | - * @param EE_Answer $answer |
|
501 | - * @param array $input_constructor_args |
|
502 | - * @return EE_Form_Input_Base |
|
503 | - */ |
|
504 | - public function generate_form_input($registration = null, $answer = null, $input_constructor_args = []) |
|
505 | - { |
|
506 | - $identifier = $this->is_system_question() ? $this->system_ID() : $this->ID(); |
|
507 | - |
|
508 | - $input_constructor_args = array_merge( |
|
509 | - [ |
|
510 | - 'required' => $this->required() ? true : false, |
|
511 | - 'html_label_text' => $this->display_text(), |
|
512 | - 'required_validation_error_message' => $this->required_text(), |
|
513 | - ], |
|
514 | - $input_constructor_args |
|
515 | - ); |
|
516 | - if (! $answer instanceof EE_Answer && $registration instanceof EE_Registration) { |
|
517 | - $answer = EEM_Answer::instance()->get_registration_question_answer_object($registration, $this->ID()); |
|
518 | - } |
|
519 | - // has this question been answered ? |
|
520 | - if ( |
|
521 | - $answer instanceof EE_Answer |
|
522 | - && $answer->value() !== '' |
|
523 | - ) { |
|
524 | - // answer gets htmlspecialchars called on it, undo that please |
|
525 | - // because the form input's display strategy may call esc_attr too |
|
526 | - // which also does html special characters |
|
527 | - $values_with_html_special_chars = $answer->value(); |
|
528 | - if (is_array($values_with_html_special_chars)) { |
|
529 | - $default_value = array_map('htmlspecialchars_decode', $values_with_html_special_chars); |
|
530 | - } else { |
|
531 | - $default_value = htmlspecialchars_decode($values_with_html_special_chars); |
|
532 | - } |
|
533 | - $input_constructor_args['default'] = $default_value; |
|
534 | - } |
|
535 | - $max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question($this->system_ID()); |
|
536 | - if ( |
|
537 | - in_array( |
|
538 | - $this->type(), |
|
539 | - EEM_Question::instance()->questionTypesWithMaxLength(), |
|
540 | - true |
|
541 | - ) |
|
542 | - ) { |
|
543 | - $input_constructor_args['validation_strategies'][] = new EE_Max_Length_Validation_Strategy( |
|
544 | - null, |
|
545 | - min($max_max_for_question, $this->max()) |
|
546 | - ); |
|
547 | - } |
|
548 | - $input_constructor_args = apply_filters( |
|
549 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__input_constructor_args', |
|
550 | - $input_constructor_args, |
|
551 | - $registration, |
|
552 | - $this, |
|
553 | - $answer |
|
554 | - ); |
|
555 | - |
|
556 | - $result = null; |
|
557 | - switch ($this->type()) { |
|
558 | - // Text |
|
559 | - case EEM_Question::QST_type_text: |
|
560 | - $result = new EE_Text_Input($input_constructor_args); |
|
561 | - break; |
|
562 | - // Textarea |
|
563 | - case EEM_Question::QST_type_textarea: |
|
564 | - $result = new EE_Text_Area_Input($input_constructor_args); |
|
565 | - break; |
|
566 | - // Radio Buttons |
|
567 | - case EEM_Question::QST_type_radio: |
|
568 | - $result = new EE_Radio_Button_Input($this->options(), $input_constructor_args); |
|
569 | - break; |
|
570 | - // Dropdown |
|
571 | - case EEM_Question::QST_type_dropdown: |
|
572 | - $result = new EE_Select_Input($this->options(), $input_constructor_args); |
|
573 | - break; |
|
574 | - // State Dropdown |
|
575 | - case EEM_Question::QST_type_state: |
|
576 | - $state_options = apply_filters( |
|
577 | - 'FHEE__EE_Question__generate_form_input__state_options', |
|
578 | - null, |
|
579 | - $this, |
|
580 | - $registration, |
|
581 | - $answer |
|
582 | - ); |
|
583 | - $result = new EE_State_Select_Input($state_options, $input_constructor_args); |
|
584 | - break; |
|
585 | - // Country Dropdown |
|
586 | - case EEM_Question::QST_type_country: |
|
587 | - $country_options = apply_filters( |
|
588 | - 'FHEE__EE_Question__generate_form_input__country_options', |
|
589 | - null, |
|
590 | - $this, |
|
591 | - $registration, |
|
592 | - $answer |
|
593 | - ); |
|
594 | - $result = new EE_Country_Select_Input($country_options, $input_constructor_args); |
|
595 | - break; |
|
596 | - // Checkboxes |
|
597 | - case EEM_Question::QST_type_checkbox: |
|
598 | - $result = new EE_Checkbox_Multi_Input($this->options(), $input_constructor_args); |
|
599 | - break; |
|
600 | - // Date |
|
601 | - case EEM_Question::QST_type_date: |
|
602 | - $result = new EE_Datepicker_Input($input_constructor_args); |
|
603 | - break; |
|
604 | - case EEM_Question::QST_type_html_textarea: |
|
605 | - $input_constructor_args['validation_strategies'][] = new EE_Simple_HTML_Validation_Strategy(); |
|
606 | - $result = new EE_Text_Area_Input($input_constructor_args); |
|
607 | - $result->remove_validation_strategy('EE_Plaintext_Validation_Strategy'); |
|
608 | - break; |
|
609 | - case EEM_Question::QST_type_email: |
|
610 | - $result = new EE_Email_Input($input_constructor_args); |
|
611 | - break; |
|
612 | - // Email confirm |
|
613 | - case EEM_Question::QST_type_email_confirm: |
|
614 | - $result = new EE_Email_Confirm_Input($input_constructor_args); |
|
615 | - break; |
|
616 | - case EEM_Question::QST_type_us_phone: |
|
617 | - $result = new EE_Phone_Input($input_constructor_args); |
|
618 | - break; |
|
619 | - case EEM_Question::QST_type_int: |
|
620 | - $result = new EE_Integer_Input($input_constructor_args); |
|
621 | - break; |
|
622 | - case EEM_Question::QST_type_decimal: |
|
623 | - $result = new EE_Float_Input($input_constructor_args); |
|
624 | - break; |
|
625 | - case EEM_Question::QST_type_url: |
|
626 | - $result = new EE_URL_Input($input_constructor_args); |
|
627 | - break; |
|
628 | - case EEM_Question::QST_type_year: |
|
629 | - $result = new EE_Year_Input( |
|
630 | - $input_constructor_args, |
|
631 | - apply_filters( |
|
632 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__four_digit', |
|
633 | - true, |
|
634 | - $this |
|
635 | - ), |
|
636 | - apply_filters( |
|
637 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__early_range', |
|
638 | - 100, |
|
639 | - $this |
|
640 | - ), |
|
641 | - apply_filters( |
|
642 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range', |
|
643 | - 100, |
|
644 | - $this |
|
645 | - ) |
|
646 | - ); |
|
647 | - break; |
|
648 | - case EEM_Question::QST_type_multi_select: |
|
649 | - $result = new EE_Select_Multiple_Input($this->options(), $input_constructor_args); |
|
650 | - break; |
|
651 | - // fallback |
|
652 | - default: |
|
653 | - $default_input = apply_filters( |
|
654 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__default', |
|
655 | - null, |
|
656 | - $this->type(), |
|
657 | - $this, |
|
658 | - $input_constructor_args |
|
659 | - ); |
|
660 | - if (! $default_input) { |
|
661 | - $default_input = new EE_Text_Input($input_constructor_args); |
|
662 | - } |
|
663 | - $result = $default_input; |
|
664 | - } |
|
665 | - return apply_filters('FHEE__EE_Question__generate_form_input__return', $result, $registration, $this, $answer); |
|
666 | - } |
|
667 | - |
|
668 | - |
|
669 | - /** |
|
670 | - * Returns whether or not this question type should have question option entries |
|
671 | - * |
|
672 | - * @return bool |
|
673 | - */ |
|
674 | - public function should_have_question_options() |
|
675 | - { |
|
676 | - return in_array( |
|
677 | - $this->type(), |
|
678 | - $this->_model->question_types_with_options(), |
|
679 | - true |
|
680 | - ); |
|
681 | - } |
|
15 | + /** |
|
16 | + * @param array $props_n_values incoming values |
|
17 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
18 | + * used.) |
|
19 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
20 | + * date_format and the second value is the time format |
|
21 | + * @return EE_Question |
|
22 | + */ |
|
23 | + public static function new_instance($props_n_values = [], $timezone = '', $date_formats = []) |
|
24 | + { |
|
25 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
26 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
27 | + } |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * @param array $props_n_values incoming values from the database |
|
32 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
33 | + * the website will be used. |
|
34 | + * @return EE_Question |
|
35 | + */ |
|
36 | + public static function new_instance_from_db($props_n_values = [], $timezone = '') |
|
37 | + { |
|
38 | + return new self($props_n_values, true, $timezone); |
|
39 | + } |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * Set Question display text |
|
44 | + * |
|
45 | + * @access public |
|
46 | + * @param string $QST_display_text |
|
47 | + */ |
|
48 | + public function set_display_text($QST_display_text = '') |
|
49 | + { |
|
50 | + $this->set('QST_display_text', $QST_display_text); |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * Set Question admin text |
|
56 | + * |
|
57 | + * @access public |
|
58 | + * @param string $QST_admin_label |
|
59 | + */ |
|
60 | + public function set_admin_label($QST_admin_label = '') |
|
61 | + { |
|
62 | + $this->set('QST_admin_label', $QST_admin_label); |
|
63 | + } |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * Set system name |
|
68 | + * |
|
69 | + * @access public |
|
70 | + * @param mixed $QST_system |
|
71 | + */ |
|
72 | + public function set_system_ID($QST_system = '') |
|
73 | + { |
|
74 | + $this->set('QST_system', $QST_system); |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * Set question's type |
|
80 | + * |
|
81 | + * @access public |
|
82 | + * @param string $QST_type |
|
83 | + */ |
|
84 | + public function set_question_type($QST_type = '') |
|
85 | + { |
|
86 | + $this->set('QST_type', $QST_type); |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * Sets whether this question must be answered when presented in a form |
|
92 | + * |
|
93 | + * @access public |
|
94 | + * @param bool $QST_required |
|
95 | + */ |
|
96 | + public function set_required($QST_required = false) |
|
97 | + { |
|
98 | + $this->set('QST_required', $QST_required); |
|
99 | + } |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * Set Question display text |
|
104 | + * |
|
105 | + * @access public |
|
106 | + * @param string $QST_required_text |
|
107 | + */ |
|
108 | + public function set_required_text($QST_required_text = '') |
|
109 | + { |
|
110 | + $this->set('QST_required_text', $QST_required_text); |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * Sets the order of this question when placed in a sequence of questions |
|
116 | + * |
|
117 | + * @access public |
|
118 | + * @param int $QST_order |
|
119 | + */ |
|
120 | + public function set_order($QST_order = 0) |
|
121 | + { |
|
122 | + $this->set('QST_order', $QST_order); |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * Sets whether the question is admin-only |
|
128 | + * |
|
129 | + * @access public |
|
130 | + * @param bool $QST_admin_only |
|
131 | + */ |
|
132 | + public function set_admin_only($QST_admin_only = false) |
|
133 | + { |
|
134 | + $this->set('QST_admin_only', $QST_admin_only); |
|
135 | + } |
|
136 | + |
|
137 | + |
|
138 | + /** |
|
139 | + * Sets the wordpress user ID on the question |
|
140 | + * |
|
141 | + * @access public |
|
142 | + * @param int $QST_wp_user |
|
143 | + */ |
|
144 | + public function set_wp_user($QST_wp_user = 1) |
|
145 | + { |
|
146 | + $this->set('QST_wp_user', $QST_wp_user); |
|
147 | + } |
|
148 | + |
|
149 | + |
|
150 | + /** |
|
151 | + * Sets whether the question has been deleted |
|
152 | + * (we use this boolean instead of actually |
|
153 | + * deleting it because when users delete this question |
|
154 | + * they really want to remove the question from future |
|
155 | + * forms, BUT keep their old answers which depend |
|
156 | + * on this record actually existing. |
|
157 | + * |
|
158 | + * @access public |
|
159 | + * @param bool $QST_deleted |
|
160 | + */ |
|
161 | + public function set_deleted($QST_deleted = false) |
|
162 | + { |
|
163 | + $this->set('QST_deleted', $QST_deleted); |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + /** |
|
168 | + * returns the text for displaying the question to users |
|
169 | + * |
|
170 | + * @access public |
|
171 | + * @return string |
|
172 | + */ |
|
173 | + public function display_text() |
|
174 | + { |
|
175 | + return $this->get('QST_display_text'); |
|
176 | + } |
|
177 | + |
|
178 | + |
|
179 | + /** |
|
180 | + * returns the text for the administrative label |
|
181 | + * |
|
182 | + * @access public |
|
183 | + * @return string |
|
184 | + */ |
|
185 | + public function admin_label() |
|
186 | + { |
|
187 | + return $this->get('QST_admin_label'); |
|
188 | + } |
|
189 | + |
|
190 | + |
|
191 | + /** |
|
192 | + * returns the attendee column name for this question |
|
193 | + * |
|
194 | + * @access public |
|
195 | + * @return string |
|
196 | + */ |
|
197 | + public function system_ID() |
|
198 | + { |
|
199 | + return $this->get('QST_system'); |
|
200 | + } |
|
201 | + |
|
202 | + |
|
203 | + /** |
|
204 | + * if question is required or not (boolean) |
|
205 | + * |
|
206 | + * @access public |
|
207 | + * @return boolean |
|
208 | + */ |
|
209 | + public function required() |
|
210 | + { |
|
211 | + return $this->get('QST_required'); |
|
212 | + } |
|
213 | + |
|
214 | + |
|
215 | + /** |
|
216 | + * returns the text which should be displayed when a user |
|
217 | + * doesn't answer this question in a form |
|
218 | + * |
|
219 | + * @access public |
|
220 | + * @return string |
|
221 | + */ |
|
222 | + public function required_text() |
|
223 | + { |
|
224 | + return $this->get('QST_required_text'); |
|
225 | + } |
|
226 | + |
|
227 | + |
|
228 | + /** |
|
229 | + * returns the type of this question |
|
230 | + * |
|
231 | + * @access public |
|
232 | + * @return string |
|
233 | + */ |
|
234 | + public function type() |
|
235 | + { |
|
236 | + return $this->get('QST_type'); |
|
237 | + } |
|
238 | + |
|
239 | + |
|
240 | + /** |
|
241 | + * returns an integer showing where this question should |
|
242 | + * be placed in a sequence of questions |
|
243 | + * |
|
244 | + * @access public |
|
245 | + * @return int |
|
246 | + */ |
|
247 | + public function order() |
|
248 | + { |
|
249 | + return $this->get('QST_order'); |
|
250 | + } |
|
251 | + |
|
252 | + |
|
253 | + /** |
|
254 | + * returns whether this question should only appears to admins, |
|
255 | + * or to everyone |
|
256 | + * |
|
257 | + * @access public |
|
258 | + * @return boolean |
|
259 | + */ |
|
260 | + public function admin_only() |
|
261 | + { |
|
262 | + return $this->get('QST_admin_only'); |
|
263 | + } |
|
264 | + |
|
265 | + |
|
266 | + /** |
|
267 | + * returns the id the wordpress user who created this question |
|
268 | + * |
|
269 | + * @access public |
|
270 | + * @return int |
|
271 | + */ |
|
272 | + public function wp_user() |
|
273 | + { |
|
274 | + return $this->get('QST_wp_user'); |
|
275 | + } |
|
276 | + |
|
277 | + |
|
278 | + /** |
|
279 | + * returns whether this question has been marked as 'deleted' |
|
280 | + * |
|
281 | + * @access public |
|
282 | + * @return boolean |
|
283 | + */ |
|
284 | + public function deleted() |
|
285 | + { |
|
286 | + return $this->get('QST_deleted'); |
|
287 | + } |
|
288 | + |
|
289 | + |
|
290 | + /** |
|
291 | + * Gets an array of related EE_Answer to this EE_Question |
|
292 | + * |
|
293 | + * @return EE_Answer[] |
|
294 | + */ |
|
295 | + public function answers() |
|
296 | + { |
|
297 | + return $this->get_many_related('Answer'); |
|
298 | + } |
|
299 | + |
|
300 | + |
|
301 | + /** |
|
302 | + * Boolean check for if there are answers on this question in th db |
|
303 | + * |
|
304 | + * @return boolean true = has answers, false = no answers. |
|
305 | + */ |
|
306 | + public function has_answers() |
|
307 | + { |
|
308 | + return $this->count_related('Answer') > 0 ? true : false; |
|
309 | + } |
|
310 | + |
|
311 | + |
|
312 | + /** |
|
313 | + * gets an array of EE_Question_Group which relate to this question |
|
314 | + * |
|
315 | + * @return EE_Question_Group[] |
|
316 | + */ |
|
317 | + public function question_groups() |
|
318 | + { |
|
319 | + return $this->get_many_related('Question_Group'); |
|
320 | + } |
|
321 | + |
|
322 | + |
|
323 | + /** |
|
324 | + * Returns all the options for this question. By default, it returns only the not-yet-deleted ones. |
|
325 | + * |
|
326 | + * @param boolean $notDeletedOptionsOnly 1 |
|
327 | + * whether to return ALL options, or only the ones which have |
|
328 | + * not yet been deleleted |
|
329 | + * @param string|array $selected_value_to_always_include , when retrieving options to an ANSWERED question, |
|
330 | + * we want to usually only show non-deleted options AND the |
|
331 | + * value that was selected for the answer, whether it was |
|
332 | + * trashed or not. |
|
333 | + * @return EE_Question_Option[] |
|
334 | + */ |
|
335 | + public function options($notDeletedOptionsOnly = true, $selected_value_to_always_include = null) |
|
336 | + { |
|
337 | + if (! $this->ID()) { |
|
338 | + return []; |
|
339 | + } |
|
340 | + $query_params = []; |
|
341 | + if ($selected_value_to_always_include) { |
|
342 | + if (is_array($selected_value_to_always_include)) { |
|
343 | + $query_params[0]['OR*options-query']['QSO_value'] = ['IN', $selected_value_to_always_include]; |
|
344 | + } else { |
|
345 | + $query_params[0]['OR*options-query']['QSO_value'] = $selected_value_to_always_include; |
|
346 | + } |
|
347 | + } |
|
348 | + if ($notDeletedOptionsOnly) { |
|
349 | + $query_params[0]['OR*options-query']['QSO_deleted'] = false; |
|
350 | + } |
|
351 | + // order by QSO_order |
|
352 | + $query_params['order_by'] = ['QSO_order' => 'ASC']; |
|
353 | + return $this->get_many_related('Question_Option', $query_params); |
|
354 | + } |
|
355 | + |
|
356 | + |
|
357 | + /** |
|
358 | + * returns an array of EE_Question_Options which relate to this question |
|
359 | + * |
|
360 | + * @return \EE_Question_Option[] |
|
361 | + */ |
|
362 | + public function temp_options() |
|
363 | + { |
|
364 | + return $this->_model_relations['Question_Option']; |
|
365 | + } |
|
366 | + |
|
367 | + |
|
368 | + /** |
|
369 | + * Adds an option for this question. Note: if the option were previously associated with a different |
|
370 | + * Question, that relationship will be overwritten. |
|
371 | + * |
|
372 | + * @param EE_Question_Option $option |
|
373 | + * @return boolean success |
|
374 | + */ |
|
375 | + public function add_option(EE_Question_Option $option) |
|
376 | + { |
|
377 | + return $this->_add_relation_to($option, 'Question_Option'); |
|
378 | + } |
|
379 | + |
|
380 | + |
|
381 | + /** |
|
382 | + * Adds an option directly to this question without saving to the db |
|
383 | + * |
|
384 | + * @param EE_Question_Option $option |
|
385 | + * @return boolean success |
|
386 | + */ |
|
387 | + public function add_temp_option(EE_Question_Option $option) |
|
388 | + { |
|
389 | + $this->_model_relations['Question_Option'][] = $option; |
|
390 | + return true; |
|
391 | + } |
|
392 | + |
|
393 | + |
|
394 | + /** |
|
395 | + * Marks the option as deleted. |
|
396 | + * |
|
397 | + * @param EE_Question_Option $option |
|
398 | + * @return boolean success |
|
399 | + */ |
|
400 | + public function remove_option(EE_Question_Option $option) |
|
401 | + { |
|
402 | + return $this->_remove_relation_to($option, 'Question_Option'); |
|
403 | + } |
|
404 | + |
|
405 | + |
|
406 | + /** |
|
407 | + * @return bool |
|
408 | + */ |
|
409 | + public function is_system_question() |
|
410 | + { |
|
411 | + $system_ID = $this->get('QST_system'); |
|
412 | + return ! empty($system_ID) ? true : false; |
|
413 | + } |
|
414 | + |
|
415 | + |
|
416 | + /** |
|
417 | + * The purpose of this method is set the question order this question order to be the max out of all questions |
|
418 | + * |
|
419 | + * @access public |
|
420 | + * @return void |
|
421 | + */ |
|
422 | + public function set_order_to_latest() |
|
423 | + { |
|
424 | + $latest_order = $this->get_model()->get_latest_question_order(); |
|
425 | + $latest_order++; |
|
426 | + $this->set('QST_order', $latest_order); |
|
427 | + } |
|
428 | + |
|
429 | + |
|
430 | + /** |
|
431 | + * Retrieves the list of allowed question types from the model. |
|
432 | + * |
|
433 | + * @return string[] |
|
434 | + */ |
|
435 | + private function _allowed_question_types() |
|
436 | + { |
|
437 | + $questionModel = $this->get_model(); |
|
438 | + /* @var $questionModel EEM_Question */ |
|
439 | + return $questionModel->allowed_question_types(); |
|
440 | + } |
|
441 | + |
|
442 | + |
|
443 | + /** |
|
444 | + * Duplicates this question and its question options |
|
445 | + * |
|
446 | + * @return \EE_Question |
|
447 | + */ |
|
448 | + public function duplicate($options = []) |
|
449 | + { |
|
450 | + $new_question = clone $this; |
|
451 | + $new_question->set('QST_ID', null); |
|
452 | + $new_question->set_display_text( |
|
453 | + sprintf(esc_html__('%s **Duplicate**', 'event_espresso'), $this->display_text()) |
|
454 | + ); |
|
455 | + $new_question->set_admin_label(sprintf(esc_html__('%s **Duplicate**', 'event_espresso'), $this->admin_label())); |
|
456 | + $new_question->set_system_ID(null); |
|
457 | + $new_question->set_wp_user(get_current_user_id()); |
|
458 | + // if we're duplicating a trashed question, assume we don't want the new one to be trashed |
|
459 | + $new_question->set_deleted(false); |
|
460 | + $success = $new_question->save(); |
|
461 | + if ($success) { |
|
462 | + // we don't totally want to duplicate the question options, because we want them to be for the NEW question |
|
463 | + foreach ($this->options() as $question_option) { |
|
464 | + $question_option->duplicate(['QST_ID' => $new_question->ID()]); |
|
465 | + } |
|
466 | + return $new_question; |
|
467 | + } else { |
|
468 | + return null; |
|
469 | + } |
|
470 | + } |
|
471 | + |
|
472 | + |
|
473 | + /** |
|
474 | + * Returns the question's maximum allowed response size |
|
475 | + * |
|
476 | + * @return int|float |
|
477 | + */ |
|
478 | + public function max() |
|
479 | + { |
|
480 | + return $this->get('QST_max'); |
|
481 | + } |
|
482 | + |
|
483 | + |
|
484 | + /** |
|
485 | + * Sets the question's maximum allowed response size |
|
486 | + * |
|
487 | + * @param int|float $new_max |
|
488 | + * @return void |
|
489 | + */ |
|
490 | + public function set_max($new_max) |
|
491 | + { |
|
492 | + $this->set('QST_max', $new_max); |
|
493 | + } |
|
494 | + |
|
495 | + |
|
496 | + /** |
|
497 | + * Creates a form input from this question which can be used in HTML forms |
|
498 | + * |
|
499 | + * @param EE_Registration $registration |
|
500 | + * @param EE_Answer $answer |
|
501 | + * @param array $input_constructor_args |
|
502 | + * @return EE_Form_Input_Base |
|
503 | + */ |
|
504 | + public function generate_form_input($registration = null, $answer = null, $input_constructor_args = []) |
|
505 | + { |
|
506 | + $identifier = $this->is_system_question() ? $this->system_ID() : $this->ID(); |
|
507 | + |
|
508 | + $input_constructor_args = array_merge( |
|
509 | + [ |
|
510 | + 'required' => $this->required() ? true : false, |
|
511 | + 'html_label_text' => $this->display_text(), |
|
512 | + 'required_validation_error_message' => $this->required_text(), |
|
513 | + ], |
|
514 | + $input_constructor_args |
|
515 | + ); |
|
516 | + if (! $answer instanceof EE_Answer && $registration instanceof EE_Registration) { |
|
517 | + $answer = EEM_Answer::instance()->get_registration_question_answer_object($registration, $this->ID()); |
|
518 | + } |
|
519 | + // has this question been answered ? |
|
520 | + if ( |
|
521 | + $answer instanceof EE_Answer |
|
522 | + && $answer->value() !== '' |
|
523 | + ) { |
|
524 | + // answer gets htmlspecialchars called on it, undo that please |
|
525 | + // because the form input's display strategy may call esc_attr too |
|
526 | + // which also does html special characters |
|
527 | + $values_with_html_special_chars = $answer->value(); |
|
528 | + if (is_array($values_with_html_special_chars)) { |
|
529 | + $default_value = array_map('htmlspecialchars_decode', $values_with_html_special_chars); |
|
530 | + } else { |
|
531 | + $default_value = htmlspecialchars_decode($values_with_html_special_chars); |
|
532 | + } |
|
533 | + $input_constructor_args['default'] = $default_value; |
|
534 | + } |
|
535 | + $max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question($this->system_ID()); |
|
536 | + if ( |
|
537 | + in_array( |
|
538 | + $this->type(), |
|
539 | + EEM_Question::instance()->questionTypesWithMaxLength(), |
|
540 | + true |
|
541 | + ) |
|
542 | + ) { |
|
543 | + $input_constructor_args['validation_strategies'][] = new EE_Max_Length_Validation_Strategy( |
|
544 | + null, |
|
545 | + min($max_max_for_question, $this->max()) |
|
546 | + ); |
|
547 | + } |
|
548 | + $input_constructor_args = apply_filters( |
|
549 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__input_constructor_args', |
|
550 | + $input_constructor_args, |
|
551 | + $registration, |
|
552 | + $this, |
|
553 | + $answer |
|
554 | + ); |
|
555 | + |
|
556 | + $result = null; |
|
557 | + switch ($this->type()) { |
|
558 | + // Text |
|
559 | + case EEM_Question::QST_type_text: |
|
560 | + $result = new EE_Text_Input($input_constructor_args); |
|
561 | + break; |
|
562 | + // Textarea |
|
563 | + case EEM_Question::QST_type_textarea: |
|
564 | + $result = new EE_Text_Area_Input($input_constructor_args); |
|
565 | + break; |
|
566 | + // Radio Buttons |
|
567 | + case EEM_Question::QST_type_radio: |
|
568 | + $result = new EE_Radio_Button_Input($this->options(), $input_constructor_args); |
|
569 | + break; |
|
570 | + // Dropdown |
|
571 | + case EEM_Question::QST_type_dropdown: |
|
572 | + $result = new EE_Select_Input($this->options(), $input_constructor_args); |
|
573 | + break; |
|
574 | + // State Dropdown |
|
575 | + case EEM_Question::QST_type_state: |
|
576 | + $state_options = apply_filters( |
|
577 | + 'FHEE__EE_Question__generate_form_input__state_options', |
|
578 | + null, |
|
579 | + $this, |
|
580 | + $registration, |
|
581 | + $answer |
|
582 | + ); |
|
583 | + $result = new EE_State_Select_Input($state_options, $input_constructor_args); |
|
584 | + break; |
|
585 | + // Country Dropdown |
|
586 | + case EEM_Question::QST_type_country: |
|
587 | + $country_options = apply_filters( |
|
588 | + 'FHEE__EE_Question__generate_form_input__country_options', |
|
589 | + null, |
|
590 | + $this, |
|
591 | + $registration, |
|
592 | + $answer |
|
593 | + ); |
|
594 | + $result = new EE_Country_Select_Input($country_options, $input_constructor_args); |
|
595 | + break; |
|
596 | + // Checkboxes |
|
597 | + case EEM_Question::QST_type_checkbox: |
|
598 | + $result = new EE_Checkbox_Multi_Input($this->options(), $input_constructor_args); |
|
599 | + break; |
|
600 | + // Date |
|
601 | + case EEM_Question::QST_type_date: |
|
602 | + $result = new EE_Datepicker_Input($input_constructor_args); |
|
603 | + break; |
|
604 | + case EEM_Question::QST_type_html_textarea: |
|
605 | + $input_constructor_args['validation_strategies'][] = new EE_Simple_HTML_Validation_Strategy(); |
|
606 | + $result = new EE_Text_Area_Input($input_constructor_args); |
|
607 | + $result->remove_validation_strategy('EE_Plaintext_Validation_Strategy'); |
|
608 | + break; |
|
609 | + case EEM_Question::QST_type_email: |
|
610 | + $result = new EE_Email_Input($input_constructor_args); |
|
611 | + break; |
|
612 | + // Email confirm |
|
613 | + case EEM_Question::QST_type_email_confirm: |
|
614 | + $result = new EE_Email_Confirm_Input($input_constructor_args); |
|
615 | + break; |
|
616 | + case EEM_Question::QST_type_us_phone: |
|
617 | + $result = new EE_Phone_Input($input_constructor_args); |
|
618 | + break; |
|
619 | + case EEM_Question::QST_type_int: |
|
620 | + $result = new EE_Integer_Input($input_constructor_args); |
|
621 | + break; |
|
622 | + case EEM_Question::QST_type_decimal: |
|
623 | + $result = new EE_Float_Input($input_constructor_args); |
|
624 | + break; |
|
625 | + case EEM_Question::QST_type_url: |
|
626 | + $result = new EE_URL_Input($input_constructor_args); |
|
627 | + break; |
|
628 | + case EEM_Question::QST_type_year: |
|
629 | + $result = new EE_Year_Input( |
|
630 | + $input_constructor_args, |
|
631 | + apply_filters( |
|
632 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__four_digit', |
|
633 | + true, |
|
634 | + $this |
|
635 | + ), |
|
636 | + apply_filters( |
|
637 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__early_range', |
|
638 | + 100, |
|
639 | + $this |
|
640 | + ), |
|
641 | + apply_filters( |
|
642 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range', |
|
643 | + 100, |
|
644 | + $this |
|
645 | + ) |
|
646 | + ); |
|
647 | + break; |
|
648 | + case EEM_Question::QST_type_multi_select: |
|
649 | + $result = new EE_Select_Multiple_Input($this->options(), $input_constructor_args); |
|
650 | + break; |
|
651 | + // fallback |
|
652 | + default: |
|
653 | + $default_input = apply_filters( |
|
654 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__default', |
|
655 | + null, |
|
656 | + $this->type(), |
|
657 | + $this, |
|
658 | + $input_constructor_args |
|
659 | + ); |
|
660 | + if (! $default_input) { |
|
661 | + $default_input = new EE_Text_Input($input_constructor_args); |
|
662 | + } |
|
663 | + $result = $default_input; |
|
664 | + } |
|
665 | + return apply_filters('FHEE__EE_Question__generate_form_input__return', $result, $registration, $this, $answer); |
|
666 | + } |
|
667 | + |
|
668 | + |
|
669 | + /** |
|
670 | + * Returns whether or not this question type should have question option entries |
|
671 | + * |
|
672 | + * @return bool |
|
673 | + */ |
|
674 | + public function should_have_question_options() |
|
675 | + { |
|
676 | + return in_array( |
|
677 | + $this->type(), |
|
678 | + $this->_model->question_types_with_options(), |
|
679 | + true |
|
680 | + ); |
|
681 | + } |
|
682 | 682 | } |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function is_espresso_event($event = null): bool |
24 | 24 | { |
25 | - if (! can_use_espresso_conditionals(__FUNCTION__)) { |
|
26 | - return false; |
|
27 | - } |
|
28 | - // extract EE_Event object from passed param regardless of what it is (within reason of course) |
|
29 | - $event = EEH_Event_View::get_event($event); |
|
30 | - // do we have a valid event ? |
|
31 | - return $event instanceof EE_Event; |
|
25 | + if (! can_use_espresso_conditionals(__FUNCTION__)) { |
|
26 | + return false; |
|
27 | + } |
|
28 | + // extract EE_Event object from passed param regardless of what it is (within reason of course) |
|
29 | + $event = EEH_Event_View::get_event($event); |
|
30 | + // do we have a valid event ? |
|
31 | + return $event instanceof EE_Event; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -39,14 +39,14 @@ discard block |
||
39 | 39 | */ |
40 | 40 | function is_espresso_event_single(): bool |
41 | 41 | { |
42 | - if (! can_use_espresso_conditionals(__FUNCTION__)) { |
|
43 | - return false; |
|
44 | - } |
|
45 | - global $wp_query; |
|
46 | - // return conditionals set by CPTs |
|
47 | - return $wp_query instanceof WP_Query |
|
48 | - && isset($wp_query->is_espresso_event_single) |
|
49 | - && $wp_query->is_espresso_event_single; |
|
42 | + if (! can_use_espresso_conditionals(__FUNCTION__)) { |
|
43 | + return false; |
|
44 | + } |
|
45 | + global $wp_query; |
|
46 | + // return conditionals set by CPTs |
|
47 | + return $wp_query instanceof WP_Query |
|
48 | + && isset($wp_query->is_espresso_event_single) |
|
49 | + && $wp_query->is_espresso_event_single; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | */ |
58 | 58 | function is_espresso_event_archive(): bool |
59 | 59 | { |
60 | - if (! can_use_espresso_conditionals(__FUNCTION__)) { |
|
61 | - return false; |
|
62 | - } |
|
63 | - global $wp_query; |
|
64 | - return $wp_query instanceof WP_Query |
|
65 | - && isset($wp_query->is_espresso_event_archive) |
|
66 | - && $wp_query->is_espresso_event_archive; |
|
60 | + if (! can_use_espresso_conditionals(__FUNCTION__)) { |
|
61 | + return false; |
|
62 | + } |
|
63 | + global $wp_query; |
|
64 | + return $wp_query instanceof WP_Query |
|
65 | + && isset($wp_query->is_espresso_event_archive) |
|
66 | + && $wp_query->is_espresso_event_archive; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -74,13 +74,13 @@ discard block |
||
74 | 74 | */ |
75 | 75 | function is_espresso_event_taxonomy(): bool |
76 | 76 | { |
77 | - if (! can_use_espresso_conditionals(__FUNCTION__)) { |
|
78 | - return false; |
|
79 | - } |
|
80 | - global $wp_query; |
|
81 | - return $wp_query instanceof WP_Query |
|
82 | - && isset($wp_query->is_espresso_event_taxonomy) |
|
83 | - && $wp_query->is_espresso_event_taxonomy; |
|
77 | + if (! can_use_espresso_conditionals(__FUNCTION__)) { |
|
78 | + return false; |
|
79 | + } |
|
80 | + global $wp_query; |
|
81 | + return $wp_query instanceof WP_Query |
|
82 | + && isset($wp_query->is_espresso_event_taxonomy) |
|
83 | + && $wp_query->is_espresso_event_taxonomy; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -94,13 +94,13 @@ discard block |
||
94 | 94 | */ |
95 | 95 | function is_espresso_venue($venue = null): bool |
96 | 96 | { |
97 | - if (! can_use_espresso_conditionals(__FUNCTION__)) { |
|
98 | - return false; |
|
99 | - } |
|
100 | - // extract EE_Venue object from passed param regardless of what it is (within reason of course) |
|
101 | - $venue = EEH_Venue_View::get_venue($venue, false); |
|
102 | - // do we have a valid event ? |
|
103 | - return $venue instanceof EE_Venue; |
|
97 | + if (! can_use_espresso_conditionals(__FUNCTION__)) { |
|
98 | + return false; |
|
99 | + } |
|
100 | + // extract EE_Venue object from passed param regardless of what it is (within reason of course) |
|
101 | + $venue = EEH_Venue_View::get_venue($venue, false); |
|
102 | + // do we have a valid event ? |
|
103 | + return $venue instanceof EE_Venue; |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | */ |
112 | 112 | function is_espresso_venue_single(): bool |
113 | 113 | { |
114 | - if (! can_use_espresso_conditionals(__FUNCTION__)) { |
|
115 | - return false; |
|
116 | - } |
|
117 | - global $wp_query; |
|
118 | - return $wp_query instanceof WP_Query |
|
119 | - && isset($wp_query->is_espresso_venue_single) |
|
120 | - && $wp_query->is_espresso_venue_single; |
|
114 | + if (! can_use_espresso_conditionals(__FUNCTION__)) { |
|
115 | + return false; |
|
116 | + } |
|
117 | + global $wp_query; |
|
118 | + return $wp_query instanceof WP_Query |
|
119 | + && isset($wp_query->is_espresso_venue_single) |
|
120 | + && $wp_query->is_espresso_venue_single; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -128,13 +128,13 @@ discard block |
||
128 | 128 | */ |
129 | 129 | function is_espresso_venue_archive(): bool |
130 | 130 | { |
131 | - if (! can_use_espresso_conditionals(__FUNCTION__)) { |
|
132 | - return false; |
|
133 | - } |
|
134 | - global $wp_query; |
|
135 | - return $wp_query instanceof WP_Query |
|
136 | - && isset($wp_query->is_espresso_venue_archive) |
|
137 | - && $wp_query->is_espresso_venue_archive; |
|
131 | + if (! can_use_espresso_conditionals(__FUNCTION__)) { |
|
132 | + return false; |
|
133 | + } |
|
134 | + global $wp_query; |
|
135 | + return $wp_query instanceof WP_Query |
|
136 | + && isset($wp_query->is_espresso_venue_archive) |
|
137 | + && $wp_query->is_espresso_venue_archive; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -145,13 +145,13 @@ discard block |
||
145 | 145 | */ |
146 | 146 | function is_espresso_venue_taxonomy(): bool |
147 | 147 | { |
148 | - if (! can_use_espresso_conditionals(__FUNCTION__)) { |
|
149 | - return false; |
|
150 | - } |
|
151 | - global $wp_query; |
|
152 | - return $wp_query instanceof WP_Query |
|
153 | - && isset($wp_query->is_espresso_venue_taxonomy) |
|
154 | - && $wp_query->is_espresso_venue_taxonomy; |
|
148 | + if (! can_use_espresso_conditionals(__FUNCTION__)) { |
|
149 | + return false; |
|
150 | + } |
|
151 | + global $wp_query; |
|
152 | + return $wp_query instanceof WP_Query |
|
153 | + && isset($wp_query->is_espresso_venue_taxonomy) |
|
154 | + && $wp_query->is_espresso_venue_taxonomy; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -163,62 +163,62 @@ discard block |
||
163 | 163 | */ |
164 | 164 | function can_use_espresso_conditionals($conditional_tag): bool |
165 | 165 | { |
166 | - if (! did_action('AHEE__EE_System__initialize')) { |
|
167 | - EE_Error::doing_it_wrong( |
|
168 | - __FUNCTION__, |
|
169 | - sprintf( |
|
170 | - esc_html__( |
|
171 | - 'The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.', |
|
172 | - 'event_espresso' |
|
173 | - ), |
|
174 | - $conditional_tag |
|
175 | - ), |
|
176 | - '4.4.0' |
|
177 | - ); |
|
178 | - return false; |
|
179 | - } |
|
180 | - return true; |
|
166 | + if (! did_action('AHEE__EE_System__initialize')) { |
|
167 | + EE_Error::doing_it_wrong( |
|
168 | + __FUNCTION__, |
|
169 | + sprintf( |
|
170 | + esc_html__( |
|
171 | + 'The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.', |
|
172 | + 'event_espresso' |
|
173 | + ), |
|
174 | + $conditional_tag |
|
175 | + ), |
|
176 | + '4.4.0' |
|
177 | + ); |
|
178 | + return false; |
|
179 | + } |
|
180 | + return true; |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | |
184 | 184 | /*************************** Event Queries ***************************/ |
185 | 185 | |
186 | 186 | if (! function_exists('espresso_get_events')) { |
187 | - /** |
|
188 | - * espresso_get_events |
|
189 | - * |
|
190 | - * @param array $params |
|
191 | - * @return array |
|
192 | - */ |
|
193 | - function espresso_get_events($params = []) |
|
194 | - { |
|
195 | - //set default params |
|
196 | - $default_espresso_events_params = [ |
|
197 | - 'limit' => 10, |
|
198 | - 'show_expired' => false, |
|
199 | - 'month' => null, |
|
200 | - 'category_slug' => null, |
|
201 | - 'order_by' => 'start_date', |
|
202 | - 'sort' => 'ASC', |
|
203 | - ]; |
|
204 | - // allow the defaults to be filtered |
|
205 | - $default_espresso_events_params = apply_filters( |
|
206 | - 'espresso_get_events__default_espresso_events_params', |
|
207 | - $default_espresso_events_params |
|
208 | - ); |
|
209 | - // grab params and merge with defaults, then extract |
|
210 | - $params = array_merge($default_espresso_events_params, $params); |
|
211 | - // run the query |
|
212 | - $events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery($params); |
|
213 | - // assign results to a variable so we can return it |
|
214 | - $events = $events_query->have_posts() ? $events_query->posts : []; |
|
215 | - // but first reset the query and postdata |
|
216 | - wp_reset_query(); |
|
217 | - wp_reset_postdata(); |
|
218 | - EED_Events_Archive::remove_all_events_archive_filters(); |
|
219 | - unset($events_query); |
|
220 | - return $events; |
|
221 | - } |
|
187 | + /** |
|
188 | + * espresso_get_events |
|
189 | + * |
|
190 | + * @param array $params |
|
191 | + * @return array |
|
192 | + */ |
|
193 | + function espresso_get_events($params = []) |
|
194 | + { |
|
195 | + //set default params |
|
196 | + $default_espresso_events_params = [ |
|
197 | + 'limit' => 10, |
|
198 | + 'show_expired' => false, |
|
199 | + 'month' => null, |
|
200 | + 'category_slug' => null, |
|
201 | + 'order_by' => 'start_date', |
|
202 | + 'sort' => 'ASC', |
|
203 | + ]; |
|
204 | + // allow the defaults to be filtered |
|
205 | + $default_espresso_events_params = apply_filters( |
|
206 | + 'espresso_get_events__default_espresso_events_params', |
|
207 | + $default_espresso_events_params |
|
208 | + ); |
|
209 | + // grab params and merge with defaults, then extract |
|
210 | + $params = array_merge($default_espresso_events_params, $params); |
|
211 | + // run the query |
|
212 | + $events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery($params); |
|
213 | + // assign results to a variable so we can return it |
|
214 | + $events = $events_query->have_posts() ? $events_query->posts : []; |
|
215 | + // but first reset the query and postdata |
|
216 | + wp_reset_query(); |
|
217 | + wp_reset_postdata(); |
|
218 | + EED_Events_Archive::remove_all_events_archive_filters(); |
|
219 | + unset($events_query); |
|
220 | + return $events; |
|
221 | + } |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | |
@@ -233,115 +233,115 @@ discard block |
||
233 | 233 | */ |
234 | 234 | function espresso_load_ticket_selector() |
235 | 235 | { |
236 | - EE_Registry::instance()->load_file(EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module'); |
|
236 | + EE_Registry::instance()->load_file(EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module'); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | if (! function_exists('espresso_ticket_selector')) { |
240 | - /** |
|
241 | - * espresso_ticket_selector |
|
242 | - * |
|
243 | - * @param null $event |
|
244 | - * @throws EE_Error |
|
245 | - * @throws ReflectionException |
|
246 | - */ |
|
247 | - function espresso_ticket_selector($event = null) |
|
248 | - { |
|
249 | - if (! apply_filters('FHEE_disable_espresso_ticket_selector', false)) { |
|
250 | - espresso_load_ticket_selector(); |
|
251 | - EED_Ticket_Selector::set_definitions(); |
|
252 | - echo EED_Ticket_Selector::display_ticket_selector($event); // already escaped |
|
253 | - } |
|
254 | - } |
|
240 | + /** |
|
241 | + * espresso_ticket_selector |
|
242 | + * |
|
243 | + * @param null $event |
|
244 | + * @throws EE_Error |
|
245 | + * @throws ReflectionException |
|
246 | + */ |
|
247 | + function espresso_ticket_selector($event = null) |
|
248 | + { |
|
249 | + if (! apply_filters('FHEE_disable_espresso_ticket_selector', false)) { |
|
250 | + espresso_load_ticket_selector(); |
|
251 | + EED_Ticket_Selector::set_definitions(); |
|
252 | + echo EED_Ticket_Selector::display_ticket_selector($event); // already escaped |
|
253 | + } |
|
254 | + } |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | |
258 | 258 | if (! function_exists('espresso_view_details_btn')) { |
259 | - /** |
|
260 | - * espresso_view_details_btn |
|
261 | - * |
|
262 | - * @param null $event |
|
263 | - * @throws EE_Error |
|
264 | - * @throws ReflectionException |
|
265 | - */ |
|
266 | - function espresso_view_details_btn($event = null) |
|
267 | - { |
|
268 | - if (! apply_filters('FHEE_disable_espresso_view_details_btn', false)) { |
|
269 | - espresso_load_ticket_selector(); |
|
270 | - echo EED_Ticket_Selector::display_ticket_selector($event, true); // already escaped |
|
271 | - } |
|
272 | - } |
|
259 | + /** |
|
260 | + * espresso_view_details_btn |
|
261 | + * |
|
262 | + * @param null $event |
|
263 | + * @throws EE_Error |
|
264 | + * @throws ReflectionException |
|
265 | + */ |
|
266 | + function espresso_view_details_btn($event = null) |
|
267 | + { |
|
268 | + if (! apply_filters('FHEE_disable_espresso_view_details_btn', false)) { |
|
269 | + espresso_load_ticket_selector(); |
|
270 | + echo EED_Ticket_Selector::display_ticket_selector($event, true); // already escaped |
|
271 | + } |
|
272 | + } |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | |
276 | 276 | /*************************** EEH_Event_View ***************************/ |
277 | 277 | |
278 | 278 | if (! function_exists('espresso_load_event_list_assets')) { |
279 | - /** |
|
280 | - * espresso_load_event_list_assets |
|
281 | - * ensures that event list styles and scripts are loaded |
|
282 | - * |
|
283 | - * @return void |
|
284 | - */ |
|
285 | - function espresso_load_event_list_assets() |
|
286 | - { |
|
287 | - $event_list = EED_Events_Archive::instance(); |
|
288 | - add_action('AHEE__EE_System__initialize_last', [$event_list, 'load_event_list_assets'], 10); |
|
289 | - add_filter('FHEE_enable_default_espresso_css', '__return_true'); |
|
290 | - } |
|
279 | + /** |
|
280 | + * espresso_load_event_list_assets |
|
281 | + * ensures that event list styles and scripts are loaded |
|
282 | + * |
|
283 | + * @return void |
|
284 | + */ |
|
285 | + function espresso_load_event_list_assets() |
|
286 | + { |
|
287 | + $event_list = EED_Events_Archive::instance(); |
|
288 | + add_action('AHEE__EE_System__initialize_last', [$event_list, 'load_event_list_assets'], 10); |
|
289 | + add_filter('FHEE_enable_default_espresso_css', '__return_true'); |
|
290 | + } |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | |
294 | 294 | if (! function_exists('espresso_event_reg_button')) { |
295 | - /** |
|
296 | - * espresso_event_reg_button |
|
297 | - * returns the "Register Now" button if event is active, |
|
298 | - * an inactive button like status banner if the event is not active |
|
299 | - * or a "Read More" button if so desired |
|
300 | - * |
|
301 | - * @param null $btn_text_if_active |
|
302 | - * @param bool $btn_text_if_inactive |
|
303 | - * @param bool $EVT_ID |
|
304 | - * @return void |
|
305 | - * @throws EE_Error |
|
306 | - * @throws ReflectionException |
|
307 | - */ |
|
308 | - function espresso_event_reg_button($btn_text_if_active = null, $btn_text_if_inactive = false, $EVT_ID = false) |
|
309 | - { |
|
310 | - $event = EEH_Event_View::get_event($EVT_ID); |
|
311 | - if (! $event instanceof EE_Event) { |
|
312 | - return; |
|
313 | - } |
|
314 | - $event_status = $event->get_active_status(); |
|
315 | - switch ($event_status) { |
|
316 | - case EE_Datetime::sold_out : |
|
317 | - $btn_text = __('Sold Out', 'event_espresso'); |
|
318 | - $class = 'ee-pink'; |
|
319 | - break; |
|
320 | - case EE_Datetime::expired : |
|
321 | - $btn_text = __('Event is Over', 'event_espresso'); |
|
322 | - $class = 'ee-grey'; |
|
323 | - break; |
|
324 | - case EE_Datetime::inactive : |
|
325 | - $btn_text = __('Event Not Active', 'event_espresso'); |
|
326 | - $class = 'ee-grey'; |
|
327 | - break; |
|
328 | - case EE_Datetime::cancelled : |
|
329 | - $btn_text = __('Event was Cancelled', 'event_espresso'); |
|
330 | - $class = 'ee-red'; |
|
331 | - break; |
|
332 | - case EE_Datetime::upcoming : |
|
333 | - case EE_Datetime::active : |
|
334 | - default : |
|
335 | - $btn_text = ! empty($btn_text_if_active) |
|
336 | - ? $btn_text_if_active |
|
337 | - : __('Register Now', 'event_espresso'); |
|
338 | - $class = 'ee-green'; |
|
339 | - } |
|
340 | - if ($event_status < 1 && ! empty($btn_text_if_inactive)) { |
|
341 | - $btn_text = $btn_text_if_inactive; |
|
342 | - $class = 'ee-grey'; |
|
343 | - } |
|
344 | - ?> |
|
295 | + /** |
|
296 | + * espresso_event_reg_button |
|
297 | + * returns the "Register Now" button if event is active, |
|
298 | + * an inactive button like status banner if the event is not active |
|
299 | + * or a "Read More" button if so desired |
|
300 | + * |
|
301 | + * @param null $btn_text_if_active |
|
302 | + * @param bool $btn_text_if_inactive |
|
303 | + * @param bool $EVT_ID |
|
304 | + * @return void |
|
305 | + * @throws EE_Error |
|
306 | + * @throws ReflectionException |
|
307 | + */ |
|
308 | + function espresso_event_reg_button($btn_text_if_active = null, $btn_text_if_inactive = false, $EVT_ID = false) |
|
309 | + { |
|
310 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
311 | + if (! $event instanceof EE_Event) { |
|
312 | + return; |
|
313 | + } |
|
314 | + $event_status = $event->get_active_status(); |
|
315 | + switch ($event_status) { |
|
316 | + case EE_Datetime::sold_out : |
|
317 | + $btn_text = __('Sold Out', 'event_espresso'); |
|
318 | + $class = 'ee-pink'; |
|
319 | + break; |
|
320 | + case EE_Datetime::expired : |
|
321 | + $btn_text = __('Event is Over', 'event_espresso'); |
|
322 | + $class = 'ee-grey'; |
|
323 | + break; |
|
324 | + case EE_Datetime::inactive : |
|
325 | + $btn_text = __('Event Not Active', 'event_espresso'); |
|
326 | + $class = 'ee-grey'; |
|
327 | + break; |
|
328 | + case EE_Datetime::cancelled : |
|
329 | + $btn_text = __('Event was Cancelled', 'event_espresso'); |
|
330 | + $class = 'ee-red'; |
|
331 | + break; |
|
332 | + case EE_Datetime::upcoming : |
|
333 | + case EE_Datetime::active : |
|
334 | + default : |
|
335 | + $btn_text = ! empty($btn_text_if_active) |
|
336 | + ? $btn_text_if_active |
|
337 | + : __('Register Now', 'event_espresso'); |
|
338 | + $class = 'ee-green'; |
|
339 | + } |
|
340 | + if ($event_status < 1 && ! empty($btn_text_if_inactive)) { |
|
341 | + $btn_text = $btn_text_if_inactive; |
|
342 | + $class = 'ee-grey'; |
|
343 | + } |
|
344 | + ?> |
|
345 | 345 | <a class="ee-button ee-register-button <?php echo esc_attr($class); ?>" |
346 | 346 | href="<?php espresso_event_link_url($EVT_ID); ?>" |
347 | 347 | <?php echo AttributesSanitizer::clean(EED_Events_Archive::link_target(), AllowedTags::getAllowedTags(), 'a'); ?> |
@@ -349,244 +349,244 @@ discard block |
||
349 | 349 | <?php echo esc_html($btn_text); ?> |
350 | 350 | </a> |
351 | 351 | <?php |
352 | - } |
|
352 | + } |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | |
356 | 356 | if (! function_exists('espresso_display_ticket_selector')) { |
357 | - /** |
|
358 | - * espresso_display_ticket_selector |
|
359 | - * whether or not to display the Ticket Selector for an event |
|
360 | - * |
|
361 | - * @param bool $EVT_ID |
|
362 | - * @return boolean |
|
363 | - * @throws EE_Error |
|
364 | - * @throws ReflectionException |
|
365 | - */ |
|
366 | - function espresso_display_ticket_selector($EVT_ID = false) |
|
367 | - { |
|
368 | - return EEH_Event_View::display_ticket_selector($EVT_ID); |
|
369 | - } |
|
357 | + /** |
|
358 | + * espresso_display_ticket_selector |
|
359 | + * whether or not to display the Ticket Selector for an event |
|
360 | + * |
|
361 | + * @param bool $EVT_ID |
|
362 | + * @return boolean |
|
363 | + * @throws EE_Error |
|
364 | + * @throws ReflectionException |
|
365 | + */ |
|
366 | + function espresso_display_ticket_selector($EVT_ID = false) |
|
367 | + { |
|
368 | + return EEH_Event_View::display_ticket_selector($EVT_ID); |
|
369 | + } |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | |
373 | 373 | if (! function_exists('espresso_event_status_banner')) { |
374 | - /** |
|
375 | - * espresso_event_status |
|
376 | - * returns a banner showing the event status if it is sold out, expired, or inactive |
|
377 | - * |
|
378 | - * @param bool $EVT_ID |
|
379 | - * @return string |
|
380 | - * @throws EE_Error |
|
381 | - * @throws ReflectionException |
|
382 | - */ |
|
383 | - function espresso_event_status_banner($EVT_ID = false) |
|
384 | - { |
|
385 | - return EEH_Event_View::event_status($EVT_ID); |
|
386 | - } |
|
374 | + /** |
|
375 | + * espresso_event_status |
|
376 | + * returns a banner showing the event status if it is sold out, expired, or inactive |
|
377 | + * |
|
378 | + * @param bool $EVT_ID |
|
379 | + * @return string |
|
380 | + * @throws EE_Error |
|
381 | + * @throws ReflectionException |
|
382 | + */ |
|
383 | + function espresso_event_status_banner($EVT_ID = false) |
|
384 | + { |
|
385 | + return EEH_Event_View::event_status($EVT_ID); |
|
386 | + } |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | |
390 | 390 | if (! function_exists('espresso_event_status')) { |
391 | - /** |
|
392 | - * espresso_event_status |
|
393 | - * returns the event status if it is sold out, expired, or inactive |
|
394 | - * |
|
395 | - * @param int $EVT_ID |
|
396 | - * @param bool $echo |
|
397 | - * @return string |
|
398 | - * @throws EE_Error |
|
399 | - * @throws ReflectionException |
|
400 | - */ |
|
401 | - function espresso_event_status($EVT_ID = 0, $echo = true) |
|
402 | - { |
|
403 | - return EEH_Event_View::event_active_status($EVT_ID, $echo); |
|
404 | - } |
|
391 | + /** |
|
392 | + * espresso_event_status |
|
393 | + * returns the event status if it is sold out, expired, or inactive |
|
394 | + * |
|
395 | + * @param int $EVT_ID |
|
396 | + * @param bool $echo |
|
397 | + * @return string |
|
398 | + * @throws EE_Error |
|
399 | + * @throws ReflectionException |
|
400 | + */ |
|
401 | + function espresso_event_status($EVT_ID = 0, $echo = true) |
|
402 | + { |
|
403 | + return EEH_Event_View::event_active_status($EVT_ID, $echo); |
|
404 | + } |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | |
408 | 408 | if (! function_exists('espresso_event_categories')) { |
409 | - /** |
|
410 | - * espresso_event_categories |
|
411 | - * returns the terms associated with an event |
|
412 | - * |
|
413 | - * @param int $EVT_ID |
|
414 | - * @param bool $hide_uncategorized |
|
415 | - * @param bool $echo |
|
416 | - * @return string |
|
417 | - * @throws EE_Error |
|
418 | - * @throws ReflectionException |
|
419 | - */ |
|
420 | - function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = true, $echo = true) |
|
421 | - { |
|
422 | - if ($echo) { |
|
423 | - echo wp_kses(EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized), AllowedTags::getWithFormTags()); |
|
424 | - return ''; |
|
425 | - } |
|
426 | - return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); |
|
427 | - } |
|
409 | + /** |
|
410 | + * espresso_event_categories |
|
411 | + * returns the terms associated with an event |
|
412 | + * |
|
413 | + * @param int $EVT_ID |
|
414 | + * @param bool $hide_uncategorized |
|
415 | + * @param bool $echo |
|
416 | + * @return string |
|
417 | + * @throws EE_Error |
|
418 | + * @throws ReflectionException |
|
419 | + */ |
|
420 | + function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = true, $echo = true) |
|
421 | + { |
|
422 | + if ($echo) { |
|
423 | + echo wp_kses(EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized), AllowedTags::getWithFormTags()); |
|
424 | + return ''; |
|
425 | + } |
|
426 | + return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); |
|
427 | + } |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | |
431 | 431 | if (! function_exists('espresso_event_tickets_available')) { |
432 | - /** |
|
433 | - * espresso_event_tickets_available |
|
434 | - * returns the ticket types available for purchase for an event |
|
435 | - * |
|
436 | - * @param int $EVT_ID |
|
437 | - * @param bool $echo |
|
438 | - * @param bool $format |
|
439 | - * @return string |
|
440 | - * @throws EE_Error |
|
441 | - * @throws ReflectionException |
|
442 | - */ |
|
443 | - function espresso_event_tickets_available($EVT_ID = 0, $echo = true, $format = true) |
|
444 | - { |
|
445 | - $tickets = EEH_Event_View::event_tickets_available($EVT_ID); |
|
446 | - if (is_array($tickets) && ! empty($tickets)) { |
|
447 | - // if formatting then $html will be a string, else it will be an array of ticket objects |
|
448 | - $html = |
|
449 | - $format ? '<ul id="ee-event-tickets-ul-' . esc_attr($EVT_ID) . '" class="ee-event-tickets-ul">' : []; |
|
450 | - foreach ($tickets as $ticket) { |
|
451 | - if ($ticket instanceof EE_Ticket) { |
|
452 | - if ($format) { |
|
453 | - $html .= '<li id="ee-event-tickets-li-' |
|
454 | - . esc_attr($ticket->ID()) |
|
455 | - . '" class="ee-event-tickets-li">'; |
|
456 | - $html .= esc_html($ticket->name()) . ' '; |
|
457 | - $html .= EEH_Template::format_currency( |
|
458 | - $ticket->get_ticket_total_with_taxes() |
|
459 | - ); // already escaped |
|
460 | - $html .= '</li>'; |
|
461 | - } else { |
|
462 | - $html[] = $ticket; |
|
463 | - } |
|
464 | - } |
|
465 | - } |
|
466 | - if ($format) { |
|
467 | - $html .= '</ul>'; |
|
468 | - } |
|
469 | - if ($echo && $format) { |
|
470 | - echo wp_kses($html, AllowedTags::getAllowedTags()); |
|
471 | - return ''; |
|
472 | - } |
|
473 | - return $html; |
|
474 | - } |
|
475 | - return ''; |
|
476 | - } |
|
432 | + /** |
|
433 | + * espresso_event_tickets_available |
|
434 | + * returns the ticket types available for purchase for an event |
|
435 | + * |
|
436 | + * @param int $EVT_ID |
|
437 | + * @param bool $echo |
|
438 | + * @param bool $format |
|
439 | + * @return string |
|
440 | + * @throws EE_Error |
|
441 | + * @throws ReflectionException |
|
442 | + */ |
|
443 | + function espresso_event_tickets_available($EVT_ID = 0, $echo = true, $format = true) |
|
444 | + { |
|
445 | + $tickets = EEH_Event_View::event_tickets_available($EVT_ID); |
|
446 | + if (is_array($tickets) && ! empty($tickets)) { |
|
447 | + // if formatting then $html will be a string, else it will be an array of ticket objects |
|
448 | + $html = |
|
449 | + $format ? '<ul id="ee-event-tickets-ul-' . esc_attr($EVT_ID) . '" class="ee-event-tickets-ul">' : []; |
|
450 | + foreach ($tickets as $ticket) { |
|
451 | + if ($ticket instanceof EE_Ticket) { |
|
452 | + if ($format) { |
|
453 | + $html .= '<li id="ee-event-tickets-li-' |
|
454 | + . esc_attr($ticket->ID()) |
|
455 | + . '" class="ee-event-tickets-li">'; |
|
456 | + $html .= esc_html($ticket->name()) . ' '; |
|
457 | + $html .= EEH_Template::format_currency( |
|
458 | + $ticket->get_ticket_total_with_taxes() |
|
459 | + ); // already escaped |
|
460 | + $html .= '</li>'; |
|
461 | + } else { |
|
462 | + $html[] = $ticket; |
|
463 | + } |
|
464 | + } |
|
465 | + } |
|
466 | + if ($format) { |
|
467 | + $html .= '</ul>'; |
|
468 | + } |
|
469 | + if ($echo && $format) { |
|
470 | + echo wp_kses($html, AllowedTags::getAllowedTags()); |
|
471 | + return ''; |
|
472 | + } |
|
473 | + return $html; |
|
474 | + } |
|
475 | + return ''; |
|
476 | + } |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | if (! function_exists('espresso_event_date_obj')) { |
480 | - /** |
|
481 | - * espresso_event_date_obj |
|
482 | - * returns the primary date object for an event |
|
483 | - * |
|
484 | - * @param bool $EVT_ID |
|
485 | - * @return EE_Datetime|null |
|
486 | - * @throws EE_Error |
|
487 | - * @throws ReflectionException |
|
488 | - */ |
|
489 | - function espresso_event_date_obj($EVT_ID = false) |
|
490 | - { |
|
491 | - return EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
492 | - } |
|
480 | + /** |
|
481 | + * espresso_event_date_obj |
|
482 | + * returns the primary date object for an event |
|
483 | + * |
|
484 | + * @param bool $EVT_ID |
|
485 | + * @return EE_Datetime|null |
|
486 | + * @throws EE_Error |
|
487 | + * @throws ReflectionException |
|
488 | + */ |
|
489 | + function espresso_event_date_obj($EVT_ID = false) |
|
490 | + { |
|
491 | + return EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
492 | + } |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | |
496 | 496 | if (! function_exists('espresso_event_date')) { |
497 | - /** |
|
498 | - * espresso_event_date |
|
499 | - * returns the primary date for an event |
|
500 | - * |
|
501 | - * @param string $date_format |
|
502 | - * @param string $time_format |
|
503 | - * @param bool $EVT_ID |
|
504 | - * @param bool $echo |
|
505 | - * @return string |
|
506 | - * @throws EE_Error |
|
507 | - * @throws ReflectionException |
|
508 | - */ |
|
509 | - function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = false, $echo = true) |
|
510 | - { |
|
511 | - $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
512 | - $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
513 | - $date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format); |
|
514 | - $time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format); |
|
515 | - if ($echo) { |
|
516 | - echo wp_kses(EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID), AllowedTags::getWithFormTags()); |
|
517 | - return ''; |
|
518 | - } |
|
519 | - return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); |
|
520 | - |
|
521 | - } |
|
497 | + /** |
|
498 | + * espresso_event_date |
|
499 | + * returns the primary date for an event |
|
500 | + * |
|
501 | + * @param string $date_format |
|
502 | + * @param string $time_format |
|
503 | + * @param bool $EVT_ID |
|
504 | + * @param bool $echo |
|
505 | + * @return string |
|
506 | + * @throws EE_Error |
|
507 | + * @throws ReflectionException |
|
508 | + */ |
|
509 | + function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = false, $echo = true) |
|
510 | + { |
|
511 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
512 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
513 | + $date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format); |
|
514 | + $time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format); |
|
515 | + if ($echo) { |
|
516 | + echo wp_kses(EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID), AllowedTags::getWithFormTags()); |
|
517 | + return ''; |
|
518 | + } |
|
519 | + return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); |
|
520 | + |
|
521 | + } |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | |
525 | 525 | if (! function_exists('espresso_list_of_event_dates')) { |
526 | - /** |
|
527 | - * espresso_list_of_event_dates |
|
528 | - * returns a unordered list of dates for an event |
|
529 | - * |
|
530 | - * @param int $EVT_ID |
|
531 | - * @param string $date_format |
|
532 | - * @param string $time_format |
|
533 | - * @param bool $echo |
|
534 | - * @param null $show_expired |
|
535 | - * @param bool $format |
|
536 | - * @param bool $add_breaks |
|
537 | - * @param null $limit |
|
538 | - * @return string |
|
539 | - * @throws EE_Error |
|
540 | - * @throws ReflectionException |
|
541 | - */ |
|
542 | - function espresso_list_of_event_dates( |
|
543 | - $EVT_ID = 0, |
|
544 | - $date_format = '', |
|
545 | - $time_format = '', |
|
546 | - $echo = true, |
|
547 | - $show_expired = null, |
|
548 | - $format = true, |
|
549 | - $add_breaks = true, |
|
550 | - $limit = null |
|
551 | - ) { |
|
552 | - $allowedtags = AllowedTags::getAllowedTags(); |
|
553 | - |
|
554 | - $DTT_ID = LoaderFactory::getShared(RequestInterface::class)->getRequestParam('datetime', 0, 'int'); |
|
555 | - $arguments = apply_filters( |
|
556 | - 'FHEE__espresso_list_of_event_dates__arguments', |
|
557 | - [ $EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit, $DTT_ID ] |
|
558 | - ); |
|
559 | - [$EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit, $DTT_ID] = $arguments; |
|
560 | - $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
561 | - $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
562 | - $date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format); |
|
563 | - $time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format); |
|
564 | - $datetimes = $DTT_ID |
|
565 | - ? [EEH_Event_View::get_date_obj($DTT_ID)] |
|
566 | - : EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, false, (int) $limit); |
|
567 | - if (! $format) { |
|
568 | - return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes); |
|
569 | - } |
|
570 | - $newline = $add_breaks ? '<br />' : ''; |
|
571 | - if (is_array($datetimes) && ! empty($datetimes)) { |
|
572 | - global $post; |
|
526 | + /** |
|
527 | + * espresso_list_of_event_dates |
|
528 | + * returns a unordered list of dates for an event |
|
529 | + * |
|
530 | + * @param int $EVT_ID |
|
531 | + * @param string $date_format |
|
532 | + * @param string $time_format |
|
533 | + * @param bool $echo |
|
534 | + * @param null $show_expired |
|
535 | + * @param bool $format |
|
536 | + * @param bool $add_breaks |
|
537 | + * @param null $limit |
|
538 | + * @return string |
|
539 | + * @throws EE_Error |
|
540 | + * @throws ReflectionException |
|
541 | + */ |
|
542 | + function espresso_list_of_event_dates( |
|
543 | + $EVT_ID = 0, |
|
544 | + $date_format = '', |
|
545 | + $time_format = '', |
|
546 | + $echo = true, |
|
547 | + $show_expired = null, |
|
548 | + $format = true, |
|
549 | + $add_breaks = true, |
|
550 | + $limit = null |
|
551 | + ) { |
|
552 | + $allowedtags = AllowedTags::getAllowedTags(); |
|
553 | + |
|
554 | + $DTT_ID = LoaderFactory::getShared(RequestInterface::class)->getRequestParam('datetime', 0, 'int'); |
|
555 | + $arguments = apply_filters( |
|
556 | + 'FHEE__espresso_list_of_event_dates__arguments', |
|
557 | + [ $EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit, $DTT_ID ] |
|
558 | + ); |
|
559 | + [$EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit, $DTT_ID] = $arguments; |
|
560 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
561 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
562 | + $date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format); |
|
563 | + $time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format); |
|
564 | + $datetimes = $DTT_ID |
|
565 | + ? [EEH_Event_View::get_date_obj($DTT_ID)] |
|
566 | + : EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, false, (int) $limit); |
|
567 | + if (! $format) { |
|
568 | + return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes); |
|
569 | + } |
|
570 | + $newline = $add_breaks ? '<br />' : ''; |
|
571 | + if (is_array($datetimes) && ! empty($datetimes)) { |
|
572 | + global $post; |
|
573 | 573 | $cols = count($datetimes); |
574 | 574 | $cols = $cols >= 3 ? 'big' : 'small'; |
575 | 575 | $ul_class = "ee-event-datetimes-ul ee-event-datetimes-ul--{$cols}"; |
576 | 576 | $html = '<ul id="ee-event-datetimes-ul-' . esc_attr($post->ID) . '" class="'. $ul_class.'">'; |
577 | - $datetime = null; |
|
578 | - foreach ($datetimes as $datetime) { |
|
579 | - if ($datetime instanceof EE_Datetime) { |
|
577 | + $datetime = null; |
|
578 | + foreach ($datetimes as $datetime) { |
|
579 | + if ($datetime instanceof EE_Datetime) { |
|
580 | 580 | |
581 | - $datetime_name = $datetime->name(); |
|
582 | - $datetime_html = ! empty($datetime_name) |
|
583 | - ? ' |
|
581 | + $datetime_name = $datetime->name(); |
|
582 | + $datetime_html = ! empty($datetime_name) |
|
583 | + ? ' |
|
584 | 584 | <strong class="ee-event-datetimes-li-date-name"> |
585 | 585 | ' . esc_html($datetime_name) . ' |
586 | 586 | </strong>' . $newline |
587 | - : ''; |
|
587 | + : ''; |
|
588 | 588 | |
589 | - $datetime_html .= ' |
|
589 | + $datetime_html .= ' |
|
590 | 590 | <span class="ee-event-datetimes-li-daterange"> |
591 | 591 | <span class="dashicons dashicons-calendar"></span> ' |
592 | 592 | . $datetime->date_range($date_format). ' |
@@ -598,501 +598,501 @@ discard block |
||
598 | 598 | </span> |
599 | 599 | '; |
600 | 600 | |
601 | - $venue = $datetime->venue(); |
|
602 | - if ($venue instanceof EE_Venue) { |
|
603 | - $venue_name = esc_html($venue->name()); |
|
604 | - $datetime_html .= '<br /><span class="ee-event-datetimes-li-venue">'; |
|
605 | - $datetime_html .= '<span class="dashicons dashicons-admin-home"></span> '; |
|
606 | - $datetime_html .= '<a href="'. esc_url_raw($venue->get_permalink()) .'" target="_blank">'; |
|
607 | - $datetime_html .= $venue_name . '</a></span>'; |
|
608 | - } |
|
609 | - |
|
610 | - $datetime_description = str_replace(['<p>', '</p>'], '', $datetime->description()); |
|
611 | - $datetime_html .= ! empty($datetime_description) |
|
612 | - ? ' |
|
601 | + $venue = $datetime->venue(); |
|
602 | + if ($venue instanceof EE_Venue) { |
|
603 | + $venue_name = esc_html($venue->name()); |
|
604 | + $datetime_html .= '<br /><span class="ee-event-datetimes-li-venue">'; |
|
605 | + $datetime_html .= '<span class="dashicons dashicons-admin-home"></span> '; |
|
606 | + $datetime_html .= '<a href="'. esc_url_raw($venue->get_permalink()) .'" target="_blank">'; |
|
607 | + $datetime_html .= $venue_name . '</a></span>'; |
|
608 | + } |
|
609 | + |
|
610 | + $datetime_description = str_replace(['<p>', '</p>'], '', $datetime->description()); |
|
611 | + $datetime_html .= ! empty($datetime_description) |
|
612 | + ? ' |
|
613 | 613 | <span class="ee-event-datetimes-li-date-desc"> |
614 | 614 | ' . wp_kses($datetime_description, $allowedtags) . ' |
615 | 615 | </span>' . $newline |
616 | - : ''; |
|
616 | + : ''; |
|
617 | 617 | |
618 | - $datetime_html = apply_filters( |
|
619 | - 'FHEE__espresso_list_of_event_dates__datetime_html', |
|
620 | - $datetime_html, |
|
621 | - $datetime, |
|
622 | - $arguments |
|
623 | - ); |
|
618 | + $datetime_html = apply_filters( |
|
619 | + 'FHEE__espresso_list_of_event_dates__datetime_html', |
|
620 | + $datetime_html, |
|
621 | + $datetime, |
|
622 | + $arguments |
|
623 | + ); |
|
624 | 624 | |
625 | - $DTD_ID = esc_attr($datetime->ID()); |
|
626 | - $active_status = esc_attr('ee-event-datetimes-li-' . $datetime->get_active_status()); |
|
625 | + $DTD_ID = esc_attr($datetime->ID()); |
|
626 | + $active_status = esc_attr('ee-event-datetimes-li-' . $datetime->get_active_status()); |
|
627 | 627 | |
628 | - $html .= ' |
|
628 | + $html .= ' |
|
629 | 629 | <li id="ee-event-datetimes-li-' . $DTD_ID . '" class="ee-event-datetimes-li ' . $active_status . '"> |
630 | 630 | ' . $datetime_html . ' |
631 | 631 | </li>'; |
632 | - } |
|
633 | - } |
|
634 | - $html .= '</ul>'; |
|
635 | - $html = apply_filters('FHEE__espresso_list_of_event_dates__html', $html, $arguments, $datetime); |
|
636 | - } else { |
|
637 | - $html = |
|
638 | - ' |
|
632 | + } |
|
633 | + } |
|
634 | + $html .= '</ul>'; |
|
635 | + $html = apply_filters('FHEE__espresso_list_of_event_dates__html', $html, $arguments, $datetime); |
|
636 | + } else { |
|
637 | + $html = |
|
638 | + ' |
|
639 | 639 | <p> |
640 | 640 | <span class="dashicons dashicons-marker pink-text"></span> |
641 | 641 | ' . esc_html__( |
642 | - 'There are no upcoming dates for this event.', |
|
643 | - 'event_espresso' |
|
644 | - ) . ' |
|
642 | + 'There are no upcoming dates for this event.', |
|
643 | + 'event_espresso' |
|
644 | + ) . ' |
|
645 | 645 | </p> |
646 | 646 | <br/>'; |
647 | - } |
|
648 | - if ($echo) { |
|
649 | - echo wp_kses($html, AllowedTags::getWithFormTags()); |
|
650 | - return ''; |
|
651 | - } |
|
652 | - return $html; |
|
653 | - } |
|
647 | + } |
|
648 | + if ($echo) { |
|
649 | + echo wp_kses($html, AllowedTags::getWithFormTags()); |
|
650 | + return ''; |
|
651 | + } |
|
652 | + return $html; |
|
653 | + } |
|
654 | 654 | } |
655 | 655 | |
656 | 656 | |
657 | 657 | if (! function_exists('espresso_event_end_date')) { |
658 | - /** |
|
659 | - * espresso_event_end_date |
|
660 | - * returns the last date for an event |
|
661 | - * |
|
662 | - * @param string $date_format |
|
663 | - * @param string $time_format |
|
664 | - * @param bool $EVT_ID |
|
665 | - * @param bool $echo |
|
666 | - * @return string |
|
667 | - * @throws EE_Error |
|
668 | - * @throws ReflectionException |
|
669 | - */ |
|
670 | - function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = false, $echo = true) |
|
671 | - { |
|
672 | - $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
673 | - $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
674 | - $date_format = apply_filters('FHEE__espresso_event_end_date__date_format', $date_format); |
|
675 | - $time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format); |
|
676 | - if ($echo) { |
|
677 | - echo wp_kses(EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID), AllowedTags::getWithFormTags()); |
|
678 | - return ''; |
|
679 | - } |
|
680 | - return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); |
|
681 | - } |
|
658 | + /** |
|
659 | + * espresso_event_end_date |
|
660 | + * returns the last date for an event |
|
661 | + * |
|
662 | + * @param string $date_format |
|
663 | + * @param string $time_format |
|
664 | + * @param bool $EVT_ID |
|
665 | + * @param bool $echo |
|
666 | + * @return string |
|
667 | + * @throws EE_Error |
|
668 | + * @throws ReflectionException |
|
669 | + */ |
|
670 | + function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = false, $echo = true) |
|
671 | + { |
|
672 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
673 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
674 | + $date_format = apply_filters('FHEE__espresso_event_end_date__date_format', $date_format); |
|
675 | + $time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format); |
|
676 | + if ($echo) { |
|
677 | + echo wp_kses(EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID), AllowedTags::getWithFormTags()); |
|
678 | + return ''; |
|
679 | + } |
|
680 | + return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); |
|
681 | + } |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | if (! function_exists('espresso_event_date_range')) { |
685 | - /** |
|
686 | - * espresso_event_date_range |
|
687 | - * returns the first and last chronologically ordered dates for an event (if different) |
|
688 | - * |
|
689 | - * @param string $date_format |
|
690 | - * @param string $time_format |
|
691 | - * @param string $single_date_format |
|
692 | - * @param string $single_time_format |
|
693 | - * @param bool $EVT_ID |
|
694 | - * @param bool $echo |
|
695 | - * @return string |
|
696 | - * @throws EE_Error |
|
697 | - * @throws ReflectionException |
|
698 | - */ |
|
699 | - function espresso_event_date_range( |
|
700 | - $date_format = '', |
|
701 | - $time_format = '', |
|
702 | - $single_date_format = '', |
|
703 | - $single_time_format = '', |
|
704 | - $EVT_ID = false, |
|
705 | - $echo = true |
|
706 | - ) { |
|
707 | - // set and filter date and time formats when a range is returned |
|
708 | - $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
709 | - $date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format); |
|
710 | - // get the start and end date with NO time portion |
|
711 | - $the_event_date = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID); |
|
712 | - $the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID); |
|
713 | - // now we can determine if date range spans more than one day |
|
714 | - if ($the_event_date != $the_event_end_date) { |
|
715 | - $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
716 | - $time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format); |
|
717 | - $html = sprintf( |
|
718 | - /* translators: 1: first event date, 2: last event date */ |
|
719 | - esc_html__('%1$s - %2$s', 'event_espresso'), |
|
720 | - EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID), |
|
721 | - EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID) |
|
722 | - ); |
|
723 | - } else { |
|
724 | - // set and filter date and time formats when only a single datetime is returned |
|
725 | - $single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format'); |
|
726 | - $single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format'); |
|
727 | - $single_date_format = |
|
728 | - apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format); |
|
729 | - $single_time_format = |
|
730 | - apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format); |
|
731 | - $html = |
|
732 | - EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID); |
|
733 | - } |
|
734 | - if ($echo) { |
|
735 | - echo wp_kses($html, AllowedTags::getAllowedTags()); |
|
736 | - return ''; |
|
737 | - } |
|
738 | - return $html; |
|
739 | - } |
|
685 | + /** |
|
686 | + * espresso_event_date_range |
|
687 | + * returns the first and last chronologically ordered dates for an event (if different) |
|
688 | + * |
|
689 | + * @param string $date_format |
|
690 | + * @param string $time_format |
|
691 | + * @param string $single_date_format |
|
692 | + * @param string $single_time_format |
|
693 | + * @param bool $EVT_ID |
|
694 | + * @param bool $echo |
|
695 | + * @return string |
|
696 | + * @throws EE_Error |
|
697 | + * @throws ReflectionException |
|
698 | + */ |
|
699 | + function espresso_event_date_range( |
|
700 | + $date_format = '', |
|
701 | + $time_format = '', |
|
702 | + $single_date_format = '', |
|
703 | + $single_time_format = '', |
|
704 | + $EVT_ID = false, |
|
705 | + $echo = true |
|
706 | + ) { |
|
707 | + // set and filter date and time formats when a range is returned |
|
708 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
709 | + $date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format); |
|
710 | + // get the start and end date with NO time portion |
|
711 | + $the_event_date = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID); |
|
712 | + $the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID); |
|
713 | + // now we can determine if date range spans more than one day |
|
714 | + if ($the_event_date != $the_event_end_date) { |
|
715 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
716 | + $time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format); |
|
717 | + $html = sprintf( |
|
718 | + /* translators: 1: first event date, 2: last event date */ |
|
719 | + esc_html__('%1$s - %2$s', 'event_espresso'), |
|
720 | + EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID), |
|
721 | + EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID) |
|
722 | + ); |
|
723 | + } else { |
|
724 | + // set and filter date and time formats when only a single datetime is returned |
|
725 | + $single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format'); |
|
726 | + $single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format'); |
|
727 | + $single_date_format = |
|
728 | + apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format); |
|
729 | + $single_time_format = |
|
730 | + apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format); |
|
731 | + $html = |
|
732 | + EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID); |
|
733 | + } |
|
734 | + if ($echo) { |
|
735 | + echo wp_kses($html, AllowedTags::getAllowedTags()); |
|
736 | + return ''; |
|
737 | + } |
|
738 | + return $html; |
|
739 | + } |
|
740 | 740 | } |
741 | 741 | |
742 | 742 | if (! function_exists('espresso_next_upcoming_datetime_obj')) { |
743 | - /** |
|
744 | - * espresso_next_upcoming_datetime_obj |
|
745 | - * returns the next upcoming datetime object for an event |
|
746 | - * |
|
747 | - * @param int $EVT_ID |
|
748 | - * @return EE_Datetime|null |
|
749 | - * @throws EE_Error |
|
750 | - */ |
|
751 | - function espresso_next_upcoming_datetime_obj($EVT_ID = 0) |
|
752 | - { |
|
753 | - return EEH_Event_View::get_next_upcoming_date_obj($EVT_ID); |
|
754 | - } |
|
743 | + /** |
|
744 | + * espresso_next_upcoming_datetime_obj |
|
745 | + * returns the next upcoming datetime object for an event |
|
746 | + * |
|
747 | + * @param int $EVT_ID |
|
748 | + * @return EE_Datetime|null |
|
749 | + * @throws EE_Error |
|
750 | + */ |
|
751 | + function espresso_next_upcoming_datetime_obj($EVT_ID = 0) |
|
752 | + { |
|
753 | + return EEH_Event_View::get_next_upcoming_date_obj($EVT_ID); |
|
754 | + } |
|
755 | 755 | } |
756 | 756 | |
757 | 757 | if (! function_exists('espresso_next_upcoming_datetime')) { |
758 | - /** |
|
759 | - * espresso_next_upcoming_datetime |
|
760 | - * returns the start date and time for the next upcoming event. |
|
761 | - * |
|
762 | - * @param string $date_format |
|
763 | - * @param string $time_format |
|
764 | - * @param int $EVT_ID |
|
765 | - * @param bool $echo |
|
766 | - * @return string |
|
767 | - * @throws EE_Error |
|
768 | - * @throws ReflectionException |
|
769 | - */ |
|
770 | - function espresso_next_upcoming_datetime($date_format = '', $time_format = '', $EVT_ID = 0, $echo = true) |
|
771 | - { |
|
772 | - |
|
773 | - $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
774 | - $date_format = apply_filters('FHEE__espresso_next_upcoming_datetime__date_format', $date_format); |
|
775 | - |
|
776 | - $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
777 | - $time_format = apply_filters('FHEE__espresso_next_upcoming_datetime__time_format', $time_format); |
|
778 | - |
|
779 | - $datetime_format = trim($date_format . ' ' . $time_format); |
|
780 | - |
|
781 | - $datetime = espresso_next_upcoming_datetime_obj($EVT_ID); |
|
782 | - |
|
783 | - if (! $datetime instanceof EE_Datetime) { |
|
784 | - return ''; |
|
785 | - } |
|
786 | - if ($echo) { |
|
787 | - echo esc_html($datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format)); |
|
788 | - return ''; |
|
789 | - } |
|
790 | - return $datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format); |
|
791 | - } |
|
758 | + /** |
|
759 | + * espresso_next_upcoming_datetime |
|
760 | + * returns the start date and time for the next upcoming event. |
|
761 | + * |
|
762 | + * @param string $date_format |
|
763 | + * @param string $time_format |
|
764 | + * @param int $EVT_ID |
|
765 | + * @param bool $echo |
|
766 | + * @return string |
|
767 | + * @throws EE_Error |
|
768 | + * @throws ReflectionException |
|
769 | + */ |
|
770 | + function espresso_next_upcoming_datetime($date_format = '', $time_format = '', $EVT_ID = 0, $echo = true) |
|
771 | + { |
|
772 | + |
|
773 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
774 | + $date_format = apply_filters('FHEE__espresso_next_upcoming_datetime__date_format', $date_format); |
|
775 | + |
|
776 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
777 | + $time_format = apply_filters('FHEE__espresso_next_upcoming_datetime__time_format', $time_format); |
|
778 | + |
|
779 | + $datetime_format = trim($date_format . ' ' . $time_format); |
|
780 | + |
|
781 | + $datetime = espresso_next_upcoming_datetime_obj($EVT_ID); |
|
782 | + |
|
783 | + if (! $datetime instanceof EE_Datetime) { |
|
784 | + return ''; |
|
785 | + } |
|
786 | + if ($echo) { |
|
787 | + echo esc_html($datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format)); |
|
788 | + return ''; |
|
789 | + } |
|
790 | + return $datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format); |
|
791 | + } |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | if (! function_exists('espresso_event_date_as_calendar_page')) { |
795 | - /** |
|
796 | - * espresso_event_date_as_calendar_page |
|
797 | - * returns the primary date for an event, stylized to appear as the page of a calendar |
|
798 | - * |
|
799 | - * @param bool $EVT_ID |
|
800 | - * @return void |
|
801 | - * @throws EE_Error |
|
802 | - * @throws ReflectionException |
|
803 | - */ |
|
804 | - function espresso_event_date_as_calendar_page($EVT_ID = false) |
|
805 | - { |
|
806 | - EEH_Event_View::event_date_as_calendar_page($EVT_ID); |
|
807 | - } |
|
795 | + /** |
|
796 | + * espresso_event_date_as_calendar_page |
|
797 | + * returns the primary date for an event, stylized to appear as the page of a calendar |
|
798 | + * |
|
799 | + * @param bool $EVT_ID |
|
800 | + * @return void |
|
801 | + * @throws EE_Error |
|
802 | + * @throws ReflectionException |
|
803 | + */ |
|
804 | + function espresso_event_date_as_calendar_page($EVT_ID = false) |
|
805 | + { |
|
806 | + EEH_Event_View::event_date_as_calendar_page($EVT_ID); |
|
807 | + } |
|
808 | 808 | } |
809 | 809 | |
810 | 810 | |
811 | 811 | if (! function_exists('espresso_event_link_url')) { |
812 | - /** |
|
813 | - * espresso_event_link_url |
|
814 | - * |
|
815 | - * @param int $EVT_ID |
|
816 | - * @param bool $echo |
|
817 | - * @return string |
|
818 | - * @throws EE_Error |
|
819 | - * @throws ReflectionException |
|
820 | - */ |
|
821 | - function espresso_event_link_url($EVT_ID = 0, $echo = true) |
|
822 | - { |
|
823 | - if ($echo) { |
|
824 | - echo wp_kses(EEH_Event_View::event_link_url($EVT_ID), AllowedTags::getWithFormTags()); |
|
825 | - return ''; |
|
826 | - } |
|
827 | - return EEH_Event_View::event_link_url($EVT_ID); |
|
828 | - } |
|
812 | + /** |
|
813 | + * espresso_event_link_url |
|
814 | + * |
|
815 | + * @param int $EVT_ID |
|
816 | + * @param bool $echo |
|
817 | + * @return string |
|
818 | + * @throws EE_Error |
|
819 | + * @throws ReflectionException |
|
820 | + */ |
|
821 | + function espresso_event_link_url($EVT_ID = 0, $echo = true) |
|
822 | + { |
|
823 | + if ($echo) { |
|
824 | + echo wp_kses(EEH_Event_View::event_link_url($EVT_ID), AllowedTags::getWithFormTags()); |
|
825 | + return ''; |
|
826 | + } |
|
827 | + return EEH_Event_View::event_link_url($EVT_ID); |
|
828 | + } |
|
829 | 829 | } |
830 | 830 | |
831 | 831 | |
832 | 832 | if (! function_exists('espresso_event_has_content_or_excerpt')) { |
833 | - /** |
|
834 | - * espresso_event_has_content_or_excerpt |
|
835 | - * |
|
836 | - * @access public |
|
837 | - * @param bool $EVT_ID |
|
838 | - * @return boolean |
|
839 | - * @throws EE_Error |
|
840 | - * @throws ReflectionException |
|
841 | - */ |
|
842 | - function espresso_event_has_content_or_excerpt($EVT_ID = false) |
|
843 | - { |
|
844 | - return EEH_Event_View::event_has_content_or_excerpt($EVT_ID); |
|
845 | - } |
|
833 | + /** |
|
834 | + * espresso_event_has_content_or_excerpt |
|
835 | + * |
|
836 | + * @access public |
|
837 | + * @param bool $EVT_ID |
|
838 | + * @return boolean |
|
839 | + * @throws EE_Error |
|
840 | + * @throws ReflectionException |
|
841 | + */ |
|
842 | + function espresso_event_has_content_or_excerpt($EVT_ID = false) |
|
843 | + { |
|
844 | + return EEH_Event_View::event_has_content_or_excerpt($EVT_ID); |
|
845 | + } |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | |
849 | 849 | if (! function_exists('espresso_event_content_or_excerpt')) { |
850 | - /** |
|
851 | - * espresso_event_content_or_excerpt |
|
852 | - * |
|
853 | - * @param int $num_words |
|
854 | - * @param null $more |
|
855 | - * @param bool $echo |
|
856 | - * @return string |
|
857 | - */ |
|
858 | - function espresso_event_content_or_excerpt($num_words = 55, $more = null, $echo = true) |
|
859 | - { |
|
860 | - if ($echo) { |
|
861 | - echo wp_kses(EEH_Event_View::event_content_or_excerpt($num_words, $more), AllowedTags::getWithFormTags()); |
|
862 | - return ''; |
|
863 | - } |
|
864 | - return EEH_Event_View::event_content_or_excerpt($num_words, $more); |
|
865 | - } |
|
850 | + /** |
|
851 | + * espresso_event_content_or_excerpt |
|
852 | + * |
|
853 | + * @param int $num_words |
|
854 | + * @param null $more |
|
855 | + * @param bool $echo |
|
856 | + * @return string |
|
857 | + */ |
|
858 | + function espresso_event_content_or_excerpt($num_words = 55, $more = null, $echo = true) |
|
859 | + { |
|
860 | + if ($echo) { |
|
861 | + echo wp_kses(EEH_Event_View::event_content_or_excerpt($num_words, $more), AllowedTags::getWithFormTags()); |
|
862 | + return ''; |
|
863 | + } |
|
864 | + return EEH_Event_View::event_content_or_excerpt($num_words, $more); |
|
865 | + } |
|
866 | 866 | } |
867 | 867 | |
868 | 868 | |
869 | 869 | if (! function_exists('espresso_event_phone')) { |
870 | - /** |
|
871 | - * espresso_event_phone |
|
872 | - * |
|
873 | - * @param int $EVT_ID |
|
874 | - * @param bool $echo |
|
875 | - * @return string |
|
876 | - * @throws EE_Error |
|
877 | - * @throws ReflectionException |
|
878 | - */ |
|
879 | - function espresso_event_phone($EVT_ID = 0, $echo = true) |
|
880 | - { |
|
881 | - if ($echo) { |
|
882 | - echo wp_kses(EEH_Event_View::event_phone($EVT_ID), AllowedTags::getWithFormTags()); |
|
883 | - return ''; |
|
884 | - } |
|
885 | - return EEH_Event_View::event_phone($EVT_ID); |
|
886 | - } |
|
870 | + /** |
|
871 | + * espresso_event_phone |
|
872 | + * |
|
873 | + * @param int $EVT_ID |
|
874 | + * @param bool $echo |
|
875 | + * @return string |
|
876 | + * @throws EE_Error |
|
877 | + * @throws ReflectionException |
|
878 | + */ |
|
879 | + function espresso_event_phone($EVT_ID = 0, $echo = true) |
|
880 | + { |
|
881 | + if ($echo) { |
|
882 | + echo wp_kses(EEH_Event_View::event_phone($EVT_ID), AllowedTags::getWithFormTags()); |
|
883 | + return ''; |
|
884 | + } |
|
885 | + return EEH_Event_View::event_phone($EVT_ID); |
|
886 | + } |
|
887 | 887 | } |
888 | 888 | |
889 | 889 | |
890 | 890 | if (! function_exists('espresso_edit_event_link')) { |
891 | - /** |
|
892 | - * espresso_edit_event_link |
|
893 | - * returns a link to edit an event |
|
894 | - * |
|
895 | - * @param int $EVT_ID |
|
896 | - * @param bool $echo |
|
897 | - * @return string |
|
898 | - * @throws EE_Error |
|
899 | - * @throws ReflectionException |
|
900 | - */ |
|
901 | - function espresso_edit_event_link($EVT_ID = 0, $echo = true) |
|
902 | - { |
|
903 | - if ($echo) { |
|
904 | - echo wp_kses(EEH_Event_View::edit_event_link($EVT_ID), AllowedTags::getWithFormTags()); |
|
905 | - return ''; |
|
906 | - } |
|
907 | - return EEH_Event_View::edit_event_link($EVT_ID); |
|
908 | - } |
|
891 | + /** |
|
892 | + * espresso_edit_event_link |
|
893 | + * returns a link to edit an event |
|
894 | + * |
|
895 | + * @param int $EVT_ID |
|
896 | + * @param bool $echo |
|
897 | + * @return string |
|
898 | + * @throws EE_Error |
|
899 | + * @throws ReflectionException |
|
900 | + */ |
|
901 | + function espresso_edit_event_link($EVT_ID = 0, $echo = true) |
|
902 | + { |
|
903 | + if ($echo) { |
|
904 | + echo wp_kses(EEH_Event_View::edit_event_link($EVT_ID), AllowedTags::getWithFormTags()); |
|
905 | + return ''; |
|
906 | + } |
|
907 | + return EEH_Event_View::edit_event_link($EVT_ID); |
|
908 | + } |
|
909 | 909 | } |
910 | 910 | |
911 | 911 | |
912 | 912 | if (! function_exists('espresso_organization_name')) { |
913 | - /** |
|
914 | - * espresso_organization_name |
|
915 | - * |
|
916 | - * @param bool $echo |
|
917 | - * @return string |
|
918 | - * @throws EE_Error |
|
919 | - */ |
|
920 | - function espresso_organization_name($echo = true) |
|
921 | - { |
|
922 | - if ($echo) { |
|
923 | - echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('name')); |
|
924 | - return ''; |
|
925 | - } |
|
926 | - return EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
927 | - } |
|
913 | + /** |
|
914 | + * espresso_organization_name |
|
915 | + * |
|
916 | + * @param bool $echo |
|
917 | + * @return string |
|
918 | + * @throws EE_Error |
|
919 | + */ |
|
920 | + function espresso_organization_name($echo = true) |
|
921 | + { |
|
922 | + if ($echo) { |
|
923 | + echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('name')); |
|
924 | + return ''; |
|
925 | + } |
|
926 | + return EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
927 | + } |
|
928 | 928 | } |
929 | 929 | |
930 | 930 | if (! function_exists('espresso_organization_address')) { |
931 | - /** |
|
932 | - * espresso_organization_address |
|
933 | - * |
|
934 | - * @param string $type |
|
935 | - * @return string |
|
936 | - */ |
|
937 | - function espresso_organization_address($type = 'inline') |
|
938 | - { |
|
939 | - if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) { |
|
940 | - $address = new EventEspresso\core\domain\entities\GenericAddress( |
|
941 | - EE_Registry::instance()->CFG->organization->address_1, |
|
942 | - EE_Registry::instance()->CFG->organization->address_2, |
|
943 | - EE_Registry::instance()->CFG->organization->city, |
|
944 | - EE_Registry::instance()->CFG->organization->STA_ID, |
|
945 | - EE_Registry::instance()->CFG->organization->zip, |
|
946 | - EE_Registry::instance()->CFG->organization->CNT_ISO |
|
947 | - ); |
|
948 | - return EEH_Address::format($address, $type); |
|
949 | - } |
|
950 | - return ''; |
|
951 | - } |
|
931 | + /** |
|
932 | + * espresso_organization_address |
|
933 | + * |
|
934 | + * @param string $type |
|
935 | + * @return string |
|
936 | + */ |
|
937 | + function espresso_organization_address($type = 'inline') |
|
938 | + { |
|
939 | + if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) { |
|
940 | + $address = new EventEspresso\core\domain\entities\GenericAddress( |
|
941 | + EE_Registry::instance()->CFG->organization->address_1, |
|
942 | + EE_Registry::instance()->CFG->organization->address_2, |
|
943 | + EE_Registry::instance()->CFG->organization->city, |
|
944 | + EE_Registry::instance()->CFG->organization->STA_ID, |
|
945 | + EE_Registry::instance()->CFG->organization->zip, |
|
946 | + EE_Registry::instance()->CFG->organization->CNT_ISO |
|
947 | + ); |
|
948 | + return EEH_Address::format($address, $type); |
|
949 | + } |
|
950 | + return ''; |
|
951 | + } |
|
952 | 952 | } |
953 | 953 | |
954 | 954 | if (! function_exists('espresso_organization_email')) { |
955 | - /** |
|
956 | - * espresso_organization_email |
|
957 | - * |
|
958 | - * @param bool $echo |
|
959 | - * @return string |
|
960 | - * @throws EE_Error |
|
961 | - */ |
|
962 | - function espresso_organization_email($echo = true) |
|
963 | - { |
|
964 | - if ($echo) { |
|
965 | - echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('email')); |
|
966 | - return ''; |
|
967 | - } |
|
968 | - return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
969 | - } |
|
955 | + /** |
|
956 | + * espresso_organization_email |
|
957 | + * |
|
958 | + * @param bool $echo |
|
959 | + * @return string |
|
960 | + * @throws EE_Error |
|
961 | + */ |
|
962 | + function espresso_organization_email($echo = true) |
|
963 | + { |
|
964 | + if ($echo) { |
|
965 | + echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('email')); |
|
966 | + return ''; |
|
967 | + } |
|
968 | + return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
969 | + } |
|
970 | 970 | } |
971 | 971 | |
972 | 972 | if (! function_exists('espresso_organization_logo_url')) { |
973 | - /** |
|
974 | - * espresso_organization_logo_url |
|
975 | - * |
|
976 | - * @param bool $echo |
|
977 | - * @return string |
|
978 | - * @throws EE_Error |
|
979 | - */ |
|
980 | - function espresso_organization_logo_url($echo = true) |
|
981 | - { |
|
982 | - if ($echo) { |
|
983 | - echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('logo_url')); |
|
984 | - return ''; |
|
985 | - } |
|
986 | - return EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
987 | - } |
|
973 | + /** |
|
974 | + * espresso_organization_logo_url |
|
975 | + * |
|
976 | + * @param bool $echo |
|
977 | + * @return string |
|
978 | + * @throws EE_Error |
|
979 | + */ |
|
980 | + function espresso_organization_logo_url($echo = true) |
|
981 | + { |
|
982 | + if ($echo) { |
|
983 | + echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('logo_url')); |
|
984 | + return ''; |
|
985 | + } |
|
986 | + return EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
987 | + } |
|
988 | 988 | } |
989 | 989 | |
990 | 990 | if (! function_exists('espresso_organization_facebook')) { |
991 | - /** |
|
992 | - * espresso_organization_facebook |
|
993 | - * |
|
994 | - * @param bool $echo |
|
995 | - * @return string |
|
996 | - * @throws EE_Error |
|
997 | - */ |
|
998 | - function espresso_organization_facebook($echo = true) |
|
999 | - { |
|
1000 | - if ($echo) { |
|
1001 | - echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('facebook')); |
|
1002 | - return ''; |
|
1003 | - } |
|
1004 | - return EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
1005 | - } |
|
991 | + /** |
|
992 | + * espresso_organization_facebook |
|
993 | + * |
|
994 | + * @param bool $echo |
|
995 | + * @return string |
|
996 | + * @throws EE_Error |
|
997 | + */ |
|
998 | + function espresso_organization_facebook($echo = true) |
|
999 | + { |
|
1000 | + if ($echo) { |
|
1001 | + echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('facebook')); |
|
1002 | + return ''; |
|
1003 | + } |
|
1004 | + return EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
1005 | + } |
|
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | if (! function_exists('espresso_organization_twitter')) { |
1009 | - /** |
|
1010 | - * espresso_organization_twitter |
|
1011 | - * |
|
1012 | - * @param bool $echo |
|
1013 | - * @return string |
|
1014 | - * @throws EE_Error |
|
1015 | - */ |
|
1016 | - function espresso_organization_twitter($echo = true) |
|
1017 | - { |
|
1018 | - if ($echo) { |
|
1019 | - echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('twitter')); |
|
1020 | - return ''; |
|
1021 | - } |
|
1022 | - return EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
1023 | - } |
|
1009 | + /** |
|
1010 | + * espresso_organization_twitter |
|
1011 | + * |
|
1012 | + * @param bool $echo |
|
1013 | + * @return string |
|
1014 | + * @throws EE_Error |
|
1015 | + */ |
|
1016 | + function espresso_organization_twitter($echo = true) |
|
1017 | + { |
|
1018 | + if ($echo) { |
|
1019 | + echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('twitter')); |
|
1020 | + return ''; |
|
1021 | + } |
|
1022 | + return EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
1023 | + } |
|
1024 | 1024 | } |
1025 | 1025 | |
1026 | 1026 | if (! function_exists('espresso_organization_linkedin')) { |
1027 | - /** |
|
1028 | - * espresso_organization_linkedin |
|
1029 | - * |
|
1030 | - * @param bool $echo |
|
1031 | - * @return string |
|
1032 | - * @throws EE_Error |
|
1033 | - */ |
|
1034 | - function espresso_organization_linkedin($echo = true) |
|
1035 | - { |
|
1036 | - if ($echo) { |
|
1037 | - echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('linkedin')); |
|
1038 | - return ''; |
|
1039 | - } |
|
1040 | - return EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
1041 | - } |
|
1027 | + /** |
|
1028 | + * espresso_organization_linkedin |
|
1029 | + * |
|
1030 | + * @param bool $echo |
|
1031 | + * @return string |
|
1032 | + * @throws EE_Error |
|
1033 | + */ |
|
1034 | + function espresso_organization_linkedin($echo = true) |
|
1035 | + { |
|
1036 | + if ($echo) { |
|
1037 | + echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('linkedin')); |
|
1038 | + return ''; |
|
1039 | + } |
|
1040 | + return EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
1041 | + } |
|
1042 | 1042 | } |
1043 | 1043 | |
1044 | 1044 | if (! function_exists('espresso_organization_pinterest')) { |
1045 | - /** |
|
1046 | - * espresso_organization_pinterest |
|
1047 | - * |
|
1048 | - * @param bool $echo |
|
1049 | - * @return string |
|
1050 | - * @throws EE_Error |
|
1051 | - */ |
|
1052 | - function espresso_organization_pinterest($echo = true) |
|
1053 | - { |
|
1054 | - if ($echo) { |
|
1055 | - echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('pinterest')); |
|
1056 | - return ''; |
|
1057 | - } |
|
1058 | - return EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
1059 | - } |
|
1045 | + /** |
|
1046 | + * espresso_organization_pinterest |
|
1047 | + * |
|
1048 | + * @param bool $echo |
|
1049 | + * @return string |
|
1050 | + * @throws EE_Error |
|
1051 | + */ |
|
1052 | + function espresso_organization_pinterest($echo = true) |
|
1053 | + { |
|
1054 | + if ($echo) { |
|
1055 | + echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('pinterest')); |
|
1056 | + return ''; |
|
1057 | + } |
|
1058 | + return EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
1059 | + } |
|
1060 | 1060 | } |
1061 | 1061 | |
1062 | 1062 | if (! function_exists('espresso_organization_google')) { |
1063 | - /** |
|
1064 | - * espresso_organization_google |
|
1065 | - * |
|
1066 | - * @param bool $echo |
|
1067 | - * @return string |
|
1068 | - * @throws EE_Error |
|
1069 | - */ |
|
1070 | - function espresso_organization_google($echo = true) |
|
1071 | - { |
|
1072 | - if ($echo) { |
|
1073 | - echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('google')); |
|
1074 | - return ''; |
|
1075 | - } |
|
1076 | - return EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
1077 | - } |
|
1063 | + /** |
|
1064 | + * espresso_organization_google |
|
1065 | + * |
|
1066 | + * @param bool $echo |
|
1067 | + * @return string |
|
1068 | + * @throws EE_Error |
|
1069 | + */ |
|
1070 | + function espresso_organization_google($echo = true) |
|
1071 | + { |
|
1072 | + if ($echo) { |
|
1073 | + echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('google')); |
|
1074 | + return ''; |
|
1075 | + } |
|
1076 | + return EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
1077 | + } |
|
1078 | 1078 | } |
1079 | 1079 | |
1080 | 1080 | if (! function_exists('espresso_organization_instagram')) { |
1081 | - /** |
|
1082 | - * espresso_organization_instagram |
|
1083 | - * |
|
1084 | - * @param bool $echo |
|
1085 | - * @return string |
|
1086 | - * @throws EE_Error |
|
1087 | - */ |
|
1088 | - function espresso_organization_instagram($echo = true) |
|
1089 | - { |
|
1090 | - if ($echo) { |
|
1091 | - echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('instagram')); |
|
1092 | - return ''; |
|
1093 | - } |
|
1094 | - return EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
1095 | - } |
|
1081 | + /** |
|
1082 | + * espresso_organization_instagram |
|
1083 | + * |
|
1084 | + * @param bool $echo |
|
1085 | + * @return string |
|
1086 | + * @throws EE_Error |
|
1087 | + */ |
|
1088 | + function espresso_organization_instagram($echo = true) |
|
1089 | + { |
|
1090 | + if ($echo) { |
|
1091 | + echo esc_html(EE_Registry::instance()->CFG->organization->get_pretty('instagram')); |
|
1092 | + return ''; |
|
1093 | + } |
|
1094 | + return EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
1095 | + } |
|
1096 | 1096 | } |
1097 | 1097 | |
1098 | 1098 | |
@@ -1100,345 +1100,345 @@ discard block |
||
1100 | 1100 | |
1101 | 1101 | |
1102 | 1102 | if (! function_exists('espresso_event_venues')) { |
1103 | - /** |
|
1104 | - * espresso_event_venues |
|
1105 | - * |
|
1106 | - * @return array all venues related to an event |
|
1107 | - * @throws EE_Error |
|
1108 | - * @throws ReflectionException |
|
1109 | - */ |
|
1110 | - function espresso_event_venues() |
|
1111 | - { |
|
1112 | - return EEH_Venue_View::get_event_venues(); |
|
1113 | - } |
|
1103 | + /** |
|
1104 | + * espresso_event_venues |
|
1105 | + * |
|
1106 | + * @return array all venues related to an event |
|
1107 | + * @throws EE_Error |
|
1108 | + * @throws ReflectionException |
|
1109 | + */ |
|
1110 | + function espresso_event_venues() |
|
1111 | + { |
|
1112 | + return EEH_Venue_View::get_event_venues(); |
|
1113 | + } |
|
1114 | 1114 | } |
1115 | 1115 | |
1116 | 1116 | |
1117 | 1117 | if (! function_exists('espresso_venue_id')) { |
1118 | - /** |
|
1119 | - * espresso_venue_name |
|
1120 | - * |
|
1121 | - * @access public |
|
1122 | - * @param int $EVT_ID |
|
1123 | - * @return string |
|
1124 | - * @throws EE_Error |
|
1125 | - * @throws ReflectionException |
|
1126 | - */ |
|
1127 | - function espresso_venue_id($EVT_ID = 0) |
|
1128 | - { |
|
1129 | - $venue = EEH_Venue_View::get_venue($EVT_ID); |
|
1130 | - return $venue instanceof EE_Venue ? $venue->ID() : 0; |
|
1131 | - } |
|
1118 | + /** |
|
1119 | + * espresso_venue_name |
|
1120 | + * |
|
1121 | + * @access public |
|
1122 | + * @param int $EVT_ID |
|
1123 | + * @return string |
|
1124 | + * @throws EE_Error |
|
1125 | + * @throws ReflectionException |
|
1126 | + */ |
|
1127 | + function espresso_venue_id($EVT_ID = 0) |
|
1128 | + { |
|
1129 | + $venue = EEH_Venue_View::get_venue($EVT_ID); |
|
1130 | + return $venue instanceof EE_Venue ? $venue->ID() : 0; |
|
1131 | + } |
|
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | |
1135 | 1135 | if (! function_exists('espresso_is_venue_private')) { |
1136 | - /** |
|
1137 | - * Return whether a venue is private or not. |
|
1138 | - * |
|
1139 | - * @param int $VNU_ID optional, the venue id to check. |
|
1140 | - * |
|
1141 | - * @return bool | null |
|
1142 | - * @throws EE_Error |
|
1143 | - * @throws ReflectionException |
|
1144 | - * @see EEH_Venue_View::get_venue() for more info on expected return results. |
|
1145 | - */ |
|
1146 | - function espresso_is_venue_private($VNU_ID = 0) |
|
1147 | - { |
|
1148 | - return EEH_Venue_View::is_venue_private($VNU_ID); |
|
1149 | - } |
|
1136 | + /** |
|
1137 | + * Return whether a venue is private or not. |
|
1138 | + * |
|
1139 | + * @param int $VNU_ID optional, the venue id to check. |
|
1140 | + * |
|
1141 | + * @return bool | null |
|
1142 | + * @throws EE_Error |
|
1143 | + * @throws ReflectionException |
|
1144 | + * @see EEH_Venue_View::get_venue() for more info on expected return results. |
|
1145 | + */ |
|
1146 | + function espresso_is_venue_private($VNU_ID = 0) |
|
1147 | + { |
|
1148 | + return EEH_Venue_View::is_venue_private($VNU_ID); |
|
1149 | + } |
|
1150 | 1150 | } |
1151 | 1151 | |
1152 | 1152 | |
1153 | 1153 | if (! function_exists('espresso_venue_is_password_protected')) { |
1154 | - /** |
|
1155 | - * returns true or false if a venue is password protected or not |
|
1156 | - * |
|
1157 | - * @param int $VNU_ID optional, the venue id to check. |
|
1158 | - * @return bool |
|
1159 | - * @throws EE_Error |
|
1160 | - * @throws ReflectionException |
|
1161 | - */ |
|
1162 | - function espresso_venue_is_password_protected($VNU_ID = 0) |
|
1163 | - { |
|
1164 | - EE_Registry::instance()->load_helper('Venue_View'); |
|
1165 | - return EEH_Venue_View::is_venue_password_protected($VNU_ID); |
|
1166 | - } |
|
1154 | + /** |
|
1155 | + * returns true or false if a venue is password protected or not |
|
1156 | + * |
|
1157 | + * @param int $VNU_ID optional, the venue id to check. |
|
1158 | + * @return bool |
|
1159 | + * @throws EE_Error |
|
1160 | + * @throws ReflectionException |
|
1161 | + */ |
|
1162 | + function espresso_venue_is_password_protected($VNU_ID = 0) |
|
1163 | + { |
|
1164 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
1165 | + return EEH_Venue_View::is_venue_password_protected($VNU_ID); |
|
1166 | + } |
|
1167 | 1167 | } |
1168 | 1168 | |
1169 | 1169 | |
1170 | 1170 | if (! function_exists('espresso_password_protected_venue_form')) { |
1171 | - /** |
|
1172 | - * Returns a password form if venue is password protected. |
|
1173 | - * |
|
1174 | - * @param int $VNU_ID optional, the venue id to check. |
|
1175 | - * @return string |
|
1176 | - * @throws EE_Error |
|
1177 | - * @throws ReflectionException |
|
1178 | - */ |
|
1179 | - function espresso_password_protected_venue_form($VNU_ID = 0) |
|
1180 | - { |
|
1181 | - EE_Registry::instance()->load_helper('Venue_View'); |
|
1182 | - return EEH_Venue_View::password_protected_venue_form($VNU_ID); |
|
1183 | - } |
|
1171 | + /** |
|
1172 | + * Returns a password form if venue is password protected. |
|
1173 | + * |
|
1174 | + * @param int $VNU_ID optional, the venue id to check. |
|
1175 | + * @return string |
|
1176 | + * @throws EE_Error |
|
1177 | + * @throws ReflectionException |
|
1178 | + */ |
|
1179 | + function espresso_password_protected_venue_form($VNU_ID = 0) |
|
1180 | + { |
|
1181 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
1182 | + return EEH_Venue_View::password_protected_venue_form($VNU_ID); |
|
1183 | + } |
|
1184 | 1184 | } |
1185 | 1185 | |
1186 | 1186 | |
1187 | 1187 | if (! function_exists('espresso_venue_name')) { |
1188 | - /** |
|
1189 | - * espresso_venue_name |
|
1190 | - * |
|
1191 | - * @access public |
|
1192 | - * @param int $VNU_ID |
|
1193 | - * @param string $link_to - options( details, website, none ) whether to turn Venue name into a clickable link to the Venue's details page or website |
|
1194 | - * @param bool $echo |
|
1195 | - * @return string |
|
1196 | - * @throws EE_Error |
|
1197 | - * @throws ReflectionException |
|
1198 | - */ |
|
1199 | - function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = true) |
|
1200 | - { |
|
1201 | - if ($echo) { |
|
1202 | - echo wp_kses(EEH_Venue_View::venue_name($link_to, $VNU_ID), AllowedTags::getWithFormTags()); |
|
1203 | - return ''; |
|
1204 | - } |
|
1205 | - return EEH_Venue_View::venue_name($link_to, $VNU_ID); |
|
1206 | - } |
|
1188 | + /** |
|
1189 | + * espresso_venue_name |
|
1190 | + * |
|
1191 | + * @access public |
|
1192 | + * @param int $VNU_ID |
|
1193 | + * @param string $link_to - options( details, website, none ) whether to turn Venue name into a clickable link to the Venue's details page or website |
|
1194 | + * @param bool $echo |
|
1195 | + * @return string |
|
1196 | + * @throws EE_Error |
|
1197 | + * @throws ReflectionException |
|
1198 | + */ |
|
1199 | + function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = true) |
|
1200 | + { |
|
1201 | + if ($echo) { |
|
1202 | + echo wp_kses(EEH_Venue_View::venue_name($link_to, $VNU_ID), AllowedTags::getWithFormTags()); |
|
1203 | + return ''; |
|
1204 | + } |
|
1205 | + return EEH_Venue_View::venue_name($link_to, $VNU_ID); |
|
1206 | + } |
|
1207 | 1207 | } |
1208 | 1208 | |
1209 | 1209 | |
1210 | 1210 | if (! function_exists('espresso_venue_link')) { |
1211 | - /** |
|
1212 | - * espresso_venue_link |
|
1213 | - * |
|
1214 | - * @access public |
|
1215 | - * @param int $VNU_ID |
|
1216 | - * @param string $text |
|
1217 | - * @return string |
|
1218 | - * @throws EE_Error |
|
1219 | - * @throws ReflectionException |
|
1220 | - */ |
|
1221 | - function espresso_venue_link($VNU_ID = 0, $text = '') |
|
1222 | - { |
|
1223 | - return EEH_Venue_View::venue_details_link($VNU_ID, $text); |
|
1224 | - } |
|
1211 | + /** |
|
1212 | + * espresso_venue_link |
|
1213 | + * |
|
1214 | + * @access public |
|
1215 | + * @param int $VNU_ID |
|
1216 | + * @param string $text |
|
1217 | + * @return string |
|
1218 | + * @throws EE_Error |
|
1219 | + * @throws ReflectionException |
|
1220 | + */ |
|
1221 | + function espresso_venue_link($VNU_ID = 0, $text = '') |
|
1222 | + { |
|
1223 | + return EEH_Venue_View::venue_details_link($VNU_ID, $text); |
|
1224 | + } |
|
1225 | 1225 | } |
1226 | 1226 | |
1227 | 1227 | |
1228 | 1228 | if (! function_exists('espresso_venue_description')) { |
1229 | - /** |
|
1230 | - * espresso_venue_description |
|
1231 | - * |
|
1232 | - * @access public |
|
1233 | - * @param bool $VNU_ID |
|
1234 | - * @param bool $echo |
|
1235 | - * @return string |
|
1236 | - * @throws EE_Error |
|
1237 | - * @throws ReflectionException |
|
1238 | - */ |
|
1239 | - function espresso_venue_description($VNU_ID = false, $echo = true) |
|
1240 | - { |
|
1241 | - if ($echo) { |
|
1242 | - echo wp_kses(EEH_Venue_View::venue_description($VNU_ID), AllowedTags::getWithFormTags()); |
|
1243 | - return ''; |
|
1244 | - } |
|
1245 | - return EEH_Venue_View::venue_description($VNU_ID); |
|
1246 | - } |
|
1229 | + /** |
|
1230 | + * espresso_venue_description |
|
1231 | + * |
|
1232 | + * @access public |
|
1233 | + * @param bool $VNU_ID |
|
1234 | + * @param bool $echo |
|
1235 | + * @return string |
|
1236 | + * @throws EE_Error |
|
1237 | + * @throws ReflectionException |
|
1238 | + */ |
|
1239 | + function espresso_venue_description($VNU_ID = false, $echo = true) |
|
1240 | + { |
|
1241 | + if ($echo) { |
|
1242 | + echo wp_kses(EEH_Venue_View::venue_description($VNU_ID), AllowedTags::getWithFormTags()); |
|
1243 | + return ''; |
|
1244 | + } |
|
1245 | + return EEH_Venue_View::venue_description($VNU_ID); |
|
1246 | + } |
|
1247 | 1247 | } |
1248 | 1248 | |
1249 | 1249 | |
1250 | 1250 | if (! function_exists('espresso_venue_excerpt')) { |
1251 | - /** |
|
1252 | - * espresso_venue_excerpt |
|
1253 | - * |
|
1254 | - * @access public |
|
1255 | - * @param int $VNU_ID |
|
1256 | - * @param bool $echo |
|
1257 | - * @return string |
|
1258 | - * @throws EE_Error |
|
1259 | - * @throws ReflectionException |
|
1260 | - */ |
|
1261 | - function espresso_venue_excerpt($VNU_ID = 0, $echo = true) |
|
1262 | - { |
|
1263 | - if ($echo) { |
|
1264 | - echo wp_kses(EEH_Venue_View::venue_excerpt($VNU_ID), AllowedTags::getWithFormTags()); |
|
1265 | - return ''; |
|
1266 | - } |
|
1267 | - return EEH_Venue_View::venue_excerpt($VNU_ID); |
|
1268 | - } |
|
1251 | + /** |
|
1252 | + * espresso_venue_excerpt |
|
1253 | + * |
|
1254 | + * @access public |
|
1255 | + * @param int $VNU_ID |
|
1256 | + * @param bool $echo |
|
1257 | + * @return string |
|
1258 | + * @throws EE_Error |
|
1259 | + * @throws ReflectionException |
|
1260 | + */ |
|
1261 | + function espresso_venue_excerpt($VNU_ID = 0, $echo = true) |
|
1262 | + { |
|
1263 | + if ($echo) { |
|
1264 | + echo wp_kses(EEH_Venue_View::venue_excerpt($VNU_ID), AllowedTags::getWithFormTags()); |
|
1265 | + return ''; |
|
1266 | + } |
|
1267 | + return EEH_Venue_View::venue_excerpt($VNU_ID); |
|
1268 | + } |
|
1269 | 1269 | } |
1270 | 1270 | |
1271 | 1271 | |
1272 | 1272 | if (! function_exists('espresso_venue_categories')) { |
1273 | - /** |
|
1274 | - * espresso_venue_categories |
|
1275 | - * returns the terms associated with a venue |
|
1276 | - * |
|
1277 | - * @param int $VNU_ID |
|
1278 | - * @param bool $hide_uncategorized |
|
1279 | - * @param bool $echo |
|
1280 | - * @return string |
|
1281 | - * @throws EE_Error |
|
1282 | - * @throws ReflectionException |
|
1283 | - */ |
|
1284 | - function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = true, $echo = true) |
|
1285 | - { |
|
1286 | - if ($echo) { |
|
1287 | - echo wp_kses(EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized), AllowedTags::getWithFormTags()); |
|
1288 | - return ''; |
|
1289 | - } |
|
1290 | - return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); |
|
1291 | - } |
|
1273 | + /** |
|
1274 | + * espresso_venue_categories |
|
1275 | + * returns the terms associated with a venue |
|
1276 | + * |
|
1277 | + * @param int $VNU_ID |
|
1278 | + * @param bool $hide_uncategorized |
|
1279 | + * @param bool $echo |
|
1280 | + * @return string |
|
1281 | + * @throws EE_Error |
|
1282 | + * @throws ReflectionException |
|
1283 | + */ |
|
1284 | + function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = true, $echo = true) |
|
1285 | + { |
|
1286 | + if ($echo) { |
|
1287 | + echo wp_kses(EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized), AllowedTags::getWithFormTags()); |
|
1288 | + return ''; |
|
1289 | + } |
|
1290 | + return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); |
|
1291 | + } |
|
1292 | 1292 | } |
1293 | 1293 | |
1294 | 1294 | |
1295 | 1295 | if (! function_exists('espresso_venue_address')) { |
1296 | - /** |
|
1297 | - * espresso_venue_address |
|
1298 | - * returns a formatted block of html for displaying a venue's address |
|
1299 | - * |
|
1300 | - * @param string $type 'inline' or 'multiline' |
|
1301 | - * @param int $VNU_ID |
|
1302 | - * @param bool $echo |
|
1303 | - * @return string |
|
1304 | - * @throws EE_Error |
|
1305 | - * @throws ReflectionException |
|
1306 | - */ |
|
1307 | - function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = true) |
|
1308 | - { |
|
1309 | - if ($echo) { |
|
1310 | - echo wp_kses(EEH_Venue_View::venue_address($type, $VNU_ID), AllowedTags::getWithFormTags()); |
|
1311 | - return ''; |
|
1312 | - } |
|
1313 | - return EEH_Venue_View::venue_address($type, $VNU_ID); |
|
1314 | - } |
|
1296 | + /** |
|
1297 | + * espresso_venue_address |
|
1298 | + * returns a formatted block of html for displaying a venue's address |
|
1299 | + * |
|
1300 | + * @param string $type 'inline' or 'multiline' |
|
1301 | + * @param int $VNU_ID |
|
1302 | + * @param bool $echo |
|
1303 | + * @return string |
|
1304 | + * @throws EE_Error |
|
1305 | + * @throws ReflectionException |
|
1306 | + */ |
|
1307 | + function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = true) |
|
1308 | + { |
|
1309 | + if ($echo) { |
|
1310 | + echo wp_kses(EEH_Venue_View::venue_address($type, $VNU_ID), AllowedTags::getWithFormTags()); |
|
1311 | + return ''; |
|
1312 | + } |
|
1313 | + return EEH_Venue_View::venue_address($type, $VNU_ID); |
|
1314 | + } |
|
1315 | 1315 | } |
1316 | 1316 | |
1317 | 1317 | |
1318 | 1318 | if (! function_exists('espresso_venue_raw_address')) { |
1319 | - /** |
|
1320 | - * espresso_venue_address |
|
1321 | - * returns an UN-formatted string containing a venue's address |
|
1322 | - * |
|
1323 | - * @param string $type 'inline' or 'multiline' |
|
1324 | - * @param int $VNU_ID |
|
1325 | - * @param bool $echo |
|
1326 | - * @return string |
|
1327 | - * @throws EE_Error |
|
1328 | - * @throws ReflectionException |
|
1329 | - */ |
|
1330 | - function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = true) |
|
1331 | - { |
|
1332 | - if ($echo) { |
|
1333 | - echo wp_kses(EEH_Venue_View::venue_address($type, $VNU_ID, false, false), AllowedTags::getWithFormTags()); |
|
1334 | - return ''; |
|
1335 | - } |
|
1336 | - return EEH_Venue_View::venue_address($type, $VNU_ID, false, false); |
|
1337 | - } |
|
1319 | + /** |
|
1320 | + * espresso_venue_address |
|
1321 | + * returns an UN-formatted string containing a venue's address |
|
1322 | + * |
|
1323 | + * @param string $type 'inline' or 'multiline' |
|
1324 | + * @param int $VNU_ID |
|
1325 | + * @param bool $echo |
|
1326 | + * @return string |
|
1327 | + * @throws EE_Error |
|
1328 | + * @throws ReflectionException |
|
1329 | + */ |
|
1330 | + function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = true) |
|
1331 | + { |
|
1332 | + if ($echo) { |
|
1333 | + echo wp_kses(EEH_Venue_View::venue_address($type, $VNU_ID, false, false), AllowedTags::getWithFormTags()); |
|
1334 | + return ''; |
|
1335 | + } |
|
1336 | + return EEH_Venue_View::venue_address($type, $VNU_ID, false, false); |
|
1337 | + } |
|
1338 | 1338 | } |
1339 | 1339 | |
1340 | 1340 | |
1341 | 1341 | if (! function_exists('espresso_venue_has_address')) { |
1342 | - /** |
|
1343 | - * espresso_venue_has_address |
|
1344 | - * returns TRUE or FALSE if a Venue has address information |
|
1345 | - * |
|
1346 | - * @param int $VNU_ID |
|
1347 | - * @return bool |
|
1348 | - * @throws EE_Error |
|
1349 | - * @throws ReflectionException |
|
1350 | - */ |
|
1351 | - function espresso_venue_has_address($VNU_ID = 0) |
|
1352 | - { |
|
1353 | - return EEH_Venue_View::venue_has_address($VNU_ID); |
|
1354 | - } |
|
1342 | + /** |
|
1343 | + * espresso_venue_has_address |
|
1344 | + * returns TRUE or FALSE if a Venue has address information |
|
1345 | + * |
|
1346 | + * @param int $VNU_ID |
|
1347 | + * @return bool |
|
1348 | + * @throws EE_Error |
|
1349 | + * @throws ReflectionException |
|
1350 | + */ |
|
1351 | + function espresso_venue_has_address($VNU_ID = 0) |
|
1352 | + { |
|
1353 | + return EEH_Venue_View::venue_has_address($VNU_ID); |
|
1354 | + } |
|
1355 | 1355 | } |
1356 | 1356 | |
1357 | 1357 | |
1358 | 1358 | if (! function_exists('espresso_venue_gmap')) { |
1359 | - /** |
|
1360 | - * espresso_venue_gmap |
|
1361 | - * returns a google map for the venue address |
|
1362 | - * |
|
1363 | - * @param int $VNU_ID |
|
1364 | - * @param bool $map_ID |
|
1365 | - * @param array $gmap |
|
1366 | - * @param bool $echo |
|
1367 | - * @return string |
|
1368 | - * @throws EE_Error |
|
1369 | - * @throws ReflectionException |
|
1370 | - */ |
|
1371 | - function espresso_venue_gmap($VNU_ID = 0, $map_ID = false, $gmap = [], $echo = true) |
|
1372 | - { |
|
1373 | - if ($echo) { |
|
1374 | - echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); // already escaped |
|
1375 | - return ''; |
|
1376 | - } |
|
1377 | - return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); |
|
1378 | - } |
|
1359 | + /** |
|
1360 | + * espresso_venue_gmap |
|
1361 | + * returns a google map for the venue address |
|
1362 | + * |
|
1363 | + * @param int $VNU_ID |
|
1364 | + * @param bool $map_ID |
|
1365 | + * @param array $gmap |
|
1366 | + * @param bool $echo |
|
1367 | + * @return string |
|
1368 | + * @throws EE_Error |
|
1369 | + * @throws ReflectionException |
|
1370 | + */ |
|
1371 | + function espresso_venue_gmap($VNU_ID = 0, $map_ID = false, $gmap = [], $echo = true) |
|
1372 | + { |
|
1373 | + if ($echo) { |
|
1374 | + echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); // already escaped |
|
1375 | + return ''; |
|
1376 | + } |
|
1377 | + return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); |
|
1378 | + } |
|
1379 | 1379 | } |
1380 | 1380 | |
1381 | 1381 | |
1382 | 1382 | if (! function_exists('espresso_venue_phone')) { |
1383 | - /** |
|
1384 | - * espresso_venue_phone |
|
1385 | - * |
|
1386 | - * @param int $VNU_ID |
|
1387 | - * @param bool $echo |
|
1388 | - * @return string |
|
1389 | - * @throws EE_Error |
|
1390 | - * @throws ReflectionException |
|
1391 | - */ |
|
1392 | - function espresso_venue_phone($VNU_ID = 0, $echo = true) |
|
1393 | - { |
|
1394 | - if ($echo) { |
|
1395 | - echo wp_kses(EEH_Venue_View::venue_phone($VNU_ID), AllowedTags::getWithFormTags()); |
|
1396 | - return ''; |
|
1397 | - } |
|
1398 | - return EEH_Venue_View::venue_phone($VNU_ID); |
|
1399 | - } |
|
1383 | + /** |
|
1384 | + * espresso_venue_phone |
|
1385 | + * |
|
1386 | + * @param int $VNU_ID |
|
1387 | + * @param bool $echo |
|
1388 | + * @return string |
|
1389 | + * @throws EE_Error |
|
1390 | + * @throws ReflectionException |
|
1391 | + */ |
|
1392 | + function espresso_venue_phone($VNU_ID = 0, $echo = true) |
|
1393 | + { |
|
1394 | + if ($echo) { |
|
1395 | + echo wp_kses(EEH_Venue_View::venue_phone($VNU_ID), AllowedTags::getWithFormTags()); |
|
1396 | + return ''; |
|
1397 | + } |
|
1398 | + return EEH_Venue_View::venue_phone($VNU_ID); |
|
1399 | + } |
|
1400 | 1400 | } |
1401 | 1401 | |
1402 | 1402 | |
1403 | 1403 | if (! function_exists('espresso_venue_website')) { |
1404 | - /** |
|
1405 | - * espresso_venue_website |
|
1406 | - * |
|
1407 | - * @param int $VNU_ID |
|
1408 | - * @param bool $echo |
|
1409 | - * @return string |
|
1410 | - * @throws EE_Error |
|
1411 | - * @throws ReflectionException |
|
1412 | - */ |
|
1413 | - function espresso_venue_website($VNU_ID = 0, $echo = true) |
|
1414 | - { |
|
1415 | - if ($echo) { |
|
1416 | - echo wp_kses(EEH_Venue_View::venue_website_link($VNU_ID), AllowedTags::getWithFormTags()); |
|
1417 | - return ''; |
|
1418 | - } |
|
1419 | - return EEH_Venue_View::venue_website_link($VNU_ID); |
|
1420 | - } |
|
1404 | + /** |
|
1405 | + * espresso_venue_website |
|
1406 | + * |
|
1407 | + * @param int $VNU_ID |
|
1408 | + * @param bool $echo |
|
1409 | + * @return string |
|
1410 | + * @throws EE_Error |
|
1411 | + * @throws ReflectionException |
|
1412 | + */ |
|
1413 | + function espresso_venue_website($VNU_ID = 0, $echo = true) |
|
1414 | + { |
|
1415 | + if ($echo) { |
|
1416 | + echo wp_kses(EEH_Venue_View::venue_website_link($VNU_ID), AllowedTags::getWithFormTags()); |
|
1417 | + return ''; |
|
1418 | + } |
|
1419 | + return EEH_Venue_View::venue_website_link($VNU_ID); |
|
1420 | + } |
|
1421 | 1421 | } |
1422 | 1422 | |
1423 | 1423 | |
1424 | 1424 | if (! function_exists('espresso_edit_venue_link')) { |
1425 | - /** |
|
1426 | - * espresso_edit_venue_link |
|
1427 | - * |
|
1428 | - * @param int $VNU_ID |
|
1429 | - * @param bool $echo |
|
1430 | - * @return string |
|
1431 | - * @throws EE_Error |
|
1432 | - * @throws ReflectionException |
|
1433 | - */ |
|
1434 | - function espresso_edit_venue_link($VNU_ID = 0, $echo = true) |
|
1435 | - { |
|
1436 | - if ($echo) { |
|
1437 | - echo wp_kses(EEH_Venue_View::edit_venue_link($VNU_ID), AllowedTags::getWithFormTags()); |
|
1438 | - return ''; |
|
1439 | - } |
|
1440 | - return EEH_Venue_View::edit_venue_link($VNU_ID); |
|
1441 | - } |
|
1425 | + /** |
|
1426 | + * espresso_edit_venue_link |
|
1427 | + * |
|
1428 | + * @param int $VNU_ID |
|
1429 | + * @param bool $echo |
|
1430 | + * @return string |
|
1431 | + * @throws EE_Error |
|
1432 | + * @throws ReflectionException |
|
1433 | + */ |
|
1434 | + function espresso_edit_venue_link($VNU_ID = 0, $echo = true) |
|
1435 | + { |
|
1436 | + if ($echo) { |
|
1437 | + echo wp_kses(EEH_Venue_View::edit_venue_link($VNU_ID), AllowedTags::getWithFormTags()); |
|
1438 | + return ''; |
|
1439 | + } |
|
1440 | + return EEH_Venue_View::edit_venue_link($VNU_ID); |
|
1441 | + } |
|
1442 | 1442 | } |
1443 | 1443 | |
1444 | 1444 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function is_espresso_event($event = null): bool |
24 | 24 | { |
25 | - if (! can_use_espresso_conditionals(__FUNCTION__)) { |
|
25 | + if ( ! can_use_espresso_conditionals(__FUNCTION__)) { |
|
26 | 26 | return false; |
27 | 27 | } |
28 | 28 | // extract EE_Event object from passed param regardless of what it is (within reason of course) |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | function is_espresso_event_single(): bool |
41 | 41 | { |
42 | - if (! can_use_espresso_conditionals(__FUNCTION__)) { |
|
42 | + if ( ! can_use_espresso_conditionals(__FUNCTION__)) { |
|
43 | 43 | return false; |
44 | 44 | } |
45 | 45 | global $wp_query; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | function is_espresso_event_archive(): bool |
59 | 59 | { |
60 | - if (! can_use_espresso_conditionals(__FUNCTION__)) { |
|
60 | + if ( ! can_use_espresso_conditionals(__FUNCTION__)) { |
|
61 | 61 | return false; |
62 | 62 | } |
63 | 63 | global $wp_query; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | function is_espresso_event_taxonomy(): bool |
76 | 76 | { |
77 | - if (! can_use_espresso_conditionals(__FUNCTION__)) { |
|
77 | + if ( ! can_use_espresso_conditionals(__FUNCTION__)) { |
|
78 | 78 | return false; |
79 | 79 | } |
80 | 80 | global $wp_query; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | function is_espresso_venue($venue = null): bool |
96 | 96 | { |
97 | - if (! can_use_espresso_conditionals(__FUNCTION__)) { |
|
97 | + if ( ! can_use_espresso_conditionals(__FUNCTION__)) { |
|
98 | 98 | return false; |
99 | 99 | } |
100 | 100 | // extract EE_Venue object from passed param regardless of what it is (within reason of course) |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | function is_espresso_venue_single(): bool |
113 | 113 | { |
114 | - if (! can_use_espresso_conditionals(__FUNCTION__)) { |
|
114 | + if ( ! can_use_espresso_conditionals(__FUNCTION__)) { |
|
115 | 115 | return false; |
116 | 116 | } |
117 | 117 | global $wp_query; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | function is_espresso_venue_archive(): bool |
130 | 130 | { |
131 | - if (! can_use_espresso_conditionals(__FUNCTION__)) { |
|
131 | + if ( ! can_use_espresso_conditionals(__FUNCTION__)) { |
|
132 | 132 | return false; |
133 | 133 | } |
134 | 134 | global $wp_query; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | */ |
146 | 146 | function is_espresso_venue_taxonomy(): bool |
147 | 147 | { |
148 | - if (! can_use_espresso_conditionals(__FUNCTION__)) { |
|
148 | + if ( ! can_use_espresso_conditionals(__FUNCTION__)) { |
|
149 | 149 | return false; |
150 | 150 | } |
151 | 151 | global $wp_query; |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | */ |
164 | 164 | function can_use_espresso_conditionals($conditional_tag): bool |
165 | 165 | { |
166 | - if (! did_action('AHEE__EE_System__initialize')) { |
|
166 | + if ( ! did_action('AHEE__EE_System__initialize')) { |
|
167 | 167 | EE_Error::doing_it_wrong( |
168 | 168 | __FUNCTION__, |
169 | 169 | sprintf( |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | |
184 | 184 | /*************************** Event Queries ***************************/ |
185 | 185 | |
186 | -if (! function_exists('espresso_get_events')) { |
|
186 | +if ( ! function_exists('espresso_get_events')) { |
|
187 | 187 | /** |
188 | 188 | * espresso_get_events |
189 | 189 | * |
@@ -233,10 +233,10 @@ discard block |
||
233 | 233 | */ |
234 | 234 | function espresso_load_ticket_selector() |
235 | 235 | { |
236 | - EE_Registry::instance()->load_file(EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module'); |
|
236 | + EE_Registry::instance()->load_file(EE_MODULES.'ticket_selector', 'EED_Ticket_Selector', 'module'); |
|
237 | 237 | } |
238 | 238 | |
239 | -if (! function_exists('espresso_ticket_selector')) { |
|
239 | +if ( ! function_exists('espresso_ticket_selector')) { |
|
240 | 240 | /** |
241 | 241 | * espresso_ticket_selector |
242 | 242 | * |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | */ |
247 | 247 | function espresso_ticket_selector($event = null) |
248 | 248 | { |
249 | - if (! apply_filters('FHEE_disable_espresso_ticket_selector', false)) { |
|
249 | + if ( ! apply_filters('FHEE_disable_espresso_ticket_selector', false)) { |
|
250 | 250 | espresso_load_ticket_selector(); |
251 | 251 | EED_Ticket_Selector::set_definitions(); |
252 | 252 | echo EED_Ticket_Selector::display_ticket_selector($event); // already escaped |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | } |
256 | 256 | |
257 | 257 | |
258 | -if (! function_exists('espresso_view_details_btn')) { |
|
258 | +if ( ! function_exists('espresso_view_details_btn')) { |
|
259 | 259 | /** |
260 | 260 | * espresso_view_details_btn |
261 | 261 | * |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | */ |
266 | 266 | function espresso_view_details_btn($event = null) |
267 | 267 | { |
268 | - if (! apply_filters('FHEE_disable_espresso_view_details_btn', false)) { |
|
268 | + if ( ! apply_filters('FHEE_disable_espresso_view_details_btn', false)) { |
|
269 | 269 | espresso_load_ticket_selector(); |
270 | 270 | echo EED_Ticket_Selector::display_ticket_selector($event, true); // already escaped |
271 | 271 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | |
276 | 276 | /*************************** EEH_Event_View ***************************/ |
277 | 277 | |
278 | -if (! function_exists('espresso_load_event_list_assets')) { |
|
278 | +if ( ! function_exists('espresso_load_event_list_assets')) { |
|
279 | 279 | /** |
280 | 280 | * espresso_load_event_list_assets |
281 | 281 | * ensures that event list styles and scripts are loaded |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | } |
292 | 292 | |
293 | 293 | |
294 | -if (! function_exists('espresso_event_reg_button')) { |
|
294 | +if ( ! function_exists('espresso_event_reg_button')) { |
|
295 | 295 | /** |
296 | 296 | * espresso_event_reg_button |
297 | 297 | * returns the "Register Now" button if event is active, |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | function espresso_event_reg_button($btn_text_if_active = null, $btn_text_if_inactive = false, $EVT_ID = false) |
309 | 309 | { |
310 | 310 | $event = EEH_Event_View::get_event($EVT_ID); |
311 | - if (! $event instanceof EE_Event) { |
|
311 | + if ( ! $event instanceof EE_Event) { |
|
312 | 312 | return; |
313 | 313 | } |
314 | 314 | $event_status = $event->get_active_status(); |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | } |
354 | 354 | |
355 | 355 | |
356 | -if (! function_exists('espresso_display_ticket_selector')) { |
|
356 | +if ( ! function_exists('espresso_display_ticket_selector')) { |
|
357 | 357 | /** |
358 | 358 | * espresso_display_ticket_selector |
359 | 359 | * whether or not to display the Ticket Selector for an event |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | } |
371 | 371 | |
372 | 372 | |
373 | -if (! function_exists('espresso_event_status_banner')) { |
|
373 | +if ( ! function_exists('espresso_event_status_banner')) { |
|
374 | 374 | /** |
375 | 375 | * espresso_event_status |
376 | 376 | * returns a banner showing the event status if it is sold out, expired, or inactive |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | } |
388 | 388 | |
389 | 389 | |
390 | -if (! function_exists('espresso_event_status')) { |
|
390 | +if ( ! function_exists('espresso_event_status')) { |
|
391 | 391 | /** |
392 | 392 | * espresso_event_status |
393 | 393 | * returns the event status if it is sold out, expired, or inactive |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | } |
406 | 406 | |
407 | 407 | |
408 | -if (! function_exists('espresso_event_categories')) { |
|
408 | +if ( ! function_exists('espresso_event_categories')) { |
|
409 | 409 | /** |
410 | 410 | * espresso_event_categories |
411 | 411 | * returns the terms associated with an event |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | } |
429 | 429 | |
430 | 430 | |
431 | -if (! function_exists('espresso_event_tickets_available')) { |
|
431 | +if ( ! function_exists('espresso_event_tickets_available')) { |
|
432 | 432 | /** |
433 | 433 | * espresso_event_tickets_available |
434 | 434 | * returns the ticket types available for purchase for an event |
@@ -446,14 +446,14 @@ discard block |
||
446 | 446 | if (is_array($tickets) && ! empty($tickets)) { |
447 | 447 | // if formatting then $html will be a string, else it will be an array of ticket objects |
448 | 448 | $html = |
449 | - $format ? '<ul id="ee-event-tickets-ul-' . esc_attr($EVT_ID) . '" class="ee-event-tickets-ul">' : []; |
|
449 | + $format ? '<ul id="ee-event-tickets-ul-'.esc_attr($EVT_ID).'" class="ee-event-tickets-ul">' : []; |
|
450 | 450 | foreach ($tickets as $ticket) { |
451 | 451 | if ($ticket instanceof EE_Ticket) { |
452 | 452 | if ($format) { |
453 | 453 | $html .= '<li id="ee-event-tickets-li-' |
454 | 454 | . esc_attr($ticket->ID()) |
455 | 455 | . '" class="ee-event-tickets-li">'; |
456 | - $html .= esc_html($ticket->name()) . ' '; |
|
456 | + $html .= esc_html($ticket->name()).' '; |
|
457 | 457 | $html .= EEH_Template::format_currency( |
458 | 458 | $ticket->get_ticket_total_with_taxes() |
459 | 459 | ); // already escaped |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | } |
477 | 477 | } |
478 | 478 | |
479 | -if (! function_exists('espresso_event_date_obj')) { |
|
479 | +if ( ! function_exists('espresso_event_date_obj')) { |
|
480 | 480 | /** |
481 | 481 | * espresso_event_date_obj |
482 | 482 | * returns the primary date object for an event |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | } |
494 | 494 | |
495 | 495 | |
496 | -if (! function_exists('espresso_event_date')) { |
|
496 | +if ( ! function_exists('espresso_event_date')) { |
|
497 | 497 | /** |
498 | 498 | * espresso_event_date |
499 | 499 | * returns the primary date for an event |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | } |
523 | 523 | |
524 | 524 | |
525 | -if (! function_exists('espresso_list_of_event_dates')) { |
|
525 | +if ( ! function_exists('espresso_list_of_event_dates')) { |
|
526 | 526 | /** |
527 | 527 | * espresso_list_of_event_dates |
528 | 528 | * returns a unordered list of dates for an event |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | $DTT_ID = LoaderFactory::getShared(RequestInterface::class)->getRequestParam('datetime', 0, 'int'); |
555 | 555 | $arguments = apply_filters( |
556 | 556 | 'FHEE__espresso_list_of_event_dates__arguments', |
557 | - [ $EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit, $DTT_ID ] |
|
557 | + [$EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit, $DTT_ID] |
|
558 | 558 | ); |
559 | 559 | [$EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit, $DTT_ID] = $arguments; |
560 | 560 | $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | $datetimes = $DTT_ID |
565 | 565 | ? [EEH_Event_View::get_date_obj($DTT_ID)] |
566 | 566 | : EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, false, (int) $limit); |
567 | - if (! $format) { |
|
567 | + if ( ! $format) { |
|
568 | 568 | return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes); |
569 | 569 | } |
570 | 570 | $newline = $add_breaks ? '<br />' : ''; |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | $cols = count($datetimes); |
574 | 574 | $cols = $cols >= 3 ? 'big' : 'small'; |
575 | 575 | $ul_class = "ee-event-datetimes-ul ee-event-datetimes-ul--{$cols}"; |
576 | - $html = '<ul id="ee-event-datetimes-ul-' . esc_attr($post->ID) . '" class="'. $ul_class.'">'; |
|
576 | + $html = '<ul id="ee-event-datetimes-ul-'.esc_attr($post->ID).'" class="'.$ul_class.'">'; |
|
577 | 577 | $datetime = null; |
578 | 578 | foreach ($datetimes as $datetime) { |
579 | 579 | if ($datetime instanceof EE_Datetime) { |
@@ -582,36 +582,36 @@ discard block |
||
582 | 582 | $datetime_html = ! empty($datetime_name) |
583 | 583 | ? ' |
584 | 584 | <strong class="ee-event-datetimes-li-date-name"> |
585 | - ' . esc_html($datetime_name) . ' |
|
585 | + ' . esc_html($datetime_name).' |
|
586 | 586 | </strong>' . $newline |
587 | 587 | : ''; |
588 | 588 | |
589 | 589 | $datetime_html .= ' |
590 | 590 | <span class="ee-event-datetimes-li-daterange"> |
591 | 591 | <span class="dashicons dashicons-calendar"></span> ' |
592 | - . $datetime->date_range($date_format). ' |
|
592 | + . $datetime->date_range($date_format).' |
|
593 | 593 | </span> |
594 | 594 | <br/> |
595 | 595 | <span class="ee-event-datetimes-li-timerange"> |
596 | 596 | <span class="dashicons dashicons-clock"></span> ' |
597 | - . $datetime->time_range($time_format) . ' |
|
597 | + . $datetime->time_range($time_format).' |
|
598 | 598 | </span> |
599 | 599 | '; |
600 | 600 | |
601 | 601 | $venue = $datetime->venue(); |
602 | 602 | if ($venue instanceof EE_Venue) { |
603 | - $venue_name = esc_html($venue->name()); |
|
603 | + $venue_name = esc_html($venue->name()); |
|
604 | 604 | $datetime_html .= '<br /><span class="ee-event-datetimes-li-venue">'; |
605 | 605 | $datetime_html .= '<span class="dashicons dashicons-admin-home"></span> '; |
606 | - $datetime_html .= '<a href="'. esc_url_raw($venue->get_permalink()) .'" target="_blank">'; |
|
607 | - $datetime_html .= $venue_name . '</a></span>'; |
|
606 | + $datetime_html .= '<a href="'.esc_url_raw($venue->get_permalink()).'" target="_blank">'; |
|
607 | + $datetime_html .= $venue_name.'</a></span>'; |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | $datetime_description = str_replace(['<p>', '</p>'], '', $datetime->description()); |
611 | 611 | $datetime_html .= ! empty($datetime_description) |
612 | 612 | ? ' |
613 | 613 | <span class="ee-event-datetimes-li-date-desc"> |
614 | - ' . wp_kses($datetime_description, $allowedtags) . ' |
|
614 | + ' . wp_kses($datetime_description, $allowedtags).' |
|
615 | 615 | </span>' . $newline |
616 | 616 | : ''; |
617 | 617 | |
@@ -623,11 +623,11 @@ discard block |
||
623 | 623 | ); |
624 | 624 | |
625 | 625 | $DTD_ID = esc_attr($datetime->ID()); |
626 | - $active_status = esc_attr('ee-event-datetimes-li-' . $datetime->get_active_status()); |
|
626 | + $active_status = esc_attr('ee-event-datetimes-li-'.$datetime->get_active_status()); |
|
627 | 627 | |
628 | 628 | $html .= ' |
629 | - <li id="ee-event-datetimes-li-' . $DTD_ID . '" class="ee-event-datetimes-li ' . $active_status . '"> |
|
630 | - ' . $datetime_html . ' |
|
629 | + <li id="ee-event-datetimes-li-' . $DTD_ID.'" class="ee-event-datetimes-li '.$active_status.'"> |
|
630 | + ' . $datetime_html.' |
|
631 | 631 | </li>'; |
632 | 632 | } |
633 | 633 | } |
@@ -641,7 +641,7 @@ discard block |
||
641 | 641 | ' . esc_html__( |
642 | 642 | 'There are no upcoming dates for this event.', |
643 | 643 | 'event_espresso' |
644 | - ) . ' |
|
644 | + ).' |
|
645 | 645 | </p> |
646 | 646 | <br/>'; |
647 | 647 | } |
@@ -654,7 +654,7 @@ discard block |
||
654 | 654 | } |
655 | 655 | |
656 | 656 | |
657 | -if (! function_exists('espresso_event_end_date')) { |
|
657 | +if ( ! function_exists('espresso_event_end_date')) { |
|
658 | 658 | /** |
659 | 659 | * espresso_event_end_date |
660 | 660 | * returns the last date for an event |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | } |
682 | 682 | } |
683 | 683 | |
684 | -if (! function_exists('espresso_event_date_range')) { |
|
684 | +if ( ! function_exists('espresso_event_date_range')) { |
|
685 | 685 | /** |
686 | 686 | * espresso_event_date_range |
687 | 687 | * returns the first and last chronologically ordered dates for an event (if different) |
@@ -739,7 +739,7 @@ discard block |
||
739 | 739 | } |
740 | 740 | } |
741 | 741 | |
742 | -if (! function_exists('espresso_next_upcoming_datetime_obj')) { |
|
742 | +if ( ! function_exists('espresso_next_upcoming_datetime_obj')) { |
|
743 | 743 | /** |
744 | 744 | * espresso_next_upcoming_datetime_obj |
745 | 745 | * returns the next upcoming datetime object for an event |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | } |
755 | 755 | } |
756 | 756 | |
757 | -if (! function_exists('espresso_next_upcoming_datetime')) { |
|
757 | +if ( ! function_exists('espresso_next_upcoming_datetime')) { |
|
758 | 758 | /** |
759 | 759 | * espresso_next_upcoming_datetime |
760 | 760 | * returns the start date and time for the next upcoming event. |
@@ -776,11 +776,11 @@ discard block |
||
776 | 776 | $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
777 | 777 | $time_format = apply_filters('FHEE__espresso_next_upcoming_datetime__time_format', $time_format); |
778 | 778 | |
779 | - $datetime_format = trim($date_format . ' ' . $time_format); |
|
779 | + $datetime_format = trim($date_format.' '.$time_format); |
|
780 | 780 | |
781 | 781 | $datetime = espresso_next_upcoming_datetime_obj($EVT_ID); |
782 | 782 | |
783 | - if (! $datetime instanceof EE_Datetime) { |
|
783 | + if ( ! $datetime instanceof EE_Datetime) { |
|
784 | 784 | return ''; |
785 | 785 | } |
786 | 786 | if ($echo) { |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | } |
792 | 792 | } |
793 | 793 | |
794 | -if (! function_exists('espresso_event_date_as_calendar_page')) { |
|
794 | +if ( ! function_exists('espresso_event_date_as_calendar_page')) { |
|
795 | 795 | /** |
796 | 796 | * espresso_event_date_as_calendar_page |
797 | 797 | * returns the primary date for an event, stylized to appear as the page of a calendar |
@@ -808,7 +808,7 @@ discard block |
||
808 | 808 | } |
809 | 809 | |
810 | 810 | |
811 | -if (! function_exists('espresso_event_link_url')) { |
|
811 | +if ( ! function_exists('espresso_event_link_url')) { |
|
812 | 812 | /** |
813 | 813 | * espresso_event_link_url |
814 | 814 | * |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | } |
830 | 830 | |
831 | 831 | |
832 | -if (! function_exists('espresso_event_has_content_or_excerpt')) { |
|
832 | +if ( ! function_exists('espresso_event_has_content_or_excerpt')) { |
|
833 | 833 | /** |
834 | 834 | * espresso_event_has_content_or_excerpt |
835 | 835 | * |
@@ -846,7 +846,7 @@ discard block |
||
846 | 846 | } |
847 | 847 | |
848 | 848 | |
849 | -if (! function_exists('espresso_event_content_or_excerpt')) { |
|
849 | +if ( ! function_exists('espresso_event_content_or_excerpt')) { |
|
850 | 850 | /** |
851 | 851 | * espresso_event_content_or_excerpt |
852 | 852 | * |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | } |
867 | 867 | |
868 | 868 | |
869 | -if (! function_exists('espresso_event_phone')) { |
|
869 | +if ( ! function_exists('espresso_event_phone')) { |
|
870 | 870 | /** |
871 | 871 | * espresso_event_phone |
872 | 872 | * |
@@ -887,7 +887,7 @@ discard block |
||
887 | 887 | } |
888 | 888 | |
889 | 889 | |
890 | -if (! function_exists('espresso_edit_event_link')) { |
|
890 | +if ( ! function_exists('espresso_edit_event_link')) { |
|
891 | 891 | /** |
892 | 892 | * espresso_edit_event_link |
893 | 893 | * returns a link to edit an event |
@@ -909,7 +909,7 @@ discard block |
||
909 | 909 | } |
910 | 910 | |
911 | 911 | |
912 | -if (! function_exists('espresso_organization_name')) { |
|
912 | +if ( ! function_exists('espresso_organization_name')) { |
|
913 | 913 | /** |
914 | 914 | * espresso_organization_name |
915 | 915 | * |
@@ -927,7 +927,7 @@ discard block |
||
927 | 927 | } |
928 | 928 | } |
929 | 929 | |
930 | -if (! function_exists('espresso_organization_address')) { |
|
930 | +if ( ! function_exists('espresso_organization_address')) { |
|
931 | 931 | /** |
932 | 932 | * espresso_organization_address |
933 | 933 | * |
@@ -951,7 +951,7 @@ discard block |
||
951 | 951 | } |
952 | 952 | } |
953 | 953 | |
954 | -if (! function_exists('espresso_organization_email')) { |
|
954 | +if ( ! function_exists('espresso_organization_email')) { |
|
955 | 955 | /** |
956 | 956 | * espresso_organization_email |
957 | 957 | * |
@@ -969,7 +969,7 @@ discard block |
||
969 | 969 | } |
970 | 970 | } |
971 | 971 | |
972 | -if (! function_exists('espresso_organization_logo_url')) { |
|
972 | +if ( ! function_exists('espresso_organization_logo_url')) { |
|
973 | 973 | /** |
974 | 974 | * espresso_organization_logo_url |
975 | 975 | * |
@@ -987,7 +987,7 @@ discard block |
||
987 | 987 | } |
988 | 988 | } |
989 | 989 | |
990 | -if (! function_exists('espresso_organization_facebook')) { |
|
990 | +if ( ! function_exists('espresso_organization_facebook')) { |
|
991 | 991 | /** |
992 | 992 | * espresso_organization_facebook |
993 | 993 | * |
@@ -1005,7 +1005,7 @@ discard block |
||
1005 | 1005 | } |
1006 | 1006 | } |
1007 | 1007 | |
1008 | -if (! function_exists('espresso_organization_twitter')) { |
|
1008 | +if ( ! function_exists('espresso_organization_twitter')) { |
|
1009 | 1009 | /** |
1010 | 1010 | * espresso_organization_twitter |
1011 | 1011 | * |
@@ -1023,7 +1023,7 @@ discard block |
||
1023 | 1023 | } |
1024 | 1024 | } |
1025 | 1025 | |
1026 | -if (! function_exists('espresso_organization_linkedin')) { |
|
1026 | +if ( ! function_exists('espresso_organization_linkedin')) { |
|
1027 | 1027 | /** |
1028 | 1028 | * espresso_organization_linkedin |
1029 | 1029 | * |
@@ -1041,7 +1041,7 @@ discard block |
||
1041 | 1041 | } |
1042 | 1042 | } |
1043 | 1043 | |
1044 | -if (! function_exists('espresso_organization_pinterest')) { |
|
1044 | +if ( ! function_exists('espresso_organization_pinterest')) { |
|
1045 | 1045 | /** |
1046 | 1046 | * espresso_organization_pinterest |
1047 | 1047 | * |
@@ -1059,7 +1059,7 @@ discard block |
||
1059 | 1059 | } |
1060 | 1060 | } |
1061 | 1061 | |
1062 | -if (! function_exists('espresso_organization_google')) { |
|
1062 | +if ( ! function_exists('espresso_organization_google')) { |
|
1063 | 1063 | /** |
1064 | 1064 | * espresso_organization_google |
1065 | 1065 | * |
@@ -1077,7 +1077,7 @@ discard block |
||
1077 | 1077 | } |
1078 | 1078 | } |
1079 | 1079 | |
1080 | -if (! function_exists('espresso_organization_instagram')) { |
|
1080 | +if ( ! function_exists('espresso_organization_instagram')) { |
|
1081 | 1081 | /** |
1082 | 1082 | * espresso_organization_instagram |
1083 | 1083 | * |
@@ -1099,7 +1099,7 @@ discard block |
||
1099 | 1099 | /*************************** EEH_Venue_View ***************************/ |
1100 | 1100 | |
1101 | 1101 | |
1102 | -if (! function_exists('espresso_event_venues')) { |
|
1102 | +if ( ! function_exists('espresso_event_venues')) { |
|
1103 | 1103 | /** |
1104 | 1104 | * espresso_event_venues |
1105 | 1105 | * |
@@ -1114,7 +1114,7 @@ discard block |
||
1114 | 1114 | } |
1115 | 1115 | |
1116 | 1116 | |
1117 | -if (! function_exists('espresso_venue_id')) { |
|
1117 | +if ( ! function_exists('espresso_venue_id')) { |
|
1118 | 1118 | /** |
1119 | 1119 | * espresso_venue_name |
1120 | 1120 | * |
@@ -1132,7 +1132,7 @@ discard block |
||
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | |
1135 | -if (! function_exists('espresso_is_venue_private')) { |
|
1135 | +if ( ! function_exists('espresso_is_venue_private')) { |
|
1136 | 1136 | /** |
1137 | 1137 | * Return whether a venue is private or not. |
1138 | 1138 | * |
@@ -1150,7 +1150,7 @@ discard block |
||
1150 | 1150 | } |
1151 | 1151 | |
1152 | 1152 | |
1153 | -if (! function_exists('espresso_venue_is_password_protected')) { |
|
1153 | +if ( ! function_exists('espresso_venue_is_password_protected')) { |
|
1154 | 1154 | /** |
1155 | 1155 | * returns true or false if a venue is password protected or not |
1156 | 1156 | * |
@@ -1167,7 +1167,7 @@ discard block |
||
1167 | 1167 | } |
1168 | 1168 | |
1169 | 1169 | |
1170 | -if (! function_exists('espresso_password_protected_venue_form')) { |
|
1170 | +if ( ! function_exists('espresso_password_protected_venue_form')) { |
|
1171 | 1171 | /** |
1172 | 1172 | * Returns a password form if venue is password protected. |
1173 | 1173 | * |
@@ -1184,7 +1184,7 @@ discard block |
||
1184 | 1184 | } |
1185 | 1185 | |
1186 | 1186 | |
1187 | -if (! function_exists('espresso_venue_name')) { |
|
1187 | +if ( ! function_exists('espresso_venue_name')) { |
|
1188 | 1188 | /** |
1189 | 1189 | * espresso_venue_name |
1190 | 1190 | * |
@@ -1207,7 +1207,7 @@ discard block |
||
1207 | 1207 | } |
1208 | 1208 | |
1209 | 1209 | |
1210 | -if (! function_exists('espresso_venue_link')) { |
|
1210 | +if ( ! function_exists('espresso_venue_link')) { |
|
1211 | 1211 | /** |
1212 | 1212 | * espresso_venue_link |
1213 | 1213 | * |
@@ -1225,7 +1225,7 @@ discard block |
||
1225 | 1225 | } |
1226 | 1226 | |
1227 | 1227 | |
1228 | -if (! function_exists('espresso_venue_description')) { |
|
1228 | +if ( ! function_exists('espresso_venue_description')) { |
|
1229 | 1229 | /** |
1230 | 1230 | * espresso_venue_description |
1231 | 1231 | * |
@@ -1247,7 +1247,7 @@ discard block |
||
1247 | 1247 | } |
1248 | 1248 | |
1249 | 1249 | |
1250 | -if (! function_exists('espresso_venue_excerpt')) { |
|
1250 | +if ( ! function_exists('espresso_venue_excerpt')) { |
|
1251 | 1251 | /** |
1252 | 1252 | * espresso_venue_excerpt |
1253 | 1253 | * |
@@ -1269,7 +1269,7 @@ discard block |
||
1269 | 1269 | } |
1270 | 1270 | |
1271 | 1271 | |
1272 | -if (! function_exists('espresso_venue_categories')) { |
|
1272 | +if ( ! function_exists('espresso_venue_categories')) { |
|
1273 | 1273 | /** |
1274 | 1274 | * espresso_venue_categories |
1275 | 1275 | * returns the terms associated with a venue |
@@ -1292,7 +1292,7 @@ discard block |
||
1292 | 1292 | } |
1293 | 1293 | |
1294 | 1294 | |
1295 | -if (! function_exists('espresso_venue_address')) { |
|
1295 | +if ( ! function_exists('espresso_venue_address')) { |
|
1296 | 1296 | /** |
1297 | 1297 | * espresso_venue_address |
1298 | 1298 | * returns a formatted block of html for displaying a venue's address |
@@ -1315,7 +1315,7 @@ discard block |
||
1315 | 1315 | } |
1316 | 1316 | |
1317 | 1317 | |
1318 | -if (! function_exists('espresso_venue_raw_address')) { |
|
1318 | +if ( ! function_exists('espresso_venue_raw_address')) { |
|
1319 | 1319 | /** |
1320 | 1320 | * espresso_venue_address |
1321 | 1321 | * returns an UN-formatted string containing a venue's address |
@@ -1338,7 +1338,7 @@ discard block |
||
1338 | 1338 | } |
1339 | 1339 | |
1340 | 1340 | |
1341 | -if (! function_exists('espresso_venue_has_address')) { |
|
1341 | +if ( ! function_exists('espresso_venue_has_address')) { |
|
1342 | 1342 | /** |
1343 | 1343 | * espresso_venue_has_address |
1344 | 1344 | * returns TRUE or FALSE if a Venue has address information |
@@ -1355,7 +1355,7 @@ discard block |
||
1355 | 1355 | } |
1356 | 1356 | |
1357 | 1357 | |
1358 | -if (! function_exists('espresso_venue_gmap')) { |
|
1358 | +if ( ! function_exists('espresso_venue_gmap')) { |
|
1359 | 1359 | /** |
1360 | 1360 | * espresso_venue_gmap |
1361 | 1361 | * returns a google map for the venue address |
@@ -1379,7 +1379,7 @@ discard block |
||
1379 | 1379 | } |
1380 | 1380 | |
1381 | 1381 | |
1382 | -if (! function_exists('espresso_venue_phone')) { |
|
1382 | +if ( ! function_exists('espresso_venue_phone')) { |
|
1383 | 1383 | /** |
1384 | 1384 | * espresso_venue_phone |
1385 | 1385 | * |
@@ -1400,7 +1400,7 @@ discard block |
||
1400 | 1400 | } |
1401 | 1401 | |
1402 | 1402 | |
1403 | -if (! function_exists('espresso_venue_website')) { |
|
1403 | +if ( ! function_exists('espresso_venue_website')) { |
|
1404 | 1404 | /** |
1405 | 1405 | * espresso_venue_website |
1406 | 1406 | * |
@@ -1421,7 +1421,7 @@ discard block |
||
1421 | 1421 | } |
1422 | 1422 | |
1423 | 1423 | |
1424 | -if (! function_exists('espresso_edit_venue_link')) { |
|
1424 | +if ( ! function_exists('espresso_edit_venue_link')) { |
|
1425 | 1425 | /** |
1426 | 1426 | * espresso_edit_venue_link |
1427 | 1427 | * |
@@ -15,81 +15,81 @@ discard block |
||
15 | 15 | */ |
16 | 16 | class EEW_Upcoming_Events extends EspressoWidget |
17 | 17 | { |
18 | - private bool $date_range = false; |
|
19 | - |
|
20 | - private bool $show_dates = true; |
|
21 | - |
|
22 | - private bool $show_desc = true; |
|
23 | - |
|
24 | - private int $date_limit = 2; |
|
25 | - |
|
26 | - private int $limit = 10; |
|
27 | - |
|
28 | - private int $show_expired = 0; |
|
29 | - |
|
30 | - private string $events_category = ''; |
|
31 | - |
|
32 | - private string $image_size = 'medium'; |
|
33 | - |
|
34 | - private string $order = 'ASC'; |
|
35 | - |
|
36 | - private string $title = ''; |
|
37 | - |
|
38 | - |
|
39 | - /** |
|
40 | - * Register widget with WordPress. |
|
41 | - */ |
|
42 | - public function __construct() |
|
43 | - { |
|
44 | - parent::__construct( |
|
45 | - esc_html__('Event Espresso Upcoming Events', 'event_espresso'), |
|
46 | - ['description' => esc_html__('A widget to display your upcoming events.', 'event_espresso')] |
|
47 | - ); |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * Back-end widget form. |
|
53 | - * |
|
54 | - * @param array $instance Previously saved values from database. |
|
55 | - * @return void |
|
56 | - * @throws EE_Error |
|
57 | - * @throws ReflectionException |
|
58 | - * @see WP_Widget::form() |
|
59 | - */ |
|
60 | - public function form($instance) |
|
61 | - { |
|
62 | - EE_Registry::instance()->load_class('Question_Option', [], false, false, true); |
|
63 | - // Set up some default widget settings. |
|
64 | - $defaults = [ |
|
65 | - 'category_name' => '', |
|
66 | - 'date_limit' => 2, |
|
67 | - 'date_range' => false, |
|
68 | - 'image_size' => 'medium', |
|
69 | - 'limit' => 10, |
|
70 | - 'show_dates' => true, |
|
71 | - 'show_desc' => true, |
|
72 | - 'show_everywhere' => false, |
|
73 | - 'show_expired' => 0, |
|
74 | - 'sort' => 'ASC', |
|
75 | - 'title' => esc_html__('Upcoming Events', 'event_espresso'), |
|
76 | - ]; |
|
77 | - |
|
78 | - $instance = wp_parse_args((array) $instance, $defaults); |
|
79 | - // don't add HTML labels for EE_Form_Fields generated inputs |
|
80 | - add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string'); |
|
81 | - $yes_no_values = [ |
|
82 | - EE_Question_Option::new_instance(['QSO_value' => false, 'QSO_desc' => esc_html__('No', 'event_espresso')]), |
|
83 | - EE_Question_Option::new_instance(['QSO_value' => true, 'QSO_desc' => esc_html__('Yes', 'event_espresso')]), |
|
84 | - ]; |
|
85 | - $sort_values = [ |
|
86 | - EE_Question_Option::new_instance(['QSO_value' => 'ASC', 'QSO_desc' => esc_html__('ASC', 'event_espresso')]), |
|
87 | - EE_Question_Option::new_instance( |
|
88 | - ['QSO_value' => 'DESC', 'QSO_desc' => esc_html__('DESC', 'event_espresso')] |
|
89 | - ), |
|
90 | - ]; |
|
91 | - |
|
92 | - ?> |
|
18 | + private bool $date_range = false; |
|
19 | + |
|
20 | + private bool $show_dates = true; |
|
21 | + |
|
22 | + private bool $show_desc = true; |
|
23 | + |
|
24 | + private int $date_limit = 2; |
|
25 | + |
|
26 | + private int $limit = 10; |
|
27 | + |
|
28 | + private int $show_expired = 0; |
|
29 | + |
|
30 | + private string $events_category = ''; |
|
31 | + |
|
32 | + private string $image_size = 'medium'; |
|
33 | + |
|
34 | + private string $order = 'ASC'; |
|
35 | + |
|
36 | + private string $title = ''; |
|
37 | + |
|
38 | + |
|
39 | + /** |
|
40 | + * Register widget with WordPress. |
|
41 | + */ |
|
42 | + public function __construct() |
|
43 | + { |
|
44 | + parent::__construct( |
|
45 | + esc_html__('Event Espresso Upcoming Events', 'event_espresso'), |
|
46 | + ['description' => esc_html__('A widget to display your upcoming events.', 'event_espresso')] |
|
47 | + ); |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * Back-end widget form. |
|
53 | + * |
|
54 | + * @param array $instance Previously saved values from database. |
|
55 | + * @return void |
|
56 | + * @throws EE_Error |
|
57 | + * @throws ReflectionException |
|
58 | + * @see WP_Widget::form() |
|
59 | + */ |
|
60 | + public function form($instance) |
|
61 | + { |
|
62 | + EE_Registry::instance()->load_class('Question_Option', [], false, false, true); |
|
63 | + // Set up some default widget settings. |
|
64 | + $defaults = [ |
|
65 | + 'category_name' => '', |
|
66 | + 'date_limit' => 2, |
|
67 | + 'date_range' => false, |
|
68 | + 'image_size' => 'medium', |
|
69 | + 'limit' => 10, |
|
70 | + 'show_dates' => true, |
|
71 | + 'show_desc' => true, |
|
72 | + 'show_everywhere' => false, |
|
73 | + 'show_expired' => 0, |
|
74 | + 'sort' => 'ASC', |
|
75 | + 'title' => esc_html__('Upcoming Events', 'event_espresso'), |
|
76 | + ]; |
|
77 | + |
|
78 | + $instance = wp_parse_args((array) $instance, $defaults); |
|
79 | + // don't add HTML labels for EE_Form_Fields generated inputs |
|
80 | + add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string'); |
|
81 | + $yes_no_values = [ |
|
82 | + EE_Question_Option::new_instance(['QSO_value' => false, 'QSO_desc' => esc_html__('No', 'event_espresso')]), |
|
83 | + EE_Question_Option::new_instance(['QSO_value' => true, 'QSO_desc' => esc_html__('Yes', 'event_espresso')]), |
|
84 | + ]; |
|
85 | + $sort_values = [ |
|
86 | + EE_Question_Option::new_instance(['QSO_value' => 'ASC', 'QSO_desc' => esc_html__('ASC', 'event_espresso')]), |
|
87 | + EE_Question_Option::new_instance( |
|
88 | + ['QSO_value' => 'DESC', 'QSO_desc' => esc_html__('DESC', 'event_espresso')] |
|
89 | + ), |
|
90 | + ]; |
|
91 | + |
|
92 | + ?> |
|
93 | 93 | <!-- Widget Title: Text Input --> |
94 | 94 | <p> |
95 | 95 | <label for="<?php echo esc_attr($this->fieldID('title')); ?>"> |
@@ -124,41 +124,41 @@ discard block |
||
124 | 124 | <?php esc_html_e('Show Expired Events:', 'event_espresso'); ?> |
125 | 125 | </label> |
126 | 126 | <?php |
127 | - $show_expired_options = [ |
|
128 | - EE_Question_Option::new_instance(['QSO_value' => 0, 'QSO_desc' => esc_html__('No', 'event_espresso')]), |
|
129 | - EE_Question_Option::new_instance(['QSO_value' => 1, 'QSO_desc' => esc_html__('Yes', 'event_espresso')]), |
|
130 | - EE_Question_Option::new_instance( |
|
131 | - ['QSO_value' => 2, 'QSO_desc' => esc_html__('Show Only Expired', 'event_espresso')] |
|
132 | - ), |
|
133 | - ]; |
|
134 | - echo wp_kses( |
|
135 | - EEH_Form_Fields::select( |
|
136 | - esc_html__('Show Expired Events:', 'event_espresso'), |
|
137 | - $instance['show_expired'], |
|
138 | - $show_expired_options, |
|
139 | - $this->fieldName('show_expired'), |
|
140 | - $this->fieldID('show_expired') |
|
141 | - ), |
|
142 | - AllowedTags::getWithFormTags() |
|
143 | - ); |
|
144 | - ?> |
|
127 | + $show_expired_options = [ |
|
128 | + EE_Question_Option::new_instance(['QSO_value' => 0, 'QSO_desc' => esc_html__('No', 'event_espresso')]), |
|
129 | + EE_Question_Option::new_instance(['QSO_value' => 1, 'QSO_desc' => esc_html__('Yes', 'event_espresso')]), |
|
130 | + EE_Question_Option::new_instance( |
|
131 | + ['QSO_value' => 2, 'QSO_desc' => esc_html__('Show Only Expired', 'event_espresso')] |
|
132 | + ), |
|
133 | + ]; |
|
134 | + echo wp_kses( |
|
135 | + EEH_Form_Fields::select( |
|
136 | + esc_html__('Show Expired Events:', 'event_espresso'), |
|
137 | + $instance['show_expired'], |
|
138 | + $show_expired_options, |
|
139 | + $this->fieldName('show_expired'), |
|
140 | + $this->fieldID('show_expired') |
|
141 | + ), |
|
142 | + AllowedTags::getWithFormTags() |
|
143 | + ); |
|
144 | + ?> |
|
145 | 145 | </p> |
146 | 146 | <p> |
147 | 147 | <label for="<?php echo esc_attr($this->fieldID('sort')); ?>"> |
148 | 148 | <?php esc_html_e('Sort Events:', 'event_espresso'); ?> |
149 | 149 | </label> |
150 | 150 | <?php |
151 | - echo wp_kses( |
|
152 | - EEH_Form_Fields::select( |
|
153 | - esc_html__('Sort Events:', 'event_espresso'), |
|
154 | - $instance['sort'], |
|
155 | - $sort_values, |
|
156 | - $this->fieldName('sort'), |
|
157 | - $this->fieldID('sort') |
|
158 | - ), |
|
159 | - AllowedTags::getWithFormTags() |
|
160 | - ); |
|
161 | - ?> |
|
151 | + echo wp_kses( |
|
152 | + EEH_Form_Fields::select( |
|
153 | + esc_html__('Sort Events:', 'event_espresso'), |
|
154 | + $instance['sort'], |
|
155 | + $sort_values, |
|
156 | + $this->fieldName('sort'), |
|
157 | + $this->fieldID('sort') |
|
158 | + ), |
|
159 | + AllowedTags::getWithFormTags() |
|
160 | + ); |
|
161 | + ?> |
|
162 | 162 | </p> |
163 | 163 | <p> |
164 | 164 | <label for="<?php echo esc_attr($this->fieldID('image_size')); ?>"> |
@@ -172,51 +172,51 @@ discard block |
||
172 | 172 | <?php esc_html_e('Show Description:', 'event_espresso'); ?> |
173 | 173 | </label> |
174 | 174 | <?php |
175 | - echo wp_kses( |
|
176 | - EEH_Form_Fields::select( |
|
177 | - esc_html__('Show Description:', 'event_espresso'), |
|
178 | - $instance['show_desc'], |
|
179 | - $yes_no_values, |
|
180 | - $this->fieldName('show_desc'), |
|
181 | - $this->fieldID('show_desc') |
|
182 | - ), |
|
183 | - AllowedTags::getWithFormTags() |
|
184 | - ); |
|
185 | - ?> |
|
175 | + echo wp_kses( |
|
176 | + EEH_Form_Fields::select( |
|
177 | + esc_html__('Show Description:', 'event_espresso'), |
|
178 | + $instance['show_desc'], |
|
179 | + $yes_no_values, |
|
180 | + $this->fieldName('show_desc'), |
|
181 | + $this->fieldID('show_desc') |
|
182 | + ), |
|
183 | + AllowedTags::getWithFormTags() |
|
184 | + ); |
|
185 | + ?> |
|
186 | 186 | </p> |
187 | 187 | <p> |
188 | 188 | <label for="<?php echo esc_attr($this->fieldID('show_dates')); ?>"> |
189 | 189 | <?php esc_html_e('Show Dates:', 'event_espresso'); ?> |
190 | 190 | </label> |
191 | 191 | <?php |
192 | - echo wp_kses( |
|
193 | - EEH_Form_Fields::select( |
|
194 | - esc_html__('Show Dates:', 'event_espresso'), |
|
195 | - $instance['show_dates'], |
|
196 | - $yes_no_values, |
|
197 | - $this->fieldName('show_dates'), |
|
198 | - $this->fieldID('show_dates') |
|
199 | - ), |
|
200 | - AllowedTags::getWithFormTags() |
|
201 | - ); |
|
202 | - ?> |
|
192 | + echo wp_kses( |
|
193 | + EEH_Form_Fields::select( |
|
194 | + esc_html__('Show Dates:', 'event_espresso'), |
|
195 | + $instance['show_dates'], |
|
196 | + $yes_no_values, |
|
197 | + $this->fieldName('show_dates'), |
|
198 | + $this->fieldID('show_dates') |
|
199 | + ), |
|
200 | + AllowedTags::getWithFormTags() |
|
201 | + ); |
|
202 | + ?> |
|
203 | 203 | </p> |
204 | 204 | <p> |
205 | 205 | <label for="<?php echo esc_attr($this->fieldID('show_everywhere')); ?>"> |
206 | 206 | <?php esc_html_e('Show on all Pages:', 'event_espresso'); ?> |
207 | 207 | </label> |
208 | 208 | <?php |
209 | - echo wp_kses( |
|
210 | - EEH_Form_Fields::select( |
|
211 | - esc_html__('Show on all Pages:', 'event_espresso'), |
|
212 | - $instance['show_everywhere'], |
|
213 | - $yes_no_values, |
|
214 | - $this->fieldName('show_everywhere'), |
|
215 | - $this->fieldID('show_everywhere') |
|
216 | - ), |
|
217 | - AllowedTags::getWithFormTags() |
|
218 | - ); |
|
219 | - ?> |
|
209 | + echo wp_kses( |
|
210 | + EEH_Form_Fields::select( |
|
211 | + esc_html__('Show on all Pages:', 'event_espresso'), |
|
212 | + $instance['show_everywhere'], |
|
213 | + $yes_no_values, |
|
214 | + $this->fieldName('show_everywhere'), |
|
215 | + $this->fieldID('show_everywhere') |
|
216 | + ), |
|
217 | + AllowedTags::getWithFormTags() |
|
218 | + ); |
|
219 | + ?> |
|
220 | 220 | </p> |
221 | 221 | <p> |
222 | 222 | <label for="<?php echo esc_attr($this->fieldID('date_limit')); ?>"> |
@@ -234,296 +234,296 @@ discard block |
||
234 | 234 | <?php esc_html_e('Show Date Range:', 'event_espresso'); ?> |
235 | 235 | </label> |
236 | 236 | <?php |
237 | - echo wp_kses( |
|
238 | - EEH_Form_Fields::select( |
|
239 | - esc_html__('Show Date Range:', 'event_espresso'), |
|
240 | - $instance['date_range'], |
|
241 | - $yes_no_values, |
|
242 | - $this->fieldName('date_range'), |
|
243 | - $this->fieldID('date_range') |
|
244 | - ), |
|
245 | - AllowedTags::getWithFormTags() |
|
246 | - ); |
|
247 | - ?> |
|
237 | + echo wp_kses( |
|
238 | + EEH_Form_Fields::select( |
|
239 | + esc_html__('Show Date Range:', 'event_espresso'), |
|
240 | + $instance['date_range'], |
|
241 | + $yes_no_values, |
|
242 | + $this->fieldName('date_range'), |
|
243 | + $this->fieldID('date_range') |
|
244 | + ), |
|
245 | + AllowedTags::getWithFormTags() |
|
246 | + ); |
|
247 | + ?> |
|
248 | 248 | <span class="description"> |
249 | 249 | <br/> |
250 | 250 | <?php esc_html_e( |
251 | - 'This setting will replace the list of dates in the widget.', |
|
252 | - 'event_espresso' |
|
253 | - ); ?> |
|
251 | + 'This setting will replace the list of dates in the widget.', |
|
252 | + 'event_espresso' |
|
253 | + ); ?> |
|
254 | 254 | </span> |
255 | 255 | </p> |
256 | 256 | <?php |
257 | - } |
|
258 | - |
|
259 | - |
|
260 | - /** |
|
261 | - * Sanitize widget form values as they are saved. |
|
262 | - * |
|
263 | - * @param array $new_instance Values just sent to be saved. |
|
264 | - * @param array $old_instance Previously saved values from database. |
|
265 | - * |
|
266 | - * @return array Updated safe values to be saved. |
|
267 | - * @see WP_Widget::update() |
|
268 | - * |
|
269 | - */ |
|
270 | - public function update($new_instance, $old_instance) |
|
271 | - { |
|
272 | - /** @var RequestInterface $request */ |
|
273 | - $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
274 | - |
|
275 | - if (! $request->isWordPressApi() || ! is_user_logged_in()) { |
|
276 | - return $old_instance; |
|
277 | - } |
|
278 | - |
|
279 | - $instance = $old_instance; |
|
280 | - $instance['title'] = ! empty($new_instance['title']) |
|
281 | - ? strip_tags((string) $new_instance['title']) |
|
282 | - : ''; |
|
283 | - $instance['category_name'] = sanitize_text_field($new_instance['category_name'] ?? ''); |
|
284 | - $instance['show_expired'] = absint($new_instance['show_expired'] ?? 0); |
|
285 | - $instance['limit'] = absint($new_instance['limit'] ?? 10); |
|
286 | - $instance['sort'] = isset($new_instance['sort']) && $new_instance['sort'] === 'DESC' |
|
287 | - ? 'DESC' |
|
288 | - : 'ASC'; |
|
289 | - $instance['image_size'] = sanitize_text_field($new_instance['image_size'] ?? 'medium'); |
|
290 | - $instance['show_desc'] = filter_var(($new_instance['show_desc'] ?? false), FILTER_VALIDATE_BOOLEAN); |
|
291 | - $instance['show_dates'] = filter_var(($new_instance['show_dates'] ?? false), FILTER_VALIDATE_BOOLEAN); |
|
292 | - $instance['show_everywhere'] = filter_var(($new_instance['show_everywhere'] ?? false), FILTER_VALIDATE_BOOLEAN); |
|
293 | - $instance['date_limit'] = absint($new_instance['date_limit'] ?? 10); |
|
294 | - $instance['date_range'] = filter_var(($new_instance['date_range'] ?? false), FILTER_VALIDATE_BOOLEAN); |
|
295 | - return $instance; |
|
296 | - } |
|
297 | - |
|
298 | - |
|
299 | - /** |
|
300 | - * Front-end display of widget. |
|
301 | - * |
|
302 | - * @param array $args Widget arguments. |
|
303 | - * @param array $instance Saved values from database. |
|
304 | - * @throws EE_Error |
|
305 | - * @throws ReflectionException |
|
306 | - * @see WP_Widget::widget() |
|
307 | - * |
|
308 | - */ |
|
309 | - public function widget($args, $instance) |
|
310 | - { |
|
311 | - global $post; |
|
312 | - // make sure there is some kinda post object |
|
313 | - if ($post instanceof WP_Post) { |
|
314 | - $before_widget = ''; |
|
315 | - $before_title = ''; |
|
316 | - $after_title = ''; |
|
317 | - $after_widget = ''; |
|
318 | - // but NOT an events archives page, cuz that would be like two event lists on the same page |
|
319 | - $show_everywhere = ! isset($instance['show_everywhere']) || absint($instance['show_everywhere']); |
|
320 | - if ($show_everywhere || ! ($post->post_type == EspressoPostType::EVENTS && is_archive())) { |
|
321 | - // let's use some of the event helper functions' |
|
322 | - // make separate vars out of attributes |
|
323 | - extract($args); |
|
324 | - |
|
325 | - // grab widget settings |
|
326 | - $this->parseWidgetSettings($instance); |
|
327 | - $title = $this->widgetTitle(); |
|
328 | - |
|
329 | - // Before widget (defined by themes). |
|
330 | - echo wp_kses($before_widget, AllowedTags::getAllowedTags()); |
|
331 | - // Display the widget title if one was input (before and after defined by themes). |
|
332 | - if (! empty($title)) { |
|
333 | - echo wp_kses($before_title . $title . $after_title, AllowedTags::getAllowedTags()); |
|
334 | - } |
|
335 | - echo wp_kses($this->widgetContent($post), AllowedTags::getWithFormTags()); |
|
336 | - // After widget (defined by themes). |
|
337 | - echo wp_kses($after_widget, AllowedTags::getAllowedTags()); |
|
338 | - } |
|
339 | - } |
|
340 | - } |
|
341 | - |
|
342 | - |
|
343 | - /** |
|
344 | - * make_the_title_a_link |
|
345 | - * callback for widget_title filter |
|
346 | - * |
|
347 | - * @param string $title |
|
348 | - * @return string |
|
349 | - */ |
|
350 | - public function make_the_title_a_link(string $title): string |
|
351 | - { |
|
352 | - return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>'; |
|
353 | - } |
|
354 | - |
|
355 | - |
|
356 | - /** |
|
357 | - * @param string $field_name |
|
358 | - * @return string |
|
359 | - * @since 4.10.14.p |
|
360 | - */ |
|
361 | - public function fieldID(string $field_name): string |
|
362 | - { |
|
363 | - return parent::get_field_id($field_name); |
|
364 | - } |
|
365 | - |
|
366 | - |
|
367 | - /** |
|
368 | - * @param string $field_name |
|
369 | - * @return string |
|
370 | - * @since 4.10.14.p |
|
371 | - */ |
|
372 | - public function fieldName(string $field_name): string |
|
373 | - { |
|
374 | - return parent::get_field_name($field_name); |
|
375 | - } |
|
376 | - |
|
377 | - |
|
378 | - /** |
|
379 | - * @param array $instance |
|
380 | - * @throws EE_Error |
|
381 | - * @throws ReflectionException |
|
382 | - * @since 4.10.14.p |
|
383 | - */ |
|
384 | - private function eventCategoriesSelector(array $instance) |
|
385 | - { |
|
386 | - $event_categories = []; |
|
387 | - $categories = EEM_Term::instance()->get_all_ee_categories(true); |
|
388 | - if ($categories) { |
|
389 | - foreach ($categories as $category) { |
|
390 | - if ($category instanceof EE_Term) { |
|
391 | - $event_categories[] = |
|
392 | - EE_Question_Option::new_instance( |
|
393 | - [ |
|
394 | - 'QSO_value' => $category->get('slug'), |
|
395 | - 'QSO_desc' => $category->get('name'), |
|
396 | - ] |
|
397 | - ); |
|
398 | - } |
|
399 | - } |
|
400 | - } |
|
401 | - array_unshift( |
|
402 | - $event_categories, |
|
403 | - EE_Question_Option::new_instance( |
|
404 | - [ |
|
405 | - 'QSO_value' => '', |
|
406 | - 'QSO_desc' => esc_html__(' - display all - ', 'event_espresso'), |
|
407 | - ] |
|
408 | - ) |
|
409 | - ); |
|
410 | - echo wp_kses( |
|
411 | - EEH_Form_Fields::select( |
|
412 | - esc_html__('Event Category:', 'event_espresso'), |
|
413 | - $instance['category_name'], |
|
414 | - $event_categories, |
|
415 | - $this->fieldName('category_name'), |
|
416 | - $this->fieldID('category_name') |
|
417 | - ), |
|
418 | - AllowedTags::getWithFormTags() |
|
419 | - ); |
|
420 | - } |
|
421 | - |
|
422 | - |
|
423 | - /** |
|
424 | - * @param array $instance |
|
425 | - * @since 4.10.14.p |
|
426 | - */ |
|
427 | - private function imageSizeSelector(array $instance) |
|
428 | - { |
|
429 | - $image_sizes = []; |
|
430 | - $sizes = get_intermediate_image_sizes(); |
|
431 | - if ($sizes) { |
|
432 | - // loop thru images and create option objects out of them |
|
433 | - foreach ($sizes as $image_size) { |
|
434 | - $image_size = trim($image_size); |
|
435 | - // no big images plz |
|
436 | - if (! in_array($image_size, ['large', 'post-thumbnail'])) { |
|
437 | - $image_sizes[] = |
|
438 | - EE_Question_Option::new_instance(['QSO_value' => $image_size, 'QSO_desc' => $image_size]); |
|
439 | - } |
|
440 | - } |
|
441 | - $image_sizes[] = |
|
442 | - EE_Question_Option::new_instance( |
|
443 | - ['QSO_value' => 'none', 'QSO_desc' => esc_html__('don\'t show images', 'event_espresso')] |
|
444 | - ); |
|
445 | - } |
|
446 | - echo wp_kses( |
|
447 | - EEH_Form_Fields::select( |
|
448 | - esc_html__('Image Size:', 'event_espresso'), |
|
449 | - $instance['image_size'], |
|
450 | - $image_sizes, |
|
451 | - $this->fieldName('image_size'), |
|
452 | - $this->fieldID('image_size') |
|
453 | - ), |
|
454 | - AllowedTags::getWithFormTags() |
|
455 | - ); |
|
456 | - } |
|
457 | - |
|
458 | - |
|
459 | - /** |
|
460 | - * @param array $instance |
|
461 | - * @since 4.10.14.p |
|
462 | - */ |
|
463 | - private function parseWidgetSettings(array $instance) |
|
464 | - { |
|
465 | - $this->title = ! empty($instance['title']) ? $instance['title'] : ''; |
|
466 | - $this->events_category = ! empty($instance['category_name']) |
|
467 | - ? $instance['category_name'] |
|
468 | - : ''; |
|
469 | - $this->show_everywhere = isset($instance['show_everywhere']) |
|
470 | - ? filter_var($instance['show_everywhere'], FILTER_VALIDATE_BOOLEAN) |
|
471 | - : false; |
|
472 | - $this->show_expired = isset($instance['show_expired']) ? absint($instance['show_expired']) : 0; |
|
473 | - $this->image_size = ! empty($instance['image_size']) |
|
474 | - ? $instance['image_size'] |
|
475 | - : 'medium'; |
|
476 | - $this->show_desc = ! isset($instance['show_desc']) |
|
477 | - || filter_var($instance['show_desc'], FILTER_VALIDATE_BOOLEAN); |
|
478 | - $this->show_dates = ! isset($instance['show_dates']) |
|
479 | - || filter_var($instance['show_dates'], FILTER_VALIDATE_BOOLEAN); |
|
480 | - $this->date_limit = ! empty($instance['date_limit']) |
|
481 | - ? $instance['date_limit'] |
|
482 | - : 2; |
|
483 | - $this->date_range = ! isset($instance['date_range']) |
|
484 | - || filter_var($instance['date_range'], FILTER_VALIDATE_BOOLEAN); |
|
485 | - $this->limit = isset($instance['limit']) ? absint($instance['limit']) : 10; |
|
486 | - $this->order = isset($instance['sort']) && $instance['sort'] === 'DESC' |
|
487 | - ? 'DESC' |
|
488 | - : 'ASC'; |
|
489 | - } |
|
490 | - |
|
491 | - |
|
492 | - /** |
|
493 | - * @return mixed|void |
|
494 | - * @since 4.10.14.p |
|
495 | - */ |
|
496 | - private function widgetTitle() |
|
497 | - { |
|
498 | - // add function to make the title a link |
|
499 | - add_filter('widget_title', [$this, 'make_the_title_a_link'], 15); |
|
500 | - // filter the title |
|
501 | - $title = apply_filters('widget_title', $this->title); |
|
502 | - // remove the function from the filter, so it does not affect other widgets |
|
503 | - remove_filter('widget_title', [$this, 'make_the_title_a_link'], 15); |
|
504 | - return $title; |
|
505 | - } |
|
506 | - |
|
507 | - |
|
508 | - /** |
|
509 | - * @param WP_Post $post |
|
510 | - * @return string |
|
511 | - * @throws EE_Error |
|
512 | - * @throws ReflectionException |
|
513 | - * @since 4.10.14.p |
|
514 | - */ |
|
515 | - private function widgetContent(WP_Post $post): string |
|
516 | - { |
|
517 | - // run the query |
|
518 | - $events = $this->getUpcomingEvents(); |
|
519 | - if (empty($events)) { |
|
520 | - return ''; |
|
521 | - } |
|
522 | - $list_items = ''; |
|
523 | - foreach ($events as $event) { |
|
524 | - if ($event instanceof EE_Event && (! is_single() || $post->ID != $event->ID())) { |
|
525 | - $event_url = $this->eventUrl($event); |
|
526 | - $list_items .= ' |
|
257 | + } |
|
258 | + |
|
259 | + |
|
260 | + /** |
|
261 | + * Sanitize widget form values as they are saved. |
|
262 | + * |
|
263 | + * @param array $new_instance Values just sent to be saved. |
|
264 | + * @param array $old_instance Previously saved values from database. |
|
265 | + * |
|
266 | + * @return array Updated safe values to be saved. |
|
267 | + * @see WP_Widget::update() |
|
268 | + * |
|
269 | + */ |
|
270 | + public function update($new_instance, $old_instance) |
|
271 | + { |
|
272 | + /** @var RequestInterface $request */ |
|
273 | + $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
274 | + |
|
275 | + if (! $request->isWordPressApi() || ! is_user_logged_in()) { |
|
276 | + return $old_instance; |
|
277 | + } |
|
278 | + |
|
279 | + $instance = $old_instance; |
|
280 | + $instance['title'] = ! empty($new_instance['title']) |
|
281 | + ? strip_tags((string) $new_instance['title']) |
|
282 | + : ''; |
|
283 | + $instance['category_name'] = sanitize_text_field($new_instance['category_name'] ?? ''); |
|
284 | + $instance['show_expired'] = absint($new_instance['show_expired'] ?? 0); |
|
285 | + $instance['limit'] = absint($new_instance['limit'] ?? 10); |
|
286 | + $instance['sort'] = isset($new_instance['sort']) && $new_instance['sort'] === 'DESC' |
|
287 | + ? 'DESC' |
|
288 | + : 'ASC'; |
|
289 | + $instance['image_size'] = sanitize_text_field($new_instance['image_size'] ?? 'medium'); |
|
290 | + $instance['show_desc'] = filter_var(($new_instance['show_desc'] ?? false), FILTER_VALIDATE_BOOLEAN); |
|
291 | + $instance['show_dates'] = filter_var(($new_instance['show_dates'] ?? false), FILTER_VALIDATE_BOOLEAN); |
|
292 | + $instance['show_everywhere'] = filter_var(($new_instance['show_everywhere'] ?? false), FILTER_VALIDATE_BOOLEAN); |
|
293 | + $instance['date_limit'] = absint($new_instance['date_limit'] ?? 10); |
|
294 | + $instance['date_range'] = filter_var(($new_instance['date_range'] ?? false), FILTER_VALIDATE_BOOLEAN); |
|
295 | + return $instance; |
|
296 | + } |
|
297 | + |
|
298 | + |
|
299 | + /** |
|
300 | + * Front-end display of widget. |
|
301 | + * |
|
302 | + * @param array $args Widget arguments. |
|
303 | + * @param array $instance Saved values from database. |
|
304 | + * @throws EE_Error |
|
305 | + * @throws ReflectionException |
|
306 | + * @see WP_Widget::widget() |
|
307 | + * |
|
308 | + */ |
|
309 | + public function widget($args, $instance) |
|
310 | + { |
|
311 | + global $post; |
|
312 | + // make sure there is some kinda post object |
|
313 | + if ($post instanceof WP_Post) { |
|
314 | + $before_widget = ''; |
|
315 | + $before_title = ''; |
|
316 | + $after_title = ''; |
|
317 | + $after_widget = ''; |
|
318 | + // but NOT an events archives page, cuz that would be like two event lists on the same page |
|
319 | + $show_everywhere = ! isset($instance['show_everywhere']) || absint($instance['show_everywhere']); |
|
320 | + if ($show_everywhere || ! ($post->post_type == EspressoPostType::EVENTS && is_archive())) { |
|
321 | + // let's use some of the event helper functions' |
|
322 | + // make separate vars out of attributes |
|
323 | + extract($args); |
|
324 | + |
|
325 | + // grab widget settings |
|
326 | + $this->parseWidgetSettings($instance); |
|
327 | + $title = $this->widgetTitle(); |
|
328 | + |
|
329 | + // Before widget (defined by themes). |
|
330 | + echo wp_kses($before_widget, AllowedTags::getAllowedTags()); |
|
331 | + // Display the widget title if one was input (before and after defined by themes). |
|
332 | + if (! empty($title)) { |
|
333 | + echo wp_kses($before_title . $title . $after_title, AllowedTags::getAllowedTags()); |
|
334 | + } |
|
335 | + echo wp_kses($this->widgetContent($post), AllowedTags::getWithFormTags()); |
|
336 | + // After widget (defined by themes). |
|
337 | + echo wp_kses($after_widget, AllowedTags::getAllowedTags()); |
|
338 | + } |
|
339 | + } |
|
340 | + } |
|
341 | + |
|
342 | + |
|
343 | + /** |
|
344 | + * make_the_title_a_link |
|
345 | + * callback for widget_title filter |
|
346 | + * |
|
347 | + * @param string $title |
|
348 | + * @return string |
|
349 | + */ |
|
350 | + public function make_the_title_a_link(string $title): string |
|
351 | + { |
|
352 | + return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>'; |
|
353 | + } |
|
354 | + |
|
355 | + |
|
356 | + /** |
|
357 | + * @param string $field_name |
|
358 | + * @return string |
|
359 | + * @since 4.10.14.p |
|
360 | + */ |
|
361 | + public function fieldID(string $field_name): string |
|
362 | + { |
|
363 | + return parent::get_field_id($field_name); |
|
364 | + } |
|
365 | + |
|
366 | + |
|
367 | + /** |
|
368 | + * @param string $field_name |
|
369 | + * @return string |
|
370 | + * @since 4.10.14.p |
|
371 | + */ |
|
372 | + public function fieldName(string $field_name): string |
|
373 | + { |
|
374 | + return parent::get_field_name($field_name); |
|
375 | + } |
|
376 | + |
|
377 | + |
|
378 | + /** |
|
379 | + * @param array $instance |
|
380 | + * @throws EE_Error |
|
381 | + * @throws ReflectionException |
|
382 | + * @since 4.10.14.p |
|
383 | + */ |
|
384 | + private function eventCategoriesSelector(array $instance) |
|
385 | + { |
|
386 | + $event_categories = []; |
|
387 | + $categories = EEM_Term::instance()->get_all_ee_categories(true); |
|
388 | + if ($categories) { |
|
389 | + foreach ($categories as $category) { |
|
390 | + if ($category instanceof EE_Term) { |
|
391 | + $event_categories[] = |
|
392 | + EE_Question_Option::new_instance( |
|
393 | + [ |
|
394 | + 'QSO_value' => $category->get('slug'), |
|
395 | + 'QSO_desc' => $category->get('name'), |
|
396 | + ] |
|
397 | + ); |
|
398 | + } |
|
399 | + } |
|
400 | + } |
|
401 | + array_unshift( |
|
402 | + $event_categories, |
|
403 | + EE_Question_Option::new_instance( |
|
404 | + [ |
|
405 | + 'QSO_value' => '', |
|
406 | + 'QSO_desc' => esc_html__(' - display all - ', 'event_espresso'), |
|
407 | + ] |
|
408 | + ) |
|
409 | + ); |
|
410 | + echo wp_kses( |
|
411 | + EEH_Form_Fields::select( |
|
412 | + esc_html__('Event Category:', 'event_espresso'), |
|
413 | + $instance['category_name'], |
|
414 | + $event_categories, |
|
415 | + $this->fieldName('category_name'), |
|
416 | + $this->fieldID('category_name') |
|
417 | + ), |
|
418 | + AllowedTags::getWithFormTags() |
|
419 | + ); |
|
420 | + } |
|
421 | + |
|
422 | + |
|
423 | + /** |
|
424 | + * @param array $instance |
|
425 | + * @since 4.10.14.p |
|
426 | + */ |
|
427 | + private function imageSizeSelector(array $instance) |
|
428 | + { |
|
429 | + $image_sizes = []; |
|
430 | + $sizes = get_intermediate_image_sizes(); |
|
431 | + if ($sizes) { |
|
432 | + // loop thru images and create option objects out of them |
|
433 | + foreach ($sizes as $image_size) { |
|
434 | + $image_size = trim($image_size); |
|
435 | + // no big images plz |
|
436 | + if (! in_array($image_size, ['large', 'post-thumbnail'])) { |
|
437 | + $image_sizes[] = |
|
438 | + EE_Question_Option::new_instance(['QSO_value' => $image_size, 'QSO_desc' => $image_size]); |
|
439 | + } |
|
440 | + } |
|
441 | + $image_sizes[] = |
|
442 | + EE_Question_Option::new_instance( |
|
443 | + ['QSO_value' => 'none', 'QSO_desc' => esc_html__('don\'t show images', 'event_espresso')] |
|
444 | + ); |
|
445 | + } |
|
446 | + echo wp_kses( |
|
447 | + EEH_Form_Fields::select( |
|
448 | + esc_html__('Image Size:', 'event_espresso'), |
|
449 | + $instance['image_size'], |
|
450 | + $image_sizes, |
|
451 | + $this->fieldName('image_size'), |
|
452 | + $this->fieldID('image_size') |
|
453 | + ), |
|
454 | + AllowedTags::getWithFormTags() |
|
455 | + ); |
|
456 | + } |
|
457 | + |
|
458 | + |
|
459 | + /** |
|
460 | + * @param array $instance |
|
461 | + * @since 4.10.14.p |
|
462 | + */ |
|
463 | + private function parseWidgetSettings(array $instance) |
|
464 | + { |
|
465 | + $this->title = ! empty($instance['title']) ? $instance['title'] : ''; |
|
466 | + $this->events_category = ! empty($instance['category_name']) |
|
467 | + ? $instance['category_name'] |
|
468 | + : ''; |
|
469 | + $this->show_everywhere = isset($instance['show_everywhere']) |
|
470 | + ? filter_var($instance['show_everywhere'], FILTER_VALIDATE_BOOLEAN) |
|
471 | + : false; |
|
472 | + $this->show_expired = isset($instance['show_expired']) ? absint($instance['show_expired']) : 0; |
|
473 | + $this->image_size = ! empty($instance['image_size']) |
|
474 | + ? $instance['image_size'] |
|
475 | + : 'medium'; |
|
476 | + $this->show_desc = ! isset($instance['show_desc']) |
|
477 | + || filter_var($instance['show_desc'], FILTER_VALIDATE_BOOLEAN); |
|
478 | + $this->show_dates = ! isset($instance['show_dates']) |
|
479 | + || filter_var($instance['show_dates'], FILTER_VALIDATE_BOOLEAN); |
|
480 | + $this->date_limit = ! empty($instance['date_limit']) |
|
481 | + ? $instance['date_limit'] |
|
482 | + : 2; |
|
483 | + $this->date_range = ! isset($instance['date_range']) |
|
484 | + || filter_var($instance['date_range'], FILTER_VALIDATE_BOOLEAN); |
|
485 | + $this->limit = isset($instance['limit']) ? absint($instance['limit']) : 10; |
|
486 | + $this->order = isset($instance['sort']) && $instance['sort'] === 'DESC' |
|
487 | + ? 'DESC' |
|
488 | + : 'ASC'; |
|
489 | + } |
|
490 | + |
|
491 | + |
|
492 | + /** |
|
493 | + * @return mixed|void |
|
494 | + * @since 4.10.14.p |
|
495 | + */ |
|
496 | + private function widgetTitle() |
|
497 | + { |
|
498 | + // add function to make the title a link |
|
499 | + add_filter('widget_title', [$this, 'make_the_title_a_link'], 15); |
|
500 | + // filter the title |
|
501 | + $title = apply_filters('widget_title', $this->title); |
|
502 | + // remove the function from the filter, so it does not affect other widgets |
|
503 | + remove_filter('widget_title', [$this, 'make_the_title_a_link'], 15); |
|
504 | + return $title; |
|
505 | + } |
|
506 | + |
|
507 | + |
|
508 | + /** |
|
509 | + * @param WP_Post $post |
|
510 | + * @return string |
|
511 | + * @throws EE_Error |
|
512 | + * @throws ReflectionException |
|
513 | + * @since 4.10.14.p |
|
514 | + */ |
|
515 | + private function widgetContent(WP_Post $post): string |
|
516 | + { |
|
517 | + // run the query |
|
518 | + $events = $this->getUpcomingEvents(); |
|
519 | + if (empty($events)) { |
|
520 | + return ''; |
|
521 | + } |
|
522 | + $list_items = ''; |
|
523 | + foreach ($events as $event) { |
|
524 | + if ($event instanceof EE_Event && (! is_single() || $post->ID != $event->ID())) { |
|
525 | + $event_url = $this->eventUrl($event); |
|
526 | + $list_items .= ' |
|
527 | 527 | <li id="ee-upcoming-events-widget-li-' . absint($event->ID()) . '" |
528 | 528 | class="ee-upcoming-events-widget-li" |
529 | 529 | > |
@@ -534,202 +534,202 @@ discard block |
||
534 | 534 | </h5> |
535 | 535 | ' . $this->eventWidgetContent($event, $event_url) . ' |
536 | 536 | </li>'; |
537 | - } |
|
538 | - } |
|
539 | - return ' |
|
537 | + } |
|
538 | + } |
|
539 | + return ' |
|
540 | 540 | <ul class="ee-upcoming-events-widget-ul"> |
541 | 541 | ' . $list_items . ' |
542 | 542 | </ul>'; |
543 | - } |
|
544 | - |
|
545 | - |
|
546 | - /** |
|
547 | - * @param EE_Event $event |
|
548 | - * @return string |
|
549 | - * @throws EE_Error |
|
550 | - * @throws ReflectionException |
|
551 | - * @since 4.10.14.p |
|
552 | - */ |
|
553 | - private function eventUrl(EE_Event $event): string |
|
554 | - { |
|
555 | - return esc_url_raw( |
|
556 | - (string) apply_filters( |
|
557 | - 'FHEE_EEW_Upcoming_Events__widget__event_url', |
|
558 | - $event->get_permalink(), |
|
559 | - $event |
|
560 | - ) |
|
561 | - ); |
|
562 | - } |
|
563 | - |
|
564 | - |
|
565 | - /** |
|
566 | - * @return EE_Base_Class[] |
|
567 | - * @throws EE_Error |
|
568 | - * @throws ReflectionException |
|
569 | - */ |
|
570 | - private function getUpcomingEvents(): array |
|
571 | - { |
|
572 | - return EEM_Event::instance()->get_all( |
|
573 | - [ |
|
574 | - $this->queryWhereParams(), |
|
575 | - 'limit' => '0,' . $this->limit, |
|
576 | - 'order_by' => 'Datetime.DTT_EVT_start', |
|
577 | - 'order' => $this->order, |
|
578 | - 'group_by' => 'EVT_ID', |
|
579 | - ] |
|
580 | - ); |
|
581 | - } |
|
582 | - |
|
583 | - |
|
584 | - /** |
|
585 | - * @return mixed|void |
|
586 | - * @throws EE_Error |
|
587 | - * @throws ReflectionException |
|
588 | - * @since 4.10.14.p |
|
589 | - */ |
|
590 | - private function queryWhereParams() |
|
591 | - { |
|
592 | - // start to build our where clause |
|
593 | - $where = [ |
|
594 | - 'status' => ['IN', ['publish', 'sold_out']], |
|
595 | - ]; |
|
596 | - // add category |
|
597 | - if ($this->events_category) { |
|
598 | - $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
599 | - $where['Term_Taxonomy.Term.slug'] = $this->events_category; |
|
600 | - } |
|
601 | - // if NOT expired then we want events that start today or in the future |
|
602 | - // if NOT show expired then we want events that start today or in the future |
|
603 | - if ($this->show_expired === 0) { |
|
604 | - $where['Datetime.DTT_EVT_end'] = [ |
|
605 | - '>=', |
|
606 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'), |
|
607 | - ]; |
|
608 | - } |
|
609 | - // if show ONLY expired we want events that ended prior to today |
|
610 | - if ($this->show_expired === 2) { |
|
611 | - $where['Datetime.DTT_EVT_end'] = [ |
|
612 | - '<=', |
|
613 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'), |
|
614 | - ]; |
|
615 | - } |
|
616 | - // allow $where to be filtered |
|
617 | - return apply_filters( |
|
618 | - 'FHEE__EEW_Upcoming_Events__widget__where', |
|
619 | - $where, |
|
620 | - $this->events_category, |
|
621 | - $this->show_expired |
|
622 | - ); |
|
623 | - } |
|
624 | - |
|
625 | - |
|
626 | - /** |
|
627 | - * @param EE_Event $event |
|
628 | - * @return string |
|
629 | - * @throws EE_Error |
|
630 | - * @throws ReflectionException |
|
631 | - * @since 4.10.14.p |
|
632 | - */ |
|
633 | - private function linkClass(EE_Event $event): string |
|
634 | - { |
|
635 | - // how big is the event name ? |
|
636 | - $name_length = strlen($event->name()); |
|
637 | - switch ($name_length) { |
|
638 | - case $name_length > 70: |
|
639 | - return ' three-line'; |
|
640 | - case $name_length > 35: |
|
641 | - return ' two-line'; |
|
642 | - } |
|
643 | - return ' one-line'; |
|
644 | - } |
|
645 | - |
|
646 | - |
|
647 | - /** |
|
648 | - * @param EE_Event $event |
|
649 | - * @param string $event_url |
|
650 | - * @return string |
|
651 | - * @throws EE_Error |
|
652 | - * @throws ReflectionException |
|
653 | - * @since 4.10.14.p |
|
654 | - */ |
|
655 | - private function eventWidgetContent(EE_Event $event, string $event_url = ''): string |
|
656 | - { |
|
657 | - if (post_password_required($event->ID())) { |
|
658 | - return (string) apply_filters( |
|
659 | - 'FHEE_EEW_Upcoming_Events__widget__password_form', |
|
660 | - get_the_password_form($event->ID()), |
|
661 | - $event |
|
662 | - ); |
|
663 | - } |
|
664 | - |
|
665 | - $content = ''; |
|
666 | - if (has_post_thumbnail($event->ID()) && $this->image_size != 'none') { |
|
667 | - $content .= ' |
|
543 | + } |
|
544 | + |
|
545 | + |
|
546 | + /** |
|
547 | + * @param EE_Event $event |
|
548 | + * @return string |
|
549 | + * @throws EE_Error |
|
550 | + * @throws ReflectionException |
|
551 | + * @since 4.10.14.p |
|
552 | + */ |
|
553 | + private function eventUrl(EE_Event $event): string |
|
554 | + { |
|
555 | + return esc_url_raw( |
|
556 | + (string) apply_filters( |
|
557 | + 'FHEE_EEW_Upcoming_Events__widget__event_url', |
|
558 | + $event->get_permalink(), |
|
559 | + $event |
|
560 | + ) |
|
561 | + ); |
|
562 | + } |
|
563 | + |
|
564 | + |
|
565 | + /** |
|
566 | + * @return EE_Base_Class[] |
|
567 | + * @throws EE_Error |
|
568 | + * @throws ReflectionException |
|
569 | + */ |
|
570 | + private function getUpcomingEvents(): array |
|
571 | + { |
|
572 | + return EEM_Event::instance()->get_all( |
|
573 | + [ |
|
574 | + $this->queryWhereParams(), |
|
575 | + 'limit' => '0,' . $this->limit, |
|
576 | + 'order_by' => 'Datetime.DTT_EVT_start', |
|
577 | + 'order' => $this->order, |
|
578 | + 'group_by' => 'EVT_ID', |
|
579 | + ] |
|
580 | + ); |
|
581 | + } |
|
582 | + |
|
583 | + |
|
584 | + /** |
|
585 | + * @return mixed|void |
|
586 | + * @throws EE_Error |
|
587 | + * @throws ReflectionException |
|
588 | + * @since 4.10.14.p |
|
589 | + */ |
|
590 | + private function queryWhereParams() |
|
591 | + { |
|
592 | + // start to build our where clause |
|
593 | + $where = [ |
|
594 | + 'status' => ['IN', ['publish', 'sold_out']], |
|
595 | + ]; |
|
596 | + // add category |
|
597 | + if ($this->events_category) { |
|
598 | + $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
599 | + $where['Term_Taxonomy.Term.slug'] = $this->events_category; |
|
600 | + } |
|
601 | + // if NOT expired then we want events that start today or in the future |
|
602 | + // if NOT show expired then we want events that start today or in the future |
|
603 | + if ($this->show_expired === 0) { |
|
604 | + $where['Datetime.DTT_EVT_end'] = [ |
|
605 | + '>=', |
|
606 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'), |
|
607 | + ]; |
|
608 | + } |
|
609 | + // if show ONLY expired we want events that ended prior to today |
|
610 | + if ($this->show_expired === 2) { |
|
611 | + $where['Datetime.DTT_EVT_end'] = [ |
|
612 | + '<=', |
|
613 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'), |
|
614 | + ]; |
|
615 | + } |
|
616 | + // allow $where to be filtered |
|
617 | + return apply_filters( |
|
618 | + 'FHEE__EEW_Upcoming_Events__widget__where', |
|
619 | + $where, |
|
620 | + $this->events_category, |
|
621 | + $this->show_expired |
|
622 | + ); |
|
623 | + } |
|
624 | + |
|
625 | + |
|
626 | + /** |
|
627 | + * @param EE_Event $event |
|
628 | + * @return string |
|
629 | + * @throws EE_Error |
|
630 | + * @throws ReflectionException |
|
631 | + * @since 4.10.14.p |
|
632 | + */ |
|
633 | + private function linkClass(EE_Event $event): string |
|
634 | + { |
|
635 | + // how big is the event name ? |
|
636 | + $name_length = strlen($event->name()); |
|
637 | + switch ($name_length) { |
|
638 | + case $name_length > 70: |
|
639 | + return ' three-line'; |
|
640 | + case $name_length > 35: |
|
641 | + return ' two-line'; |
|
642 | + } |
|
643 | + return ' one-line'; |
|
644 | + } |
|
645 | + |
|
646 | + |
|
647 | + /** |
|
648 | + * @param EE_Event $event |
|
649 | + * @param string $event_url |
|
650 | + * @return string |
|
651 | + * @throws EE_Error |
|
652 | + * @throws ReflectionException |
|
653 | + * @since 4.10.14.p |
|
654 | + */ |
|
655 | + private function eventWidgetContent(EE_Event $event, string $event_url = ''): string |
|
656 | + { |
|
657 | + if (post_password_required($event->ID())) { |
|
658 | + return (string) apply_filters( |
|
659 | + 'FHEE_EEW_Upcoming_Events__widget__password_form', |
|
660 | + get_the_password_form($event->ID()), |
|
661 | + $event |
|
662 | + ); |
|
663 | + } |
|
664 | + |
|
665 | + $content = ''; |
|
666 | + if (has_post_thumbnail($event->ID()) && $this->image_size != 'none') { |
|
667 | + $content .= ' |
|
668 | 668 | <div class="ee-upcoming-events-widget-img-dv"> |
669 | 669 | <a class="ee-upcoming-events-widget-img" href="' . $event_url . '"> |
670 | 670 | ' . get_the_post_thumbnail($event->ID(), $this->image_size) . ' |
671 | 671 | </a> |
672 | 672 | </div>'; |
673 | - } |
|
674 | - |
|
675 | - if ($this->show_dates) { |
|
676 | - $content .= $this->eventDates($event); |
|
677 | - } |
|
678 | - |
|
679 | - if ($this->show_desc) { |
|
680 | - $allowedtags = AllowedTags::getAllowedTags(); |
|
681 | - $desc = $event->short_description(25); |
|
682 | - $content .= $desc ? '<p style="margin-top: .5em">' . wp_kses($desc, $allowedtags) . '</p>' : ''; |
|
683 | - } |
|
684 | - |
|
685 | - return $content; |
|
686 | - } |
|
687 | - |
|
688 | - |
|
689 | - /** |
|
690 | - * @param EE_Event $event |
|
691 | - * @return string |
|
692 | - * @throws EE_Error |
|
693 | - * @throws ReflectionException |
|
694 | - * @since 4.10.14.p |
|
695 | - */ |
|
696 | - private function eventDates(EE_Event $event): string |
|
697 | - { |
|
698 | - $date_format = apply_filters( |
|
699 | - 'FHEE__espresso_event_date_range__date_format', |
|
700 | - get_option('date_format') |
|
701 | - ); |
|
702 | - $time_format = apply_filters( |
|
703 | - 'FHEE__espresso_event_date_range__time_format', |
|
704 | - get_option('time_format') |
|
705 | - ); |
|
706 | - $single_date_format = apply_filters( |
|
707 | - 'FHEE__espresso_event_date_range__single_date_format', |
|
708 | - get_option('date_format') |
|
709 | - ); |
|
710 | - $single_time_format = apply_filters( |
|
711 | - 'FHEE__espresso_event_date_range__single_time_format', |
|
712 | - get_option('time_format') |
|
713 | - ); |
|
714 | - if ($this->date_range) { |
|
715 | - return espresso_event_date_range( |
|
716 | - $date_format, |
|
717 | - $time_format, |
|
718 | - $single_date_format, |
|
719 | - $single_time_format, |
|
720 | - $event->ID(), |
|
721 | - false |
|
722 | - ); |
|
723 | - } |
|
724 | - return espresso_list_of_event_dates( |
|
725 | - $event->ID(), |
|
726 | - $date_format, |
|
727 | - $time_format, |
|
728 | - false, |
|
729 | - null, |
|
730 | - true, |
|
731 | - true, |
|
732 | - $this->date_limit |
|
733 | - ); |
|
734 | - } |
|
673 | + } |
|
674 | + |
|
675 | + if ($this->show_dates) { |
|
676 | + $content .= $this->eventDates($event); |
|
677 | + } |
|
678 | + |
|
679 | + if ($this->show_desc) { |
|
680 | + $allowedtags = AllowedTags::getAllowedTags(); |
|
681 | + $desc = $event->short_description(25); |
|
682 | + $content .= $desc ? '<p style="margin-top: .5em">' . wp_kses($desc, $allowedtags) . '</p>' : ''; |
|
683 | + } |
|
684 | + |
|
685 | + return $content; |
|
686 | + } |
|
687 | + |
|
688 | + |
|
689 | + /** |
|
690 | + * @param EE_Event $event |
|
691 | + * @return string |
|
692 | + * @throws EE_Error |
|
693 | + * @throws ReflectionException |
|
694 | + * @since 4.10.14.p |
|
695 | + */ |
|
696 | + private function eventDates(EE_Event $event): string |
|
697 | + { |
|
698 | + $date_format = apply_filters( |
|
699 | + 'FHEE__espresso_event_date_range__date_format', |
|
700 | + get_option('date_format') |
|
701 | + ); |
|
702 | + $time_format = apply_filters( |
|
703 | + 'FHEE__espresso_event_date_range__time_format', |
|
704 | + get_option('time_format') |
|
705 | + ); |
|
706 | + $single_date_format = apply_filters( |
|
707 | + 'FHEE__espresso_event_date_range__single_date_format', |
|
708 | + get_option('date_format') |
|
709 | + ); |
|
710 | + $single_time_format = apply_filters( |
|
711 | + 'FHEE__espresso_event_date_range__single_time_format', |
|
712 | + get_option('time_format') |
|
713 | + ); |
|
714 | + if ($this->date_range) { |
|
715 | + return espresso_event_date_range( |
|
716 | + $date_format, |
|
717 | + $time_format, |
|
718 | + $single_date_format, |
|
719 | + $single_time_format, |
|
720 | + $event->ID(), |
|
721 | + false |
|
722 | + ); |
|
723 | + } |
|
724 | + return espresso_list_of_event_dates( |
|
725 | + $event->ID(), |
|
726 | + $date_format, |
|
727 | + $time_format, |
|
728 | + false, |
|
729 | + null, |
|
730 | + true, |
|
731 | + true, |
|
732 | + $this->date_limit |
|
733 | + ); |
|
734 | + } |
|
735 | 735 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | EE_Question_Option::new_instance(['QSO_value' => false, 'QSO_desc' => esc_html__('No', 'event_espresso')]), |
83 | 83 | EE_Question_Option::new_instance(['QSO_value' => true, 'QSO_desc' => esc_html__('Yes', 'event_espresso')]), |
84 | 84 | ]; |
85 | - $sort_values = [ |
|
85 | + $sort_values = [ |
|
86 | 86 | EE_Question_Option::new_instance(['QSO_value' => 'ASC', 'QSO_desc' => esc_html__('ASC', 'event_espresso')]), |
87 | 87 | EE_Question_Option::new_instance( |
88 | 88 | ['QSO_value' => 'DESC', 'QSO_desc' => esc_html__('DESC', 'event_espresso')] |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | /** @var RequestInterface $request */ |
273 | 273 | $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
274 | 274 | |
275 | - if (! $request->isWordPressApi() || ! is_user_logged_in()) { |
|
275 | + if ( ! $request->isWordPressApi() || ! is_user_logged_in()) { |
|
276 | 276 | return $old_instance; |
277 | 277 | } |
278 | 278 | |
@@ -329,8 +329,8 @@ discard block |
||
329 | 329 | // Before widget (defined by themes). |
330 | 330 | echo wp_kses($before_widget, AllowedTags::getAllowedTags()); |
331 | 331 | // Display the widget title if one was input (before and after defined by themes). |
332 | - if (! empty($title)) { |
|
333 | - echo wp_kses($before_title . $title . $after_title, AllowedTags::getAllowedTags()); |
|
332 | + if ( ! empty($title)) { |
|
333 | + echo wp_kses($before_title.$title.$after_title, AllowedTags::getAllowedTags()); |
|
334 | 334 | } |
335 | 335 | echo wp_kses($this->widgetContent($post), AllowedTags::getWithFormTags()); |
336 | 336 | // After widget (defined by themes). |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | */ |
350 | 350 | public function make_the_title_a_link(string $title): string |
351 | 351 | { |
352 | - return '<a href="' . EEH_Event_View::event_archive_url() . '">' . $title . '</a>'; |
|
352 | + return '<a href="'.EEH_Event_View::event_archive_url().'">'.$title.'</a>'; |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | foreach ($sizes as $image_size) { |
434 | 434 | $image_size = trim($image_size); |
435 | 435 | // no big images plz |
436 | - if (! in_array($image_size, ['large', 'post-thumbnail'])) { |
|
436 | + if ( ! in_array($image_size, ['large', 'post-thumbnail'])) { |
|
437 | 437 | $image_sizes[] = |
438 | 438 | EE_Question_Option::new_instance(['QSO_value' => $image_size, 'QSO_desc' => $image_size]); |
439 | 439 | } |
@@ -521,24 +521,24 @@ discard block |
||
521 | 521 | } |
522 | 522 | $list_items = ''; |
523 | 523 | foreach ($events as $event) { |
524 | - if ($event instanceof EE_Event && (! is_single() || $post->ID != $event->ID())) { |
|
525 | - $event_url = $this->eventUrl($event); |
|
524 | + if ($event instanceof EE_Event && ( ! is_single() || $post->ID != $event->ID())) { |
|
525 | + $event_url = $this->eventUrl($event); |
|
526 | 526 | $list_items .= ' |
527 | - <li id="ee-upcoming-events-widget-li-' . absint($event->ID()) . '" |
|
527 | + <li id="ee-upcoming-events-widget-li-' . absint($event->ID()).'" |
|
528 | 528 | class="ee-upcoming-events-widget-li" |
529 | 529 | > |
530 | 530 | <h5 class="ee-upcoming-events-widget-title-h5"> |
531 | - <a class="ee-widget-event-name-a' . $this->linkClass($event) . '" href="' . $event_url . '"> |
|
532 | - ' . esc_html($event->name()) . ' |
|
531 | + <a class="ee-widget-event-name-a' . $this->linkClass($event).'" href="'.$event_url.'"> |
|
532 | + ' . esc_html($event->name()).' |
|
533 | 533 | </a> |
534 | 534 | </h5> |
535 | - ' . $this->eventWidgetContent($event, $event_url) . ' |
|
535 | + ' . $this->eventWidgetContent($event, $event_url).' |
|
536 | 536 | </li>'; |
537 | 537 | } |
538 | 538 | } |
539 | 539 | return ' |
540 | 540 | <ul class="ee-upcoming-events-widget-ul"> |
541 | - ' . $list_items . ' |
|
541 | + ' . $list_items.' |
|
542 | 542 | </ul>'; |
543 | 543 | } |
544 | 544 | |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | return EEM_Event::instance()->get_all( |
573 | 573 | [ |
574 | 574 | $this->queryWhereParams(), |
575 | - 'limit' => '0,' . $this->limit, |
|
575 | + 'limit' => '0,'.$this->limit, |
|
576 | 576 | 'order_by' => 'Datetime.DTT_EVT_start', |
577 | 577 | 'order' => $this->order, |
578 | 578 | 'group_by' => 'EVT_ID', |
@@ -666,8 +666,8 @@ discard block |
||
666 | 666 | if (has_post_thumbnail($event->ID()) && $this->image_size != 'none') { |
667 | 667 | $content .= ' |
668 | 668 | <div class="ee-upcoming-events-widget-img-dv"> |
669 | - <a class="ee-upcoming-events-widget-img" href="' . $event_url . '"> |
|
670 | - ' . get_the_post_thumbnail($event->ID(), $this->image_size) . ' |
|
669 | + <a class="ee-upcoming-events-widget-img" href="' . $event_url.'"> |
|
670 | + ' . get_the_post_thumbnail($event->ID(), $this->image_size).' |
|
671 | 671 | </a> |
672 | 672 | </div>'; |
673 | 673 | } |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | if ($this->show_desc) { |
680 | 680 | $allowedtags = AllowedTags::getAllowedTags(); |
681 | 681 | $desc = $event->short_description(25); |
682 | - $content .= $desc ? '<p style="margin-top: .5em">' . wp_kses($desc, $allowedtags) . '</p>' : ''; |
|
682 | + $content .= $desc ? '<p style="margin-top: .5em">'.wp_kses($desc, $allowedtags).'</p>' : ''; |
|
683 | 683 | } |
684 | 684 | |
685 | 685 | return $content; |
@@ -695,11 +695,11 @@ discard block |
||
695 | 695 | */ |
696 | 696 | private function eventDates(EE_Event $event): string |
697 | 697 | { |
698 | - $date_format = apply_filters( |
|
698 | + $date_format = apply_filters( |
|
699 | 699 | 'FHEE__espresso_event_date_range__date_format', |
700 | 700 | get_option('date_format') |
701 | 701 | ); |
702 | - $time_format = apply_filters( |
|
702 | + $time_format = apply_filters( |
|
703 | 703 | 'FHEE__espresso_event_date_range__time_format', |
704 | 704 | get_option('time_format') |
705 | 705 | ); |
@@ -13,28 +13,28 @@ |
||
13 | 13 | */ |
14 | 14 | class EspressoWidget extends WP_Widget |
15 | 15 | { |
16 | - /** |
|
17 | - * @param string $name |
|
18 | - * @param array $widget_options |
|
19 | - * @param array $control_options |
|
20 | - */ |
|
21 | - public function __construct($name = '', array $widget_options = [], array $control_options = []) |
|
22 | - { |
|
23 | - $id_base = EspressoWidget::getIdBase(get_class($this)); |
|
24 | - $control_options['id_base'] = $id_base; |
|
25 | - $control_options['height'] = $control_options['height'] ?? 300; |
|
26 | - $control_options['width'] = $control_options['width'] ?? 350; |
|
27 | - // Register widget with WordPress |
|
28 | - parent::__construct($id_base, $name, $widget_options, $control_options); |
|
29 | - } |
|
16 | + /** |
|
17 | + * @param string $name |
|
18 | + * @param array $widget_options |
|
19 | + * @param array $control_options |
|
20 | + */ |
|
21 | + public function __construct($name = '', array $widget_options = [], array $control_options = []) |
|
22 | + { |
|
23 | + $id_base = EspressoWidget::getIdBase(get_class($this)); |
|
24 | + $control_options['id_base'] = $id_base; |
|
25 | + $control_options['height'] = $control_options['height'] ?? 300; |
|
26 | + $control_options['width'] = $control_options['width'] ?? 350; |
|
27 | + // Register widget with WordPress |
|
28 | + parent::__construct($id_base, $name, $widget_options, $control_options); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * @param string $widget_class |
|
34 | - * @return string |
|
35 | - */ |
|
36 | - public static function getIdBase(string $widget_class): string |
|
37 | - { |
|
38 | - return sanitize_title(str_replace(['EEW_', '_'], ['EE_', '-'], $widget_class)) . '-widget'; |
|
39 | - } |
|
32 | + /** |
|
33 | + * @param string $widget_class |
|
34 | + * @return string |
|
35 | + */ |
|
36 | + public static function getIdBase(string $widget_class): string |
|
37 | + { |
|
38 | + return sanitize_title(str_replace(['EEW_', '_'], ['EE_', '-'], $widget_class)) . '-widget'; |
|
39 | + } |
|
40 | 40 | } |
@@ -35,6 +35,6 @@ |
||
35 | 35 | */ |
36 | 36 | public static function getIdBase(string $widget_class): string |
37 | 37 | { |
38 | - return sanitize_title(str_replace(['EEW_', '_'], ['EE_', '-'], $widget_class)) . '-widget'; |
|
38 | + return sanitize_title(str_replace(['EEW_', '_'], ['EE_', '-'], $widget_class)).'-widget'; |
|
39 | 39 | } |
40 | 40 | } |