@@ -5,8 +5,8 @@ discard block |
||
5 | 5 | // if you're a dev and want to receive all errors via email |
6 | 6 | // add this to your wp-config.php: define( 'EE_ERROR_EMAILS', TRUE ); |
7 | 7 | if (defined('WP_DEBUG') && WP_DEBUG === true && defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS === true) { |
8 | - set_error_handler(array('EE_Error', 'error_handler')); |
|
9 | - register_shutdown_function(array('EE_Error', 'fatal_error_handler')); |
|
8 | + set_error_handler(array('EE_Error', 'error_handler')); |
|
9 | + register_shutdown_function(array('EE_Error', 'fatal_error_handler')); |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | |
@@ -23,259 +23,259 @@ discard block |
||
23 | 23 | { |
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * name of the file to log exceptions to |
|
28 | - * |
|
29 | - * @var string |
|
30 | - */ |
|
31 | - private static $_exception_log_file = 'espresso_error_log.txt'; |
|
32 | - |
|
33 | - /** |
|
34 | - * stores details for all exception |
|
35 | - * |
|
36 | - * @var array |
|
37 | - */ |
|
38 | - private static $_all_exceptions = array(); |
|
39 | - |
|
40 | - /** |
|
41 | - * tracks number of errors |
|
42 | - * |
|
43 | - * @var int |
|
44 | - */ |
|
45 | - private static $_error_count = 0; |
|
46 | - |
|
47 | - /** |
|
48 | - * has shutdown action been added ? |
|
49 | - * |
|
50 | - * @var array $_espresso_notices |
|
51 | - */ |
|
52 | - private static $_espresso_notices = array('success' => false, 'errors' => false, 'attention' => false); |
|
53 | - |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * @override default exception handling |
|
58 | - * @param string $message |
|
59 | - * @param int $code |
|
60 | - * @param Exception|null $previous |
|
61 | - */ |
|
62 | - public function __construct($message, $code = 0, Exception $previous = null) |
|
63 | - { |
|
64 | - if (version_compare(PHP_VERSION, '5.3.0', '<')) { |
|
65 | - parent::__construct($message, $code); |
|
66 | - } else { |
|
67 | - parent::__construct($message, $code, $previous); |
|
68 | - } |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * error_handler |
|
75 | - * |
|
76 | - * @param $code |
|
77 | - * @param $message |
|
78 | - * @param $file |
|
79 | - * @param $line |
|
80 | - * @return void |
|
81 | - */ |
|
82 | - public static function error_handler($code, $message, $file, $line) |
|
83 | - { |
|
84 | - $type = EE_Error::error_type($code); |
|
85 | - $site = site_url(); |
|
86 | - switch ($site) { |
|
87 | - case 'http://ee4.eventespresso.com/' : |
|
88 | - case 'http://ee4decaf.eventespresso.com/' : |
|
89 | - case 'http://ee4hf.eventespresso.com/' : |
|
90 | - case 'http://ee4a.eventespresso.com/' : |
|
91 | - case 'http://ee4ad.eventespresso.com/' : |
|
92 | - case 'http://ee4b.eventespresso.com/' : |
|
93 | - case 'http://ee4bd.eventespresso.com/' : |
|
94 | - case 'http://ee4d.eventespresso.com/' : |
|
95 | - case 'http://ee4dd.eventespresso.com/' : |
|
96 | - $to = '[email protected]'; |
|
97 | - break; |
|
98 | - default : |
|
99 | - $to = get_option('admin_email'); |
|
100 | - } |
|
101 | - $subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url(); |
|
102 | - $msg = EE_Error::_format_error($type, $message, $file, $line); |
|
103 | - if (function_exists('wp_mail')) { |
|
104 | - add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
105 | - wp_mail($to, $subject, $msg); |
|
106 | - } |
|
107 | - echo '<div id="message" class="espresso-notices error"><p>'; |
|
108 | - echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line; |
|
109 | - echo '<br /></p></div>'; |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * error_type |
|
116 | - * http://www.php.net/manual/en/errorfunc.constants.php#109430 |
|
117 | - * |
|
118 | - * @param $code |
|
119 | - * @return string |
|
120 | - */ |
|
121 | - public static function error_type($code) |
|
122 | - { |
|
123 | - switch ($code) { |
|
124 | - case E_ERROR: // 1 // |
|
125 | - return 'E_ERROR'; |
|
126 | - case E_WARNING: // 2 // |
|
127 | - return 'E_WARNING'; |
|
128 | - case E_PARSE: // 4 // |
|
129 | - return 'E_PARSE'; |
|
130 | - case E_NOTICE: // 8 // |
|
131 | - return 'E_NOTICE'; |
|
132 | - case E_CORE_ERROR: // 16 // |
|
133 | - return 'E_CORE_ERROR'; |
|
134 | - case E_CORE_WARNING: // 32 // |
|
135 | - return 'E_CORE_WARNING'; |
|
136 | - case E_COMPILE_ERROR: // 64 // |
|
137 | - return 'E_COMPILE_ERROR'; |
|
138 | - case E_COMPILE_WARNING: // 128 // |
|
139 | - return 'E_COMPILE_WARNING'; |
|
140 | - case E_USER_ERROR: // 256 // |
|
141 | - return 'E_USER_ERROR'; |
|
142 | - case E_USER_WARNING: // 512 // |
|
143 | - return 'E_USER_WARNING'; |
|
144 | - case E_USER_NOTICE: // 1024 // |
|
145 | - return 'E_USER_NOTICE'; |
|
146 | - case E_STRICT: // 2048 // |
|
147 | - return 'E_STRICT'; |
|
148 | - case E_RECOVERABLE_ERROR: // 4096 // |
|
149 | - return 'E_RECOVERABLE_ERROR'; |
|
150 | - case E_DEPRECATED: // 8192 // |
|
151 | - return 'E_DEPRECATED'; |
|
152 | - case E_USER_DEPRECATED: // 16384 // |
|
153 | - return 'E_USER_DEPRECATED'; |
|
154 | - case E_ALL: // 16384 // |
|
155 | - return 'E_ALL'; |
|
156 | - } |
|
157 | - return ''; |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * fatal_error_handler |
|
164 | - * |
|
165 | - * @return void |
|
166 | - */ |
|
167 | - public static function fatal_error_handler() |
|
168 | - { |
|
169 | - $last_error = error_get_last(); |
|
170 | - if ($last_error['type'] === E_ERROR) { |
|
171 | - EE_Error::error_handler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']); |
|
172 | - } |
|
173 | - } |
|
174 | - |
|
175 | - |
|
176 | - |
|
177 | - /** |
|
178 | - * _format_error |
|
179 | - * |
|
180 | - * @param $code |
|
181 | - * @param $message |
|
182 | - * @param $file |
|
183 | - * @param $line |
|
184 | - * @return string |
|
185 | - */ |
|
186 | - private static function _format_error($code, $message, $file, $line) |
|
187 | - { |
|
188 | - $html = "<table cellpadding='5'><thead bgcolor='#f8f8f8'><th>Item</th><th align='left'>Details</th></thead><tbody>"; |
|
189 | - $html .= "<tr valign='top'><td><b>Code</b></td><td>$code</td></tr>"; |
|
190 | - $html .= "<tr valign='top'><td><b>Error</b></td><td>$message</td></tr>"; |
|
191 | - $html .= "<tr valign='top'><td><b>File</b></td><td>$file</td></tr>"; |
|
192 | - $html .= "<tr valign='top'><td><b>Line</b></td><td>$line</td></tr>"; |
|
193 | - $html .= '</tbody></table>'; |
|
194 | - return $html; |
|
195 | - } |
|
196 | - |
|
197 | - |
|
198 | - |
|
199 | - /** |
|
200 | - * set_content_type |
|
201 | - * |
|
202 | - * @param $content_type |
|
203 | - * @return string |
|
204 | - */ |
|
205 | - public static function set_content_type($content_type) |
|
206 | - { |
|
207 | - return 'text/html'; |
|
208 | - } |
|
209 | - |
|
210 | - |
|
211 | - |
|
212 | - /** |
|
213 | - * @return void |
|
214 | - * @throws EE_Error |
|
215 | - * @throws ReflectionException |
|
216 | - */ |
|
217 | - public function get_error() |
|
218 | - { |
|
219 | - if (apply_filters('FHEE__EE_Error__get_error__show_normal_exceptions', false)) { |
|
220 | - throw $this; |
|
221 | - } |
|
222 | - // get separate user and developer messages if they exist |
|
223 | - $msg = explode('||', $this->getMessage()); |
|
224 | - $user_msg = $msg[0]; |
|
225 | - $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
226 | - $msg = WP_DEBUG ? $dev_msg : $user_msg; |
|
227 | - // add details to _all_exceptions array |
|
228 | - $x_time = time(); |
|
229 | - self::$_all_exceptions[$x_time]['name'] = get_class($this); |
|
230 | - self::$_all_exceptions[$x_time]['file'] = $this->getFile(); |
|
231 | - self::$_all_exceptions[$x_time]['line'] = $this->getLine(); |
|
232 | - self::$_all_exceptions[$x_time]['msg'] = $msg; |
|
233 | - self::$_all_exceptions[$x_time]['code'] = $this->getCode(); |
|
234 | - self::$_all_exceptions[$x_time]['trace'] = $this->getTrace(); |
|
235 | - self::$_all_exceptions[$x_time]['string'] = $this->getTraceAsString(); |
|
236 | - self::$_error_count++; |
|
237 | - //add_action( 'shutdown', array( $this, 'display_errors' )); |
|
238 | - $this->display_errors(); |
|
239 | - } |
|
240 | - |
|
241 | - |
|
242 | - |
|
243 | - /** |
|
244 | - * has_error |
|
245 | - * |
|
246 | - * @param bool $check_stored |
|
247 | - * @param string $type_to_check |
|
248 | - * @return bool |
|
249 | - */ |
|
250 | - public static function has_error($check_stored = false, $type_to_check = 'errors') |
|
251 | - { |
|
252 | - $has_error = isset(self::$_espresso_notices[$type_to_check]) |
|
253 | - && ! empty(self::$_espresso_notices[$type_to_check]) |
|
254 | - ? true |
|
255 | - : false; |
|
256 | - if ($check_stored && ! $has_error) { |
|
257 | - $notices = (array)get_option('ee_notices', array()); |
|
258 | - foreach ($notices as $type => $notice) { |
|
259 | - if ($type === $type_to_check && $notice) { |
|
260 | - return true; |
|
261 | - } |
|
262 | - } |
|
263 | - } |
|
264 | - return $has_error; |
|
265 | - } |
|
266 | - |
|
267 | - |
|
268 | - |
|
269 | - /** |
|
270 | - * display_errors |
|
271 | - * |
|
272 | - * @echo string |
|
273 | - * @throws \ReflectionException |
|
274 | - */ |
|
275 | - public function display_errors() |
|
276 | - { |
|
277 | - $trace_details = ''; |
|
278 | - $output = ' |
|
26 | + /** |
|
27 | + * name of the file to log exceptions to |
|
28 | + * |
|
29 | + * @var string |
|
30 | + */ |
|
31 | + private static $_exception_log_file = 'espresso_error_log.txt'; |
|
32 | + |
|
33 | + /** |
|
34 | + * stores details for all exception |
|
35 | + * |
|
36 | + * @var array |
|
37 | + */ |
|
38 | + private static $_all_exceptions = array(); |
|
39 | + |
|
40 | + /** |
|
41 | + * tracks number of errors |
|
42 | + * |
|
43 | + * @var int |
|
44 | + */ |
|
45 | + private static $_error_count = 0; |
|
46 | + |
|
47 | + /** |
|
48 | + * has shutdown action been added ? |
|
49 | + * |
|
50 | + * @var array $_espresso_notices |
|
51 | + */ |
|
52 | + private static $_espresso_notices = array('success' => false, 'errors' => false, 'attention' => false); |
|
53 | + |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * @override default exception handling |
|
58 | + * @param string $message |
|
59 | + * @param int $code |
|
60 | + * @param Exception|null $previous |
|
61 | + */ |
|
62 | + public function __construct($message, $code = 0, Exception $previous = null) |
|
63 | + { |
|
64 | + if (version_compare(PHP_VERSION, '5.3.0', '<')) { |
|
65 | + parent::__construct($message, $code); |
|
66 | + } else { |
|
67 | + parent::__construct($message, $code, $previous); |
|
68 | + } |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * error_handler |
|
75 | + * |
|
76 | + * @param $code |
|
77 | + * @param $message |
|
78 | + * @param $file |
|
79 | + * @param $line |
|
80 | + * @return void |
|
81 | + */ |
|
82 | + public static function error_handler($code, $message, $file, $line) |
|
83 | + { |
|
84 | + $type = EE_Error::error_type($code); |
|
85 | + $site = site_url(); |
|
86 | + switch ($site) { |
|
87 | + case 'http://ee4.eventespresso.com/' : |
|
88 | + case 'http://ee4decaf.eventespresso.com/' : |
|
89 | + case 'http://ee4hf.eventespresso.com/' : |
|
90 | + case 'http://ee4a.eventespresso.com/' : |
|
91 | + case 'http://ee4ad.eventespresso.com/' : |
|
92 | + case 'http://ee4b.eventespresso.com/' : |
|
93 | + case 'http://ee4bd.eventespresso.com/' : |
|
94 | + case 'http://ee4d.eventespresso.com/' : |
|
95 | + case 'http://ee4dd.eventespresso.com/' : |
|
96 | + $to = '[email protected]'; |
|
97 | + break; |
|
98 | + default : |
|
99 | + $to = get_option('admin_email'); |
|
100 | + } |
|
101 | + $subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url(); |
|
102 | + $msg = EE_Error::_format_error($type, $message, $file, $line); |
|
103 | + if (function_exists('wp_mail')) { |
|
104 | + add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
105 | + wp_mail($to, $subject, $msg); |
|
106 | + } |
|
107 | + echo '<div id="message" class="espresso-notices error"><p>'; |
|
108 | + echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line; |
|
109 | + echo '<br /></p></div>'; |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * error_type |
|
116 | + * http://www.php.net/manual/en/errorfunc.constants.php#109430 |
|
117 | + * |
|
118 | + * @param $code |
|
119 | + * @return string |
|
120 | + */ |
|
121 | + public static function error_type($code) |
|
122 | + { |
|
123 | + switch ($code) { |
|
124 | + case E_ERROR: // 1 // |
|
125 | + return 'E_ERROR'; |
|
126 | + case E_WARNING: // 2 // |
|
127 | + return 'E_WARNING'; |
|
128 | + case E_PARSE: // 4 // |
|
129 | + return 'E_PARSE'; |
|
130 | + case E_NOTICE: // 8 // |
|
131 | + return 'E_NOTICE'; |
|
132 | + case E_CORE_ERROR: // 16 // |
|
133 | + return 'E_CORE_ERROR'; |
|
134 | + case E_CORE_WARNING: // 32 // |
|
135 | + return 'E_CORE_WARNING'; |
|
136 | + case E_COMPILE_ERROR: // 64 // |
|
137 | + return 'E_COMPILE_ERROR'; |
|
138 | + case E_COMPILE_WARNING: // 128 // |
|
139 | + return 'E_COMPILE_WARNING'; |
|
140 | + case E_USER_ERROR: // 256 // |
|
141 | + return 'E_USER_ERROR'; |
|
142 | + case E_USER_WARNING: // 512 // |
|
143 | + return 'E_USER_WARNING'; |
|
144 | + case E_USER_NOTICE: // 1024 // |
|
145 | + return 'E_USER_NOTICE'; |
|
146 | + case E_STRICT: // 2048 // |
|
147 | + return 'E_STRICT'; |
|
148 | + case E_RECOVERABLE_ERROR: // 4096 // |
|
149 | + return 'E_RECOVERABLE_ERROR'; |
|
150 | + case E_DEPRECATED: // 8192 // |
|
151 | + return 'E_DEPRECATED'; |
|
152 | + case E_USER_DEPRECATED: // 16384 // |
|
153 | + return 'E_USER_DEPRECATED'; |
|
154 | + case E_ALL: // 16384 // |
|
155 | + return 'E_ALL'; |
|
156 | + } |
|
157 | + return ''; |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * fatal_error_handler |
|
164 | + * |
|
165 | + * @return void |
|
166 | + */ |
|
167 | + public static function fatal_error_handler() |
|
168 | + { |
|
169 | + $last_error = error_get_last(); |
|
170 | + if ($last_error['type'] === E_ERROR) { |
|
171 | + EE_Error::error_handler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']); |
|
172 | + } |
|
173 | + } |
|
174 | + |
|
175 | + |
|
176 | + |
|
177 | + /** |
|
178 | + * _format_error |
|
179 | + * |
|
180 | + * @param $code |
|
181 | + * @param $message |
|
182 | + * @param $file |
|
183 | + * @param $line |
|
184 | + * @return string |
|
185 | + */ |
|
186 | + private static function _format_error($code, $message, $file, $line) |
|
187 | + { |
|
188 | + $html = "<table cellpadding='5'><thead bgcolor='#f8f8f8'><th>Item</th><th align='left'>Details</th></thead><tbody>"; |
|
189 | + $html .= "<tr valign='top'><td><b>Code</b></td><td>$code</td></tr>"; |
|
190 | + $html .= "<tr valign='top'><td><b>Error</b></td><td>$message</td></tr>"; |
|
191 | + $html .= "<tr valign='top'><td><b>File</b></td><td>$file</td></tr>"; |
|
192 | + $html .= "<tr valign='top'><td><b>Line</b></td><td>$line</td></tr>"; |
|
193 | + $html .= '</tbody></table>'; |
|
194 | + return $html; |
|
195 | + } |
|
196 | + |
|
197 | + |
|
198 | + |
|
199 | + /** |
|
200 | + * set_content_type |
|
201 | + * |
|
202 | + * @param $content_type |
|
203 | + * @return string |
|
204 | + */ |
|
205 | + public static function set_content_type($content_type) |
|
206 | + { |
|
207 | + return 'text/html'; |
|
208 | + } |
|
209 | + |
|
210 | + |
|
211 | + |
|
212 | + /** |
|
213 | + * @return void |
|
214 | + * @throws EE_Error |
|
215 | + * @throws ReflectionException |
|
216 | + */ |
|
217 | + public function get_error() |
|
218 | + { |
|
219 | + if (apply_filters('FHEE__EE_Error__get_error__show_normal_exceptions', false)) { |
|
220 | + throw $this; |
|
221 | + } |
|
222 | + // get separate user and developer messages if they exist |
|
223 | + $msg = explode('||', $this->getMessage()); |
|
224 | + $user_msg = $msg[0]; |
|
225 | + $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
226 | + $msg = WP_DEBUG ? $dev_msg : $user_msg; |
|
227 | + // add details to _all_exceptions array |
|
228 | + $x_time = time(); |
|
229 | + self::$_all_exceptions[$x_time]['name'] = get_class($this); |
|
230 | + self::$_all_exceptions[$x_time]['file'] = $this->getFile(); |
|
231 | + self::$_all_exceptions[$x_time]['line'] = $this->getLine(); |
|
232 | + self::$_all_exceptions[$x_time]['msg'] = $msg; |
|
233 | + self::$_all_exceptions[$x_time]['code'] = $this->getCode(); |
|
234 | + self::$_all_exceptions[$x_time]['trace'] = $this->getTrace(); |
|
235 | + self::$_all_exceptions[$x_time]['string'] = $this->getTraceAsString(); |
|
236 | + self::$_error_count++; |
|
237 | + //add_action( 'shutdown', array( $this, 'display_errors' )); |
|
238 | + $this->display_errors(); |
|
239 | + } |
|
240 | + |
|
241 | + |
|
242 | + |
|
243 | + /** |
|
244 | + * has_error |
|
245 | + * |
|
246 | + * @param bool $check_stored |
|
247 | + * @param string $type_to_check |
|
248 | + * @return bool |
|
249 | + */ |
|
250 | + public static function has_error($check_stored = false, $type_to_check = 'errors') |
|
251 | + { |
|
252 | + $has_error = isset(self::$_espresso_notices[$type_to_check]) |
|
253 | + && ! empty(self::$_espresso_notices[$type_to_check]) |
|
254 | + ? true |
|
255 | + : false; |
|
256 | + if ($check_stored && ! $has_error) { |
|
257 | + $notices = (array)get_option('ee_notices', array()); |
|
258 | + foreach ($notices as $type => $notice) { |
|
259 | + if ($type === $type_to_check && $notice) { |
|
260 | + return true; |
|
261 | + } |
|
262 | + } |
|
263 | + } |
|
264 | + return $has_error; |
|
265 | + } |
|
266 | + |
|
267 | + |
|
268 | + |
|
269 | + /** |
|
270 | + * display_errors |
|
271 | + * |
|
272 | + * @echo string |
|
273 | + * @throws \ReflectionException |
|
274 | + */ |
|
275 | + public function display_errors() |
|
276 | + { |
|
277 | + $trace_details = ''; |
|
278 | + $output = ' |
|
279 | 279 | <style type="text/css"> |
280 | 280 | #ee-error-message { |
281 | 281 | max-width:90% !important; |
@@ -331,19 +331,19 @@ discard block |
||
331 | 331 | } |
332 | 332 | </style> |
333 | 333 | <div id="ee-error-message" class="error">'; |
334 | - if (! WP_DEBUG) { |
|
335 | - $output .= ' |
|
334 | + if (! WP_DEBUG) { |
|
335 | + $output .= ' |
|
336 | 336 | <p>'; |
337 | - } |
|
338 | - // cycle thru errors |
|
339 | - foreach (self::$_all_exceptions as $time => $ex) { |
|
340 | - $error_code = ''; |
|
341 | - // process trace info |
|
342 | - if (empty($ex['trace'])) { |
|
343 | - $trace_details .= __('Sorry, but no trace information was available for this exception.', |
|
344 | - 'event_espresso'); |
|
345 | - } else { |
|
346 | - $trace_details .= ' |
|
337 | + } |
|
338 | + // cycle thru errors |
|
339 | + foreach (self::$_all_exceptions as $time => $ex) { |
|
340 | + $error_code = ''; |
|
341 | + // process trace info |
|
342 | + if (empty($ex['trace'])) { |
|
343 | + $trace_details .= __('Sorry, but no trace information was available for this exception.', |
|
344 | + 'event_espresso'); |
|
345 | + } else { |
|
346 | + $trace_details .= ' |
|
347 | 347 | <div id="ee-trace-details"> |
348 | 348 | <table width="100%" border="0" cellpadding="5" cellspacing="0"> |
349 | 349 | <tr> |
@@ -353,38 +353,38 @@ discard block |
||
353 | 353 | <th scope="col" align="left">Class</th> |
354 | 354 | <th scope="col" align="left">Method( arguments )</th> |
355 | 355 | </tr>'; |
356 | - $last_on_stack = count($ex['trace']) - 1; |
|
357 | - // reverse array so that stack is in proper chronological order |
|
358 | - $sorted_trace = array_reverse($ex['trace']); |
|
359 | - foreach ($sorted_trace as $nmbr => $trace) { |
|
360 | - $file = isset($trace['file']) ? $trace['file'] : ''; |
|
361 | - $class = isset($trace['class']) ? $trace['class'] : ''; |
|
362 | - $type = isset($trace['type']) ? $trace['type'] : ''; |
|
363 | - $function = isset($trace['function']) ? $trace['function'] : ''; |
|
364 | - $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
|
365 | - $line = isset($trace['line']) ? $trace['line'] : ''; |
|
366 | - $zebra = ($nmbr % 2) ? ' odd' : ''; |
|
367 | - if (empty($file) && ! empty($class)) { |
|
368 | - $a = new ReflectionClass($class); |
|
369 | - $file = $a->getFileName(); |
|
370 | - if (empty($line) && ! empty($function)) { |
|
371 | - $b = new ReflectionMethod($class, $function); |
|
372 | - $line = $b->getStartLine(); |
|
373 | - } |
|
374 | - } |
|
375 | - if ($nmbr === $last_on_stack) { |
|
376 | - $file = $ex['file'] !== '' ? $ex['file'] : $file; |
|
377 | - $line = $ex['line'] !== '' ? $ex['line'] : $line; |
|
378 | - $error_code = self::generate_error_code($file, $trace['function'], $line); |
|
379 | - } |
|
380 | - $nmbr_dsply = ! empty($nmbr) ? $nmbr : ' '; |
|
381 | - $line_dsply = ! empty($line) ? $line : ' '; |
|
382 | - $file_dsply = ! empty($file) ? $file : ' '; |
|
383 | - $class_dsply = ! empty($class) ? $class : ' '; |
|
384 | - $type_dsply = ! empty($type) ? $type : ' '; |
|
385 | - $function_dsply = ! empty($function) ? $function : ' '; |
|
386 | - $args_dsply = ! empty($args) ? '( ' . $args . ' )' : ''; |
|
387 | - $trace_details .= ' |
|
356 | + $last_on_stack = count($ex['trace']) - 1; |
|
357 | + // reverse array so that stack is in proper chronological order |
|
358 | + $sorted_trace = array_reverse($ex['trace']); |
|
359 | + foreach ($sorted_trace as $nmbr => $trace) { |
|
360 | + $file = isset($trace['file']) ? $trace['file'] : ''; |
|
361 | + $class = isset($trace['class']) ? $trace['class'] : ''; |
|
362 | + $type = isset($trace['type']) ? $trace['type'] : ''; |
|
363 | + $function = isset($trace['function']) ? $trace['function'] : ''; |
|
364 | + $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
|
365 | + $line = isset($trace['line']) ? $trace['line'] : ''; |
|
366 | + $zebra = ($nmbr % 2) ? ' odd' : ''; |
|
367 | + if (empty($file) && ! empty($class)) { |
|
368 | + $a = new ReflectionClass($class); |
|
369 | + $file = $a->getFileName(); |
|
370 | + if (empty($line) && ! empty($function)) { |
|
371 | + $b = new ReflectionMethod($class, $function); |
|
372 | + $line = $b->getStartLine(); |
|
373 | + } |
|
374 | + } |
|
375 | + if ($nmbr === $last_on_stack) { |
|
376 | + $file = $ex['file'] !== '' ? $ex['file'] : $file; |
|
377 | + $line = $ex['line'] !== '' ? $ex['line'] : $line; |
|
378 | + $error_code = self::generate_error_code($file, $trace['function'], $line); |
|
379 | + } |
|
380 | + $nmbr_dsply = ! empty($nmbr) ? $nmbr : ' '; |
|
381 | + $line_dsply = ! empty($line) ? $line : ' '; |
|
382 | + $file_dsply = ! empty($file) ? $file : ' '; |
|
383 | + $class_dsply = ! empty($class) ? $class : ' '; |
|
384 | + $type_dsply = ! empty($type) ? $type : ' '; |
|
385 | + $function_dsply = ! empty($function) ? $function : ' '; |
|
386 | + $args_dsply = ! empty($args) ? '( ' . $args . ' )' : ''; |
|
387 | + $trace_details .= ' |
|
388 | 388 | <tr> |
389 | 389 | <td align="right" class="' . $zebra . '">' . $nmbr_dsply . '</td> |
390 | 390 | <td align="right" class="' . $zebra . '">' . $line_dsply . '</td> |
@@ -392,669 +392,669 @@ discard block |
||
392 | 392 | <td align="left" class="' . $zebra . '">' . $class_dsply . '</td> |
393 | 393 | <td align="left" class="' . $zebra . '">' . $type_dsply . $function_dsply . $args_dsply . '</td> |
394 | 394 | </tr>'; |
395 | - } |
|
396 | - $trace_details .= ' |
|
395 | + } |
|
396 | + $trace_details .= ' |
|
397 | 397 | </table> |
398 | 398 | </div>'; |
399 | - } |
|
400 | - $ex['code'] = $ex['code'] ? $ex['code'] : $error_code; |
|
401 | - // add generic non-identifying messages for non-privileged users |
|
402 | - if (! WP_DEBUG) { |
|
403 | - $output .= '<span class="ee-error-user-msg-spn">' |
|
404 | - . trim($ex['msg']) |
|
405 | - . '</span> <sup>' |
|
406 | - . $ex['code'] |
|
407 | - . '</sup><br />'; |
|
408 | - } else { |
|
409 | - // or helpful developer messages if debugging is on |
|
410 | - $output .= ' |
|
399 | + } |
|
400 | + $ex['code'] = $ex['code'] ? $ex['code'] : $error_code; |
|
401 | + // add generic non-identifying messages for non-privileged users |
|
402 | + if (! WP_DEBUG) { |
|
403 | + $output .= '<span class="ee-error-user-msg-spn">' |
|
404 | + . trim($ex['msg']) |
|
405 | + . '</span> <sup>' |
|
406 | + . $ex['code'] |
|
407 | + . '</sup><br />'; |
|
408 | + } else { |
|
409 | + // or helpful developer messages if debugging is on |
|
410 | + $output .= ' |
|
411 | 411 | <div class="ee-error-dev-msg-dv"> |
412 | 412 | <p class="ee-error-dev-msg-pg"> |
413 | 413 | <strong class="ee-error-dev-msg-str">An ' |
414 | - . $ex['name'] |
|
415 | - . ' exception was thrown!</strong> <span>code: ' |
|
416 | - . $ex['code'] |
|
417 | - . '</span><br /> |
|
414 | + . $ex['name'] |
|
415 | + . ' exception was thrown!</strong> <span>code: ' |
|
416 | + . $ex['code'] |
|
417 | + . '</span><br /> |
|
418 | 418 | <span class="big-text">"' |
419 | - . trim($ex['msg']) |
|
420 | - . '"</span><br/> |
|
419 | + . trim($ex['msg']) |
|
420 | + . '"</span><br/> |
|
421 | 421 | <a id="display-ee-error-trace-' |
422 | - . self::$_error_count |
|
423 | - . $time |
|
424 | - . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-' |
|
425 | - . self::$_error_count |
|
426 | - . $time |
|
427 | - . '"> |
|
422 | + . self::$_error_count |
|
423 | + . $time |
|
424 | + . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-' |
|
425 | + . self::$_error_count |
|
426 | + . $time |
|
427 | + . '"> |
|
428 | 428 | ' |
429 | - . __('click to view backtrace and class/method details', 'event_espresso') |
|
430 | - . ' |
|
429 | + . __('click to view backtrace and class/method details', 'event_espresso') |
|
430 | + . ' |
|
431 | 431 | </a><br /> |
432 | 432 | <span class="small-text lt-grey-text">' |
433 | - . $ex['file'] |
|
434 | - . ' ( line no: ' |
|
435 | - . $ex['line'] |
|
436 | - . ' )</span> |
|
433 | + . $ex['file'] |
|
434 | + . ' ( line no: ' |
|
435 | + . $ex['line'] |
|
436 | + . ' )</span> |
|
437 | 437 | </p> |
438 | 438 | <div id="ee-error-trace-' |
439 | - . self::$_error_count |
|
440 | - . $time |
|
441 | - . '-dv" class="ee-error-trace-dv" style="display: none;"> |
|
439 | + . self::$_error_count |
|
440 | + . $time |
|
441 | + . '-dv" class="ee-error-trace-dv" style="display: none;"> |
|
442 | 442 | ' |
443 | - . $trace_details; |
|
444 | - if (! empty($class)) { |
|
445 | - $output .= ' |
|
443 | + . $trace_details; |
|
444 | + if (! empty($class)) { |
|
445 | + $output .= ' |
|
446 | 446 | <div style="padding:3px; margin:0 0 1em; border:1px solid #666; background:#fff; border-radius:3px;"> |
447 | 447 | <div style="padding:1em 2em; border:1px solid #666; background:#f9f9f9;"> |
448 | 448 | <h3>Class Details</h3>'; |
449 | - $a = new ReflectionClass($class); |
|
450 | - $output .= ' |
|
449 | + $a = new ReflectionClass($class); |
|
450 | + $output .= ' |
|
451 | 451 | <pre>' . $a . '</pre> |
452 | 452 | </div> |
453 | 453 | </div>'; |
454 | - } |
|
455 | - $output .= ' |
|
454 | + } |
|
455 | + $output .= ' |
|
456 | 456 | </div> |
457 | 457 | </div> |
458 | 458 | <br />'; |
459 | - } |
|
460 | - $this->write_to_error_log($time, $ex); |
|
461 | - } |
|
462 | - // remove last linebreak |
|
463 | - $output = substr($output, 0, -6); |
|
464 | - if (! WP_DEBUG) { |
|
465 | - $output .= ' |
|
459 | + } |
|
460 | + $this->write_to_error_log($time, $ex); |
|
461 | + } |
|
462 | + // remove last linebreak |
|
463 | + $output = substr($output, 0, -6); |
|
464 | + if (! WP_DEBUG) { |
|
465 | + $output .= ' |
|
466 | 466 | </p>'; |
467 | - } |
|
468 | - $output .= ' |
|
467 | + } |
|
468 | + $output .= ' |
|
469 | 469 | </div>'; |
470 | - $output .= self::_print_scripts(true); |
|
471 | - if (defined('DOING_AJAX')) { |
|
472 | - echo wp_json_encode(array('error' => $output)); |
|
473 | - exit(); |
|
474 | - } |
|
475 | - echo $output; |
|
476 | - die(); |
|
477 | - } |
|
478 | - |
|
479 | - |
|
480 | - |
|
481 | - /** |
|
482 | - * generate string from exception trace args |
|
483 | - * |
|
484 | - * @param array $arguments |
|
485 | - * @param bool $array |
|
486 | - * @return string |
|
487 | - */ |
|
488 | - private function _convert_args_to_string($arguments = array(), $array = false) |
|
489 | - { |
|
490 | - $arg_string = ''; |
|
491 | - if (! empty($arguments)) { |
|
492 | - $args = array(); |
|
493 | - foreach ($arguments as $arg) { |
|
494 | - if (! empty($arg)) { |
|
495 | - if (is_string($arg)) { |
|
496 | - $args[] = " '" . $arg . "'"; |
|
497 | - } elseif (is_array($arg)) { |
|
498 | - $args[] = 'ARRAY(' . $this->_convert_args_to_string($arg, true); |
|
499 | - } elseif ($arg === null) { |
|
500 | - $args[] = ' NULL'; |
|
501 | - } elseif (is_bool($arg)) { |
|
502 | - $args[] = ($arg) ? ' TRUE' : ' FALSE'; |
|
503 | - } elseif (is_object($arg)) { |
|
504 | - $args[] = ' OBJECT ' . get_class($arg); |
|
505 | - } elseif (is_resource($arg)) { |
|
506 | - $args[] = get_resource_type($arg); |
|
507 | - } else { |
|
508 | - $args[] = $arg; |
|
509 | - } |
|
510 | - } |
|
511 | - } |
|
512 | - $arg_string = implode(', ', $args); |
|
513 | - } |
|
514 | - if ($array) { |
|
515 | - $arg_string .= ' )'; |
|
516 | - } |
|
517 | - return $arg_string; |
|
518 | - } |
|
519 | - |
|
520 | - |
|
521 | - |
|
522 | - /** |
|
523 | - * add error message |
|
524 | - * |
|
525 | - * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates |
|
526 | - * separate messages for user || dev |
|
527 | - * @param string $file the file that the error occurred in - just use __FILE__ |
|
528 | - * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
529 | - * @param string $line the line number where the error occurred - just use __LINE__ |
|
530 | - * @return void |
|
531 | - */ |
|
532 | - public static function add_error($msg = null, $file = null, $func = null, $line = null) |
|
533 | - { |
|
534 | - self::_add_notice('errors', $msg, $file, $func, $line); |
|
535 | - self::$_error_count++; |
|
536 | - } |
|
537 | - |
|
538 | - |
|
539 | - |
|
540 | - /** |
|
541 | - * If WP_DEBUG is active, throws an exception. If WP_DEBUG is off, just |
|
542 | - * adds an error |
|
543 | - * |
|
544 | - * @param string $msg |
|
545 | - * @param string $file |
|
546 | - * @param string $func |
|
547 | - * @param string $line |
|
548 | - * @throws EE_Error |
|
549 | - */ |
|
550 | - public static function throw_exception_if_debugging($msg = null, $file = null, $func = null, $line = null) |
|
551 | - { |
|
552 | - if (WP_DEBUG) { |
|
553 | - throw new EE_Error($msg); |
|
554 | - } |
|
555 | - EE_Error::add_error($msg, $file, $func, $line); |
|
556 | - } |
|
557 | - |
|
558 | - |
|
559 | - |
|
560 | - /** |
|
561 | - * add success message |
|
562 | - * |
|
563 | - * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates |
|
564 | - * separate messages for user || dev |
|
565 | - * @param string $file the file that the error occurred in - just use __FILE__ |
|
566 | - * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
567 | - * @param string $line the line number where the error occurred - just use __LINE__ |
|
568 | - * @return void |
|
569 | - */ |
|
570 | - public static function add_success($msg = null, $file = null, $func = null, $line = null) |
|
571 | - { |
|
572 | - self::_add_notice('success', $msg, $file, $func, $line); |
|
573 | - } |
|
574 | - |
|
575 | - |
|
576 | - |
|
577 | - /** |
|
578 | - * add attention message |
|
579 | - * |
|
580 | - * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates |
|
581 | - * separate messages for user || dev |
|
582 | - * @param string $file the file that the error occurred in - just use __FILE__ |
|
583 | - * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
584 | - * @param string $line the line number where the error occurred - just use __LINE__ |
|
585 | - * @return void |
|
586 | - */ |
|
587 | - public static function add_attention($msg = null, $file = null, $func = null, $line = null) |
|
588 | - { |
|
589 | - self::_add_notice('attention', $msg, $file, $func, $line); |
|
590 | - } |
|
591 | - |
|
592 | - |
|
593 | - |
|
594 | - /** |
|
595 | - * add success message |
|
596 | - * |
|
597 | - * @param string $type whether the message is for a success or error notification |
|
598 | - * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates |
|
599 | - * separate messages for user || dev |
|
600 | - * @param string $file the file that the error occurred in - just use __FILE__ |
|
601 | - * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
602 | - * @param string $line the line number where the error occurred - just use __LINE__ |
|
603 | - * @return void |
|
604 | - */ |
|
605 | - private static function _add_notice($type = 'success', $msg = null, $file = null, $func = null, $line = null) |
|
606 | - { |
|
607 | - if (empty($msg)) { |
|
608 | - EE_Error::doing_it_wrong( |
|
609 | - 'EE_Error::add_' . $type . '()', |
|
610 | - sprintf( |
|
611 | - __('Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d', |
|
612 | - 'event_espresso'), |
|
613 | - $type, |
|
614 | - $file, |
|
615 | - $line |
|
616 | - ), |
|
617 | - EVENT_ESPRESSO_VERSION |
|
618 | - ); |
|
619 | - } |
|
620 | - if ($type === 'errors' && (empty($file) || empty($func) || empty($line))) { |
|
621 | - EE_Error::doing_it_wrong( |
|
622 | - 'EE_Error::add_error()', |
|
623 | - __('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.', |
|
624 | - 'event_espresso'), |
|
625 | - EVENT_ESPRESSO_VERSION |
|
626 | - ); |
|
627 | - } |
|
628 | - // get separate user and developer messages if they exist |
|
629 | - $msg = explode('||', $msg); |
|
630 | - $user_msg = $msg[0]; |
|
631 | - $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
632 | - /** |
|
633 | - * Do an action so other code can be triggered when a notice is created |
|
634 | - * |
|
635 | - * @param string $type can be 'errors', 'attention', or 'success' |
|
636 | - * @param string $user_msg message displayed to user when WP_DEBUG is off |
|
637 | - * @param string $user_msg message displayed to user when WP_DEBUG is on |
|
638 | - * @param string $file file where error was generated |
|
639 | - * @param string $func function where error was generated |
|
640 | - * @param string $line line where error was generated |
|
641 | - */ |
|
642 | - do_action('AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line); |
|
643 | - $msg = WP_DEBUG ? $dev_msg : $user_msg; |
|
644 | - // add notice if message exists |
|
645 | - if (! empty($msg)) { |
|
646 | - // get error code |
|
647 | - $notice_code = EE_Error::generate_error_code($file, $func, $line); |
|
648 | - if (WP_DEBUG && $type === 'errors') { |
|
649 | - $msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>'; |
|
650 | - } |
|
651 | - // add notice. Index by code if it's not blank |
|
652 | - if ($notice_code) { |
|
653 | - self::$_espresso_notices[$type][$notice_code] = $msg; |
|
654 | - } else { |
|
655 | - self::$_espresso_notices[$type][] = $msg; |
|
656 | - } |
|
657 | - add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1); |
|
658 | - } |
|
659 | - } |
|
660 | - |
|
661 | - |
|
662 | - |
|
663 | - /** |
|
664 | - * in some case it may be necessary to overwrite the existing success messages |
|
665 | - * |
|
666 | - * @return void |
|
667 | - */ |
|
668 | - public static function overwrite_success() |
|
669 | - { |
|
670 | - self::$_espresso_notices['success'] = false; |
|
671 | - } |
|
672 | - |
|
673 | - |
|
674 | - |
|
675 | - /** |
|
676 | - * in some case it may be necessary to overwrite the existing attention messages |
|
677 | - * |
|
678 | - * @return void |
|
679 | - */ |
|
680 | - public static function overwrite_attention() |
|
681 | - { |
|
682 | - self::$_espresso_notices['attention'] = false; |
|
683 | - } |
|
684 | - |
|
685 | - |
|
686 | - |
|
687 | - /** |
|
688 | - * in some case it may be necessary to overwrite the existing error messages |
|
689 | - * |
|
690 | - * @return void |
|
691 | - */ |
|
692 | - public static function overwrite_errors() |
|
693 | - { |
|
694 | - self::$_espresso_notices['errors'] = false; |
|
695 | - } |
|
696 | - |
|
697 | - |
|
698 | - |
|
699 | - /** |
|
700 | - * reset_notices |
|
701 | - * |
|
702 | - * @return void |
|
703 | - */ |
|
704 | - public static function reset_notices() |
|
705 | - { |
|
706 | - self::$_espresso_notices['success'] = false; |
|
707 | - self::$_espresso_notices['attention'] = false; |
|
708 | - self::$_espresso_notices['errors'] = false; |
|
709 | - } |
|
710 | - |
|
711 | - |
|
712 | - |
|
713 | - /** |
|
714 | - * has_errors |
|
715 | - * |
|
716 | - * @return int |
|
717 | - */ |
|
718 | - public static function has_notices() |
|
719 | - { |
|
720 | - $has_notices = 0; |
|
721 | - // check for success messages |
|
722 | - $has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success']) ? 3 |
|
723 | - : $has_notices; |
|
724 | - // check for attention messages |
|
725 | - $has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention']) ? 2 |
|
726 | - : $has_notices; |
|
727 | - // check for error messages |
|
728 | - $has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors']) ? 1 |
|
729 | - : $has_notices; |
|
730 | - return $has_notices; |
|
731 | - } |
|
732 | - |
|
733 | - |
|
734 | - |
|
735 | - /** |
|
736 | - * This simply returns non formatted error notices as they were sent into the EE_Error object. |
|
737 | - * |
|
738 | - * @since 4.9.0 |
|
739 | - * @return array |
|
740 | - */ |
|
741 | - public static function get_vanilla_notices() |
|
742 | - { |
|
743 | - return array( |
|
744 | - 'success' => isset(self::$_espresso_notices['success']) ? self::$_espresso_notices['success'] : array(), |
|
745 | - 'attention' => isset(self::$_espresso_notices['attention']) ? self::$_espresso_notices['attention'] |
|
746 | - : array(), |
|
747 | - 'errors' => isset(self::$_espresso_notices['errors']) ? self::$_espresso_notices['errors'] : array(), |
|
748 | - ); |
|
749 | - } |
|
750 | - |
|
751 | - |
|
752 | - |
|
753 | - /** |
|
754 | - * compile all error or success messages into one string |
|
755 | - * |
|
756 | - * @see EE_Error::get_raw_notices if you want the raw notices without any preparations made to them |
|
757 | - * @param boolean $format_output whether or not to format the messages for display in the WP admin |
|
758 | - * @param boolean $save_to_transient whether or not to save notices to the db for retrieval on next request |
|
759 | - * - ONLY do this just before redirecting |
|
760 | - * @param boolean $remove_empty whether or not to unset empty messages |
|
761 | - * @return array |
|
762 | - */ |
|
763 | - public static function get_notices($format_output = true, $save_to_transient = false, $remove_empty = true) |
|
764 | - { |
|
765 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
766 | - $success_messages = ''; |
|
767 | - $attention_messages = ''; |
|
768 | - $error_messages = ''; |
|
769 | - $print_scripts = false; |
|
770 | - // either save notices to the db |
|
771 | - if ($save_to_transient) { |
|
772 | - update_option('ee_notices', self::$_espresso_notices); |
|
773 | - return array(); |
|
774 | - } |
|
775 | - // grab any notices that have been previously saved |
|
776 | - if ($notices = get_option('ee_notices', false)) { |
|
777 | - foreach ($notices as $type => $notice) { |
|
778 | - if (is_array($notice) && ! empty($notice)) { |
|
779 | - // make sure that existing notice type is an array |
|
780 | - self::$_espresso_notices[$type] = is_array(self::$_espresso_notices[$type]) |
|
781 | - && ! empty(self::$_espresso_notices[$type]) |
|
782 | - ? self::$_espresso_notices[$type] : array(); |
|
783 | - // merge stored notices with any newly created ones |
|
784 | - self::$_espresso_notices[$type] = array_merge(self::$_espresso_notices[$type], $notice); |
|
785 | - $print_scripts = true; |
|
786 | - } |
|
787 | - } |
|
788 | - // now clear any stored notices |
|
789 | - update_option('ee_notices', false); |
|
790 | - } |
|
791 | - // check for success messages |
|
792 | - if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) { |
|
793 | - // combine messages |
|
794 | - $success_messages .= implode(self::$_espresso_notices['success'], '<br /><br />'); |
|
795 | - $print_scripts = true; |
|
796 | - } |
|
797 | - // check for attention messages |
|
798 | - if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) { |
|
799 | - // combine messages |
|
800 | - $attention_messages .= implode(self::$_espresso_notices['attention'], '<br /><br />'); |
|
801 | - $print_scripts = true; |
|
802 | - } |
|
803 | - // check for error messages |
|
804 | - if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) { |
|
805 | - $error_messages .= count(self::$_espresso_notices['errors']) > 1 |
|
806 | - ? __('The following errors have occurred:<br />', 'event_espresso') |
|
807 | - : __('An error has occurred:<br />', 'event_espresso'); |
|
808 | - // combine messages |
|
809 | - $error_messages .= implode(self::$_espresso_notices['errors'], '<br /><br />'); |
|
810 | - $print_scripts = true; |
|
811 | - } |
|
812 | - if ($format_output) { |
|
813 | - $notices = '<div id="espresso-notices">'; |
|
814 | - $close = is_admin() ? '' |
|
815 | - : '<a class="close-espresso-notice hide-if-no-js"><span class="dashicons dashicons-no"></span></a>'; |
|
816 | - if ($success_messages !== '') { |
|
817 | - $css_id = is_admin() ? 'message' : 'espresso-notices-success'; |
|
818 | - $css_class = is_admin() ? 'updated fade' : 'success fade-away'; |
|
819 | - //showMessage( $success_messages ); |
|
820 | - $notices .= '<div id="' |
|
821 | - . $css_id |
|
822 | - . '" class="espresso-notices ' |
|
823 | - . $css_class |
|
824 | - . '" style="display:none;"><p>' |
|
825 | - . $success_messages |
|
826 | - . '</p>' |
|
827 | - . $close |
|
828 | - . '</div>'; |
|
829 | - } |
|
830 | - if ($attention_messages !== '') { |
|
831 | - $css_id = is_admin() ? 'message' : 'espresso-notices-attention'; |
|
832 | - $css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away'; |
|
833 | - //showMessage( $error_messages, TRUE ); |
|
834 | - $notices .= '<div id="' |
|
835 | - . $css_id |
|
836 | - . '" class="espresso-notices ' |
|
837 | - . $css_class |
|
838 | - . '" style="display:none;"><p>' |
|
839 | - . $attention_messages |
|
840 | - . '</p>' |
|
841 | - . $close |
|
842 | - . '</div>'; |
|
843 | - } |
|
844 | - if ($error_messages !== '') { |
|
845 | - $css_id = is_admin() ? 'message' : 'espresso-notices-error'; |
|
846 | - $css_class = is_admin() ? 'error' : 'error fade-away'; |
|
847 | - //showMessage( $error_messages, TRUE ); |
|
848 | - $notices .= '<div id="' |
|
849 | - . $css_id |
|
850 | - . '" class="espresso-notices ' |
|
851 | - . $css_class |
|
852 | - . '" style="display:none;"><p>' |
|
853 | - . $error_messages |
|
854 | - . '</p>' |
|
855 | - . $close |
|
856 | - . '</div>'; |
|
857 | - } |
|
858 | - $notices .= '</div>'; |
|
859 | - } else { |
|
860 | - $notices = array( |
|
861 | - 'success' => $success_messages, |
|
862 | - 'attention' => $attention_messages, |
|
863 | - 'errors' => $error_messages, |
|
864 | - ); |
|
865 | - if ($remove_empty) { |
|
866 | - // remove empty notices |
|
867 | - foreach ($notices as $type => $notice) { |
|
868 | - if (empty($notice)) { |
|
869 | - unset($notices[$type]); |
|
870 | - } |
|
871 | - } |
|
872 | - } |
|
873 | - } |
|
874 | - if ($print_scripts) { |
|
875 | - self::_print_scripts(); |
|
876 | - } |
|
877 | - return $notices; |
|
878 | - } |
|
879 | - |
|
880 | - |
|
881 | - |
|
882 | - /** |
|
883 | - * add_persistent_admin_notice |
|
884 | - * |
|
885 | - * @param string $pan_name the name, or key of the Persistent Admin Notice to be stored |
|
886 | - * @param string $pan_message the message to be stored persistently until dismissed |
|
887 | - * @param bool $force_update allows one to enforce the reappearance of a persistent message. |
|
888 | - * @return void |
|
889 | - */ |
|
890 | - public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = false) |
|
891 | - { |
|
892 | - if (! empty($pan_name) && ! empty($pan_message)) { |
|
893 | - $persistent_admin_notices = get_option('ee_pers_admin_notices', array()); |
|
894 | - //maybe initialize persistent_admin_notices |
|
895 | - if (empty($persistent_admin_notices)) { |
|
896 | - add_option('ee_pers_admin_notices', array(), '', 'no'); |
|
897 | - } |
|
898 | - $pan_name = sanitize_key($pan_name); |
|
899 | - if (! array_key_exists($pan_name, $persistent_admin_notices) || $force_update) { |
|
900 | - $persistent_admin_notices[$pan_name] = $pan_message; |
|
901 | - update_option('ee_pers_admin_notices', $persistent_admin_notices); |
|
902 | - } |
|
903 | - } |
|
904 | - } |
|
905 | - |
|
906 | - |
|
907 | - |
|
908 | - /** |
|
909 | - * dismiss_persistent_admin_notice |
|
910 | - * |
|
911 | - * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed |
|
912 | - * @param bool $purge |
|
913 | - * @param bool $return_immediately |
|
914 | - * @return void |
|
915 | - */ |
|
916 | - public static function dismiss_persistent_admin_notice($pan_name = '', $purge = false, $return_immediately = false) |
|
917 | - { |
|
918 | - $pan_name = EE_Registry::instance()->REQ->is_set('ee_nag_notice') |
|
919 | - ? EE_Registry::instance()->REQ->get('ee_nag_notice') : $pan_name; |
|
920 | - if (! empty($pan_name)) { |
|
921 | - $persistent_admin_notices = get_option('ee_pers_admin_notices', array()); |
|
922 | - // check if notice we wish to dismiss is actually in the $persistent_admin_notices array |
|
923 | - if (is_array($persistent_admin_notices) && isset($persistent_admin_notices[$pan_name])) { |
|
924 | - // completely delete nag notice, or just NULL message so that it can NOT be added again ? |
|
925 | - if ($purge) { |
|
926 | - unset($persistent_admin_notices[$pan_name]); |
|
927 | - } else { |
|
928 | - $persistent_admin_notices[$pan_name] = null; |
|
929 | - } |
|
930 | - if (update_option('ee_pers_admin_notices', $persistent_admin_notices) === false) { |
|
931 | - EE_Error::add_error(sprintf(__('The persistent admin notice for "%s" could not be deleted.', |
|
932 | - 'event_espresso'), $pan_name), __FILE__, __FUNCTION__, __LINE__); |
|
933 | - } |
|
934 | - } |
|
935 | - } |
|
936 | - if ($return_immediately) { |
|
937 | - return; |
|
938 | - } |
|
939 | - if (EE_Registry::instance()->REQ->ajax) { |
|
940 | - // grab any notices and concatenate into string |
|
941 | - echo wp_json_encode(array('errors' => implode('<br />', EE_Error::get_notices(false)))); |
|
942 | - exit(); |
|
943 | - } |
|
944 | - // save errors to a transient to be displayed on next request (after redirect) |
|
945 | - EE_Error::get_notices(false, true); |
|
946 | - $return_url = EE_Registry::instance()->REQ->is_set('return_url') |
|
947 | - ? EE_Registry::instance()->REQ->get('return_url') : ''; |
|
948 | - wp_safe_redirect(urldecode($return_url)); |
|
949 | - } |
|
950 | - |
|
951 | - |
|
952 | - |
|
953 | - /** |
|
954 | - * display_persistent_admin_notices |
|
955 | - * |
|
956 | - * @param string $pan_name the name, or key of the Persistent Admin Notice to be stored |
|
957 | - * @param string $pan_message the message to be stored persistently until dismissed |
|
958 | - * @param string $return_url URL to go back to after nag notice is dismissed |
|
959 | - * @return string |
|
960 | - */ |
|
961 | - public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '') |
|
962 | - { |
|
963 | - if (! empty($pan_name) && ! empty($pan_message)) { |
|
964 | - $args = array( |
|
965 | - 'nag_notice' => $pan_name, |
|
966 | - 'return_url' => urlencode($return_url), |
|
967 | - 'ajax_url' => WP_AJAX_URL, |
|
968 | - 'unknown_error' => __('An unknown error has occurred on the server while attempting to dismiss this notice.', |
|
969 | - 'event_espresso'), |
|
970 | - ); |
|
971 | - wp_localize_script('espresso_core', 'ee_dismiss', $args); |
|
972 | - return ' |
|
470 | + $output .= self::_print_scripts(true); |
|
471 | + if (defined('DOING_AJAX')) { |
|
472 | + echo wp_json_encode(array('error' => $output)); |
|
473 | + exit(); |
|
474 | + } |
|
475 | + echo $output; |
|
476 | + die(); |
|
477 | + } |
|
478 | + |
|
479 | + |
|
480 | + |
|
481 | + /** |
|
482 | + * generate string from exception trace args |
|
483 | + * |
|
484 | + * @param array $arguments |
|
485 | + * @param bool $array |
|
486 | + * @return string |
|
487 | + */ |
|
488 | + private function _convert_args_to_string($arguments = array(), $array = false) |
|
489 | + { |
|
490 | + $arg_string = ''; |
|
491 | + if (! empty($arguments)) { |
|
492 | + $args = array(); |
|
493 | + foreach ($arguments as $arg) { |
|
494 | + if (! empty($arg)) { |
|
495 | + if (is_string($arg)) { |
|
496 | + $args[] = " '" . $arg . "'"; |
|
497 | + } elseif (is_array($arg)) { |
|
498 | + $args[] = 'ARRAY(' . $this->_convert_args_to_string($arg, true); |
|
499 | + } elseif ($arg === null) { |
|
500 | + $args[] = ' NULL'; |
|
501 | + } elseif (is_bool($arg)) { |
|
502 | + $args[] = ($arg) ? ' TRUE' : ' FALSE'; |
|
503 | + } elseif (is_object($arg)) { |
|
504 | + $args[] = ' OBJECT ' . get_class($arg); |
|
505 | + } elseif (is_resource($arg)) { |
|
506 | + $args[] = get_resource_type($arg); |
|
507 | + } else { |
|
508 | + $args[] = $arg; |
|
509 | + } |
|
510 | + } |
|
511 | + } |
|
512 | + $arg_string = implode(', ', $args); |
|
513 | + } |
|
514 | + if ($array) { |
|
515 | + $arg_string .= ' )'; |
|
516 | + } |
|
517 | + return $arg_string; |
|
518 | + } |
|
519 | + |
|
520 | + |
|
521 | + |
|
522 | + /** |
|
523 | + * add error message |
|
524 | + * |
|
525 | + * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates |
|
526 | + * separate messages for user || dev |
|
527 | + * @param string $file the file that the error occurred in - just use __FILE__ |
|
528 | + * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
529 | + * @param string $line the line number where the error occurred - just use __LINE__ |
|
530 | + * @return void |
|
531 | + */ |
|
532 | + public static function add_error($msg = null, $file = null, $func = null, $line = null) |
|
533 | + { |
|
534 | + self::_add_notice('errors', $msg, $file, $func, $line); |
|
535 | + self::$_error_count++; |
|
536 | + } |
|
537 | + |
|
538 | + |
|
539 | + |
|
540 | + /** |
|
541 | + * If WP_DEBUG is active, throws an exception. If WP_DEBUG is off, just |
|
542 | + * adds an error |
|
543 | + * |
|
544 | + * @param string $msg |
|
545 | + * @param string $file |
|
546 | + * @param string $func |
|
547 | + * @param string $line |
|
548 | + * @throws EE_Error |
|
549 | + */ |
|
550 | + public static function throw_exception_if_debugging($msg = null, $file = null, $func = null, $line = null) |
|
551 | + { |
|
552 | + if (WP_DEBUG) { |
|
553 | + throw new EE_Error($msg); |
|
554 | + } |
|
555 | + EE_Error::add_error($msg, $file, $func, $line); |
|
556 | + } |
|
557 | + |
|
558 | + |
|
559 | + |
|
560 | + /** |
|
561 | + * add success message |
|
562 | + * |
|
563 | + * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates |
|
564 | + * separate messages for user || dev |
|
565 | + * @param string $file the file that the error occurred in - just use __FILE__ |
|
566 | + * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
567 | + * @param string $line the line number where the error occurred - just use __LINE__ |
|
568 | + * @return void |
|
569 | + */ |
|
570 | + public static function add_success($msg = null, $file = null, $func = null, $line = null) |
|
571 | + { |
|
572 | + self::_add_notice('success', $msg, $file, $func, $line); |
|
573 | + } |
|
574 | + |
|
575 | + |
|
576 | + |
|
577 | + /** |
|
578 | + * add attention message |
|
579 | + * |
|
580 | + * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates |
|
581 | + * separate messages for user || dev |
|
582 | + * @param string $file the file that the error occurred in - just use __FILE__ |
|
583 | + * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
584 | + * @param string $line the line number where the error occurred - just use __LINE__ |
|
585 | + * @return void |
|
586 | + */ |
|
587 | + public static function add_attention($msg = null, $file = null, $func = null, $line = null) |
|
588 | + { |
|
589 | + self::_add_notice('attention', $msg, $file, $func, $line); |
|
590 | + } |
|
591 | + |
|
592 | + |
|
593 | + |
|
594 | + /** |
|
595 | + * add success message |
|
596 | + * |
|
597 | + * @param string $type whether the message is for a success or error notification |
|
598 | + * @param string $msg the message to display to users or developers - adding a double pipe || (OR) creates |
|
599 | + * separate messages for user || dev |
|
600 | + * @param string $file the file that the error occurred in - just use __FILE__ |
|
601 | + * @param string $func the function/method that the error occurred in - just use __FUNCTION__ |
|
602 | + * @param string $line the line number where the error occurred - just use __LINE__ |
|
603 | + * @return void |
|
604 | + */ |
|
605 | + private static function _add_notice($type = 'success', $msg = null, $file = null, $func = null, $line = null) |
|
606 | + { |
|
607 | + if (empty($msg)) { |
|
608 | + EE_Error::doing_it_wrong( |
|
609 | + 'EE_Error::add_' . $type . '()', |
|
610 | + sprintf( |
|
611 | + __('Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d', |
|
612 | + 'event_espresso'), |
|
613 | + $type, |
|
614 | + $file, |
|
615 | + $line |
|
616 | + ), |
|
617 | + EVENT_ESPRESSO_VERSION |
|
618 | + ); |
|
619 | + } |
|
620 | + if ($type === 'errors' && (empty($file) || empty($func) || empty($line))) { |
|
621 | + EE_Error::doing_it_wrong( |
|
622 | + 'EE_Error::add_error()', |
|
623 | + __('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.', |
|
624 | + 'event_espresso'), |
|
625 | + EVENT_ESPRESSO_VERSION |
|
626 | + ); |
|
627 | + } |
|
628 | + // get separate user and developer messages if they exist |
|
629 | + $msg = explode('||', $msg); |
|
630 | + $user_msg = $msg[0]; |
|
631 | + $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
632 | + /** |
|
633 | + * Do an action so other code can be triggered when a notice is created |
|
634 | + * |
|
635 | + * @param string $type can be 'errors', 'attention', or 'success' |
|
636 | + * @param string $user_msg message displayed to user when WP_DEBUG is off |
|
637 | + * @param string $user_msg message displayed to user when WP_DEBUG is on |
|
638 | + * @param string $file file where error was generated |
|
639 | + * @param string $func function where error was generated |
|
640 | + * @param string $line line where error was generated |
|
641 | + */ |
|
642 | + do_action('AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line); |
|
643 | + $msg = WP_DEBUG ? $dev_msg : $user_msg; |
|
644 | + // add notice if message exists |
|
645 | + if (! empty($msg)) { |
|
646 | + // get error code |
|
647 | + $notice_code = EE_Error::generate_error_code($file, $func, $line); |
|
648 | + if (WP_DEBUG && $type === 'errors') { |
|
649 | + $msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>'; |
|
650 | + } |
|
651 | + // add notice. Index by code if it's not blank |
|
652 | + if ($notice_code) { |
|
653 | + self::$_espresso_notices[$type][$notice_code] = $msg; |
|
654 | + } else { |
|
655 | + self::$_espresso_notices[$type][] = $msg; |
|
656 | + } |
|
657 | + add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1); |
|
658 | + } |
|
659 | + } |
|
660 | + |
|
661 | + |
|
662 | + |
|
663 | + /** |
|
664 | + * in some case it may be necessary to overwrite the existing success messages |
|
665 | + * |
|
666 | + * @return void |
|
667 | + */ |
|
668 | + public static function overwrite_success() |
|
669 | + { |
|
670 | + self::$_espresso_notices['success'] = false; |
|
671 | + } |
|
672 | + |
|
673 | + |
|
674 | + |
|
675 | + /** |
|
676 | + * in some case it may be necessary to overwrite the existing attention messages |
|
677 | + * |
|
678 | + * @return void |
|
679 | + */ |
|
680 | + public static function overwrite_attention() |
|
681 | + { |
|
682 | + self::$_espresso_notices['attention'] = false; |
|
683 | + } |
|
684 | + |
|
685 | + |
|
686 | + |
|
687 | + /** |
|
688 | + * in some case it may be necessary to overwrite the existing error messages |
|
689 | + * |
|
690 | + * @return void |
|
691 | + */ |
|
692 | + public static function overwrite_errors() |
|
693 | + { |
|
694 | + self::$_espresso_notices['errors'] = false; |
|
695 | + } |
|
696 | + |
|
697 | + |
|
698 | + |
|
699 | + /** |
|
700 | + * reset_notices |
|
701 | + * |
|
702 | + * @return void |
|
703 | + */ |
|
704 | + public static function reset_notices() |
|
705 | + { |
|
706 | + self::$_espresso_notices['success'] = false; |
|
707 | + self::$_espresso_notices['attention'] = false; |
|
708 | + self::$_espresso_notices['errors'] = false; |
|
709 | + } |
|
710 | + |
|
711 | + |
|
712 | + |
|
713 | + /** |
|
714 | + * has_errors |
|
715 | + * |
|
716 | + * @return int |
|
717 | + */ |
|
718 | + public static function has_notices() |
|
719 | + { |
|
720 | + $has_notices = 0; |
|
721 | + // check for success messages |
|
722 | + $has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success']) ? 3 |
|
723 | + : $has_notices; |
|
724 | + // check for attention messages |
|
725 | + $has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention']) ? 2 |
|
726 | + : $has_notices; |
|
727 | + // check for error messages |
|
728 | + $has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors']) ? 1 |
|
729 | + : $has_notices; |
|
730 | + return $has_notices; |
|
731 | + } |
|
732 | + |
|
733 | + |
|
734 | + |
|
735 | + /** |
|
736 | + * This simply returns non formatted error notices as they were sent into the EE_Error object. |
|
737 | + * |
|
738 | + * @since 4.9.0 |
|
739 | + * @return array |
|
740 | + */ |
|
741 | + public static function get_vanilla_notices() |
|
742 | + { |
|
743 | + return array( |
|
744 | + 'success' => isset(self::$_espresso_notices['success']) ? self::$_espresso_notices['success'] : array(), |
|
745 | + 'attention' => isset(self::$_espresso_notices['attention']) ? self::$_espresso_notices['attention'] |
|
746 | + : array(), |
|
747 | + 'errors' => isset(self::$_espresso_notices['errors']) ? self::$_espresso_notices['errors'] : array(), |
|
748 | + ); |
|
749 | + } |
|
750 | + |
|
751 | + |
|
752 | + |
|
753 | + /** |
|
754 | + * compile all error or success messages into one string |
|
755 | + * |
|
756 | + * @see EE_Error::get_raw_notices if you want the raw notices without any preparations made to them |
|
757 | + * @param boolean $format_output whether or not to format the messages for display in the WP admin |
|
758 | + * @param boolean $save_to_transient whether or not to save notices to the db for retrieval on next request |
|
759 | + * - ONLY do this just before redirecting |
|
760 | + * @param boolean $remove_empty whether or not to unset empty messages |
|
761 | + * @return array |
|
762 | + */ |
|
763 | + public static function get_notices($format_output = true, $save_to_transient = false, $remove_empty = true) |
|
764 | + { |
|
765 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
766 | + $success_messages = ''; |
|
767 | + $attention_messages = ''; |
|
768 | + $error_messages = ''; |
|
769 | + $print_scripts = false; |
|
770 | + // either save notices to the db |
|
771 | + if ($save_to_transient) { |
|
772 | + update_option('ee_notices', self::$_espresso_notices); |
|
773 | + return array(); |
|
774 | + } |
|
775 | + // grab any notices that have been previously saved |
|
776 | + if ($notices = get_option('ee_notices', false)) { |
|
777 | + foreach ($notices as $type => $notice) { |
|
778 | + if (is_array($notice) && ! empty($notice)) { |
|
779 | + // make sure that existing notice type is an array |
|
780 | + self::$_espresso_notices[$type] = is_array(self::$_espresso_notices[$type]) |
|
781 | + && ! empty(self::$_espresso_notices[$type]) |
|
782 | + ? self::$_espresso_notices[$type] : array(); |
|
783 | + // merge stored notices with any newly created ones |
|
784 | + self::$_espresso_notices[$type] = array_merge(self::$_espresso_notices[$type], $notice); |
|
785 | + $print_scripts = true; |
|
786 | + } |
|
787 | + } |
|
788 | + // now clear any stored notices |
|
789 | + update_option('ee_notices', false); |
|
790 | + } |
|
791 | + // check for success messages |
|
792 | + if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) { |
|
793 | + // combine messages |
|
794 | + $success_messages .= implode(self::$_espresso_notices['success'], '<br /><br />'); |
|
795 | + $print_scripts = true; |
|
796 | + } |
|
797 | + // check for attention messages |
|
798 | + if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) { |
|
799 | + // combine messages |
|
800 | + $attention_messages .= implode(self::$_espresso_notices['attention'], '<br /><br />'); |
|
801 | + $print_scripts = true; |
|
802 | + } |
|
803 | + // check for error messages |
|
804 | + if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) { |
|
805 | + $error_messages .= count(self::$_espresso_notices['errors']) > 1 |
|
806 | + ? __('The following errors have occurred:<br />', 'event_espresso') |
|
807 | + : __('An error has occurred:<br />', 'event_espresso'); |
|
808 | + // combine messages |
|
809 | + $error_messages .= implode(self::$_espresso_notices['errors'], '<br /><br />'); |
|
810 | + $print_scripts = true; |
|
811 | + } |
|
812 | + if ($format_output) { |
|
813 | + $notices = '<div id="espresso-notices">'; |
|
814 | + $close = is_admin() ? '' |
|
815 | + : '<a class="close-espresso-notice hide-if-no-js"><span class="dashicons dashicons-no"></span></a>'; |
|
816 | + if ($success_messages !== '') { |
|
817 | + $css_id = is_admin() ? 'message' : 'espresso-notices-success'; |
|
818 | + $css_class = is_admin() ? 'updated fade' : 'success fade-away'; |
|
819 | + //showMessage( $success_messages ); |
|
820 | + $notices .= '<div id="' |
|
821 | + . $css_id |
|
822 | + . '" class="espresso-notices ' |
|
823 | + . $css_class |
|
824 | + . '" style="display:none;"><p>' |
|
825 | + . $success_messages |
|
826 | + . '</p>' |
|
827 | + . $close |
|
828 | + . '</div>'; |
|
829 | + } |
|
830 | + if ($attention_messages !== '') { |
|
831 | + $css_id = is_admin() ? 'message' : 'espresso-notices-attention'; |
|
832 | + $css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away'; |
|
833 | + //showMessage( $error_messages, TRUE ); |
|
834 | + $notices .= '<div id="' |
|
835 | + . $css_id |
|
836 | + . '" class="espresso-notices ' |
|
837 | + . $css_class |
|
838 | + . '" style="display:none;"><p>' |
|
839 | + . $attention_messages |
|
840 | + . '</p>' |
|
841 | + . $close |
|
842 | + . '</div>'; |
|
843 | + } |
|
844 | + if ($error_messages !== '') { |
|
845 | + $css_id = is_admin() ? 'message' : 'espresso-notices-error'; |
|
846 | + $css_class = is_admin() ? 'error' : 'error fade-away'; |
|
847 | + //showMessage( $error_messages, TRUE ); |
|
848 | + $notices .= '<div id="' |
|
849 | + . $css_id |
|
850 | + . '" class="espresso-notices ' |
|
851 | + . $css_class |
|
852 | + . '" style="display:none;"><p>' |
|
853 | + . $error_messages |
|
854 | + . '</p>' |
|
855 | + . $close |
|
856 | + . '</div>'; |
|
857 | + } |
|
858 | + $notices .= '</div>'; |
|
859 | + } else { |
|
860 | + $notices = array( |
|
861 | + 'success' => $success_messages, |
|
862 | + 'attention' => $attention_messages, |
|
863 | + 'errors' => $error_messages, |
|
864 | + ); |
|
865 | + if ($remove_empty) { |
|
866 | + // remove empty notices |
|
867 | + foreach ($notices as $type => $notice) { |
|
868 | + if (empty($notice)) { |
|
869 | + unset($notices[$type]); |
|
870 | + } |
|
871 | + } |
|
872 | + } |
|
873 | + } |
|
874 | + if ($print_scripts) { |
|
875 | + self::_print_scripts(); |
|
876 | + } |
|
877 | + return $notices; |
|
878 | + } |
|
879 | + |
|
880 | + |
|
881 | + |
|
882 | + /** |
|
883 | + * add_persistent_admin_notice |
|
884 | + * |
|
885 | + * @param string $pan_name the name, or key of the Persistent Admin Notice to be stored |
|
886 | + * @param string $pan_message the message to be stored persistently until dismissed |
|
887 | + * @param bool $force_update allows one to enforce the reappearance of a persistent message. |
|
888 | + * @return void |
|
889 | + */ |
|
890 | + public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = false) |
|
891 | + { |
|
892 | + if (! empty($pan_name) && ! empty($pan_message)) { |
|
893 | + $persistent_admin_notices = get_option('ee_pers_admin_notices', array()); |
|
894 | + //maybe initialize persistent_admin_notices |
|
895 | + if (empty($persistent_admin_notices)) { |
|
896 | + add_option('ee_pers_admin_notices', array(), '', 'no'); |
|
897 | + } |
|
898 | + $pan_name = sanitize_key($pan_name); |
|
899 | + if (! array_key_exists($pan_name, $persistent_admin_notices) || $force_update) { |
|
900 | + $persistent_admin_notices[$pan_name] = $pan_message; |
|
901 | + update_option('ee_pers_admin_notices', $persistent_admin_notices); |
|
902 | + } |
|
903 | + } |
|
904 | + } |
|
905 | + |
|
906 | + |
|
907 | + |
|
908 | + /** |
|
909 | + * dismiss_persistent_admin_notice |
|
910 | + * |
|
911 | + * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed |
|
912 | + * @param bool $purge |
|
913 | + * @param bool $return_immediately |
|
914 | + * @return void |
|
915 | + */ |
|
916 | + public static function dismiss_persistent_admin_notice($pan_name = '', $purge = false, $return_immediately = false) |
|
917 | + { |
|
918 | + $pan_name = EE_Registry::instance()->REQ->is_set('ee_nag_notice') |
|
919 | + ? EE_Registry::instance()->REQ->get('ee_nag_notice') : $pan_name; |
|
920 | + if (! empty($pan_name)) { |
|
921 | + $persistent_admin_notices = get_option('ee_pers_admin_notices', array()); |
|
922 | + // check if notice we wish to dismiss is actually in the $persistent_admin_notices array |
|
923 | + if (is_array($persistent_admin_notices) && isset($persistent_admin_notices[$pan_name])) { |
|
924 | + // completely delete nag notice, or just NULL message so that it can NOT be added again ? |
|
925 | + if ($purge) { |
|
926 | + unset($persistent_admin_notices[$pan_name]); |
|
927 | + } else { |
|
928 | + $persistent_admin_notices[$pan_name] = null; |
|
929 | + } |
|
930 | + if (update_option('ee_pers_admin_notices', $persistent_admin_notices) === false) { |
|
931 | + EE_Error::add_error(sprintf(__('The persistent admin notice for "%s" could not be deleted.', |
|
932 | + 'event_espresso'), $pan_name), __FILE__, __FUNCTION__, __LINE__); |
|
933 | + } |
|
934 | + } |
|
935 | + } |
|
936 | + if ($return_immediately) { |
|
937 | + return; |
|
938 | + } |
|
939 | + if (EE_Registry::instance()->REQ->ajax) { |
|
940 | + // grab any notices and concatenate into string |
|
941 | + echo wp_json_encode(array('errors' => implode('<br />', EE_Error::get_notices(false)))); |
|
942 | + exit(); |
|
943 | + } |
|
944 | + // save errors to a transient to be displayed on next request (after redirect) |
|
945 | + EE_Error::get_notices(false, true); |
|
946 | + $return_url = EE_Registry::instance()->REQ->is_set('return_url') |
|
947 | + ? EE_Registry::instance()->REQ->get('return_url') : ''; |
|
948 | + wp_safe_redirect(urldecode($return_url)); |
|
949 | + } |
|
950 | + |
|
951 | + |
|
952 | + |
|
953 | + /** |
|
954 | + * display_persistent_admin_notices |
|
955 | + * |
|
956 | + * @param string $pan_name the name, or key of the Persistent Admin Notice to be stored |
|
957 | + * @param string $pan_message the message to be stored persistently until dismissed |
|
958 | + * @param string $return_url URL to go back to after nag notice is dismissed |
|
959 | + * @return string |
|
960 | + */ |
|
961 | + public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '') |
|
962 | + { |
|
963 | + if (! empty($pan_name) && ! empty($pan_message)) { |
|
964 | + $args = array( |
|
965 | + 'nag_notice' => $pan_name, |
|
966 | + 'return_url' => urlencode($return_url), |
|
967 | + 'ajax_url' => WP_AJAX_URL, |
|
968 | + 'unknown_error' => __('An unknown error has occurred on the server while attempting to dismiss this notice.', |
|
969 | + 'event_espresso'), |
|
970 | + ); |
|
971 | + wp_localize_script('espresso_core', 'ee_dismiss', $args); |
|
972 | + return ' |
|
973 | 973 | <div id="' |
974 | - . $pan_name |
|
975 | - . '" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;"> |
|
974 | + . $pan_name |
|
975 | + . '" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;"> |
|
976 | 976 | <p>' |
977 | - . $pan_message |
|
978 | - . '</p> |
|
977 | + . $pan_message |
|
978 | + . '</p> |
|
979 | 979 | <a class="dismiss-ee-nag-notice hide-if-no-js" style="float: right; cursor: pointer; text-decoration:none;" rel="' |
980 | - . $pan_name |
|
981 | - . '"> |
|
980 | + . $pan_name |
|
981 | + . '"> |
|
982 | 982 | <span class="dashicons dashicons-dismiss" style="position:relative; top:-1px; margin-right:.25em;"></span>' |
983 | - . __('Dismiss', 'event_espresso') |
|
984 | - . ' |
|
983 | + . __('Dismiss', 'event_espresso') |
|
984 | + . ' |
|
985 | 985 | </a> |
986 | 986 | <div style="clear:both;"></div> |
987 | 987 | </div>'; |
988 | - } |
|
989 | - return ''; |
|
990 | - } |
|
991 | - |
|
992 | - |
|
993 | - |
|
994 | - /** |
|
995 | - * get_persistent_admin_notices |
|
996 | - * |
|
997 | - * @param string $return_url |
|
998 | - * @return string |
|
999 | - */ |
|
1000 | - public static function get_persistent_admin_notices($return_url = '') |
|
1001 | - { |
|
1002 | - $notices = ''; |
|
1003 | - // check for persistent admin notices |
|
1004 | - //filter the list though so plugins can notify the admin in a different way if they want |
|
1005 | - $persistent_admin_notices = apply_filters( |
|
1006 | - 'FHEE__EE_Error__get_persistent_admin_notices', |
|
1007 | - get_option('ee_pers_admin_notices', false), |
|
1008 | - 'ee_pers_admin_notices', |
|
1009 | - $return_url |
|
1010 | - ); |
|
1011 | - if ($persistent_admin_notices) { |
|
1012 | - // load scripts |
|
1013 | - wp_register_script( |
|
1014 | - 'espresso_core', |
|
1015 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
1016 | - array('jquery'), |
|
1017 | - EVENT_ESPRESSO_VERSION, |
|
1018 | - true |
|
1019 | - ); |
|
1020 | - wp_register_script( |
|
1021 | - 'ee_error_js', |
|
1022 | - EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', |
|
1023 | - array('espresso_core'), |
|
1024 | - EVENT_ESPRESSO_VERSION, |
|
1025 | - true |
|
1026 | - ); |
|
1027 | - wp_enqueue_script('ee_error_js'); |
|
1028 | - // and display notices |
|
1029 | - foreach ($persistent_admin_notices as $pan_name => $pan_message) { |
|
1030 | - $notices .= self::display_persistent_admin_notices($pan_name, $pan_message, $return_url); |
|
1031 | - } |
|
1032 | - } |
|
1033 | - return $notices; |
|
1034 | - } |
|
1035 | - |
|
1036 | - |
|
1037 | - |
|
1038 | - /** |
|
1039 | - * _print_scripts |
|
1040 | - * |
|
1041 | - * @param bool $force_print |
|
1042 | - * @return string |
|
1043 | - */ |
|
1044 | - private static function _print_scripts($force_print = false) |
|
1045 | - { |
|
1046 | - if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
1047 | - if (wp_script_is('ee_error_js', 'enqueued')) { |
|
1048 | - return ''; |
|
1049 | - } |
|
1050 | - if (wp_script_is('ee_error_js', 'registered')) { |
|
1051 | - wp_enqueue_style('espresso_default'); |
|
1052 | - wp_enqueue_style('espresso_custom_css'); |
|
1053 | - wp_enqueue_script('ee_error_js'); |
|
1054 | - wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG)); |
|
1055 | - } |
|
1056 | - } else { |
|
1057 | - return ' |
|
988 | + } |
|
989 | + return ''; |
|
990 | + } |
|
991 | + |
|
992 | + |
|
993 | + |
|
994 | + /** |
|
995 | + * get_persistent_admin_notices |
|
996 | + * |
|
997 | + * @param string $return_url |
|
998 | + * @return string |
|
999 | + */ |
|
1000 | + public static function get_persistent_admin_notices($return_url = '') |
|
1001 | + { |
|
1002 | + $notices = ''; |
|
1003 | + // check for persistent admin notices |
|
1004 | + //filter the list though so plugins can notify the admin in a different way if they want |
|
1005 | + $persistent_admin_notices = apply_filters( |
|
1006 | + 'FHEE__EE_Error__get_persistent_admin_notices', |
|
1007 | + get_option('ee_pers_admin_notices', false), |
|
1008 | + 'ee_pers_admin_notices', |
|
1009 | + $return_url |
|
1010 | + ); |
|
1011 | + if ($persistent_admin_notices) { |
|
1012 | + // load scripts |
|
1013 | + wp_register_script( |
|
1014 | + 'espresso_core', |
|
1015 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
1016 | + array('jquery'), |
|
1017 | + EVENT_ESPRESSO_VERSION, |
|
1018 | + true |
|
1019 | + ); |
|
1020 | + wp_register_script( |
|
1021 | + 'ee_error_js', |
|
1022 | + EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', |
|
1023 | + array('espresso_core'), |
|
1024 | + EVENT_ESPRESSO_VERSION, |
|
1025 | + true |
|
1026 | + ); |
|
1027 | + wp_enqueue_script('ee_error_js'); |
|
1028 | + // and display notices |
|
1029 | + foreach ($persistent_admin_notices as $pan_name => $pan_message) { |
|
1030 | + $notices .= self::display_persistent_admin_notices($pan_name, $pan_message, $return_url); |
|
1031 | + } |
|
1032 | + } |
|
1033 | + return $notices; |
|
1034 | + } |
|
1035 | + |
|
1036 | + |
|
1037 | + |
|
1038 | + /** |
|
1039 | + * _print_scripts |
|
1040 | + * |
|
1041 | + * @param bool $force_print |
|
1042 | + * @return string |
|
1043 | + */ |
|
1044 | + private static function _print_scripts($force_print = false) |
|
1045 | + { |
|
1046 | + if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) { |
|
1047 | + if (wp_script_is('ee_error_js', 'enqueued')) { |
|
1048 | + return ''; |
|
1049 | + } |
|
1050 | + if (wp_script_is('ee_error_js', 'registered')) { |
|
1051 | + wp_enqueue_style('espresso_default'); |
|
1052 | + wp_enqueue_style('espresso_custom_css'); |
|
1053 | + wp_enqueue_script('ee_error_js'); |
|
1054 | + wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG)); |
|
1055 | + } |
|
1056 | + } else { |
|
1057 | + return ' |
|
1058 | 1058 | <script> |
1059 | 1059 | /* <![CDATA[ */ |
1060 | 1060 | var ee_settings = {"wp_debug":"' . WP_DEBUG . '"}; |
@@ -1064,143 +1064,143 @@ discard block |
||
1064 | 1064 | <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
1065 | 1065 | <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
1066 | 1066 | '; |
1067 | - } |
|
1068 | - return ''; |
|
1069 | - } |
|
1070 | - |
|
1071 | - |
|
1072 | - |
|
1073 | - /** |
|
1074 | - * enqueue_error_scripts |
|
1075 | - * |
|
1076 | - * @return void |
|
1077 | - */ |
|
1078 | - public static function enqueue_error_scripts() |
|
1079 | - { |
|
1080 | - self::_print_scripts(); |
|
1081 | - } |
|
1082 | - |
|
1083 | - |
|
1084 | - |
|
1085 | - /** |
|
1086 | - * create error code from filepath, function name, |
|
1087 | - * and line number where exception or error was thrown |
|
1088 | - * |
|
1089 | - * @param string $file |
|
1090 | - * @param string $func |
|
1091 | - * @param string $line |
|
1092 | - * @return string |
|
1093 | - */ |
|
1094 | - public static function generate_error_code($file = '', $func = '', $line = '') |
|
1095 | - { |
|
1096 | - $file = explode('.', basename($file)); |
|
1097 | - $error_code = ! empty($file[0]) ? $file[0] : ''; |
|
1098 | - $error_code .= ! empty($func) ? ' - ' . $func : ''; |
|
1099 | - $error_code .= ! empty($line) ? ' - ' . $line : ''; |
|
1100 | - return $error_code; |
|
1101 | - } |
|
1102 | - |
|
1103 | - |
|
1104 | - |
|
1105 | - /** |
|
1106 | - * write exception details to log file |
|
1107 | - * |
|
1108 | - * @param int $time |
|
1109 | - * @param array $ex |
|
1110 | - * @param bool $clear |
|
1111 | - * @return void |
|
1112 | - */ |
|
1113 | - public function write_to_error_log($time = 0, $ex = array(), $clear = false) |
|
1114 | - { |
|
1115 | - if (empty($ex)) { |
|
1116 | - return; |
|
1117 | - } |
|
1118 | - if (! $time) { |
|
1119 | - $time = time(); |
|
1120 | - } |
|
1121 | - $exception_log = '----------------------------------------------------------------------------------------' |
|
1122 | - . PHP_EOL; |
|
1123 | - $exception_log .= '[' . date('Y-m-d H:i:s', $time) . '] Exception Details' . PHP_EOL; |
|
1124 | - $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL; |
|
1125 | - $exception_log .= 'Code: ' . $ex['code'] . PHP_EOL; |
|
1126 | - $exception_log .= 'File: ' . $ex['file'] . PHP_EOL; |
|
1127 | - $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL; |
|
1128 | - $exception_log .= 'Stack trace: ' . PHP_EOL; |
|
1129 | - $exception_log .= $ex['string'] . PHP_EOL; |
|
1130 | - $exception_log .= '----------------------------------------------------------------------------------------' |
|
1131 | - . PHP_EOL; |
|
1132 | - try { |
|
1133 | - EEH_File::ensure_file_exists_and_is_writable( |
|
1134 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file |
|
1135 | - ); |
|
1136 | - EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs'); |
|
1137 | - if (! $clear) { |
|
1138 | - //get existing log file and append new log info |
|
1139 | - $exception_log = EEH_File::get_file_contents( |
|
1140 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file |
|
1141 | - ) . $exception_log; |
|
1142 | - } |
|
1143 | - EEH_File::write_to_file( |
|
1144 | - EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file, |
|
1145 | - $exception_log |
|
1146 | - ); |
|
1147 | - } catch (EE_Error $e) { |
|
1148 | - EE_Error::add_error(sprintf(__('Event Espresso error logging could not be setup because: %s', |
|
1149 | - 'event_espresso'), $e->getMessage())); |
|
1150 | - return; |
|
1151 | - } |
|
1152 | - } |
|
1153 | - |
|
1154 | - |
|
1155 | - |
|
1156 | - /** |
|
1157 | - * This is just a wrapper for the EEH_Debug_Tools::instance()->doing_it_wrong() method. |
|
1158 | - * doing_it_wrong() is used in those cases where a normal PHP error won't get thrown, |
|
1159 | - * but the code execution is done in a manner that could lead to unexpected results |
|
1160 | - * (i.e. running to early, or too late in WP or EE loading process). |
|
1161 | - * A good test for knowing whether to use this method is: |
|
1162 | - * 1. Is there going to be a PHP error if something isn't setup/used correctly? |
|
1163 | - * Yes -> use EE_Error::add_error() or throw new EE_Error() |
|
1164 | - * 2. If this is loaded before something else, it won't break anything, |
|
1165 | - * but just wont' do what its supposed to do? Yes -> use EE_Error::doing_it_wrong() |
|
1166 | - * |
|
1167 | - * @uses constant WP_DEBUG test if wp_debug is on or not |
|
1168 | - * @param string $function The function that was called |
|
1169 | - * @param string $message A message explaining what has been done incorrectly |
|
1170 | - * @param string $version The version of Event Espresso where the error was added |
|
1171 | - * @param string $applies_when a version string for when you want the doing_it_wrong notice to begin appearing |
|
1172 | - * for a deprecated function. This allows deprecation to occur during one version, |
|
1173 | - * but not have any notices appear until a later version. This allows developers |
|
1174 | - * extra time to update their code before notices appear. |
|
1175 | - * @param int $error_type |
|
1176 | - */ |
|
1177 | - public static function doing_it_wrong( |
|
1178 | - $function, |
|
1179 | - $message, |
|
1180 | - $version, |
|
1181 | - $applies_when = '', |
|
1182 | - $error_type = null |
|
1183 | - ) { |
|
1184 | - if (defined('WP_DEBUG') && WP_DEBUG) { |
|
1185 | - EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $applies_when, $error_type); |
|
1186 | - } |
|
1187 | - } |
|
1188 | - |
|
1189 | - |
|
1190 | - |
|
1191 | - /** |
|
1192 | - * Like get_notices, but returns an array of all the notices of the given type. |
|
1193 | - * |
|
1194 | - * @return array { |
|
1195 | - * @type array $success all the success messages |
|
1196 | - * @type array $errors all the error messages |
|
1197 | - * @type array $attention all the attention messages |
|
1198 | - * } |
|
1199 | - */ |
|
1200 | - public static function get_raw_notices() |
|
1201 | - { |
|
1202 | - return self::$_espresso_notices; |
|
1203 | - } |
|
1067 | + } |
|
1068 | + return ''; |
|
1069 | + } |
|
1070 | + |
|
1071 | + |
|
1072 | + |
|
1073 | + /** |
|
1074 | + * enqueue_error_scripts |
|
1075 | + * |
|
1076 | + * @return void |
|
1077 | + */ |
|
1078 | + public static function enqueue_error_scripts() |
|
1079 | + { |
|
1080 | + self::_print_scripts(); |
|
1081 | + } |
|
1082 | + |
|
1083 | + |
|
1084 | + |
|
1085 | + /** |
|
1086 | + * create error code from filepath, function name, |
|
1087 | + * and line number where exception or error was thrown |
|
1088 | + * |
|
1089 | + * @param string $file |
|
1090 | + * @param string $func |
|
1091 | + * @param string $line |
|
1092 | + * @return string |
|
1093 | + */ |
|
1094 | + public static function generate_error_code($file = '', $func = '', $line = '') |
|
1095 | + { |
|
1096 | + $file = explode('.', basename($file)); |
|
1097 | + $error_code = ! empty($file[0]) ? $file[0] : ''; |
|
1098 | + $error_code .= ! empty($func) ? ' - ' . $func : ''; |
|
1099 | + $error_code .= ! empty($line) ? ' - ' . $line : ''; |
|
1100 | + return $error_code; |
|
1101 | + } |
|
1102 | + |
|
1103 | + |
|
1104 | + |
|
1105 | + /** |
|
1106 | + * write exception details to log file |
|
1107 | + * |
|
1108 | + * @param int $time |
|
1109 | + * @param array $ex |
|
1110 | + * @param bool $clear |
|
1111 | + * @return void |
|
1112 | + */ |
|
1113 | + public function write_to_error_log($time = 0, $ex = array(), $clear = false) |
|
1114 | + { |
|
1115 | + if (empty($ex)) { |
|
1116 | + return; |
|
1117 | + } |
|
1118 | + if (! $time) { |
|
1119 | + $time = time(); |
|
1120 | + } |
|
1121 | + $exception_log = '----------------------------------------------------------------------------------------' |
|
1122 | + . PHP_EOL; |
|
1123 | + $exception_log .= '[' . date('Y-m-d H:i:s', $time) . '] Exception Details' . PHP_EOL; |
|
1124 | + $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL; |
|
1125 | + $exception_log .= 'Code: ' . $ex['code'] . PHP_EOL; |
|
1126 | + $exception_log .= 'File: ' . $ex['file'] . PHP_EOL; |
|
1127 | + $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL; |
|
1128 | + $exception_log .= 'Stack trace: ' . PHP_EOL; |
|
1129 | + $exception_log .= $ex['string'] . PHP_EOL; |
|
1130 | + $exception_log .= '----------------------------------------------------------------------------------------' |
|
1131 | + . PHP_EOL; |
|
1132 | + try { |
|
1133 | + EEH_File::ensure_file_exists_and_is_writable( |
|
1134 | + EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file |
|
1135 | + ); |
|
1136 | + EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs'); |
|
1137 | + if (! $clear) { |
|
1138 | + //get existing log file and append new log info |
|
1139 | + $exception_log = EEH_File::get_file_contents( |
|
1140 | + EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file |
|
1141 | + ) . $exception_log; |
|
1142 | + } |
|
1143 | + EEH_File::write_to_file( |
|
1144 | + EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file, |
|
1145 | + $exception_log |
|
1146 | + ); |
|
1147 | + } catch (EE_Error $e) { |
|
1148 | + EE_Error::add_error(sprintf(__('Event Espresso error logging could not be setup because: %s', |
|
1149 | + 'event_espresso'), $e->getMessage())); |
|
1150 | + return; |
|
1151 | + } |
|
1152 | + } |
|
1153 | + |
|
1154 | + |
|
1155 | + |
|
1156 | + /** |
|
1157 | + * This is just a wrapper for the EEH_Debug_Tools::instance()->doing_it_wrong() method. |
|
1158 | + * doing_it_wrong() is used in those cases where a normal PHP error won't get thrown, |
|
1159 | + * but the code execution is done in a manner that could lead to unexpected results |
|
1160 | + * (i.e. running to early, or too late in WP or EE loading process). |
|
1161 | + * A good test for knowing whether to use this method is: |
|
1162 | + * 1. Is there going to be a PHP error if something isn't setup/used correctly? |
|
1163 | + * Yes -> use EE_Error::add_error() or throw new EE_Error() |
|
1164 | + * 2. If this is loaded before something else, it won't break anything, |
|
1165 | + * but just wont' do what its supposed to do? Yes -> use EE_Error::doing_it_wrong() |
|
1166 | + * |
|
1167 | + * @uses constant WP_DEBUG test if wp_debug is on or not |
|
1168 | + * @param string $function The function that was called |
|
1169 | + * @param string $message A message explaining what has been done incorrectly |
|
1170 | + * @param string $version The version of Event Espresso where the error was added |
|
1171 | + * @param string $applies_when a version string for when you want the doing_it_wrong notice to begin appearing |
|
1172 | + * for a deprecated function. This allows deprecation to occur during one version, |
|
1173 | + * but not have any notices appear until a later version. This allows developers |
|
1174 | + * extra time to update their code before notices appear. |
|
1175 | + * @param int $error_type |
|
1176 | + */ |
|
1177 | + public static function doing_it_wrong( |
|
1178 | + $function, |
|
1179 | + $message, |
|
1180 | + $version, |
|
1181 | + $applies_when = '', |
|
1182 | + $error_type = null |
|
1183 | + ) { |
|
1184 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
1185 | + EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $applies_when, $error_type); |
|
1186 | + } |
|
1187 | + } |
|
1188 | + |
|
1189 | + |
|
1190 | + |
|
1191 | + /** |
|
1192 | + * Like get_notices, but returns an array of all the notices of the given type. |
|
1193 | + * |
|
1194 | + * @return array { |
|
1195 | + * @type array $success all the success messages |
|
1196 | + * @type array $errors all the error messages |
|
1197 | + * @type array $attention all the attention messages |
|
1198 | + * } |
|
1199 | + */ |
|
1200 | + public static function get_raw_notices() |
|
1201 | + { |
|
1202 | + return self::$_espresso_notices; |
|
1203 | + } |
|
1204 | 1204 | |
1205 | 1205 | |
1206 | 1206 | |
@@ -1216,27 +1216,27 @@ discard block |
||
1216 | 1216 | */ |
1217 | 1217 | function espresso_error_enqueue_scripts() |
1218 | 1218 | { |
1219 | - // js for error handling |
|
1220 | - wp_register_script( |
|
1221 | - 'espresso_core', |
|
1222 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
1223 | - array('jquery'), |
|
1224 | - EVENT_ESPRESSO_VERSION, |
|
1225 | - false |
|
1226 | - ); |
|
1227 | - wp_register_script( |
|
1228 | - 'ee_error_js', |
|
1229 | - EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', |
|
1230 | - array('espresso_core'), |
|
1231 | - EVENT_ESPRESSO_VERSION, |
|
1232 | - false |
|
1233 | - ); |
|
1219 | + // js for error handling |
|
1220 | + wp_register_script( |
|
1221 | + 'espresso_core', |
|
1222 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
1223 | + array('jquery'), |
|
1224 | + EVENT_ESPRESSO_VERSION, |
|
1225 | + false |
|
1226 | + ); |
|
1227 | + wp_register_script( |
|
1228 | + 'ee_error_js', |
|
1229 | + EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', |
|
1230 | + array('espresso_core'), |
|
1231 | + EVENT_ESPRESSO_VERSION, |
|
1232 | + false |
|
1233 | + ); |
|
1234 | 1234 | } |
1235 | 1235 | |
1236 | 1236 | if (is_admin()) { |
1237 | - add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2); |
|
1237 | + add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2); |
|
1238 | 1238 | } else { |
1239 | - add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2); |
|
1239 | + add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2); |
|
1240 | 1240 | } |
1241 | 1241 | |
1242 | 1242 |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @param array $query_params like EEM_Base::get_all |
207 | 207 | * @param string $field_to_sum |
208 | - * @return int |
|
208 | + * @return double |
|
209 | 209 | */ |
210 | 210 | public function sum_deleted($query_params = null, $field_to_sum = null) |
211 | 211 | { |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
271 | 271 | * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
272 | 272 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
273 | - * @return boolean success |
|
273 | + * @return integer success |
|
274 | 274 | */ |
275 | 275 | public function delete_permanently($query_params = array(), $allow_blocking = true) |
276 | 276 | { |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | require_once(EE_MODELS . 'EEM_Base.model.php'); |
5 | 5 | |
@@ -32,362 +32,362 @@ discard block |
||
32 | 32 | abstract class EEM_Soft_Delete_Base extends EEM_Base |
33 | 33 | { |
34 | 34 | |
35 | - /** |
|
36 | - * @param null $timezone |
|
37 | - */ |
|
38 | - protected function __construct($timezone = null) |
|
39 | - { |
|
40 | - if (! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
41 | - $this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions(); |
|
42 | - } |
|
43 | - parent::__construct($timezone); |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * Searches for field on this model of type 'deleted_flag'. if it is found, |
|
50 | - * returns it's name. |
|
51 | - * |
|
52 | - * @return string |
|
53 | - * @throws EE_Error |
|
54 | - */ |
|
55 | - public function deleted_field_name() |
|
56 | - { |
|
57 | - $field = $this->get_a_field_of_type('EE_Trashed_Flag_Field'); |
|
58 | - if ($field) { |
|
59 | - return $field->get_name(); |
|
60 | - } else { |
|
61 | - throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', |
|
62 | - 'event_espresso'), get_class($this), get_class($this))); |
|
63 | - } |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * Gets one item that's been deleted, according to $query_params |
|
70 | - * |
|
71 | - * @param array $query_params like EEM_Base::get_all's $query_params |
|
72 | - * @return EE_Soft_Delete_Base_Class |
|
73 | - */ |
|
74 | - public function get_one_deleted($query_params = array()) |
|
75 | - { |
|
76 | - $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
77 | - return parent::get_one($query_params); |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * Gets one item from the DB, regardless of whether it's been soft-deleted or not |
|
84 | - * |
|
85 | - * @param array $query_params like EEM_base::get_all's $query_params |
|
86 | - * @return EE_Soft_Delete_Base_Class |
|
87 | - */ |
|
88 | - public function get_one_deleted_or_undeleted($query_params = array()) |
|
89 | - { |
|
90 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
91 | - return parent::get_one($query_params); |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * Gets the item indicated by its ID. But if it's soft-deleted, pretends it doesn't exist. |
|
98 | - * |
|
99 | - * @param int|string $id |
|
100 | - * @return EE_Soft_Delete_Base_Class |
|
101 | - */ |
|
102 | - public function get_one_by_ID_but_ignore_deleted($id) |
|
103 | - { |
|
104 | - return $this->get_one( |
|
105 | - $this->alter_query_params_to_restrict_by_ID( |
|
106 | - $id, |
|
107 | - array('default_where_conditions' => 'default') |
|
108 | - ) |
|
109 | - ); |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * Counts all the deleted/trashed items |
|
116 | - * |
|
117 | - * @param array $query_params like EEM_Base::get_all |
|
118 | - * @param string $field_to_count |
|
119 | - * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
|
120 | - * @return int |
|
121 | - */ |
|
122 | - public function count_deleted($query_params = null, $field_to_count = null, $distinct = false) |
|
123 | - { |
|
124 | - $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
125 | - return parent::count($query_params, $field_to_count, $distinct); |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * Alters the query params so that only trashed/soft-deleted items are considered |
|
132 | - * |
|
133 | - * @param array $query_params like EEM_Base::get_all's $query_params |
|
134 | - * @return array like EEM_Base::get_all's $query_params |
|
135 | - */ |
|
136 | - protected function _alter_query_params_so_only_trashed_items_included($query_params) |
|
137 | - { |
|
138 | - $deletedFlagFieldName = $this->deleted_field_name(); |
|
139 | - $query_params[0][$deletedFlagFieldName] = true; |
|
140 | - return $query_params; |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - |
|
145 | - /** |
|
146 | - * Alters the query params so that only trashed/soft-deleted items are considered |
|
147 | - * |
|
148 | - * @param array $query_params like EEM_Base::get_all's $query_params |
|
149 | - * @return array like EEM_Base::get_all's $query_params |
|
150 | - */ |
|
151 | - public function alter_query_params_so_only_trashed_items_included($query_params) |
|
152 | - { |
|
153 | - return $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
154 | - } |
|
155 | - |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * Alters the query params so each item's deleted status is ignored. |
|
160 | - * |
|
161 | - * @param array $query_params |
|
162 | - * @return array |
|
163 | - */ |
|
164 | - public function alter_query_params_so_deleted_and_undeleted_items_included($query_params = array()) |
|
165 | - { |
|
166 | - return $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * Alters the query params so each item's deleted status is ignored. |
|
173 | - * |
|
174 | - * @param array $query_params |
|
175 | - * @return array |
|
176 | - */ |
|
177 | - protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) |
|
178 | - { |
|
179 | - if (! isset($query_params['default_where_conditions'])) { |
|
180 | - $query_params['default_where_conditions'] = 'minimum'; |
|
181 | - } |
|
182 | - return $query_params; |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - |
|
187 | - /** |
|
188 | - * Counts all deleted and undeleted items |
|
189 | - * |
|
190 | - * @param array $query_params like EEM_Base::get_all |
|
191 | - * @param string $field_to_count |
|
192 | - * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
|
193 | - * @return int |
|
194 | - */ |
|
195 | - public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = false) |
|
196 | - { |
|
197 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
198 | - return parent::count($query_params, $field_to_count, $distinct); |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - |
|
203 | - /** |
|
204 | - * Sum all the deleted items. |
|
205 | - * |
|
206 | - * @param array $query_params like EEM_Base::get_all |
|
207 | - * @param string $field_to_sum |
|
208 | - * @return int |
|
209 | - */ |
|
210 | - public function sum_deleted($query_params = null, $field_to_sum = null) |
|
211 | - { |
|
212 | - $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
213 | - return parent::sum($query_params, $field_to_sum); |
|
214 | - } |
|
215 | - |
|
216 | - |
|
217 | - |
|
218 | - /** |
|
219 | - * Sums all the deleted and undeleted items. |
|
220 | - * |
|
221 | - * @param array $query_params lik eEEM_Base::get_all |
|
222 | - * @param string $field_to_sum |
|
223 | - * @return int |
|
224 | - */ |
|
225 | - public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null) |
|
226 | - { |
|
227 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
228 | - parent::sum($query_params, $field_to_sum); |
|
229 | - } |
|
230 | - |
|
231 | - |
|
232 | - |
|
233 | - /** |
|
234 | - * Gets all deleted and undeleted mode objects from the db that meet the criteria, regardless of |
|
235 | - * whether they've been soft-deleted or not |
|
236 | - * |
|
237 | - * @param array $query_params like EEM_Base::get_all |
|
238 | - * @return EE_Soft_Delete_Base_Class[] |
|
239 | - */ |
|
240 | - public function get_all_deleted_and_undeleted($query_params = array()) |
|
241 | - { |
|
242 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
243 | - return parent::get_all($query_params); |
|
244 | - } |
|
245 | - |
|
246 | - |
|
247 | - |
|
248 | - /** |
|
249 | - * For 'soft deletable' models, gets all which ARE deleted, according to conditions specified in $query_params. |
|
250 | - * |
|
251 | - * @param array $query_params like EEM_Base::get_all |
|
252 | - * @return EE_Soft_Delete_Base_Class[] |
|
253 | - */ |
|
254 | - public function get_all_deleted($query_params = array()) |
|
255 | - { |
|
256 | - $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
257 | - return parent::get_all($query_params); |
|
258 | - } |
|
259 | - |
|
260 | - |
|
261 | - |
|
262 | - /** |
|
263 | - * Permanently deletes the selected rows. When selecting rows for deletion, ignores |
|
264 | - * whether they've been soft-deleted or not. (ie, you don't have to soft-delete objects |
|
265 | - * before you can permanently delete them). |
|
266 | - * Because this will cause a real deletion, related models may block this deletion (ie, add an error |
|
267 | - * and abort the delete) |
|
268 | - * |
|
269 | - * @param array $query_params like EEM_Base::get_all |
|
270 | - * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
|
271 | - * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
|
272 | - * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
|
273 | - * @return boolean success |
|
274 | - */ |
|
275 | - public function delete_permanently($query_params = array(), $allow_blocking = true) |
|
276 | - { |
|
277 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
278 | - return parent::delete_permanently($query_params, $allow_blocking); |
|
279 | - } |
|
280 | - |
|
281 | - |
|
282 | - |
|
283 | - /** |
|
284 | - * Restores a particular item by its ID (primary key). Ignores the fact whether the item |
|
285 | - * has been soft-deleted or not. |
|
286 | - * |
|
287 | - * @param mixed $ID int if primary key is an int, string otherwise |
|
288 | - * @return boolean success |
|
289 | - */ |
|
290 | - public function restore_by_ID($ID = false) |
|
291 | - { |
|
292 | - return $this->delete_or_restore_by_ID(false, $ID); |
|
293 | - } |
|
294 | - |
|
295 | - |
|
296 | - |
|
297 | - /** |
|
298 | - * For deleting or restoring a particular item. Note that this model is a SOFT-DELETABLE model! However, |
|
299 | - * this function will ignore whether the items have been soft-deleted or not. |
|
300 | - * |
|
301 | - * @param boolean $delete true for delete, false for restore |
|
302 | - * @param mixed $ID int if primary key is an int, string otherwise |
|
303 | - * @return boolean |
|
304 | - */ |
|
305 | - public function delete_or_restore_by_ID($delete = true, $ID = false) |
|
306 | - { |
|
307 | - if (! $ID) { |
|
308 | - return false; |
|
309 | - } |
|
310 | - if ( |
|
311 | - $this->delete_or_restore( |
|
312 | - $delete, |
|
313 | - $this->alter_query_params_to_restrict_by_ID($ID) |
|
314 | - ) |
|
315 | - ) { |
|
316 | - return true; |
|
317 | - } else { |
|
318 | - return false; |
|
319 | - } |
|
320 | - } |
|
321 | - |
|
322 | - |
|
323 | - |
|
324 | - /** |
|
325 | - * Overrides parent's 'delete' method to instead do a soft delete on all rows that |
|
326 | - * meet the criteria in $where_col_n_values. This particular function ignores whether the items have been soft-deleted or not. |
|
327 | - * Note: because this item will be soft-deleted only, |
|
328 | - * doesn't block because of model dependencies |
|
329 | - * |
|
330 | - * @param array $query_params like EEM_Base::get_all |
|
331 | - * @param bool $block_deletes |
|
332 | - * @return boolean |
|
333 | - */ |
|
334 | - public function delete($query_params = array(), $block_deletes = false) |
|
335 | - { |
|
336 | - //no matter what, we WON'T block soft deletes. |
|
337 | - return $this->delete_or_restore(true, $query_params); |
|
338 | - } |
|
339 | - |
|
340 | - |
|
341 | - |
|
342 | - /** |
|
343 | - * 'Un-deletes' the chosen items. Note that this model is a SOFT-DELETABLE model! That means that, by default, trashed/soft-deleted |
|
344 | - * items are ignored in queries. However, this particular function ignores whether the items have been soft-deleted or not. |
|
345 | - * |
|
346 | - * @param array $query_params like EEM_Base::get_all |
|
347 | - * @return boolean |
|
348 | - */ |
|
349 | - public function restore($query_params = array()) |
|
350 | - { |
|
351 | - return $this->delete_or_restore(false, $query_params); |
|
352 | - } |
|
353 | - |
|
354 | - |
|
355 | - |
|
356 | - /** |
|
357 | - * Performs deletes or restores on items. Both soft-deleted and non-soft-deleted items considered. |
|
358 | - * |
|
359 | - * @param boolean $delete true to indicate deletion, false to indicate restoration |
|
360 | - * @param array $query_params like EEM_Base::get_all |
|
361 | - * @return boolean |
|
362 | - */ |
|
363 | - function delete_or_restore($delete = true, $query_params = array()) |
|
364 | - { |
|
365 | - $deletedFlagFieldName = $this->deleted_field_name(); |
|
366 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
367 | - if ($this->update(array($deletedFlagFieldName => $delete), $query_params)) { |
|
368 | - return true; |
|
369 | - } else { |
|
370 | - return false; |
|
371 | - } |
|
372 | - } |
|
373 | - |
|
374 | - |
|
375 | - |
|
376 | - /** |
|
377 | - * Updates all the items of this model which match the $query params, regardless of whether |
|
378 | - * they've been soft-deleted or not |
|
379 | - * |
|
380 | - * @param array $fields_n_values like EEM_Base::update's $fields_n_value |
|
381 | - * @param array $query_params like EEM_base::get_all's $query_params |
|
382 | - * @param boolean $keep_model_objs_in_sync if TRUE, makes sure we ALSO update model objects |
|
383 | - * in this model's entity map according to $fields_n_values that match $query_params. This |
|
384 | - * obviously has some overhead, so you can disable it by setting this to FALSE, but |
|
385 | - * be aware that model objects being used could get out-of-sync with the database |
|
386 | - * @return int number of items updated |
|
387 | - */ |
|
388 | - public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = true) |
|
389 | - { |
|
390 | - $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
391 | - return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
392 | - } |
|
35 | + /** |
|
36 | + * @param null $timezone |
|
37 | + */ |
|
38 | + protected function __construct($timezone = null) |
|
39 | + { |
|
40 | + if (! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
41 | + $this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions(); |
|
42 | + } |
|
43 | + parent::__construct($timezone); |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * Searches for field on this model of type 'deleted_flag'. if it is found, |
|
50 | + * returns it's name. |
|
51 | + * |
|
52 | + * @return string |
|
53 | + * @throws EE_Error |
|
54 | + */ |
|
55 | + public function deleted_field_name() |
|
56 | + { |
|
57 | + $field = $this->get_a_field_of_type('EE_Trashed_Flag_Field'); |
|
58 | + if ($field) { |
|
59 | + return $field->get_name(); |
|
60 | + } else { |
|
61 | + throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', |
|
62 | + 'event_espresso'), get_class($this), get_class($this))); |
|
63 | + } |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * Gets one item that's been deleted, according to $query_params |
|
70 | + * |
|
71 | + * @param array $query_params like EEM_Base::get_all's $query_params |
|
72 | + * @return EE_Soft_Delete_Base_Class |
|
73 | + */ |
|
74 | + public function get_one_deleted($query_params = array()) |
|
75 | + { |
|
76 | + $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
77 | + return parent::get_one($query_params); |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * Gets one item from the DB, regardless of whether it's been soft-deleted or not |
|
84 | + * |
|
85 | + * @param array $query_params like EEM_base::get_all's $query_params |
|
86 | + * @return EE_Soft_Delete_Base_Class |
|
87 | + */ |
|
88 | + public function get_one_deleted_or_undeleted($query_params = array()) |
|
89 | + { |
|
90 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
91 | + return parent::get_one($query_params); |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * Gets the item indicated by its ID. But if it's soft-deleted, pretends it doesn't exist. |
|
98 | + * |
|
99 | + * @param int|string $id |
|
100 | + * @return EE_Soft_Delete_Base_Class |
|
101 | + */ |
|
102 | + public function get_one_by_ID_but_ignore_deleted($id) |
|
103 | + { |
|
104 | + return $this->get_one( |
|
105 | + $this->alter_query_params_to_restrict_by_ID( |
|
106 | + $id, |
|
107 | + array('default_where_conditions' => 'default') |
|
108 | + ) |
|
109 | + ); |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * Counts all the deleted/trashed items |
|
116 | + * |
|
117 | + * @param array $query_params like EEM_Base::get_all |
|
118 | + * @param string $field_to_count |
|
119 | + * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
|
120 | + * @return int |
|
121 | + */ |
|
122 | + public function count_deleted($query_params = null, $field_to_count = null, $distinct = false) |
|
123 | + { |
|
124 | + $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
125 | + return parent::count($query_params, $field_to_count, $distinct); |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * Alters the query params so that only trashed/soft-deleted items are considered |
|
132 | + * |
|
133 | + * @param array $query_params like EEM_Base::get_all's $query_params |
|
134 | + * @return array like EEM_Base::get_all's $query_params |
|
135 | + */ |
|
136 | + protected function _alter_query_params_so_only_trashed_items_included($query_params) |
|
137 | + { |
|
138 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
139 | + $query_params[0][$deletedFlagFieldName] = true; |
|
140 | + return $query_params; |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + |
|
145 | + /** |
|
146 | + * Alters the query params so that only trashed/soft-deleted items are considered |
|
147 | + * |
|
148 | + * @param array $query_params like EEM_Base::get_all's $query_params |
|
149 | + * @return array like EEM_Base::get_all's $query_params |
|
150 | + */ |
|
151 | + public function alter_query_params_so_only_trashed_items_included($query_params) |
|
152 | + { |
|
153 | + return $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
154 | + } |
|
155 | + |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * Alters the query params so each item's deleted status is ignored. |
|
160 | + * |
|
161 | + * @param array $query_params |
|
162 | + * @return array |
|
163 | + */ |
|
164 | + public function alter_query_params_so_deleted_and_undeleted_items_included($query_params = array()) |
|
165 | + { |
|
166 | + return $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * Alters the query params so each item's deleted status is ignored. |
|
173 | + * |
|
174 | + * @param array $query_params |
|
175 | + * @return array |
|
176 | + */ |
|
177 | + protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) |
|
178 | + { |
|
179 | + if (! isset($query_params['default_where_conditions'])) { |
|
180 | + $query_params['default_where_conditions'] = 'minimum'; |
|
181 | + } |
|
182 | + return $query_params; |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + |
|
187 | + /** |
|
188 | + * Counts all deleted and undeleted items |
|
189 | + * |
|
190 | + * @param array $query_params like EEM_Base::get_all |
|
191 | + * @param string $field_to_count |
|
192 | + * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
|
193 | + * @return int |
|
194 | + */ |
|
195 | + public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = false) |
|
196 | + { |
|
197 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
198 | + return parent::count($query_params, $field_to_count, $distinct); |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + |
|
203 | + /** |
|
204 | + * Sum all the deleted items. |
|
205 | + * |
|
206 | + * @param array $query_params like EEM_Base::get_all |
|
207 | + * @param string $field_to_sum |
|
208 | + * @return int |
|
209 | + */ |
|
210 | + public function sum_deleted($query_params = null, $field_to_sum = null) |
|
211 | + { |
|
212 | + $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
213 | + return parent::sum($query_params, $field_to_sum); |
|
214 | + } |
|
215 | + |
|
216 | + |
|
217 | + |
|
218 | + /** |
|
219 | + * Sums all the deleted and undeleted items. |
|
220 | + * |
|
221 | + * @param array $query_params lik eEEM_Base::get_all |
|
222 | + * @param string $field_to_sum |
|
223 | + * @return int |
|
224 | + */ |
|
225 | + public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null) |
|
226 | + { |
|
227 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
228 | + parent::sum($query_params, $field_to_sum); |
|
229 | + } |
|
230 | + |
|
231 | + |
|
232 | + |
|
233 | + /** |
|
234 | + * Gets all deleted and undeleted mode objects from the db that meet the criteria, regardless of |
|
235 | + * whether they've been soft-deleted or not |
|
236 | + * |
|
237 | + * @param array $query_params like EEM_Base::get_all |
|
238 | + * @return EE_Soft_Delete_Base_Class[] |
|
239 | + */ |
|
240 | + public function get_all_deleted_and_undeleted($query_params = array()) |
|
241 | + { |
|
242 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
243 | + return parent::get_all($query_params); |
|
244 | + } |
|
245 | + |
|
246 | + |
|
247 | + |
|
248 | + /** |
|
249 | + * For 'soft deletable' models, gets all which ARE deleted, according to conditions specified in $query_params. |
|
250 | + * |
|
251 | + * @param array $query_params like EEM_Base::get_all |
|
252 | + * @return EE_Soft_Delete_Base_Class[] |
|
253 | + */ |
|
254 | + public function get_all_deleted($query_params = array()) |
|
255 | + { |
|
256 | + $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
|
257 | + return parent::get_all($query_params); |
|
258 | + } |
|
259 | + |
|
260 | + |
|
261 | + |
|
262 | + /** |
|
263 | + * Permanently deletes the selected rows. When selecting rows for deletion, ignores |
|
264 | + * whether they've been soft-deleted or not. (ie, you don't have to soft-delete objects |
|
265 | + * before you can permanently delete them). |
|
266 | + * Because this will cause a real deletion, related models may block this deletion (ie, add an error |
|
267 | + * and abort the delete) |
|
268 | + * |
|
269 | + * @param array $query_params like EEM_Base::get_all |
|
270 | + * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
|
271 | + * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
|
272 | + * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
|
273 | + * @return boolean success |
|
274 | + */ |
|
275 | + public function delete_permanently($query_params = array(), $allow_blocking = true) |
|
276 | + { |
|
277 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
278 | + return parent::delete_permanently($query_params, $allow_blocking); |
|
279 | + } |
|
280 | + |
|
281 | + |
|
282 | + |
|
283 | + /** |
|
284 | + * Restores a particular item by its ID (primary key). Ignores the fact whether the item |
|
285 | + * has been soft-deleted or not. |
|
286 | + * |
|
287 | + * @param mixed $ID int if primary key is an int, string otherwise |
|
288 | + * @return boolean success |
|
289 | + */ |
|
290 | + public function restore_by_ID($ID = false) |
|
291 | + { |
|
292 | + return $this->delete_or_restore_by_ID(false, $ID); |
|
293 | + } |
|
294 | + |
|
295 | + |
|
296 | + |
|
297 | + /** |
|
298 | + * For deleting or restoring a particular item. Note that this model is a SOFT-DELETABLE model! However, |
|
299 | + * this function will ignore whether the items have been soft-deleted or not. |
|
300 | + * |
|
301 | + * @param boolean $delete true for delete, false for restore |
|
302 | + * @param mixed $ID int if primary key is an int, string otherwise |
|
303 | + * @return boolean |
|
304 | + */ |
|
305 | + public function delete_or_restore_by_ID($delete = true, $ID = false) |
|
306 | + { |
|
307 | + if (! $ID) { |
|
308 | + return false; |
|
309 | + } |
|
310 | + if ( |
|
311 | + $this->delete_or_restore( |
|
312 | + $delete, |
|
313 | + $this->alter_query_params_to_restrict_by_ID($ID) |
|
314 | + ) |
|
315 | + ) { |
|
316 | + return true; |
|
317 | + } else { |
|
318 | + return false; |
|
319 | + } |
|
320 | + } |
|
321 | + |
|
322 | + |
|
323 | + |
|
324 | + /** |
|
325 | + * Overrides parent's 'delete' method to instead do a soft delete on all rows that |
|
326 | + * meet the criteria in $where_col_n_values. This particular function ignores whether the items have been soft-deleted or not. |
|
327 | + * Note: because this item will be soft-deleted only, |
|
328 | + * doesn't block because of model dependencies |
|
329 | + * |
|
330 | + * @param array $query_params like EEM_Base::get_all |
|
331 | + * @param bool $block_deletes |
|
332 | + * @return boolean |
|
333 | + */ |
|
334 | + public function delete($query_params = array(), $block_deletes = false) |
|
335 | + { |
|
336 | + //no matter what, we WON'T block soft deletes. |
|
337 | + return $this->delete_or_restore(true, $query_params); |
|
338 | + } |
|
339 | + |
|
340 | + |
|
341 | + |
|
342 | + /** |
|
343 | + * 'Un-deletes' the chosen items. Note that this model is a SOFT-DELETABLE model! That means that, by default, trashed/soft-deleted |
|
344 | + * items are ignored in queries. However, this particular function ignores whether the items have been soft-deleted or not. |
|
345 | + * |
|
346 | + * @param array $query_params like EEM_Base::get_all |
|
347 | + * @return boolean |
|
348 | + */ |
|
349 | + public function restore($query_params = array()) |
|
350 | + { |
|
351 | + return $this->delete_or_restore(false, $query_params); |
|
352 | + } |
|
353 | + |
|
354 | + |
|
355 | + |
|
356 | + /** |
|
357 | + * Performs deletes or restores on items. Both soft-deleted and non-soft-deleted items considered. |
|
358 | + * |
|
359 | + * @param boolean $delete true to indicate deletion, false to indicate restoration |
|
360 | + * @param array $query_params like EEM_Base::get_all |
|
361 | + * @return boolean |
|
362 | + */ |
|
363 | + function delete_or_restore($delete = true, $query_params = array()) |
|
364 | + { |
|
365 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
366 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
367 | + if ($this->update(array($deletedFlagFieldName => $delete), $query_params)) { |
|
368 | + return true; |
|
369 | + } else { |
|
370 | + return false; |
|
371 | + } |
|
372 | + } |
|
373 | + |
|
374 | + |
|
375 | + |
|
376 | + /** |
|
377 | + * Updates all the items of this model which match the $query params, regardless of whether |
|
378 | + * they've been soft-deleted or not |
|
379 | + * |
|
380 | + * @param array $fields_n_values like EEM_Base::update's $fields_n_value |
|
381 | + * @param array $query_params like EEM_base::get_all's $query_params |
|
382 | + * @param boolean $keep_model_objs_in_sync if TRUE, makes sure we ALSO update model objects |
|
383 | + * in this model's entity map according to $fields_n_values that match $query_params. This |
|
384 | + * obviously has some overhead, so you can disable it by setting this to FALSE, but |
|
385 | + * be aware that model objects being used could get out-of-sync with the database |
|
386 | + * @return int number of items updated |
|
387 | + */ |
|
388 | + public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = true) |
|
389 | + { |
|
390 | + $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
|
391 | + return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
392 | + } |
|
393 | 393 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | -require_once(EE_MODELS . 'EEM_Base.model.php'); |
|
4 | +require_once(EE_MODELS.'EEM_Base.model.php'); |
|
5 | 5 | |
6 | 6 | |
7 | 7 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | protected function __construct($timezone = null) |
39 | 39 | { |
40 | - if (! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
40 | + if ( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
41 | 41 | $this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions(); |
42 | 42 | } |
43 | 43 | parent::__construct($timezone); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | */ |
177 | 177 | protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) |
178 | 178 | { |
179 | - if (! isset($query_params['default_where_conditions'])) { |
|
179 | + if ( ! isset($query_params['default_where_conditions'])) { |
|
180 | 180 | $query_params['default_where_conditions'] = 'minimum'; |
181 | 181 | } |
182 | 182 | return $query_params; |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | */ |
305 | 305 | public function delete_or_restore_by_ID($delete = true, $ID = false) |
306 | 306 | { |
307 | - if (! $ID) { |
|
307 | + if ( ! $ID) { |
|
308 | 308 | return false; |
309 | 309 | } |
310 | 310 | if ( |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -26,55 +26,55 @@ discard block |
||
26 | 26 | { |
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * Overrides parent _delete() so that we do soft deletes. |
|
31 | - * |
|
32 | - * @return bool|int |
|
33 | - */ |
|
34 | - protected function _delete() |
|
35 | - { |
|
36 | - return $this->delete_or_restore(); |
|
37 | - } |
|
29 | + /** |
|
30 | + * Overrides parent _delete() so that we do soft deletes. |
|
31 | + * |
|
32 | + * @return bool|int |
|
33 | + */ |
|
34 | + protected function _delete() |
|
35 | + { |
|
36 | + return $this->delete_or_restore(); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * Deletes or restores this object. |
|
43 | - * |
|
44 | - * @param bool $delete true=>delete, false=>restore |
|
45 | - * @return bool|int |
|
46 | - */ |
|
47 | - public function delete_or_restore($delete = true) |
|
48 | - { |
|
49 | - /** |
|
50 | - * Called just before trashing (soft delete) or restoring a trashed item. |
|
51 | - * |
|
52 | - * @param EE_Base_Class $model_object about to be trashed or restored |
|
53 | - * @param bool $delete true the item is being trashed, false the item is being restored. |
|
54 | - */ |
|
55 | - do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__before', $this, $delete); |
|
56 | - $model = $this->get_model(); |
|
57 | - $result = $model->delete_or_restore_by_ID($delete, $this->ID()); |
|
58 | - /** |
|
59 | - * Called just after trashing (soft delete) or restoring a trashed item. |
|
60 | - * |
|
61 | - * @param EE_Base_Class $model_object that was just trashed or restored. |
|
62 | - * @param bool $delete true the item is being trashed, false the item is being restored. |
|
63 | - * @param bool|int $result |
|
64 | - */ |
|
65 | - do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__after', $this, $delete, $result); |
|
66 | - return $result; |
|
67 | - } |
|
41 | + /** |
|
42 | + * Deletes or restores this object. |
|
43 | + * |
|
44 | + * @param bool $delete true=>delete, false=>restore |
|
45 | + * @return bool|int |
|
46 | + */ |
|
47 | + public function delete_or_restore($delete = true) |
|
48 | + { |
|
49 | + /** |
|
50 | + * Called just before trashing (soft delete) or restoring a trashed item. |
|
51 | + * |
|
52 | + * @param EE_Base_Class $model_object about to be trashed or restored |
|
53 | + * @param bool $delete true the item is being trashed, false the item is being restored. |
|
54 | + */ |
|
55 | + do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__before', $this, $delete); |
|
56 | + $model = $this->get_model(); |
|
57 | + $result = $model->delete_or_restore_by_ID($delete, $this->ID()); |
|
58 | + /** |
|
59 | + * Called just after trashing (soft delete) or restoring a trashed item. |
|
60 | + * |
|
61 | + * @param EE_Base_Class $model_object that was just trashed or restored. |
|
62 | + * @param bool $delete true the item is being trashed, false the item is being restored. |
|
63 | + * @param bool|int $result |
|
64 | + */ |
|
65 | + do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__after', $this, $delete, $result); |
|
66 | + return $result; |
|
67 | + } |
|
68 | 68 | |
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * Performs a restoration (un-deletes) this object |
|
73 | - * |
|
74 | - * @return bool|int |
|
75 | - */ |
|
76 | - public function restore() |
|
77 | - { |
|
78 | - return $this->delete_or_restore(false); |
|
79 | - } |
|
71 | + /** |
|
72 | + * Performs a restoration (un-deletes) this object |
|
73 | + * |
|
74 | + * @return bool|int |
|
75 | + */ |
|
76 | + public function restore() |
|
77 | + { |
|
78 | + return $this->delete_or_restore(false); |
|
79 | + } |
|
80 | 80 | } |
81 | 81 | \ No newline at end of file |
@@ -1,4 +1,4 @@ |
||
1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | 4 | /** |
@@ -14,12 +14,12 @@ discard block |
||
14 | 14 | * @param int | \EE_Event $event |
15 | 15 | * @return bool |
16 | 16 | */ |
17 | -function is_espresso_event( $event = NULL ) { |
|
18 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
17 | +function is_espresso_event($event = NULL) { |
|
18 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
19 | 19 | // extract EE_Event object from passed param regardless of what it is (within reason of course) |
20 | - $event = EEH_Event_View::get_event( $event ); |
|
20 | + $event = EEH_Event_View::get_event($event); |
|
21 | 21 | // do we have a valid event ? |
22 | - return $event instanceof EE_Event ? TRUE : FALSE; |
|
22 | + return $event instanceof EE_Event ? TRUE : FALSE; |
|
23 | 23 | } |
24 | 24 | return FALSE; |
25 | 25 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @return bool |
32 | 32 | */ |
33 | 33 | function is_espresso_event_single() { |
34 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
34 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
35 | 35 | global $wp_query; |
36 | 36 | // return conditionals set by CPTs |
37 | 37 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_single : FALSE; |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @return bool |
47 | 47 | */ |
48 | 48 | function is_espresso_event_archive() { |
49 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
49 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
50 | 50 | global $wp_query; |
51 | 51 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_archive : FALSE; |
52 | 52 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @return bool |
61 | 61 | */ |
62 | 62 | function is_espresso_event_taxonomy() { |
63 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
63 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
64 | 64 | global $wp_query; |
65 | 65 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_taxonomy : FALSE; |
66 | 66 | } |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | * @param int | \EE_Venue $venue |
75 | 75 | * @return bool |
76 | 76 | */ |
77 | -function is_espresso_venue( $venue = NULL ) { |
|
78 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
77 | +function is_espresso_venue($venue = NULL) { |
|
78 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
79 | 79 | // extract EE_Venue object from passed param regardless of what it is (within reason of course) |
80 | - $venue = EEH_Venue_View::get_venue( $venue, FALSE ); |
|
80 | + $venue = EEH_Venue_View::get_venue($venue, FALSE); |
|
81 | 81 | // do we have a valid event ? |
82 | 82 | return $venue instanceof EE_Venue ? TRUE : FALSE; |
83 | 83 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @return bool |
92 | 92 | */ |
93 | 93 | function is_espresso_venue_single() { |
94 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
94 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
95 | 95 | global $wp_query; |
96 | 96 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_single : FALSE; |
97 | 97 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @return bool |
106 | 106 | */ |
107 | 107 | function is_espresso_venue_archive() { |
108 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
108 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
109 | 109 | global $wp_query; |
110 | 110 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_archive : FALSE; |
111 | 111 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @return bool |
120 | 120 | */ |
121 | 121 | function is_espresso_venue_taxonomy() { |
122 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
122 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
123 | 123 | global $wp_query; |
124 | 124 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_taxonomy : FALSE; |
125 | 125 | } |
@@ -133,12 +133,12 @@ discard block |
||
133 | 133 | * @param $conditional_tag |
134 | 134 | * @return bool |
135 | 135 | */ |
136 | -function can_use_espresso_conditionals( $conditional_tag ) { |
|
137 | - if ( ! did_action( 'AHEE__EE_System__initialize' )) { |
|
136 | +function can_use_espresso_conditionals($conditional_tag) { |
|
137 | + if ( ! did_action('AHEE__EE_System__initialize')) { |
|
138 | 138 | EE_Error::doing_it_wrong( |
139 | 139 | __FUNCTION__, |
140 | 140 | sprintf( |
141 | - __( '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.','event_espresso'), |
|
141 | + __('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.', 'event_espresso'), |
|
142 | 142 | $conditional_tag |
143 | 143 | ), |
144 | 144 | '4.4.0' |
@@ -153,13 +153,13 @@ discard block |
||
153 | 153 | |
154 | 154 | /*************************** Event Queries ***************************/ |
155 | 155 | |
156 | -if ( ! function_exists( 'espresso_get_events' )) { |
|
156 | +if ( ! function_exists('espresso_get_events')) { |
|
157 | 157 | /** |
158 | 158 | * espresso_get_events |
159 | 159 | * @param array $params |
160 | 160 | * @return array |
161 | 161 | */ |
162 | - function espresso_get_events( $params = array() ) { |
|
162 | + function espresso_get_events($params = array()) { |
|
163 | 163 | //set default params |
164 | 164 | $default_espresso_events_params = array( |
165 | 165 | 'limit' => 10, |
@@ -170,18 +170,18 @@ discard block |
||
170 | 170 | 'sort' => 'ASC' |
171 | 171 | ); |
172 | 172 | // allow the defaults to be filtered |
173 | - $default_espresso_events_params = apply_filters( 'espresso_get_events__default_espresso_events_params', $default_espresso_events_params ); |
|
173 | + $default_espresso_events_params = apply_filters('espresso_get_events__default_espresso_events_params', $default_espresso_events_params); |
|
174 | 174 | // grab params and merge with defaults, then extract |
175 | - $params = array_merge( $default_espresso_events_params, $params ); |
|
175 | + $params = array_merge($default_espresso_events_params, $params); |
|
176 | 176 | // run the query |
177 | - $events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery( $params ); |
|
177 | + $events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery($params); |
|
178 | 178 | // assign results to a variable so we can return it |
179 | 179 | $events = $events_query->have_posts() ? $events_query->posts : array(); |
180 | 180 | // but first reset the query and postdata |
181 | 181 | wp_reset_query(); |
182 | 182 | wp_reset_postdata(); |
183 | 183 | EED_Events_Archive::remove_all_events_archive_filters(); |
184 | - unset( $events_query ); |
|
184 | + unset($events_query); |
|
185 | 185 | return $events; |
186 | 186 | } |
187 | 187 | } |
@@ -195,32 +195,32 @@ discard block |
||
195 | 195 | * espresso_load_ticket_selector |
196 | 196 | */ |
197 | 197 | function espresso_load_ticket_selector() { |
198 | - EE_Registry::instance()->load_file( EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module' ); |
|
198 | + EE_Registry::instance()->load_file(EE_MODULES.'ticket_selector', 'EED_Ticket_Selector', 'module'); |
|
199 | 199 | } |
200 | 200 | |
201 | -if ( ! function_exists( 'espresso_ticket_selector' )) { |
|
201 | +if ( ! function_exists('espresso_ticket_selector')) { |
|
202 | 202 | /** |
203 | 203 | * espresso_ticket_selector |
204 | 204 | * @param null $event |
205 | 205 | */ |
206 | - function espresso_ticket_selector( $event = NULL ) { |
|
207 | - if ( ! apply_filters( 'FHEE_disable_espresso_ticket_selector', FALSE ) ) { |
|
206 | + function espresso_ticket_selector($event = NULL) { |
|
207 | + if ( ! apply_filters('FHEE_disable_espresso_ticket_selector', FALSE)) { |
|
208 | 208 | espresso_load_ticket_selector(); |
209 | - echo EED_Ticket_Selector::display_ticket_selector( $event ); |
|
209 | + echo EED_Ticket_Selector::display_ticket_selector($event); |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | } |
213 | 213 | |
214 | 214 | |
215 | - if ( ! function_exists( 'espresso_view_details_btn' )) { |
|
215 | + if ( ! function_exists('espresso_view_details_btn')) { |
|
216 | 216 | /** |
217 | 217 | * espresso_view_details_btn |
218 | 218 | * @param null $event |
219 | 219 | */ |
220 | - function espresso_view_details_btn( $event = NULL ) { |
|
221 | - if ( ! apply_filters( 'FHEE_disable_espresso_view_details_btn', FALSE ) ) { |
|
220 | + function espresso_view_details_btn($event = NULL) { |
|
221 | + if ( ! apply_filters('FHEE_disable_espresso_view_details_btn', FALSE)) { |
|
222 | 222 | espresso_load_ticket_selector(); |
223 | - echo EED_Ticket_Selector::display_ticket_selector( $event, TRUE ); |
|
223 | + echo EED_Ticket_Selector::display_ticket_selector($event, TRUE); |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | |
231 | 231 | /*************************** EEH_Event_View ***************************/ |
232 | 232 | |
233 | -if ( ! function_exists( 'espresso_load_event_list_assets' )) { |
|
233 | +if ( ! function_exists('espresso_load_event_list_assets')) { |
|
234 | 234 | /** |
235 | 235 | * espresso_load_event_list_assets |
236 | 236 | * ensures that event list styles and scripts are loaded |
@@ -239,13 +239,13 @@ discard block |
||
239 | 239 | */ |
240 | 240 | function espresso_load_event_list_assets() { |
241 | 241 | $event_list = EED_Events_Archive::instance(); |
242 | - add_action( 'AHEE__EE_System__initialize_last', array( $event_list, 'load_event_list_assets' ), 10 ); |
|
243 | - add_filter( 'FHEE_enable_default_espresso_css', '__return_true' ); |
|
242 | + add_action('AHEE__EE_System__initialize_last', array($event_list, 'load_event_list_assets'), 10); |
|
243 | + add_filter('FHEE_enable_default_espresso_css', '__return_true'); |
|
244 | 244 | } |
245 | 245 | } |
246 | 246 | |
247 | 247 | |
248 | -if ( ! function_exists( 'espresso_event_reg_button' )) { |
|
248 | +if ( ! function_exists('espresso_event_reg_button')) { |
|
249 | 249 | /** |
250 | 250 | * espresso_event_reg_button |
251 | 251 | * returns the "Register Now" button if event is active, |
@@ -257,9 +257,9 @@ discard block |
||
257 | 257 | * @param bool $EVT_ID |
258 | 258 | * @return string |
259 | 259 | */ |
260 | - function espresso_event_reg_button( $btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE ) { |
|
261 | - $event_status = EEH_Event_View::event_active_status( $EVT_ID ); |
|
262 | - switch ( $event_status ) { |
|
260 | + function espresso_event_reg_button($btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE) { |
|
261 | + $event_status = EEH_Event_View::event_active_status($EVT_ID); |
|
262 | + switch ($event_status) { |
|
263 | 263 | case EE_Datetime::sold_out : |
264 | 264 | $btn_text = __('Sold Out', 'event_espresso'); |
265 | 265 | $class = 'ee-pink'; |
@@ -275,10 +275,10 @@ discard block |
||
275 | 275 | case EE_Datetime::upcoming : |
276 | 276 | case EE_Datetime::active : |
277 | 277 | default : |
278 | - $btn_text =! empty( $btn_text_if_active ) ? $btn_text_if_active : __( 'Register Now', 'event_espresso' ); |
|
278 | + $btn_text = ! empty($btn_text_if_active) ? $btn_text_if_active : __('Register Now', 'event_espresso'); |
|
279 | 279 | $class = 'ee-green'; |
280 | 280 | } |
281 | - if ( $event_status < 1 && ! empty( $btn_text_if_inactive )) { |
|
281 | + if ($event_status < 1 && ! empty($btn_text_if_inactive)) { |
|
282 | 282 | $btn_text = $btn_text_if_inactive; |
283 | 283 | $class = 'ee-grey'; |
284 | 284 | } |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | |
293 | 293 | |
294 | 294 | |
295 | -if ( ! function_exists( 'espresso_display_ticket_selector' )) { |
|
295 | +if ( ! function_exists('espresso_display_ticket_selector')) { |
|
296 | 296 | /** |
297 | 297 | * espresso_display_ticket_selector |
298 | 298 | * whether or not to display the Ticket Selector for an event |
@@ -300,14 +300,14 @@ discard block |
||
300 | 300 | * @param bool $EVT_ID |
301 | 301 | * @return boolean |
302 | 302 | */ |
303 | - function espresso_display_ticket_selector( $EVT_ID = FALSE ) { |
|
304 | - return EEH_Event_View::display_ticket_selector( $EVT_ID ); |
|
303 | + function espresso_display_ticket_selector($EVT_ID = FALSE) { |
|
304 | + return EEH_Event_View::display_ticket_selector($EVT_ID); |
|
305 | 305 | } |
306 | 306 | } |
307 | 307 | |
308 | 308 | |
309 | 309 | |
310 | -if ( ! function_exists( 'espresso_event_status_banner' )) { |
|
310 | +if ( ! function_exists('espresso_event_status_banner')) { |
|
311 | 311 | /** |
312 | 312 | * espresso_event_status |
313 | 313 | * returns a banner showing the event status if it is sold out, expired, or inactive |
@@ -315,13 +315,13 @@ discard block |
||
315 | 315 | * @param bool $EVT_ID |
316 | 316 | * @return string |
317 | 317 | */ |
318 | - function espresso_event_status_banner( $EVT_ID = FALSE ) { |
|
319 | - return EEH_Event_View::event_status( $EVT_ID ); |
|
318 | + function espresso_event_status_banner($EVT_ID = FALSE) { |
|
319 | + return EEH_Event_View::event_status($EVT_ID); |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
323 | 323 | |
324 | -if ( ! function_exists( 'espresso_event_status' )) { |
|
324 | +if ( ! function_exists('espresso_event_status')) { |
|
325 | 325 | /** |
326 | 326 | * espresso_event_status |
327 | 327 | * returns the event status if it is sold out, expired, or inactive |
@@ -330,17 +330,17 @@ discard block |
||
330 | 330 | * @param bool $echo |
331 | 331 | * @return string |
332 | 332 | */ |
333 | - function espresso_event_status( $EVT_ID = 0, $echo = TRUE ) { |
|
334 | - if ( $echo ) { |
|
335 | - echo EEH_Event_View::event_active_status( $EVT_ID ); |
|
333 | + function espresso_event_status($EVT_ID = 0, $echo = TRUE) { |
|
334 | + if ($echo) { |
|
335 | + echo EEH_Event_View::event_active_status($EVT_ID); |
|
336 | 336 | return ''; |
337 | 337 | } |
338 | - return EEH_Event_View::event_active_status( $EVT_ID ); |
|
338 | + return EEH_Event_View::event_active_status($EVT_ID); |
|
339 | 339 | } |
340 | 340 | } |
341 | 341 | |
342 | 342 | |
343 | -if ( ! function_exists( 'espresso_event_categories' )) { |
|
343 | +if ( ! function_exists('espresso_event_categories')) { |
|
344 | 344 | /** |
345 | 345 | * espresso_event_categories |
346 | 346 | * returns the terms associated with an event |
@@ -350,17 +350,17 @@ discard block |
||
350 | 350 | * @param bool $echo |
351 | 351 | * @return string |
352 | 352 | */ |
353 | - function espresso_event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE ) { |
|
354 | - if ( $echo ) { |
|
355 | - echo EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized ); |
|
353 | + function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) { |
|
354 | + if ($echo) { |
|
355 | + echo EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); |
|
356 | 356 | return ''; |
357 | 357 | } |
358 | - return EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized ); |
|
358 | + return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); |
|
359 | 359 | } |
360 | 360 | } |
361 | 361 | |
362 | 362 | |
363 | -if ( ! function_exists( 'espresso_event_tickets_available' )) { |
|
363 | +if ( ! function_exists('espresso_event_tickets_available')) { |
|
364 | 364 | /** |
365 | 365 | * espresso_event_tickets_available |
366 | 366 | * returns the ticket types available for purchase for an event |
@@ -370,26 +370,26 @@ discard block |
||
370 | 370 | * @param bool $format |
371 | 371 | * @return string |
372 | 372 | */ |
373 | - function espresso_event_tickets_available( $EVT_ID = 0, $echo = TRUE, $format = TRUE ) { |
|
374 | - $tickets = EEH_Event_View::event_tickets_available( $EVT_ID ); |
|
375 | - if ( is_array( $tickets ) && ! empty( $tickets )) { |
|
373 | + function espresso_event_tickets_available($EVT_ID = 0, $echo = TRUE, $format = TRUE) { |
|
374 | + $tickets = EEH_Event_View::event_tickets_available($EVT_ID); |
|
375 | + if (is_array($tickets) && ! empty($tickets)) { |
|
376 | 376 | // if formatting then $html will be a string, else it will be an array of ticket objects |
377 | - $html = $format ? '<ul id="ee-event-tickets-ul-' . $EVT_ID . '" class="ee-event-tickets-ul">' : array(); |
|
378 | - foreach ( $tickets as $ticket ) { |
|
379 | - if ( $ticket instanceof EE_Ticket ) { |
|
380 | - if ( $format ) { |
|
381 | - $html .= '<li id="ee-event-tickets-li-' . $ticket->ID() . '" class="ee-event-tickets-li">'; |
|
382 | - $html .= $ticket->name() . ' ' . EEH_Template::format_currency( $ticket->get_ticket_total_with_taxes() ); |
|
377 | + $html = $format ? '<ul id="ee-event-tickets-ul-'.$EVT_ID.'" class="ee-event-tickets-ul">' : array(); |
|
378 | + foreach ($tickets as $ticket) { |
|
379 | + if ($ticket instanceof EE_Ticket) { |
|
380 | + if ($format) { |
|
381 | + $html .= '<li id="ee-event-tickets-li-'.$ticket->ID().'" class="ee-event-tickets-li">'; |
|
382 | + $html .= $ticket->name().' '.EEH_Template::format_currency($ticket->get_ticket_total_with_taxes()); |
|
383 | 383 | $html .= '</li>'; |
384 | 384 | } else { |
385 | 385 | $html[] = $ticket; |
386 | 386 | } |
387 | 387 | } |
388 | 388 | } |
389 | - if ( $format ) { |
|
389 | + if ($format) { |
|
390 | 390 | $html .= '</ul>'; |
391 | 391 | } |
392 | - if ( $echo && ! $format ) { |
|
392 | + if ($echo && ! $format) { |
|
393 | 393 | echo $html; |
394 | 394 | return ''; |
395 | 395 | } |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | } |
400 | 400 | } |
401 | 401 | |
402 | -if ( ! function_exists( 'espresso_event_date_obj' )) { |
|
402 | +if ( ! function_exists('espresso_event_date_obj')) { |
|
403 | 403 | /** |
404 | 404 | * espresso_event_date_obj |
405 | 405 | * returns the primary date object for an event |
@@ -407,13 +407,13 @@ discard block |
||
407 | 407 | * @param bool $EVT_ID |
408 | 408 | * @return object |
409 | 409 | */ |
410 | - function espresso_event_date_obj( $EVT_ID = FALSE ) { |
|
411 | - return EEH_Event_View::get_primary_date_obj( $EVT_ID ); |
|
410 | + function espresso_event_date_obj($EVT_ID = FALSE) { |
|
411 | + return EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
412 | 412 | } |
413 | 413 | } |
414 | 414 | |
415 | 415 | |
416 | -if ( ! function_exists( 'espresso_event_date' )) { |
|
416 | +if ( ! function_exists('espresso_event_date')) { |
|
417 | 417 | /** |
418 | 418 | * espresso_event_date |
419 | 419 | * returns the primary date for an event |
@@ -424,22 +424,22 @@ discard block |
||
424 | 424 | * @param bool $echo |
425 | 425 | * @return string |
426 | 426 | */ |
427 | - function espresso_event_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) { |
|
428 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
429 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
430 | - $date_format = apply_filters( 'FHEE__espresso_event_date__date_format', $date_format ); |
|
431 | - $time_format = apply_filters( 'FHEE__espresso_event_date__time_format', $time_format ); |
|
432 | - if($echo){ |
|
433 | - echo EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID ); |
|
427 | + function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) { |
|
428 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
429 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
430 | + $date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format); |
|
431 | + $time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format); |
|
432 | + if ($echo) { |
|
433 | + echo EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); |
|
434 | 434 | return ''; |
435 | 435 | } |
436 | - return EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID ); |
|
436 | + return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); |
|
437 | 437 | |
438 | 438 | } |
439 | 439 | } |
440 | 440 | |
441 | 441 | |
442 | -if ( ! function_exists( 'espresso_list_of_event_dates' )) { |
|
442 | +if ( ! function_exists('espresso_list_of_event_dates')) { |
|
443 | 443 | /** |
444 | 444 | * espresso_list_of_event_dates |
445 | 445 | * returns a unordered list of dates for an event |
@@ -454,40 +454,40 @@ discard block |
||
454 | 454 | * @param null $limit |
455 | 455 | * @return string |
456 | 456 | */ |
457 | - function espresso_list_of_event_dates( $EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL ) { |
|
458 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
459 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
460 | - $date_format = apply_filters( 'FHEE__espresso_list_of_event_dates__date_format', $date_format ); |
|
461 | - $time_format = apply_filters( 'FHEE__espresso_list_of_event_dates__time_format', $time_format ); |
|
462 | - $datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, $show_expired, FALSE, $limit ); |
|
463 | - if ( ! $format ) { |
|
464 | - return apply_filters( 'FHEE__espresso_list_of_event_dates__datetimes', $datetimes ); |
|
457 | + function espresso_list_of_event_dates($EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL) { |
|
458 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
459 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
460 | + $date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format); |
|
461 | + $time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format); |
|
462 | + $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, FALSE, $limit); |
|
463 | + if ( ! $format) { |
|
464 | + return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes); |
|
465 | 465 | } |
466 | 466 | //d( $datetimes ); |
467 | - if ( is_array( $datetimes ) && ! empty( $datetimes )) { |
|
467 | + if (is_array($datetimes) && ! empty($datetimes)) { |
|
468 | 468 | global $post; |
469 | - $html = $format ? '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="ee-event-datetimes-ul ee-clearfix">' : ''; |
|
470 | - foreach ( $datetimes as $datetime ) { |
|
471 | - if ( $datetime instanceof EE_Datetime ) { |
|
472 | - $html .= '<li id="ee-event-datetimes-li-' . $datetime->ID(); |
|
473 | - $html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-' . $datetime->get_active_status() . '">'; |
|
469 | + $html = $format ? '<ul id="ee-event-datetimes-ul-'.$post->ID.'" class="ee-event-datetimes-ul ee-clearfix">' : ''; |
|
470 | + foreach ($datetimes as $datetime) { |
|
471 | + if ($datetime instanceof EE_Datetime) { |
|
472 | + $html .= '<li id="ee-event-datetimes-li-'.$datetime->ID(); |
|
473 | + $html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-'.$datetime->get_active_status().'">'; |
|
474 | 474 | $datetime_name = $datetime->name(); |
475 | - $html .= ! empty( $datetime_name ) ? '<strong>' . $datetime_name . '</strong>' : ''; |
|
476 | - $html .= ! empty( $datetime_name ) && $add_breaks ? '<br />' : ''; |
|
477 | - $html .= '<span class="dashicons dashicons-calendar"></span><span class="ee-event-datetimes-li-daterange">' . $datetime->date_range( $date_format ) . '</span><br/>'; |
|
478 | - $html .= '<span class="dashicons dashicons-clock"></span><span class="ee-event-datetimes-li-timerange">' . $datetime->time_range( $time_format ) . '</span>'; |
|
475 | + $html .= ! empty($datetime_name) ? '<strong>'.$datetime_name.'</strong>' : ''; |
|
476 | + $html .= ! empty($datetime_name) && $add_breaks ? '<br />' : ''; |
|
477 | + $html .= '<span class="dashicons dashicons-calendar"></span><span class="ee-event-datetimes-li-daterange">'.$datetime->date_range($date_format).'</span><br/>'; |
|
478 | + $html .= '<span class="dashicons dashicons-clock"></span><span class="ee-event-datetimes-li-timerange">'.$datetime->time_range($time_format).'</span>'; |
|
479 | 479 | $datetime_description = $datetime->description(); |
480 | - $html .= ! empty( $datetime_description ) && $add_breaks ? '<br />' : ''; |
|
481 | - $html .= ! empty( $datetime_description ) ? ' - ' . $datetime_description : ''; |
|
482 | - $html = apply_filters( 'FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime ); |
|
480 | + $html .= ! empty($datetime_description) && $add_breaks ? '<br />' : ''; |
|
481 | + $html .= ! empty($datetime_description) ? ' - '.$datetime_description : ''; |
|
482 | + $html = apply_filters('FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime); |
|
483 | 483 | $html .= '</li>'; |
484 | 484 | } |
485 | 485 | } |
486 | 486 | $html .= $format ? '</ul>' : ''; |
487 | 487 | } else { |
488 | - $html = $format ? '<p><span class="dashicons dashicons-marker pink-text"></span>' . __( 'There are no upcoming dates for this event.', 'event_espresso' ) . '</p><br/>' : ''; |
|
488 | + $html = $format ? '<p><span class="dashicons dashicons-marker pink-text"></span>'.__('There are no upcoming dates for this event.', 'event_espresso').'</p><br/>' : ''; |
|
489 | 489 | } |
490 | - if ( $echo ) { |
|
490 | + if ($echo) { |
|
491 | 491 | echo $html; |
492 | 492 | return ''; |
493 | 493 | } |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | } |
497 | 497 | |
498 | 498 | |
499 | -if ( ! function_exists( 'espresso_event_end_date' )) { |
|
499 | +if ( ! function_exists('espresso_event_end_date')) { |
|
500 | 500 | /** |
501 | 501 | * espresso_event_end_date |
502 | 502 | * returns the last date for an event |
@@ -507,20 +507,20 @@ discard block |
||
507 | 507 | * @param bool $echo |
508 | 508 | * @return string |
509 | 509 | */ |
510 | - function espresso_event_end_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) { |
|
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_end_date__date_format', $date_format ); |
|
514 | - $time_format = apply_filters( 'FHEE__espresso_event_end_date__time_format', $time_format ); |
|
515 | - if($echo){ |
|
516 | - echo EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID ); |
|
510 | + function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) { |
|
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_end_date__date_format', $date_format); |
|
514 | + $time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format); |
|
515 | + if ($echo) { |
|
516 | + echo EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); |
|
517 | 517 | return ''; |
518 | 518 | } |
519 | - return EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID ); |
|
519 | + return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); |
|
520 | 520 | } |
521 | 521 | } |
522 | 522 | |
523 | -if ( ! function_exists( 'espresso_event_date_range' )) { |
|
523 | +if ( ! function_exists('espresso_event_date_range')) { |
|
524 | 524 | /** |
525 | 525 | * espresso_event_date_range |
526 | 526 | * returns the first and last chronologically ordered dates for an event (if different) |
@@ -533,31 +533,31 @@ discard block |
||
533 | 533 | * @param bool $echo |
534 | 534 | * @return string |
535 | 535 | */ |
536 | - function espresso_event_date_range( $date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE ) { |
|
536 | + function espresso_event_date_range($date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE) { |
|
537 | 537 | // set and filter date and time formats when a range is returned |
538 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
539 | - $date_format = apply_filters( 'FHEE__espresso_event_date_range__date_format', $date_format ); |
|
538 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
539 | + $date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format); |
|
540 | 540 | // get the start and end date with NO time portion |
541 | - $the_event_date = EEH_Event_View::the_earliest_event_date( $date_format, '', $EVT_ID ); |
|
542 | - $the_event_end_date = EEH_Event_View::the_latest_event_date( $date_format, '', $EVT_ID ); |
|
541 | + $the_event_date = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID); |
|
542 | + $the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID); |
|
543 | 543 | // now we can determine if date range spans more than one day |
544 | - if ( $the_event_date != $the_event_end_date ) { |
|
545 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
546 | - $time_format = apply_filters( 'FHEE__espresso_event_date_range__time_format', $time_format ); |
|
544 | + if ($the_event_date != $the_event_end_date) { |
|
545 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
546 | + $time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format); |
|
547 | 547 | $html = sprintf( |
548 | - __( '%1$s - %2$s', 'event_espresso' ), |
|
549 | - EEH_Event_View::the_earliest_event_date( $date_format, $time_format, $EVT_ID ), |
|
550 | - EEH_Event_View::the_latest_event_date( $date_format, $time_format, $EVT_ID ) |
|
548 | + __('%1$s - %2$s', 'event_espresso'), |
|
549 | + EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID), |
|
550 | + EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID) |
|
551 | 551 | ); |
552 | 552 | } else { |
553 | 553 | // set and filter date and time formats when only a single datetime is returned |
554 | - $single_date_format = ! empty( $single_date_format ) ? $single_date_format : get_option( 'date_format' ); |
|
555 | - $single_time_format = ! empty( $single_time_format ) ? $single_time_format : get_option( 'time_format' ); |
|
556 | - $single_date_format = apply_filters( 'FHEE__espresso_event_date_range__single_date_format', $single_date_format ); |
|
557 | - $single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', $single_time_format ); |
|
558 | - $html = EEH_Event_View::the_earliest_event_date( $single_date_format, $single_time_format, $EVT_ID ); |
|
554 | + $single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format'); |
|
555 | + $single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format'); |
|
556 | + $single_date_format = apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format); |
|
557 | + $single_time_format = apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format); |
|
558 | + $html = EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID); |
|
559 | 559 | } |
560 | - if ( $echo ) { |
|
560 | + if ($echo) { |
|
561 | 561 | echo $html; |
562 | 562 | return ''; |
563 | 563 | } |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | } |
567 | 567 | |
568 | 568 | |
569 | -if ( ! function_exists( 'espresso_event_date_as_calendar_page' )) { |
|
569 | +if ( ! function_exists('espresso_event_date_as_calendar_page')) { |
|
570 | 570 | /** |
571 | 571 | * espresso_event_date_as_calendar_page |
572 | 572 | * returns the primary date for an event, stylized to appear as the page of a calendar |
@@ -574,15 +574,15 @@ discard block |
||
574 | 574 | * @param bool $EVT_ID |
575 | 575 | * @return string |
576 | 576 | */ |
577 | - function espresso_event_date_as_calendar_page( $EVT_ID = FALSE ) { |
|
578 | - EEH_Event_View::event_date_as_calendar_page( $EVT_ID ); |
|
577 | + function espresso_event_date_as_calendar_page($EVT_ID = FALSE) { |
|
578 | + EEH_Event_View::event_date_as_calendar_page($EVT_ID); |
|
579 | 579 | } |
580 | 580 | } |
581 | 581 | |
582 | 582 | |
583 | 583 | |
584 | 584 | |
585 | -if ( ! function_exists( 'espresso_event_link_url' )) { |
|
585 | +if ( ! function_exists('espresso_event_link_url')) { |
|
586 | 586 | /** |
587 | 587 | * espresso_event_link_url |
588 | 588 | * |
@@ -590,18 +590,18 @@ discard block |
||
590 | 590 | * @param bool $echo |
591 | 591 | * @return string |
592 | 592 | */ |
593 | - function espresso_event_link_url( $EVT_ID = 0, $echo = TRUE ) { |
|
594 | - if ( $echo ) { |
|
595 | - echo EEH_Event_View::event_link_url( $EVT_ID ); |
|
593 | + function espresso_event_link_url($EVT_ID = 0, $echo = TRUE) { |
|
594 | + if ($echo) { |
|
595 | + echo EEH_Event_View::event_link_url($EVT_ID); |
|
596 | 596 | return ''; |
597 | 597 | } |
598 | - return EEH_Event_View::event_link_url( $EVT_ID ); |
|
598 | + return EEH_Event_View::event_link_url($EVT_ID); |
|
599 | 599 | } |
600 | 600 | } |
601 | 601 | |
602 | 602 | |
603 | 603 | |
604 | -if ( ! function_exists( 'espresso_event_has_content_or_excerpt' )) { |
|
604 | +if ( ! function_exists('espresso_event_has_content_or_excerpt')) { |
|
605 | 605 | /** |
606 | 606 | * espresso_event_has_content_or_excerpt |
607 | 607 | * |
@@ -609,15 +609,15 @@ discard block |
||
609 | 609 | * @param bool $EVT_ID |
610 | 610 | * @return boolean |
611 | 611 | */ |
612 | - function espresso_event_has_content_or_excerpt( $EVT_ID = FALSE ) { |
|
613 | - return EEH_Event_View::event_has_content_or_excerpt( $EVT_ID ); |
|
612 | + function espresso_event_has_content_or_excerpt($EVT_ID = FALSE) { |
|
613 | + return EEH_Event_View::event_has_content_or_excerpt($EVT_ID); |
|
614 | 614 | } |
615 | 615 | } |
616 | 616 | |
617 | 617 | |
618 | 618 | |
619 | 619 | |
620 | -if ( ! function_exists( 'espresso_event_content_or_excerpt' )) { |
|
620 | +if ( ! function_exists('espresso_event_content_or_excerpt')) { |
|
621 | 621 | /** |
622 | 622 | * espresso_event_content_or_excerpt |
623 | 623 | * |
@@ -626,18 +626,18 @@ discard block |
||
626 | 626 | * @param bool $echo |
627 | 627 | * @return string |
628 | 628 | */ |
629 | - function espresso_event_content_or_excerpt( $num_words = 55, $more = NULL, $echo = TRUE ) { |
|
630 | - if ( $echo ) { |
|
631 | - echo EEH_Event_View::event_content_or_excerpt( $num_words, $more ); |
|
629 | + function espresso_event_content_or_excerpt($num_words = 55, $more = NULL, $echo = TRUE) { |
|
630 | + if ($echo) { |
|
631 | + echo EEH_Event_View::event_content_or_excerpt($num_words, $more); |
|
632 | 632 | return ''; |
633 | 633 | } |
634 | - return EEH_Event_View::event_content_or_excerpt( $num_words, $more ); |
|
634 | + return EEH_Event_View::event_content_or_excerpt($num_words, $more); |
|
635 | 635 | } |
636 | 636 | } |
637 | 637 | |
638 | 638 | |
639 | 639 | |
640 | -if ( ! function_exists( 'espresso_event_phone' )) { |
|
640 | +if ( ! function_exists('espresso_event_phone')) { |
|
641 | 641 | /** |
642 | 642 | * espresso_event_phone |
643 | 643 | * |
@@ -645,18 +645,18 @@ discard block |
||
645 | 645 | * @param bool $echo |
646 | 646 | * @return string |
647 | 647 | */ |
648 | - function espresso_event_phone( $EVT_ID = 0, $echo = TRUE ) { |
|
649 | - if ( $echo ) { |
|
650 | - echo EEH_Event_View::event_phone( $EVT_ID ); |
|
648 | + function espresso_event_phone($EVT_ID = 0, $echo = TRUE) { |
|
649 | + if ($echo) { |
|
650 | + echo EEH_Event_View::event_phone($EVT_ID); |
|
651 | 651 | return ''; |
652 | 652 | } |
653 | - return EEH_Event_View::event_phone( $EVT_ID ); |
|
653 | + return EEH_Event_View::event_phone($EVT_ID); |
|
654 | 654 | } |
655 | 655 | } |
656 | 656 | |
657 | 657 | |
658 | 658 | |
659 | -if ( ! function_exists( 'espresso_edit_event_link' )) { |
|
659 | +if ( ! function_exists('espresso_edit_event_link')) { |
|
660 | 660 | /** |
661 | 661 | * espresso_edit_event_link |
662 | 662 | * returns a link to edit an event |
@@ -665,39 +665,39 @@ discard block |
||
665 | 665 | * @param bool $echo |
666 | 666 | * @return string |
667 | 667 | */ |
668 | - function espresso_edit_event_link( $EVT_ID = 0, $echo = TRUE ) { |
|
669 | - if ( $echo ) { |
|
670 | - echo EEH_Event_View::edit_event_link( $EVT_ID ); |
|
668 | + function espresso_edit_event_link($EVT_ID = 0, $echo = TRUE) { |
|
669 | + if ($echo) { |
|
670 | + echo EEH_Event_View::edit_event_link($EVT_ID); |
|
671 | 671 | return ''; |
672 | 672 | } |
673 | - return EEH_Event_View::edit_event_link( $EVT_ID ); |
|
673 | + return EEH_Event_View::edit_event_link($EVT_ID); |
|
674 | 674 | } |
675 | 675 | } |
676 | 676 | |
677 | 677 | |
678 | -if ( ! function_exists( 'espresso_organization_name' )) { |
|
678 | +if ( ! function_exists('espresso_organization_name')) { |
|
679 | 679 | /** |
680 | 680 | * espresso_organization_name |
681 | 681 | * @param bool $echo |
682 | 682 | * @return string |
683 | 683 | */ |
684 | 684 | function espresso_organization_name($echo = TRUE) { |
685 | - if($echo){ |
|
686 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'name' ); |
|
685 | + if ($echo) { |
|
686 | + echo EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
687 | 687 | return ''; |
688 | 688 | } |
689 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'name' ); |
|
689 | + return EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
690 | 690 | } |
691 | 691 | } |
692 | 692 | |
693 | -if ( ! function_exists( 'espresso_organization_address' )) { |
|
693 | +if ( ! function_exists('espresso_organization_address')) { |
|
694 | 694 | /** |
695 | 695 | * espresso_organization_address |
696 | 696 | * @param string $type |
697 | 697 | * @return string |
698 | 698 | */ |
699 | - function espresso_organization_address( $type = 'inline' ) { |
|
700 | - if ( EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ) { |
|
699 | + function espresso_organization_address($type = 'inline') { |
|
700 | + if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) { |
|
701 | 701 | $address = new EventEspresso\core\domain\entities\GenericAddress( |
702 | 702 | EE_Registry::instance()->CFG->organization->address_1, |
703 | 703 | EE_Registry::instance()->CFG->organization->address_2, |
@@ -706,129 +706,129 @@ discard block |
||
706 | 706 | EE_Registry::instance()->CFG->organization->zip, |
707 | 707 | EE_Registry::instance()->CFG->organization->CNT_ISO |
708 | 708 | ); |
709 | - return EEH_Address::format( $address, $type ); |
|
709 | + return EEH_Address::format($address, $type); |
|
710 | 710 | } |
711 | 711 | return ''; |
712 | 712 | } |
713 | 713 | } |
714 | 714 | |
715 | -if ( ! function_exists( 'espresso_organization_email' )) { |
|
715 | +if ( ! function_exists('espresso_organization_email')) { |
|
716 | 716 | /** |
717 | 717 | * espresso_organization_email |
718 | 718 | * @param bool $echo |
719 | 719 | * @return string |
720 | 720 | */ |
721 | - function espresso_organization_email( $echo = TRUE ) { |
|
722 | - if($echo){ |
|
723 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'email' ); |
|
721 | + function espresso_organization_email($echo = TRUE) { |
|
722 | + if ($echo) { |
|
723 | + echo EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
724 | 724 | return ''; |
725 | 725 | } |
726 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'email' ); |
|
726 | + return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
727 | 727 | } |
728 | 728 | } |
729 | 729 | |
730 | -if ( ! function_exists( 'espresso_organization_logo_url' )) { |
|
730 | +if ( ! function_exists('espresso_organization_logo_url')) { |
|
731 | 731 | /** |
732 | 732 | * espresso_organization_logo_url |
733 | 733 | * @param bool $echo |
734 | 734 | * @return string |
735 | 735 | */ |
736 | - function espresso_organization_logo_url( $echo = TRUE ) { |
|
737 | - if($echo){ |
|
738 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ); |
|
736 | + function espresso_organization_logo_url($echo = TRUE) { |
|
737 | + if ($echo) { |
|
738 | + echo EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
739 | 739 | return ''; |
740 | 740 | } |
741 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ); |
|
741 | + return EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
742 | 742 | } |
743 | 743 | } |
744 | 744 | |
745 | -if ( ! function_exists( 'espresso_organization_facebook' )) { |
|
745 | +if ( ! function_exists('espresso_organization_facebook')) { |
|
746 | 746 | /** |
747 | 747 | * espresso_organization_facebook |
748 | 748 | * @param bool $echo |
749 | 749 | * @return string |
750 | 750 | */ |
751 | - function espresso_organization_facebook( $echo = TRUE ) { |
|
752 | - if($echo){ |
|
753 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ); |
|
751 | + function espresso_organization_facebook($echo = TRUE) { |
|
752 | + if ($echo) { |
|
753 | + echo EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
754 | 754 | return ''; |
755 | 755 | } |
756 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ); |
|
756 | + return EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
757 | 757 | } |
758 | 758 | } |
759 | 759 | |
760 | -if ( ! function_exists( 'espresso_organization_twitter' )) { |
|
760 | +if ( ! function_exists('espresso_organization_twitter')) { |
|
761 | 761 | /** |
762 | 762 | * espresso_organization_twitter |
763 | 763 | * @param bool $echo |
764 | 764 | * @return string |
765 | 765 | */ |
766 | - function espresso_organization_twitter( $echo = TRUE ) { |
|
767 | - if($echo){ |
|
768 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ); |
|
766 | + function espresso_organization_twitter($echo = TRUE) { |
|
767 | + if ($echo) { |
|
768 | + echo EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
769 | 769 | return ''; |
770 | 770 | } |
771 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ); |
|
771 | + return EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
772 | 772 | } |
773 | 773 | } |
774 | 774 | |
775 | -if ( ! function_exists( 'espresso_organization_linkedin' )) { |
|
775 | +if ( ! function_exists('espresso_organization_linkedin')) { |
|
776 | 776 | /** |
777 | 777 | * espresso_organization_linkedin |
778 | 778 | * @param bool $echo |
779 | 779 | * @return string |
780 | 780 | */ |
781 | - function espresso_organization_linkedin( $echo = TRUE ) { |
|
782 | - if($echo){ |
|
783 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' ); |
|
781 | + function espresso_organization_linkedin($echo = TRUE) { |
|
782 | + if ($echo) { |
|
783 | + echo EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
784 | 784 | return ''; |
785 | 785 | } |
786 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' ); |
|
786 | + return EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
787 | 787 | } |
788 | 788 | } |
789 | 789 | |
790 | -if ( ! function_exists( 'espresso_organization_pinterest' )) { |
|
790 | +if ( ! function_exists('espresso_organization_pinterest')) { |
|
791 | 791 | /** |
792 | 792 | * espresso_organization_pinterest |
793 | 793 | * @param bool $echo |
794 | 794 | * @return string |
795 | 795 | */ |
796 | - function espresso_organization_pinterest( $echo = TRUE ) { |
|
797 | - if($echo){ |
|
798 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' ); |
|
796 | + function espresso_organization_pinterest($echo = TRUE) { |
|
797 | + if ($echo) { |
|
798 | + echo EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
799 | 799 | return ''; |
800 | 800 | } |
801 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' ); |
|
801 | + return EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
802 | 802 | } |
803 | 803 | } |
804 | 804 | |
805 | -if ( ! function_exists( 'espresso_organization_google' )) { |
|
805 | +if ( ! function_exists('espresso_organization_google')) { |
|
806 | 806 | /** |
807 | 807 | * espresso_organization_google |
808 | 808 | * @param bool $echo |
809 | 809 | * @return string |
810 | 810 | */ |
811 | - function espresso_organization_google( $echo = TRUE ) { |
|
812 | - if($echo){ |
|
813 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'google' ); |
|
811 | + function espresso_organization_google($echo = TRUE) { |
|
812 | + if ($echo) { |
|
813 | + echo EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
814 | 814 | return ''; |
815 | 815 | } |
816 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'google' ); |
|
816 | + return EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
817 | 817 | } |
818 | 818 | } |
819 | 819 | |
820 | -if ( ! function_exists( 'espresso_organization_instagram' )) { |
|
820 | +if ( ! function_exists('espresso_organization_instagram')) { |
|
821 | 821 | /** |
822 | 822 | * espresso_organization_instagram |
823 | 823 | * @param bool $echo |
824 | 824 | * @return string |
825 | 825 | */ |
826 | - function espresso_organization_instagram( $echo = TRUE ) { |
|
827 | - if($echo){ |
|
828 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' ); |
|
826 | + function espresso_organization_instagram($echo = TRUE) { |
|
827 | + if ($echo) { |
|
828 | + echo EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
829 | 829 | return ''; |
830 | 830 | } |
831 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' ); |
|
831 | + return EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
832 | 832 | } |
833 | 833 | } |
834 | 834 | |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | |
839 | 839 | |
840 | 840 | |
841 | -if ( ! function_exists( 'espresso_event_venues' )) { |
|
841 | +if ( ! function_exists('espresso_event_venues')) { |
|
842 | 842 | /** |
843 | 843 | * espresso_event_venues |
844 | 844 | * |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | |
853 | 853 | |
854 | 854 | |
855 | -if ( ! function_exists( 'espresso_venue_id' )) { |
|
855 | +if ( ! function_exists('espresso_venue_id')) { |
|
856 | 856 | /** |
857 | 857 | * espresso_venue_name |
858 | 858 | * |
@@ -860,15 +860,15 @@ discard block |
||
860 | 860 | * @param int $EVT_ID |
861 | 861 | * @return string |
862 | 862 | */ |
863 | - function espresso_venue_id( $EVT_ID = 0 ) { |
|
864 | - $venue = EEH_Venue_View::get_venue( $EVT_ID ); |
|
863 | + function espresso_venue_id($EVT_ID = 0) { |
|
864 | + $venue = EEH_Venue_View::get_venue($EVT_ID); |
|
865 | 865 | return $venue instanceof EE_Venue ? $venue->ID() : 0; |
866 | 866 | } |
867 | 867 | } |
868 | 868 | |
869 | 869 | |
870 | 870 | |
871 | -if ( ! function_exists( 'espresso_is_venue_private' ) ) { |
|
871 | +if ( ! function_exists('espresso_is_venue_private')) { |
|
872 | 872 | /** |
873 | 873 | * Return whether a venue is private or not. |
874 | 874 | * @see EEH_Venue_View::get_venue() for more info on expected return results. |
@@ -877,45 +877,45 @@ discard block |
||
877 | 877 | * |
878 | 878 | * @return bool | null |
879 | 879 | */ |
880 | - function espresso_is_venue_private( $VNU_ID = 0 ) { |
|
881 | - return EEH_Venue_View::is_venue_private( $VNU_ID ); |
|
880 | + function espresso_is_venue_private($VNU_ID = 0) { |
|
881 | + return EEH_Venue_View::is_venue_private($VNU_ID); |
|
882 | 882 | } |
883 | 883 | } |
884 | 884 | |
885 | 885 | |
886 | 886 | |
887 | -if ( ! function_exists( 'espresso_venue_is_password_protected' ) ) { |
|
887 | +if ( ! function_exists('espresso_venue_is_password_protected')) { |
|
888 | 888 | /** |
889 | 889 | * returns true or false if a venue is password protected or not |
890 | 890 | * |
891 | 891 | * @param int $VNU_ID optional, the venue id to check. |
892 | 892 | * @return string |
893 | 893 | */ |
894 | - function espresso_venue_is_password_protected( $VNU_ID = 0 ) { |
|
895 | - EE_Registry::instance()->load_helper( 'Venue_View' ); |
|
896 | - return EEH_Venue_View::is_venue_password_protected( $VNU_ID ); |
|
894 | + function espresso_venue_is_password_protected($VNU_ID = 0) { |
|
895 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
896 | + return EEH_Venue_View::is_venue_password_protected($VNU_ID); |
|
897 | 897 | } |
898 | 898 | } |
899 | 899 | |
900 | 900 | |
901 | 901 | |
902 | -if ( ! function_exists( 'espresso_password_protected_venue_form' ) ) { |
|
902 | +if ( ! function_exists('espresso_password_protected_venue_form')) { |
|
903 | 903 | /** |
904 | 904 | * Returns a password form if venue is password protected. |
905 | 905 | * |
906 | 906 | * @param int $VNU_ID optional, the venue id to check. |
907 | 907 | * @return string |
908 | 908 | */ |
909 | - function espresso_password_protected_venue_form( $VNU_ID = 0 ) { |
|
910 | - EE_Registry::instance()->load_helper( 'Venue_View' ); |
|
911 | - return EEH_Venue_View::password_protected_venue_form( $VNU_ID ); |
|
909 | + function espresso_password_protected_venue_form($VNU_ID = 0) { |
|
910 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
911 | + return EEH_Venue_View::password_protected_venue_form($VNU_ID); |
|
912 | 912 | } |
913 | 913 | } |
914 | 914 | |
915 | 915 | |
916 | 916 | |
917 | 917 | |
918 | -if ( ! function_exists( 'espresso_venue_name' )) { |
|
918 | +if ( ! function_exists('espresso_venue_name')) { |
|
919 | 919 | /** |
920 | 920 | * espresso_venue_name |
921 | 921 | * |
@@ -925,19 +925,19 @@ discard block |
||
925 | 925 | * @param bool $echo |
926 | 926 | * @return string |
927 | 927 | */ |
928 | - function espresso_venue_name( $VNU_ID = 0, $link_to = 'details', $echo = TRUE ) { |
|
929 | - if($echo){ |
|
930 | - echo EEH_Venue_View::venue_name( $link_to, $VNU_ID ); |
|
928 | + function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = TRUE) { |
|
929 | + if ($echo) { |
|
930 | + echo EEH_Venue_View::venue_name($link_to, $VNU_ID); |
|
931 | 931 | return ''; |
932 | 932 | } |
933 | - return EEH_Venue_View::venue_name( $link_to, $VNU_ID ); |
|
933 | + return EEH_Venue_View::venue_name($link_to, $VNU_ID); |
|
934 | 934 | } |
935 | 935 | } |
936 | 936 | |
937 | 937 | |
938 | 938 | |
939 | 939 | |
940 | -if ( ! function_exists( 'espresso_venue_link' )) { |
|
940 | +if ( ! function_exists('espresso_venue_link')) { |
|
941 | 941 | /** |
942 | 942 | * espresso_venue_link |
943 | 943 | * |
@@ -946,14 +946,14 @@ discard block |
||
946 | 946 | * @param string $text |
947 | 947 | * @return string |
948 | 948 | */ |
949 | - function espresso_venue_link( $VNU_ID = 0, $text = '' ) { |
|
950 | - return EEH_Venue_View::venue_details_link( $VNU_ID, $text ); |
|
949 | + function espresso_venue_link($VNU_ID = 0, $text = '') { |
|
950 | + return EEH_Venue_View::venue_details_link($VNU_ID, $text); |
|
951 | 951 | } |
952 | 952 | } |
953 | 953 | |
954 | 954 | |
955 | 955 | |
956 | -if ( ! function_exists( 'espresso_venue_description' )) { |
|
956 | +if ( ! function_exists('espresso_venue_description')) { |
|
957 | 957 | /** |
958 | 958 | * espresso_venue_description |
959 | 959 | * |
@@ -962,17 +962,17 @@ discard block |
||
962 | 962 | * @param bool $echo |
963 | 963 | * @return string |
964 | 964 | */ |
965 | - function espresso_venue_description( $VNU_ID = FALSE, $echo = TRUE ) { |
|
966 | - if($echo){ |
|
967 | - echo EEH_Venue_View::venue_description( $VNU_ID ); |
|
965 | + function espresso_venue_description($VNU_ID = FALSE, $echo = TRUE) { |
|
966 | + if ($echo) { |
|
967 | + echo EEH_Venue_View::venue_description($VNU_ID); |
|
968 | 968 | return ''; |
969 | 969 | } |
970 | - return EEH_Venue_View::venue_description( $VNU_ID ); |
|
970 | + return EEH_Venue_View::venue_description($VNU_ID); |
|
971 | 971 | } |
972 | 972 | } |
973 | 973 | |
974 | 974 | |
975 | -if ( ! function_exists( 'espresso_venue_excerpt' )) { |
|
975 | +if ( ! function_exists('espresso_venue_excerpt')) { |
|
976 | 976 | /** |
977 | 977 | * espresso_venue_excerpt |
978 | 978 | * |
@@ -981,18 +981,18 @@ discard block |
||
981 | 981 | * @param bool $echo |
982 | 982 | * @return string |
983 | 983 | */ |
984 | - function espresso_venue_excerpt( $VNU_ID = 0, $echo = TRUE ) { |
|
985 | - if ( $echo ) { |
|
986 | - echo EEH_Venue_View::venue_excerpt( $VNU_ID ); |
|
984 | + function espresso_venue_excerpt($VNU_ID = 0, $echo = TRUE) { |
|
985 | + if ($echo) { |
|
986 | + echo EEH_Venue_View::venue_excerpt($VNU_ID); |
|
987 | 987 | return ''; |
988 | 988 | } |
989 | - return EEH_Venue_View::venue_excerpt( $VNU_ID ); |
|
989 | + return EEH_Venue_View::venue_excerpt($VNU_ID); |
|
990 | 990 | } |
991 | 991 | } |
992 | 992 | |
993 | 993 | |
994 | 994 | |
995 | -if ( ! function_exists( 'espresso_venue_categories' )) { |
|
995 | +if ( ! function_exists('espresso_venue_categories')) { |
|
996 | 996 | /** |
997 | 997 | * espresso_venue_categories |
998 | 998 | * returns the terms associated with a venue |
@@ -1002,17 +1002,17 @@ discard block |
||
1002 | 1002 | * @param bool $echo |
1003 | 1003 | * @return string |
1004 | 1004 | */ |
1005 | - function espresso_venue_categories( $VNU_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE ) { |
|
1006 | - if ( $echo ) { |
|
1007 | - echo EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized ); |
|
1005 | + function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) { |
|
1006 | + if ($echo) { |
|
1007 | + echo EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); |
|
1008 | 1008 | return ''; |
1009 | 1009 | } |
1010 | - return EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized ); |
|
1010 | + return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); |
|
1011 | 1011 | } |
1012 | 1012 | } |
1013 | 1013 | |
1014 | 1014 | |
1015 | -if ( ! function_exists( 'espresso_venue_address' )) { |
|
1015 | +if ( ! function_exists('espresso_venue_address')) { |
|
1016 | 1016 | /** |
1017 | 1017 | * espresso_venue_address |
1018 | 1018 | * returns a formatted block of html for displaying a venue's address |
@@ -1022,17 +1022,17 @@ discard block |
||
1022 | 1022 | * @param bool $echo |
1023 | 1023 | * @return string |
1024 | 1024 | */ |
1025 | - function espresso_venue_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) { |
|
1026 | - if ( $echo ) { |
|
1027 | - echo EEH_Venue_View::venue_address( $type, $VNU_ID ); |
|
1025 | + function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) { |
|
1026 | + if ($echo) { |
|
1027 | + echo EEH_Venue_View::venue_address($type, $VNU_ID); |
|
1028 | 1028 | return ''; |
1029 | 1029 | } |
1030 | - return EEH_Venue_View::venue_address( $type, $VNU_ID ); |
|
1030 | + return EEH_Venue_View::venue_address($type, $VNU_ID); |
|
1031 | 1031 | } |
1032 | 1032 | } |
1033 | 1033 | |
1034 | 1034 | |
1035 | -if ( ! function_exists( 'espresso_venue_raw_address' )) { |
|
1035 | +if ( ! function_exists('espresso_venue_raw_address')) { |
|
1036 | 1036 | /** |
1037 | 1037 | * espresso_venue_address |
1038 | 1038 | * returns an UN-formatted string containing a venue's address |
@@ -1042,17 +1042,17 @@ discard block |
||
1042 | 1042 | * @param bool $echo |
1043 | 1043 | * @return string |
1044 | 1044 | */ |
1045 | - function espresso_venue_raw_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) { |
|
1046 | - if ( $echo ) { |
|
1047 | - echo EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE ); |
|
1045 | + function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) { |
|
1046 | + if ($echo) { |
|
1047 | + echo EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE); |
|
1048 | 1048 | return ''; |
1049 | 1049 | } |
1050 | - return EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE ); |
|
1050 | + return EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE); |
|
1051 | 1051 | } |
1052 | 1052 | } |
1053 | 1053 | |
1054 | 1054 | |
1055 | -if ( ! function_exists( 'espresso_venue_has_address' )) { |
|
1055 | +if ( ! function_exists('espresso_venue_has_address')) { |
|
1056 | 1056 | /** |
1057 | 1057 | * espresso_venue_has_address |
1058 | 1058 | * returns TRUE or FALSE if a Venue has address information |
@@ -1060,13 +1060,13 @@ discard block |
||
1060 | 1060 | * @param int $VNU_ID |
1061 | 1061 | * @return bool |
1062 | 1062 | */ |
1063 | - function espresso_venue_has_address( $VNU_ID = 0 ) { |
|
1064 | - return EEH_Venue_View::venue_has_address( $VNU_ID ); |
|
1063 | + function espresso_venue_has_address($VNU_ID = 0) { |
|
1064 | + return EEH_Venue_View::venue_has_address($VNU_ID); |
|
1065 | 1065 | } |
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | |
1069 | -if ( ! function_exists( 'espresso_venue_gmap' )) { |
|
1069 | +if ( ! function_exists('espresso_venue_gmap')) { |
|
1070 | 1070 | /** |
1071 | 1071 | * espresso_venue_gmap |
1072 | 1072 | * returns a google map for the venue address |
@@ -1077,17 +1077,17 @@ discard block |
||
1077 | 1077 | * @param bool $echo |
1078 | 1078 | * @return string |
1079 | 1079 | */ |
1080 | - function espresso_venue_gmap( $VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE ) { |
|
1081 | - if ( $echo ) { |
|
1082 | - echo EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap ); |
|
1080 | + function espresso_venue_gmap($VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE) { |
|
1081 | + if ($echo) { |
|
1082 | + echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); |
|
1083 | 1083 | return ''; |
1084 | 1084 | } |
1085 | - return EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap ); |
|
1085 | + return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); |
|
1086 | 1086 | } |
1087 | 1087 | } |
1088 | 1088 | |
1089 | 1089 | |
1090 | -if ( ! function_exists( 'espresso_venue_phone' )) { |
|
1090 | +if ( ! function_exists('espresso_venue_phone')) { |
|
1091 | 1091 | /** |
1092 | 1092 | * espresso_venue_phone |
1093 | 1093 | * |
@@ -1095,18 +1095,18 @@ discard block |
||
1095 | 1095 | * @param bool $echo |
1096 | 1096 | * @return string |
1097 | 1097 | */ |
1098 | - function espresso_venue_phone( $VNU_ID = 0, $echo = TRUE ) { |
|
1099 | - if ( $echo ) { |
|
1100 | - echo EEH_Venue_View::venue_phone( $VNU_ID ); |
|
1098 | + function espresso_venue_phone($VNU_ID = 0, $echo = TRUE) { |
|
1099 | + if ($echo) { |
|
1100 | + echo EEH_Venue_View::venue_phone($VNU_ID); |
|
1101 | 1101 | return ''; |
1102 | 1102 | } |
1103 | - return EEH_Venue_View::venue_phone( $VNU_ID ); |
|
1103 | + return EEH_Venue_View::venue_phone($VNU_ID); |
|
1104 | 1104 | } |
1105 | 1105 | } |
1106 | 1106 | |
1107 | 1107 | |
1108 | 1108 | |
1109 | -if ( ! function_exists( 'espresso_venue_website' )) { |
|
1109 | +if ( ! function_exists('espresso_venue_website')) { |
|
1110 | 1110 | /** |
1111 | 1111 | * espresso_venue_website |
1112 | 1112 | * |
@@ -1114,18 +1114,18 @@ discard block |
||
1114 | 1114 | * @param bool $echo |
1115 | 1115 | * @return string |
1116 | 1116 | */ |
1117 | - function espresso_venue_website( $VNU_ID = 0, $echo = TRUE ) { |
|
1118 | - if ( $echo ) { |
|
1119 | - echo EEH_Venue_View::venue_website_link( $VNU_ID ); |
|
1117 | + function espresso_venue_website($VNU_ID = 0, $echo = TRUE) { |
|
1118 | + if ($echo) { |
|
1119 | + echo EEH_Venue_View::venue_website_link($VNU_ID); |
|
1120 | 1120 | return ''; |
1121 | 1121 | } |
1122 | - return EEH_Venue_View::venue_website_link( $VNU_ID ); |
|
1122 | + return EEH_Venue_View::venue_website_link($VNU_ID); |
|
1123 | 1123 | } |
1124 | 1124 | } |
1125 | 1125 | |
1126 | 1126 | |
1127 | 1127 | |
1128 | -if ( ! function_exists( 'espresso_edit_venue_link' )) { |
|
1128 | +if ( ! function_exists('espresso_edit_venue_link')) { |
|
1129 | 1129 | /** |
1130 | 1130 | * espresso_edit_venue_link |
1131 | 1131 | * |
@@ -1133,12 +1133,12 @@ discard block |
||
1133 | 1133 | * @param bool $echo |
1134 | 1134 | * @return string |
1135 | 1135 | */ |
1136 | - function espresso_edit_venue_link( $VNU_ID = 0, $echo = TRUE ) { |
|
1137 | - if($echo){ |
|
1138 | - echo EEH_Venue_View::edit_venue_link( $VNU_ID ); |
|
1136 | + function espresso_edit_venue_link($VNU_ID = 0, $echo = TRUE) { |
|
1137 | + if ($echo) { |
|
1138 | + echo EEH_Venue_View::edit_venue_link($VNU_ID); |
|
1139 | 1139 | return ''; |
1140 | 1140 | } |
1141 | - return EEH_Venue_View::edit_venue_link( $VNU_ID ); |
|
1141 | + return EEH_Venue_View::edit_venue_link($VNU_ID); |
|
1142 | 1142 | } |
1143 | 1143 | } |
1144 | 1144 |
@@ -11,7 +11,7 @@ |
||
11 | 11 | */ |
12 | 12 | function ee_recurse_into_array_for_display($data) { |
13 | 13 | if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {//is_object($incomplete_class) actually returns false, hence why we check for it |
14 | - $data = json_decode(json_encode($data), true); |
|
14 | + $data = json_decode(json_encode($data), true); |
|
15 | 15 | } |
16 | 16 | if (is_array($data)) { |
17 | 17 | if (EEH_Array::is_associative_array($data)) { |
@@ -23,10 +23,10 @@ discard block |
||
23 | 23 | ?> |
24 | 24 | <tr> |
25 | 25 | <td> |
26 | - <?php echo $data_key;?> |
|
26 | + <?php echo $data_key; ?> |
|
27 | 27 | </td> |
28 | 28 | <td> |
29 | - <?php ee_recurse_into_array_for_display($data_values);?> |
|
29 | + <?php ee_recurse_into_array_for_display($data_values); ?> |
|
30 | 30 | </td> |
31 | 31 | </tr> |
32 | 32 | <?php |
@@ -40,19 +40,19 @@ discard block |
||
40 | 40 | <ul> |
41 | 41 | <?php |
42 | 42 | foreach ($data as $datum) { |
43 | - echo "<li>";ee_recurse_into_array_for_display($datum);echo "</li>"; |
|
43 | + echo "<li>"; ee_recurse_into_array_for_display($datum); echo "</li>"; |
|
44 | 44 | }?> |
45 | 45 | </ul> |
46 | 46 | <?php |
47 | 47 | } |
48 | - }else { |
|
48 | + } else { |
|
49 | 49 | //simple value |
50 | 50 | echo $data; |
51 | 51 | } |
52 | 52 | } |
53 | 53 | ?> |
54 | 54 | <h1> |
55 | - <?php _e("System Information", "event_espresso");?> <a href="<?php echo $download_system_status_url;?>" class="button-secondary"><?php esc_html_e( 'Download to File', 'event_espresso' );?></a> |
|
55 | + <?php _e("System Information", "event_espresso"); ?> <a href="<?php echo $download_system_status_url; ?>" class="button-secondary"><?php esc_html_e('Download to File', 'event_espresso'); ?></a> |
|
56 | 56 | </h1> |
57 | 57 | <div class="padding"> |
58 | 58 |
@@ -21,59 +21,59 @@ |
||
21 | 21 | { |
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * the actual shortcode tag that gets registered with WordPress |
|
26 | - * |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - public function getTag() |
|
30 | - { |
|
31 | - return 'ESPRESSO_CHECKOUT'; |
|
32 | - } |
|
33 | - |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * the time in seconds to cache the results of the processShortcode() method |
|
38 | - * 0 means the processShortcode() results will NOT be cached at all |
|
39 | - * |
|
40 | - * @return int |
|
41 | - */ |
|
42 | - public function cacheExpiration() |
|
43 | - { |
|
44 | - return 0; |
|
45 | - } |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
50 | - * this may be required for shortcodes that utilize a corresponding module, |
|
51 | - * and need to enqueue assets for that module |
|
52 | - * |
|
53 | - * @return void |
|
54 | - * @throws \EE_Error |
|
55 | - */ |
|
56 | - public function initializeShortcode() |
|
57 | - { |
|
58 | - global $wp_query; |
|
59 | - EED_Single_Page_Checkout::init($wp_query); |
|
60 | - $this->shortcodeHasBeenInitialized(); |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * callback that runs when the shortcode is encountered in post content. |
|
67 | - * IMPORTANT !!! |
|
68 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
69 | - * |
|
70 | - * @param array $attributes |
|
71 | - * @return string |
|
72 | - */ |
|
73 | - public function processShortcode($attributes = array()) |
|
74 | - { |
|
75 | - return EE_Registry::instance()->REQ->get_output(); |
|
76 | - } |
|
24 | + /** |
|
25 | + * the actual shortcode tag that gets registered with WordPress |
|
26 | + * |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + public function getTag() |
|
30 | + { |
|
31 | + return 'ESPRESSO_CHECKOUT'; |
|
32 | + } |
|
33 | + |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * the time in seconds to cache the results of the processShortcode() method |
|
38 | + * 0 means the processShortcode() results will NOT be cached at all |
|
39 | + * |
|
40 | + * @return int |
|
41 | + */ |
|
42 | + public function cacheExpiration() |
|
43 | + { |
|
44 | + return 0; |
|
45 | + } |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
50 | + * this may be required for shortcodes that utilize a corresponding module, |
|
51 | + * and need to enqueue assets for that module |
|
52 | + * |
|
53 | + * @return void |
|
54 | + * @throws \EE_Error |
|
55 | + */ |
|
56 | + public function initializeShortcode() |
|
57 | + { |
|
58 | + global $wp_query; |
|
59 | + EED_Single_Page_Checkout::init($wp_query); |
|
60 | + $this->shortcodeHasBeenInitialized(); |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * callback that runs when the shortcode is encountered in post content. |
|
67 | + * IMPORTANT !!! |
|
68 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
69 | + * |
|
70 | + * @param array $attributes |
|
71 | + * @return string |
|
72 | + */ |
|
73 | + public function processShortcode($attributes = array()) |
|
74 | + { |
|
75 | + return EE_Registry::instance()->REQ->get_output(); |
|
76 | + } |
|
77 | 77 | |
78 | 78 | |
79 | 79 |
@@ -27,92 +27,92 @@ |
||
27 | 27 | |
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * the actual shortcode tag that gets registered with WordPress |
|
32 | - * |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public function getTag() |
|
36 | - { |
|
37 | - return 'ESPRESSO_TXN_PAGE'; |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * the time in seconds to cache the results of the processShortcode() method |
|
44 | - * 0 means the processShortcode() results will NOT be cached at all |
|
45 | - * |
|
46 | - * @return int |
|
47 | - */ |
|
48 | - public function cacheExpiration() |
|
49 | - { |
|
50 | - return 0; |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
56 | - * this may be required for shortcodes that utilize a corresponding module, |
|
57 | - * and need to enqueue assets for that module |
|
58 | - * |
|
59 | - * @return void |
|
60 | - * @throws \Exception |
|
61 | - * @throws \EE_Error |
|
62 | - */ |
|
63 | - public function initializeShortcode() |
|
64 | - { |
|
65 | - $transaction = null; |
|
66 | - if (EE_Registry::instance()->REQ->is_set('e_reg_url_link')) { |
|
67 | - /** @var EEM_Transaction $EEM_Transaction */ |
|
68 | - $EEM_Transaction = EE_Registry::instance()->load_model('Transaction'); |
|
69 | - $transaction = $EEM_Transaction->get_transaction_from_reg_url_link(); |
|
70 | - } |
|
71 | - if ($transaction instanceof EE_Transaction) { |
|
72 | - $payment_method = null; |
|
73 | - $payment_method_slug = EE_Registry::instance()->REQ->get('ee_payment_method', null); |
|
74 | - if ($payment_method_slug) { |
|
75 | - $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($payment_method_slug); |
|
76 | - } |
|
77 | - if ($payment_method instanceof EE_Payment_Method && $payment_method->is_off_site()) { |
|
78 | - $gateway = $payment_method->type_obj()->get_gateway(); |
|
79 | - if ( |
|
80 | - $gateway instanceof EE_Offsite_Gateway |
|
81 | - && $gateway->handle_IPN_in_this_request( |
|
82 | - \EE_Registry::instance()->REQ->params(), |
|
83 | - true |
|
84 | - ) |
|
85 | - ) { |
|
86 | - /** @type EE_Payment_Processor $payment_processor */ |
|
87 | - $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
88 | - $payment_processor->process_ipn($_REQUEST, $transaction, $payment_method); |
|
89 | - } |
|
90 | - } |
|
91 | - //allow gateways to add a filter to stop rendering the page |
|
92 | - if (apply_filters('FHEE__EES_Espresso_Txn_Page__run__exit', false)) { |
|
93 | - exit; |
|
94 | - } |
|
95 | - } |
|
96 | - $this->shortcodeHasBeenInitialized(); |
|
97 | - } |
|
98 | - |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * callback that runs when the shortcode is encountered in post content. |
|
103 | - * IMPORTANT !!! |
|
104 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
105 | - * |
|
106 | - * @param array $attributes |
|
107 | - * @return string |
|
108 | - */ |
|
109 | - public function processShortcode($attributes = array()) |
|
110 | - { |
|
111 | - return esc_html__( |
|
112 | - 'This is the Event Espresso Transactions page. This page receives instant payment notification (IPN) requests and should have a status of published, but should not be easily accessible by site visitors. Do not add it to your website\'s navigation menu or link to it from another page. Also, do not delete it or change its status to private.', |
|
113 | - 'event_espresso' |
|
114 | - ); |
|
115 | - } |
|
30 | + /** |
|
31 | + * the actual shortcode tag that gets registered with WordPress |
|
32 | + * |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public function getTag() |
|
36 | + { |
|
37 | + return 'ESPRESSO_TXN_PAGE'; |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * the time in seconds to cache the results of the processShortcode() method |
|
44 | + * 0 means the processShortcode() results will NOT be cached at all |
|
45 | + * |
|
46 | + * @return int |
|
47 | + */ |
|
48 | + public function cacheExpiration() |
|
49 | + { |
|
50 | + return 0; |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
56 | + * this may be required for shortcodes that utilize a corresponding module, |
|
57 | + * and need to enqueue assets for that module |
|
58 | + * |
|
59 | + * @return void |
|
60 | + * @throws \Exception |
|
61 | + * @throws \EE_Error |
|
62 | + */ |
|
63 | + public function initializeShortcode() |
|
64 | + { |
|
65 | + $transaction = null; |
|
66 | + if (EE_Registry::instance()->REQ->is_set('e_reg_url_link')) { |
|
67 | + /** @var EEM_Transaction $EEM_Transaction */ |
|
68 | + $EEM_Transaction = EE_Registry::instance()->load_model('Transaction'); |
|
69 | + $transaction = $EEM_Transaction->get_transaction_from_reg_url_link(); |
|
70 | + } |
|
71 | + if ($transaction instanceof EE_Transaction) { |
|
72 | + $payment_method = null; |
|
73 | + $payment_method_slug = EE_Registry::instance()->REQ->get('ee_payment_method', null); |
|
74 | + if ($payment_method_slug) { |
|
75 | + $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($payment_method_slug); |
|
76 | + } |
|
77 | + if ($payment_method instanceof EE_Payment_Method && $payment_method->is_off_site()) { |
|
78 | + $gateway = $payment_method->type_obj()->get_gateway(); |
|
79 | + if ( |
|
80 | + $gateway instanceof EE_Offsite_Gateway |
|
81 | + && $gateway->handle_IPN_in_this_request( |
|
82 | + \EE_Registry::instance()->REQ->params(), |
|
83 | + true |
|
84 | + ) |
|
85 | + ) { |
|
86 | + /** @type EE_Payment_Processor $payment_processor */ |
|
87 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
88 | + $payment_processor->process_ipn($_REQUEST, $transaction, $payment_method); |
|
89 | + } |
|
90 | + } |
|
91 | + //allow gateways to add a filter to stop rendering the page |
|
92 | + if (apply_filters('FHEE__EES_Espresso_Txn_Page__run__exit', false)) { |
|
93 | + exit; |
|
94 | + } |
|
95 | + } |
|
96 | + $this->shortcodeHasBeenInitialized(); |
|
97 | + } |
|
98 | + |
|
99 | + |
|
100 | + |
|
101 | + /** |
|
102 | + * callback that runs when the shortcode is encountered in post content. |
|
103 | + * IMPORTANT !!! |
|
104 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
105 | + * |
|
106 | + * @param array $attributes |
|
107 | + * @return string |
|
108 | + */ |
|
109 | + public function processShortcode($attributes = array()) |
|
110 | + { |
|
111 | + return esc_html__( |
|
112 | + 'This is the Event Espresso Transactions page. This page receives instant payment notification (IPN) requests and should have a status of published, but should not be easily accessible by site visitors. Do not add it to your website\'s navigation menu or link to it from another page. Also, do not delete it or change its status to private.', |
|
113 | + 'event_espresso' |
|
114 | + ); |
|
115 | + } |
|
116 | 116 | } |
117 | 117 | // End of file EspressoTxnPage.php |
118 | 118 | // Location: EventEspresso\core\domain\entities\shortcodes/EspressoTxnPage.php |
119 | 119 | \ No newline at end of file |
@@ -20,75 +20,75 @@ |
||
20 | 20 | class EspressoThankYou extends EspressoShortcode |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @var boolean $is_thank_you_page |
|
25 | - */ |
|
26 | - private $is_thank_you_page = false; |
|
27 | - |
|
28 | - /** |
|
29 | - * the actual shortcode tag that gets registered with WordPress |
|
30 | - * |
|
31 | - * @return string |
|
32 | - */ |
|
33 | - public function getTag() |
|
34 | - { |
|
35 | - return 'ESPRESSO_THANK_YOU'; |
|
36 | - } |
|
37 | - |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * the time in seconds to cache the results of the processShortcode() method |
|
42 | - * 0 means the processShortcode() results will NOT be cached at all |
|
43 | - * |
|
44 | - * @return int |
|
45 | - */ |
|
46 | - public function cacheExpiration() |
|
47 | - { |
|
48 | - return 0; |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
54 | - * this may be required for shortcodes that utilize a corresponding module, |
|
55 | - * and need to enqueue assets for that module |
|
56 | - * |
|
57 | - * @return void |
|
58 | - * @throws \EE_Error |
|
59 | - */ |
|
60 | - public function initializeShortcode() |
|
61 | - { |
|
62 | - global $wp_query; |
|
63 | - if (empty($wp_query->posts) || count($wp_query->posts) > 1) { |
|
64 | - return; |
|
65 | - } |
|
66 | - $post = reset($wp_query->posts); |
|
67 | - if ( ! $post instanceof WP_Post || $post->ID !== EE_Registry::instance()->CFG->core->thank_you_page_id ) { |
|
68 | - return; |
|
69 | - } |
|
70 | - $this->is_thank_you_page = true; |
|
71 | - \EED_Thank_You_Page::instance()->load_resources(); |
|
72 | - $this->shortcodeHasBeenInitialized(); |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * callback that runs when the shortcode is encountered in post content. |
|
79 | - * IMPORTANT !!! |
|
80 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
81 | - * |
|
82 | - * @param array $attributes |
|
83 | - * @return string |
|
84 | - * @throws \EE_Error |
|
85 | - */ |
|
86 | - public function processShortcode($attributes = array()) |
|
87 | - { |
|
88 | - return $this->is_thank_you_page |
|
89 | - ? \EED_Thank_You_Page::instance()->thank_you_page_results() |
|
90 | - : ''; |
|
91 | - } |
|
23 | + /** |
|
24 | + * @var boolean $is_thank_you_page |
|
25 | + */ |
|
26 | + private $is_thank_you_page = false; |
|
27 | + |
|
28 | + /** |
|
29 | + * the actual shortcode tag that gets registered with WordPress |
|
30 | + * |
|
31 | + * @return string |
|
32 | + */ |
|
33 | + public function getTag() |
|
34 | + { |
|
35 | + return 'ESPRESSO_THANK_YOU'; |
|
36 | + } |
|
37 | + |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * the time in seconds to cache the results of the processShortcode() method |
|
42 | + * 0 means the processShortcode() results will NOT be cached at all |
|
43 | + * |
|
44 | + * @return int |
|
45 | + */ |
|
46 | + public function cacheExpiration() |
|
47 | + { |
|
48 | + return 0; |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
54 | + * this may be required for shortcodes that utilize a corresponding module, |
|
55 | + * and need to enqueue assets for that module |
|
56 | + * |
|
57 | + * @return void |
|
58 | + * @throws \EE_Error |
|
59 | + */ |
|
60 | + public function initializeShortcode() |
|
61 | + { |
|
62 | + global $wp_query; |
|
63 | + if (empty($wp_query->posts) || count($wp_query->posts) > 1) { |
|
64 | + return; |
|
65 | + } |
|
66 | + $post = reset($wp_query->posts); |
|
67 | + if ( ! $post instanceof WP_Post || $post->ID !== EE_Registry::instance()->CFG->core->thank_you_page_id ) { |
|
68 | + return; |
|
69 | + } |
|
70 | + $this->is_thank_you_page = true; |
|
71 | + \EED_Thank_You_Page::instance()->load_resources(); |
|
72 | + $this->shortcodeHasBeenInitialized(); |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * callback that runs when the shortcode is encountered in post content. |
|
79 | + * IMPORTANT !!! |
|
80 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
81 | + * |
|
82 | + * @param array $attributes |
|
83 | + * @return string |
|
84 | + * @throws \EE_Error |
|
85 | + */ |
|
86 | + public function processShortcode($attributes = array()) |
|
87 | + { |
|
88 | + return $this->is_thank_you_page |
|
89 | + ? \EED_Thank_You_Page::instance()->thank_you_page_results() |
|
90 | + : ''; |
|
91 | + } |
|
92 | 92 | |
93 | 93 | |
94 | 94 |
@@ -34,134 +34,134 @@ |
||
34 | 34 | |
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * the actual shortcode tag that gets registered with WordPress |
|
39 | - * |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - public function getTag() |
|
43 | - { |
|
44 | - return 'ESPRESSO_EVENTS'; |
|
45 | - } |
|
46 | - |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * the time in seconds to cache the results of the processShortcode() method |
|
51 | - * 0 means the processShortcode() results will NOT be cached at all |
|
52 | - * |
|
53 | - * @return int |
|
54 | - */ |
|
55 | - public function cacheExpiration() |
|
56 | - { |
|
57 | - return MINUTE_IN_SECONDS * 15; |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * a place for adding any initialization code that needs to run prior to wp_header(). |
|
64 | - * this may be required for shortcodes that utilize a corresponding module, |
|
65 | - * and need to enqueue assets for that module |
|
66 | - * |
|
67 | - * @return void |
|
68 | - */ |
|
69 | - public function initializeShortcode() |
|
70 | - { |
|
71 | - EED_Events_Archive::instance()->event_list(); |
|
72 | - $this->shortcodeHasBeenInitialized(); |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * callback that runs when the shortcode is encountered in post content. |
|
79 | - * IMPORTANT !!! |
|
80 | - * remember that shortcode content should be RETURNED and NOT echoed out |
|
81 | - * |
|
82 | - * @param array $attributes |
|
83 | - * @return string |
|
84 | - */ |
|
85 | - public function processShortcode($attributes = array()) |
|
86 | - { |
|
87 | - // grab attributes and merge with defaults |
|
88 | - $attributes = $this->getAttributes($attributes); |
|
89 | - // make sure we use the_excerpt() |
|
90 | - add_filter('FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true'); |
|
91 | - // apply query filters |
|
92 | - add_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
93 | - // run the query |
|
94 | - global $wp_query; |
|
95 | - // yes we have to overwrite the main wp query, but it's ok... |
|
96 | - // we're going to reset it again below, so everything will be Hunky Dory (amazing album) |
|
97 | - $wp_query = new EventListQuery($attributes); |
|
98 | - // check what template is loaded and load filters accordingly |
|
99 | - EED_Events_Archive::instance()->template_include('loop-espresso_events.php'); |
|
100 | - // load our template |
|
101 | - $event_list = EEH_Template::locate_template('loop-espresso_events.php', array(), true, true); |
|
102 | - // now reset the query and postdata |
|
103 | - wp_reset_query(); |
|
104 | - wp_reset_postdata(); |
|
105 | - EED_Events_Archive::remove_all_events_archive_filters(); |
|
106 | - // remove query filters |
|
107 | - remove_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
108 | - // pull our content from the output buffer and return it |
|
109 | - return $event_list; |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * merge incoming attributes with filtered defaults |
|
116 | - * |
|
117 | - * @param array $attributes |
|
118 | - * @return array |
|
119 | - */ |
|
120 | - private function getAttributes(array $attributes) |
|
121 | - { |
|
122 | - return array_merge( |
|
123 | - (array)apply_filters( |
|
124 | - 'EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts', |
|
125 | - array( |
|
126 | - 'title' => '', |
|
127 | - 'limit' => 10, |
|
128 | - 'css_class' => '', |
|
129 | - 'show_expired' => false, |
|
130 | - 'month' => '', |
|
131 | - 'category_slug' => '', |
|
132 | - 'order_by' => 'start_date', |
|
133 | - 'sort' => 'ASC', |
|
134 | - 'show_title' => true, |
|
135 | - ) |
|
136 | - ), |
|
137 | - $attributes |
|
138 | - ); |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * array for defining custom attribute sanitization callbacks, |
|
145 | - * where keys match keys in your attributes array, |
|
146 | - * and values represent the sanitization function you wish to be applied to that attribute. |
|
147 | - * So for example, if you had an integer attribute named "event_id" |
|
148 | - * that you wanted to be sanitized using absint(), |
|
149 | - * then you would pass the following for your $custom_sanitization array: |
|
150 | - * array('event_id' => 'absint') |
|
151 | - * |
|
152 | - * @return array |
|
153 | - */ |
|
154 | - protected function customAttributeSanitizationMap() |
|
155 | - { |
|
156 | - // the following get sanitized/whitelisted in EEH_Event_Query |
|
157 | - return array( |
|
158 | - 'category_slug' => 'skip_sanitization', |
|
159 | - 'show_expired' => 'skip_sanitization', |
|
160 | - 'order_by' => 'skip_sanitization', |
|
161 | - 'month' => 'skip_sanitization', |
|
162 | - 'sort' => 'skip_sanitization', |
|
163 | - ); |
|
164 | - } |
|
37 | + /** |
|
38 | + * the actual shortcode tag that gets registered with WordPress |
|
39 | + * |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + public function getTag() |
|
43 | + { |
|
44 | + return 'ESPRESSO_EVENTS'; |
|
45 | + } |
|
46 | + |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * the time in seconds to cache the results of the processShortcode() method |
|
51 | + * 0 means the processShortcode() results will NOT be cached at all |
|
52 | + * |
|
53 | + * @return int |
|
54 | + */ |
|
55 | + public function cacheExpiration() |
|
56 | + { |
|
57 | + return MINUTE_IN_SECONDS * 15; |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * a place for adding any initialization code that needs to run prior to wp_header(). |
|
64 | + * this may be required for shortcodes that utilize a corresponding module, |
|
65 | + * and need to enqueue assets for that module |
|
66 | + * |
|
67 | + * @return void |
|
68 | + */ |
|
69 | + public function initializeShortcode() |
|
70 | + { |
|
71 | + EED_Events_Archive::instance()->event_list(); |
|
72 | + $this->shortcodeHasBeenInitialized(); |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * callback that runs when the shortcode is encountered in post content. |
|
79 | + * IMPORTANT !!! |
|
80 | + * remember that shortcode content should be RETURNED and NOT echoed out |
|
81 | + * |
|
82 | + * @param array $attributes |
|
83 | + * @return string |
|
84 | + */ |
|
85 | + public function processShortcode($attributes = array()) |
|
86 | + { |
|
87 | + // grab attributes and merge with defaults |
|
88 | + $attributes = $this->getAttributes($attributes); |
|
89 | + // make sure we use the_excerpt() |
|
90 | + add_filter('FHEE__EES_Espresso_Events__process_shortcode__true', '__return_true'); |
|
91 | + // apply query filters |
|
92 | + add_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
93 | + // run the query |
|
94 | + global $wp_query; |
|
95 | + // yes we have to overwrite the main wp query, but it's ok... |
|
96 | + // we're going to reset it again below, so everything will be Hunky Dory (amazing album) |
|
97 | + $wp_query = new EventListQuery($attributes); |
|
98 | + // check what template is loaded and load filters accordingly |
|
99 | + EED_Events_Archive::instance()->template_include('loop-espresso_events.php'); |
|
100 | + // load our template |
|
101 | + $event_list = EEH_Template::locate_template('loop-espresso_events.php', array(), true, true); |
|
102 | + // now reset the query and postdata |
|
103 | + wp_reset_query(); |
|
104 | + wp_reset_postdata(); |
|
105 | + EED_Events_Archive::remove_all_events_archive_filters(); |
|
106 | + // remove query filters |
|
107 | + remove_filter('FHEE__EEH_Event_Query__apply_query_filters', '__return_true'); |
|
108 | + // pull our content from the output buffer and return it |
|
109 | + return $event_list; |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * merge incoming attributes with filtered defaults |
|
116 | + * |
|
117 | + * @param array $attributes |
|
118 | + * @return array |
|
119 | + */ |
|
120 | + private function getAttributes(array $attributes) |
|
121 | + { |
|
122 | + return array_merge( |
|
123 | + (array)apply_filters( |
|
124 | + 'EES_Espresso_Events__process_shortcode__default_espresso_events_shortcode_atts', |
|
125 | + array( |
|
126 | + 'title' => '', |
|
127 | + 'limit' => 10, |
|
128 | + 'css_class' => '', |
|
129 | + 'show_expired' => false, |
|
130 | + 'month' => '', |
|
131 | + 'category_slug' => '', |
|
132 | + 'order_by' => 'start_date', |
|
133 | + 'sort' => 'ASC', |
|
134 | + 'show_title' => true, |
|
135 | + ) |
|
136 | + ), |
|
137 | + $attributes |
|
138 | + ); |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * array for defining custom attribute sanitization callbacks, |
|
145 | + * where keys match keys in your attributes array, |
|
146 | + * and values represent the sanitization function you wish to be applied to that attribute. |
|
147 | + * So for example, if you had an integer attribute named "event_id" |
|
148 | + * that you wanted to be sanitized using absint(), |
|
149 | + * then you would pass the following for your $custom_sanitization array: |
|
150 | + * array('event_id' => 'absint') |
|
151 | + * |
|
152 | + * @return array |
|
153 | + */ |
|
154 | + protected function customAttributeSanitizationMap() |
|
155 | + { |
|
156 | + // the following get sanitized/whitelisted in EEH_Event_Query |
|
157 | + return array( |
|
158 | + 'category_slug' => 'skip_sanitization', |
|
159 | + 'show_expired' => 'skip_sanitization', |
|
160 | + 'order_by' => 'skip_sanitization', |
|
161 | + 'month' => 'skip_sanitization', |
|
162 | + 'sort' => 'skip_sanitization', |
|
163 | + ); |
|
164 | + } |
|
165 | 165 | |
166 | 166 | |
167 | 167 |