@@ -14,280 +14,280 @@ |
||
14 | 14 | class EEH_URL |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * _add_query_arg |
|
19 | - * adds nonce to array of arguments then calls WP add_query_arg function |
|
20 | - * |
|
21 | - * @access public |
|
22 | - * @param array $args |
|
23 | - * @param string $url |
|
24 | - * @param bool $exclude_nonce If true then the nonce will be excluded from the generated url. |
|
25 | - * @return string |
|
26 | - */ |
|
27 | - public static function add_query_args_and_nonce($args = [], $url = '', $exclude_nonce = false) |
|
28 | - { |
|
29 | - // check that an action exists and add nonce |
|
30 | - if (! $exclude_nonce) { |
|
31 | - if (isset($args['action']) && ! empty($args['action'])) { |
|
32 | - $args = array_merge( |
|
33 | - $args, |
|
34 | - [ |
|
35 | - $args['action'] . '_nonce' => wp_create_nonce($args['action'] . '_nonce'), |
|
36 | - ] |
|
37 | - ); |
|
38 | - } else { |
|
39 | - $args = array_merge( |
|
40 | - $args, |
|
41 | - [ |
|
42 | - 'action' => 'default', |
|
43 | - 'default_nonce' => wp_create_nonce('default_nonce'), |
|
44 | - ] |
|
45 | - ); |
|
46 | - } |
|
47 | - } |
|
17 | + /** |
|
18 | + * _add_query_arg |
|
19 | + * adds nonce to array of arguments then calls WP add_query_arg function |
|
20 | + * |
|
21 | + * @access public |
|
22 | + * @param array $args |
|
23 | + * @param string $url |
|
24 | + * @param bool $exclude_nonce If true then the nonce will be excluded from the generated url. |
|
25 | + * @return string |
|
26 | + */ |
|
27 | + public static function add_query_args_and_nonce($args = [], $url = '', $exclude_nonce = false) |
|
28 | + { |
|
29 | + // check that an action exists and add nonce |
|
30 | + if (! $exclude_nonce) { |
|
31 | + if (isset($args['action']) && ! empty($args['action'])) { |
|
32 | + $args = array_merge( |
|
33 | + $args, |
|
34 | + [ |
|
35 | + $args['action'] . '_nonce' => wp_create_nonce($args['action'] . '_nonce'), |
|
36 | + ] |
|
37 | + ); |
|
38 | + } else { |
|
39 | + $args = array_merge( |
|
40 | + $args, |
|
41 | + [ |
|
42 | + 'action' => 'default', |
|
43 | + 'default_nonce' => wp_create_nonce('default_nonce'), |
|
44 | + ] |
|
45 | + ); |
|
46 | + } |
|
47 | + } |
|
48 | 48 | |
49 | - $action = EEH_URL::getRequest()->getRequestParam('action', ''); |
|
50 | - // finally, let's always add a return address (if present) :) |
|
51 | - if ($action !== '') { |
|
52 | - $args['return'] = $action; |
|
53 | - } |
|
49 | + $action = EEH_URL::getRequest()->getRequestParam('action', ''); |
|
50 | + // finally, let's always add a return address (if present) :) |
|
51 | + if ($action !== '') { |
|
52 | + $args['return'] = $action; |
|
53 | + } |
|
54 | 54 | |
55 | - return add_query_arg($args, $url); |
|
56 | - } |
|
55 | + return add_query_arg($args, $url); |
|
56 | + } |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * Returns whether not the remote file exists. |
|
61 | - * Checking via GET because HEAD requests are blocked on some server configurations. |
|
62 | - * |
|
63 | - * @param string $url |
|
64 | - * @param array $args the arguments that should be passed through to the wp_remote_request call. |
|
65 | - * @return boolean |
|
66 | - */ |
|
67 | - public static function remote_file_exists($url, $args = []) |
|
68 | - { |
|
69 | - $results = wp_remote_request( |
|
70 | - $url, |
|
71 | - array_merge( |
|
72 | - [ |
|
73 | - 'method' => 'GET', |
|
74 | - 'redirection' => 1, |
|
75 | - ], |
|
76 | - $args |
|
77 | - ) |
|
78 | - ); |
|
79 | - return ! $results instanceof WP_Error |
|
80 | - && isset($results['response']['code']) |
|
81 | - && $results['response']['code'] == '200'; |
|
82 | - } |
|
59 | + /** |
|
60 | + * Returns whether not the remote file exists. |
|
61 | + * Checking via GET because HEAD requests are blocked on some server configurations. |
|
62 | + * |
|
63 | + * @param string $url |
|
64 | + * @param array $args the arguments that should be passed through to the wp_remote_request call. |
|
65 | + * @return boolean |
|
66 | + */ |
|
67 | + public static function remote_file_exists($url, $args = []) |
|
68 | + { |
|
69 | + $results = wp_remote_request( |
|
70 | + $url, |
|
71 | + array_merge( |
|
72 | + [ |
|
73 | + 'method' => 'GET', |
|
74 | + 'redirection' => 1, |
|
75 | + ], |
|
76 | + $args |
|
77 | + ) |
|
78 | + ); |
|
79 | + return ! $results instanceof WP_Error |
|
80 | + && isset($results['response']['code']) |
|
81 | + && $results['response']['code'] == '200'; |
|
82 | + } |
|
83 | 83 | |
84 | 84 | |
85 | - /** |
|
86 | - * refactor_url |
|
87 | - * primarily used for removing the query string from a URL |
|
88 | - * |
|
89 | - * @param string $url |
|
90 | - * @param bool $remove_query - TRUE (default) will strip off any URL params, ie: ?this=1&that=2 |
|
91 | - * @param bool $base_url_only - TRUE will only return the scheme and host with no other parameters |
|
92 | - * @return string |
|
93 | - */ |
|
94 | - public static function refactor_url($url = '', $remove_query = true, $base_url_only = false) |
|
95 | - { |
|
96 | - // break apart incoming URL |
|
97 | - $url_bits = parse_url($url); |
|
98 | - // HTTP or HTTPS ? |
|
99 | - $scheme = isset($url_bits['scheme']) ? $url_bits['scheme'] . '://' : 'https://'; |
|
100 | - // domain |
|
101 | - $host = isset($url_bits['host']) ? $url_bits['host'] : ''; |
|
102 | - // if only the base URL is requested, then return that now |
|
103 | - if ($base_url_only) { |
|
104 | - return $scheme . $host; |
|
105 | - } |
|
106 | - $port = isset($url_bits['port']) ? ':' . $url_bits['port'] : ''; |
|
107 | - $user = isset($url_bits['user']) ? $url_bits['user'] : ''; |
|
108 | - $pass = isset($url_bits['pass']) ? ':' . $url_bits['pass'] : ''; |
|
109 | - $pass = ($user || $pass) ? $pass . '@' : ''; |
|
110 | - $path = isset($url_bits['path']) ? $url_bits['path'] : ''; |
|
111 | - // if the query string is not required, then return what we have so far |
|
112 | - if ($remove_query) { |
|
113 | - return $scheme . $user . $pass . $host . $port . $path; |
|
114 | - } |
|
115 | - $query = isset($url_bits['query']) ? '?' . $url_bits['query'] : ''; |
|
116 | - $fragment = isset($url_bits['fragment']) ? '#' . $url_bits['fragment'] : ''; |
|
117 | - return $scheme . $user . $pass . $host . $port . $path . $query . $fragment; |
|
118 | - } |
|
85 | + /** |
|
86 | + * refactor_url |
|
87 | + * primarily used for removing the query string from a URL |
|
88 | + * |
|
89 | + * @param string $url |
|
90 | + * @param bool $remove_query - TRUE (default) will strip off any URL params, ie: ?this=1&that=2 |
|
91 | + * @param bool $base_url_only - TRUE will only return the scheme and host with no other parameters |
|
92 | + * @return string |
|
93 | + */ |
|
94 | + public static function refactor_url($url = '', $remove_query = true, $base_url_only = false) |
|
95 | + { |
|
96 | + // break apart incoming URL |
|
97 | + $url_bits = parse_url($url); |
|
98 | + // HTTP or HTTPS ? |
|
99 | + $scheme = isset($url_bits['scheme']) ? $url_bits['scheme'] . '://' : 'https://'; |
|
100 | + // domain |
|
101 | + $host = isset($url_bits['host']) ? $url_bits['host'] : ''; |
|
102 | + // if only the base URL is requested, then return that now |
|
103 | + if ($base_url_only) { |
|
104 | + return $scheme . $host; |
|
105 | + } |
|
106 | + $port = isset($url_bits['port']) ? ':' . $url_bits['port'] : ''; |
|
107 | + $user = isset($url_bits['user']) ? $url_bits['user'] : ''; |
|
108 | + $pass = isset($url_bits['pass']) ? ':' . $url_bits['pass'] : ''; |
|
109 | + $pass = ($user || $pass) ? $pass . '@' : ''; |
|
110 | + $path = isset($url_bits['path']) ? $url_bits['path'] : ''; |
|
111 | + // if the query string is not required, then return what we have so far |
|
112 | + if ($remove_query) { |
|
113 | + return $scheme . $user . $pass . $host . $port . $path; |
|
114 | + } |
|
115 | + $query = isset($url_bits['query']) ? '?' . $url_bits['query'] : ''; |
|
116 | + $fragment = isset($url_bits['fragment']) ? '#' . $url_bits['fragment'] : ''; |
|
117 | + return $scheme . $user . $pass . $host . $port . $path . $query . $fragment; |
|
118 | + } |
|
119 | 119 | |
120 | 120 | |
121 | - /** |
|
122 | - * get_query_string |
|
123 | - * returns just the query string from a URL, formatted by default into an array of key value pairs |
|
124 | - * |
|
125 | - * @param string $url |
|
126 | - * @param bool $as_array TRUE (default) will return query params as an array of key value pairs, FALSE will |
|
127 | - * simply return the query string |
|
128 | - * @return string|array |
|
129 | - */ |
|
130 | - public static function get_query_string($url = '', $as_array = true) |
|
131 | - { |
|
132 | - // decode, then break apart incoming URL |
|
133 | - $url_bits = parse_url(html_entity_decode($url)); |
|
134 | - // grab query string from URL |
|
135 | - $query = isset($url_bits['query']) ? $url_bits['query'] : ''; |
|
136 | - // if we don't want the query string formatted into an array of key => value pairs, then just return it as is |
|
137 | - if (! $as_array) { |
|
138 | - return $query; |
|
139 | - } |
|
140 | - // if no query string exists then just return an empty array now |
|
141 | - if (empty($query)) { |
|
142 | - return []; |
|
143 | - } |
|
144 | - // empty array to hold results |
|
145 | - $query_params = []; |
|
146 | - // now break apart the query string into separate params |
|
147 | - $query = explode('&', $query); |
|
148 | - // loop thru our query params |
|
149 | - foreach ($query as $query_args) { |
|
150 | - // break apart the key value pairs |
|
151 | - $query_args = explode('=', $query_args); |
|
152 | - // and add to our results array |
|
153 | - $query_params[ $query_args[0] ] = $query_args[1]; |
|
154 | - } |
|
155 | - return $query_params; |
|
156 | - } |
|
121 | + /** |
|
122 | + * get_query_string |
|
123 | + * returns just the query string from a URL, formatted by default into an array of key value pairs |
|
124 | + * |
|
125 | + * @param string $url |
|
126 | + * @param bool $as_array TRUE (default) will return query params as an array of key value pairs, FALSE will |
|
127 | + * simply return the query string |
|
128 | + * @return string|array |
|
129 | + */ |
|
130 | + public static function get_query_string($url = '', $as_array = true) |
|
131 | + { |
|
132 | + // decode, then break apart incoming URL |
|
133 | + $url_bits = parse_url(html_entity_decode($url)); |
|
134 | + // grab query string from URL |
|
135 | + $query = isset($url_bits['query']) ? $url_bits['query'] : ''; |
|
136 | + // if we don't want the query string formatted into an array of key => value pairs, then just return it as is |
|
137 | + if (! $as_array) { |
|
138 | + return $query; |
|
139 | + } |
|
140 | + // if no query string exists then just return an empty array now |
|
141 | + if (empty($query)) { |
|
142 | + return []; |
|
143 | + } |
|
144 | + // empty array to hold results |
|
145 | + $query_params = []; |
|
146 | + // now break apart the query string into separate params |
|
147 | + $query = explode('&', $query); |
|
148 | + // loop thru our query params |
|
149 | + foreach ($query as $query_args) { |
|
150 | + // break apart the key value pairs |
|
151 | + $query_args = explode('=', $query_args); |
|
152 | + // and add to our results array |
|
153 | + $query_params[ $query_args[0] ] = $query_args[1]; |
|
154 | + } |
|
155 | + return $query_params; |
|
156 | + } |
|
157 | 157 | |
158 | 158 | |
159 | - /** |
|
160 | - * prevent_prefetching |
|
161 | - * |
|
162 | - * @return void |
|
163 | - */ |
|
164 | - public static function prevent_prefetching() |
|
165 | - { |
|
166 | - // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes |
|
167 | - // with the registration process |
|
168 | - remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
169 | - } |
|
159 | + /** |
|
160 | + * prevent_prefetching |
|
161 | + * |
|
162 | + * @return void |
|
163 | + */ |
|
164 | + public static function prevent_prefetching() |
|
165 | + { |
|
166 | + // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes |
|
167 | + // with the registration process |
|
168 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
169 | + } |
|
170 | 170 | |
171 | 171 | |
172 | - /** |
|
173 | - * This generates a unique site-specific string. |
|
174 | - * An example usage for this string would be to save as a unique identifier for a record in the db for usage in |
|
175 | - * urls. |
|
176 | - * |
|
177 | - * @param string $prefix Use this to prefix the string with something. |
|
178 | - * @return string |
|
179 | - */ |
|
180 | - public static function generate_unique_token($prefix = '') |
|
181 | - { |
|
182 | - $token = md5(uniqid() . mt_rand()); |
|
183 | - return $prefix ? $prefix . '_' . $token : $token; |
|
184 | - } |
|
172 | + /** |
|
173 | + * This generates a unique site-specific string. |
|
174 | + * An example usage for this string would be to save as a unique identifier for a record in the db for usage in |
|
175 | + * urls. |
|
176 | + * |
|
177 | + * @param string $prefix Use this to prefix the string with something. |
|
178 | + * @return string |
|
179 | + */ |
|
180 | + public static function generate_unique_token($prefix = '') |
|
181 | + { |
|
182 | + $token = md5(uniqid() . mt_rand()); |
|
183 | + return $prefix ? $prefix . '_' . $token : $token; |
|
184 | + } |
|
185 | 185 | |
186 | 186 | |
187 | - /** |
|
188 | - * filter_input_server_url |
|
189 | - * uses filter_input() to sanitize one of the INPUT_SERVER URL values |
|
190 | - * but adds a backup in case filter_input() returns nothing, which can erringly happen on some servers |
|
191 | - * |
|
192 | - * @param string $server_variable |
|
193 | - * @return string |
|
194 | - */ |
|
195 | - public static function filter_input_server_url($server_variable = 'REQUEST_URI') |
|
196 | - { |
|
197 | - $URL = ''; |
|
198 | - $server_variables = [ |
|
199 | - 'REQUEST_URI' => 1, |
|
200 | - 'HTTP_HOST' => 1, |
|
201 | - 'PHP_SELF' => 1, |
|
202 | - ]; |
|
203 | - $server_variable = strtoupper($server_variable); |
|
204 | - // whitelist INPUT_SERVER var |
|
205 | - if (isset($server_variables[ $server_variable ])) { |
|
206 | - $URL = filter_input(INPUT_SERVER, $server_variable, FILTER_SANITIZE_URL, FILTER_NULL_ON_FAILURE); |
|
207 | - if (empty($URL) || $URL !== $_SERVER[ $server_variable ]) { |
|
208 | - // fallback sanitization if the above fails or URL has changed after filtering |
|
209 | - $URL = wp_sanitize_redirect($_SERVER[ $server_variable ]); |
|
210 | - } |
|
211 | - } |
|
212 | - return $URL; |
|
213 | - } |
|
187 | + /** |
|
188 | + * filter_input_server_url |
|
189 | + * uses filter_input() to sanitize one of the INPUT_SERVER URL values |
|
190 | + * but adds a backup in case filter_input() returns nothing, which can erringly happen on some servers |
|
191 | + * |
|
192 | + * @param string $server_variable |
|
193 | + * @return string |
|
194 | + */ |
|
195 | + public static function filter_input_server_url($server_variable = 'REQUEST_URI') |
|
196 | + { |
|
197 | + $URL = ''; |
|
198 | + $server_variables = [ |
|
199 | + 'REQUEST_URI' => 1, |
|
200 | + 'HTTP_HOST' => 1, |
|
201 | + 'PHP_SELF' => 1, |
|
202 | + ]; |
|
203 | + $server_variable = strtoupper($server_variable); |
|
204 | + // whitelist INPUT_SERVER var |
|
205 | + if (isset($server_variables[ $server_variable ])) { |
|
206 | + $URL = filter_input(INPUT_SERVER, $server_variable, FILTER_SANITIZE_URL, FILTER_NULL_ON_FAILURE); |
|
207 | + if (empty($URL) || $URL !== $_SERVER[ $server_variable ]) { |
|
208 | + // fallback sanitization if the above fails or URL has changed after filtering |
|
209 | + $URL = wp_sanitize_redirect($_SERVER[ $server_variable ]); |
|
210 | + } |
|
211 | + } |
|
212 | + return $URL; |
|
213 | + } |
|
214 | 214 | |
215 | 215 | |
216 | - /** |
|
217 | - * Gets the current page's full URL. |
|
218 | - * |
|
219 | - * @return string |
|
220 | - */ |
|
221 | - public static function current_url() |
|
222 | - { |
|
223 | - $url = ''; |
|
224 | - if ( |
|
225 | - EEH_URL::getRequest()->serverParamIsSet('HTTP_HOST') |
|
226 | - && EEH_URL::getRequest()->serverParamIsSet('REQUEST_URI') |
|
227 | - ) { |
|
228 | - $url = is_ssl() ? 'https://' : 'http://'; |
|
229 | - $url .= EEH_URL::filter_input_server_url('HTTP_HOST'); |
|
230 | - $url .= EEH_URL::filter_input_server_url(); |
|
231 | - } |
|
232 | - return $url; |
|
233 | - } |
|
216 | + /** |
|
217 | + * Gets the current page's full URL. |
|
218 | + * |
|
219 | + * @return string |
|
220 | + */ |
|
221 | + public static function current_url() |
|
222 | + { |
|
223 | + $url = ''; |
|
224 | + if ( |
|
225 | + EEH_URL::getRequest()->serverParamIsSet('HTTP_HOST') |
|
226 | + && EEH_URL::getRequest()->serverParamIsSet('REQUEST_URI') |
|
227 | + ) { |
|
228 | + $url = is_ssl() ? 'https://' : 'http://'; |
|
229 | + $url .= EEH_URL::filter_input_server_url('HTTP_HOST'); |
|
230 | + $url .= EEH_URL::filter_input_server_url(); |
|
231 | + } |
|
232 | + return $url; |
|
233 | + } |
|
234 | 234 | |
235 | 235 | |
236 | - /** |
|
237 | - * Identical in functionality to EEH_current_url except it removes any provided query_parameters from it. |
|
238 | - * |
|
239 | - * @param array $query_parameters An array of query_parameters to remove from the current url. |
|
240 | - * @return string |
|
241 | - * @since 4.9.46.rc.029 |
|
242 | - */ |
|
243 | - public static function current_url_without_query_paramaters(array $query_parameters) |
|
244 | - { |
|
245 | - return remove_query_arg($query_parameters, EEH_URL::current_url()); |
|
246 | - } |
|
236 | + /** |
|
237 | + * Identical in functionality to EEH_current_url except it removes any provided query_parameters from it. |
|
238 | + * |
|
239 | + * @param array $query_parameters An array of query_parameters to remove from the current url. |
|
240 | + * @return string |
|
241 | + * @since 4.9.46.rc.029 |
|
242 | + */ |
|
243 | + public static function current_url_without_query_paramaters(array $query_parameters) |
|
244 | + { |
|
245 | + return remove_query_arg($query_parameters, EEH_URL::current_url()); |
|
246 | + } |
|
247 | 247 | |
248 | 248 | |
249 | - /** |
|
250 | - * @param string $location |
|
251 | - * @param int $status |
|
252 | - * @param string $exit_notice |
|
253 | - */ |
|
254 | - public static function safeRedirectAndExit($location, $status = 302, $exit_notice = '') |
|
255 | - { |
|
256 | - EE_Error::get_notices(false, true); |
|
257 | - wp_safe_redirect($location, $status); |
|
258 | - exit($exit_notice); |
|
259 | - } |
|
249 | + /** |
|
250 | + * @param string $location |
|
251 | + * @param int $status |
|
252 | + * @param string $exit_notice |
|
253 | + */ |
|
254 | + public static function safeRedirectAndExit($location, $status = 302, $exit_notice = '') |
|
255 | + { |
|
256 | + EE_Error::get_notices(false, true); |
|
257 | + wp_safe_redirect($location, $status); |
|
258 | + exit($exit_notice); |
|
259 | + } |
|
260 | 260 | |
261 | 261 | |
262 | - /** |
|
263 | - * Slugifies text for usage in a URL. |
|
264 | - * |
|
265 | - * Currently, this isn't just calling `sanitize_title()` on it, because that percent-encodes unicode characters, |
|
266 | - * and WordPress chokes on them when used as CPT and custom taxonomy slugs. |
|
267 | - * |
|
268 | - * @param string $text |
|
269 | - * @param string $fallback |
|
270 | - * @return string which can be used in a URL |
|
271 | - * @since 4.9.66.p |
|
272 | - */ |
|
273 | - public static function slugify($text, $fallback) |
|
274 | - { |
|
275 | - // url decode after sanitizing title to restore unicode characters, |
|
276 | - // see https://github.com/eventespresso/event-espresso-core/issues/575 |
|
277 | - return urldecode(sanitize_title($text, $fallback)); |
|
278 | - } |
|
262 | + /** |
|
263 | + * Slugifies text for usage in a URL. |
|
264 | + * |
|
265 | + * Currently, this isn't just calling `sanitize_title()` on it, because that percent-encodes unicode characters, |
|
266 | + * and WordPress chokes on them when used as CPT and custom taxonomy slugs. |
|
267 | + * |
|
268 | + * @param string $text |
|
269 | + * @param string $fallback |
|
270 | + * @return string which can be used in a URL |
|
271 | + * @since 4.9.66.p |
|
272 | + */ |
|
273 | + public static function slugify($text, $fallback) |
|
274 | + { |
|
275 | + // url decode after sanitizing title to restore unicode characters, |
|
276 | + // see https://github.com/eventespresso/event-espresso-core/issues/575 |
|
277 | + return urldecode(sanitize_title($text, $fallback)); |
|
278 | + } |
|
279 | 279 | |
280 | 280 | |
281 | - /** |
|
282 | - * @return RequestInterface |
|
283 | - * @since 4.10.14.p |
|
284 | - */ |
|
285 | - protected static function getRequest() |
|
286 | - { |
|
287 | - static $request; |
|
288 | - if (! $request instanceof RequestInterface) { |
|
289 | - $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
290 | - } |
|
291 | - return $request; |
|
292 | - } |
|
281 | + /** |
|
282 | + * @return RequestInterface |
|
283 | + * @since 4.10.14.p |
|
284 | + */ |
|
285 | + protected static function getRequest() |
|
286 | + { |
|
287 | + static $request; |
|
288 | + if (! $request instanceof RequestInterface) { |
|
289 | + $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
290 | + } |
|
291 | + return $request; |
|
292 | + } |
|
293 | 293 | } |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | public static function add_query_args_and_nonce($args = [], $url = '', $exclude_nonce = false) |
28 | 28 | { |
29 | 29 | // check that an action exists and add nonce |
30 | - if (! $exclude_nonce) { |
|
30 | + if ( ! $exclude_nonce) { |
|
31 | 31 | if (isset($args['action']) && ! empty($args['action'])) { |
32 | 32 | $args = array_merge( |
33 | 33 | $args, |
34 | 34 | [ |
35 | - $args['action'] . '_nonce' => wp_create_nonce($args['action'] . '_nonce'), |
|
35 | + $args['action'].'_nonce' => wp_create_nonce($args['action'].'_nonce'), |
|
36 | 36 | ] |
37 | 37 | ); |
38 | 38 | } else { |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | - $action = EEH_URL::getRequest()->getRequestParam('action', ''); |
|
49 | + $action = EEH_URL::getRequest()->getRequestParam('action', ''); |
|
50 | 50 | // finally, let's always add a return address (if present) :) |
51 | 51 | if ($action !== '') { |
52 | 52 | $args['return'] = $action; |
@@ -96,25 +96,25 @@ discard block |
||
96 | 96 | // break apart incoming URL |
97 | 97 | $url_bits = parse_url($url); |
98 | 98 | // HTTP or HTTPS ? |
99 | - $scheme = isset($url_bits['scheme']) ? $url_bits['scheme'] . '://' : 'https://'; |
|
99 | + $scheme = isset($url_bits['scheme']) ? $url_bits['scheme'].'://' : 'https://'; |
|
100 | 100 | // domain |
101 | 101 | $host = isset($url_bits['host']) ? $url_bits['host'] : ''; |
102 | 102 | // if only the base URL is requested, then return that now |
103 | 103 | if ($base_url_only) { |
104 | - return $scheme . $host; |
|
104 | + return $scheme.$host; |
|
105 | 105 | } |
106 | - $port = isset($url_bits['port']) ? ':' . $url_bits['port'] : ''; |
|
106 | + $port = isset($url_bits['port']) ? ':'.$url_bits['port'] : ''; |
|
107 | 107 | $user = isset($url_bits['user']) ? $url_bits['user'] : ''; |
108 | - $pass = isset($url_bits['pass']) ? ':' . $url_bits['pass'] : ''; |
|
109 | - $pass = ($user || $pass) ? $pass . '@' : ''; |
|
108 | + $pass = isset($url_bits['pass']) ? ':'.$url_bits['pass'] : ''; |
|
109 | + $pass = ($user || $pass) ? $pass.'@' : ''; |
|
110 | 110 | $path = isset($url_bits['path']) ? $url_bits['path'] : ''; |
111 | 111 | // if the query string is not required, then return what we have so far |
112 | 112 | if ($remove_query) { |
113 | - return $scheme . $user . $pass . $host . $port . $path; |
|
113 | + return $scheme.$user.$pass.$host.$port.$path; |
|
114 | 114 | } |
115 | - $query = isset($url_bits['query']) ? '?' . $url_bits['query'] : ''; |
|
116 | - $fragment = isset($url_bits['fragment']) ? '#' . $url_bits['fragment'] : ''; |
|
117 | - return $scheme . $user . $pass . $host . $port . $path . $query . $fragment; |
|
115 | + $query = isset($url_bits['query']) ? '?'.$url_bits['query'] : ''; |
|
116 | + $fragment = isset($url_bits['fragment']) ? '#'.$url_bits['fragment'] : ''; |
|
117 | + return $scheme.$user.$pass.$host.$port.$path.$query.$fragment; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | // grab query string from URL |
135 | 135 | $query = isset($url_bits['query']) ? $url_bits['query'] : ''; |
136 | 136 | // if we don't want the query string formatted into an array of key => value pairs, then just return it as is |
137 | - if (! $as_array) { |
|
137 | + if ( ! $as_array) { |
|
138 | 138 | return $query; |
139 | 139 | } |
140 | 140 | // if no query string exists then just return an empty array now |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | // break apart the key value pairs |
151 | 151 | $query_args = explode('=', $query_args); |
152 | 152 | // and add to our results array |
153 | - $query_params[ $query_args[0] ] = $query_args[1]; |
|
153 | + $query_params[$query_args[0]] = $query_args[1]; |
|
154 | 154 | } |
155 | 155 | return $query_params; |
156 | 156 | } |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public static function generate_unique_token($prefix = '') |
181 | 181 | { |
182 | - $token = md5(uniqid() . mt_rand()); |
|
183 | - return $prefix ? $prefix . '_' . $token : $token; |
|
182 | + $token = md5(uniqid().mt_rand()); |
|
183 | + return $prefix ? $prefix.'_'.$token : $token; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | |
@@ -200,13 +200,13 @@ discard block |
||
200 | 200 | 'HTTP_HOST' => 1, |
201 | 201 | 'PHP_SELF' => 1, |
202 | 202 | ]; |
203 | - $server_variable = strtoupper($server_variable); |
|
203 | + $server_variable = strtoupper($server_variable); |
|
204 | 204 | // whitelist INPUT_SERVER var |
205 | - if (isset($server_variables[ $server_variable ])) { |
|
205 | + if (isset($server_variables[$server_variable])) { |
|
206 | 206 | $URL = filter_input(INPUT_SERVER, $server_variable, FILTER_SANITIZE_URL, FILTER_NULL_ON_FAILURE); |
207 | - if (empty($URL) || $URL !== $_SERVER[ $server_variable ]) { |
|
207 | + if (empty($URL) || $URL !== $_SERVER[$server_variable]) { |
|
208 | 208 | // fallback sanitization if the above fails or URL has changed after filtering |
209 | - $URL = wp_sanitize_redirect($_SERVER[ $server_variable ]); |
|
209 | + $URL = wp_sanitize_redirect($_SERVER[$server_variable]); |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | return $URL; |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | protected static function getRequest() |
286 | 286 | { |
287 | 287 | static $request; |
288 | - if (! $request instanceof RequestInterface) { |
|
288 | + if ( ! $request instanceof RequestInterface) { |
|
289 | 289 | $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
290 | 290 | } |
291 | 291 | return $request; |
@@ -38,103 +38,103 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.6.2'); |
|
65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.6.2'); |
|
65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.10.29.rc.006'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.10.29.rc.006'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | - bootstrap_espresso(); |
|
121 | - } |
|
119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | + bootstrap_espresso(); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
124 | - /** |
|
125 | - * deactivate_plugin |
|
126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | - { |
|
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | - } |
|
137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | - deactivate_plugins($plugin_basename); |
|
139 | - } |
|
124 | + /** |
|
125 | + * deactivate_plugin |
|
126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | + { |
|
134 | + if (! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | + } |
|
137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | + deactivate_plugins($plugin_basename); |
|
139 | + } |
|
140 | 140 | } |
@@ -16,1355 +16,1355 @@ |
||
16 | 16 | class EED_Messages extends EED_Module |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * This holds the EE_messages controller |
|
21 | - * |
|
22 | - * @deprecated 4.9.0 |
|
23 | - * @var EE_messages $_EEMSG |
|
24 | - */ |
|
25 | - protected static $_EEMSG; |
|
26 | - |
|
27 | - /** |
|
28 | - * @type EE_Message_Resource_Manager $_message_resource_manager |
|
29 | - */ |
|
30 | - protected static $_message_resource_manager; |
|
31 | - |
|
32 | - /** |
|
33 | - * This holds the EE_Messages_Processor business class. |
|
34 | - * |
|
35 | - * @type EE_Messages_Processor |
|
36 | - */ |
|
37 | - protected static $_MSG_PROCESSOR; |
|
38 | - |
|
39 | - /** |
|
40 | - * holds all the paths for various messages components. |
|
41 | - * Utilized by autoloader registry |
|
42 | - * |
|
43 | - * @var array |
|
44 | - */ |
|
45 | - protected static $_MSG_PATHS; |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * This will hold an array of messages template packs that are registered in the messages system. |
|
50 | - * Format is: |
|
51 | - * array( |
|
52 | - * 'template_pack_dbref' => EE_Messages_Template_Pack (instance) |
|
53 | - * ) |
|
54 | - * |
|
55 | - * @var EE_Messages_Template_Pack[] |
|
56 | - */ |
|
57 | - protected static $_TMP_PACKS = []; |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * @return EED_Messages|EED_Module |
|
62 | - * @throws EE_Error |
|
63 | - * @throws ReflectionException |
|
64 | - */ |
|
65 | - public static function instance() |
|
66 | - { |
|
67 | - return parent::get_instance(__CLASS__); |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
73 | - * |
|
74 | - * @return void |
|
75 | - * @since 4.5.0 |
|
76 | - */ |
|
77 | - public static function set_hooks() |
|
78 | - { |
|
79 | - // actions |
|
80 | - add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', ['EED_Messages', 'payment'], 10, 2); |
|
81 | - add_action( |
|
82 | - 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
|
83 | - ['EED_Messages', 'maybe_registration'], |
|
84 | - 10, |
|
85 | - 2 |
|
86 | - ); |
|
87 | - // filters |
|
88 | - add_filter( |
|
89 | - 'FHEE__EE_Registration__receipt_url__receipt_url', |
|
90 | - ['EED_Messages', 'registration_message_trigger_url'], |
|
91 | - 10, |
|
92 | - 4 |
|
93 | - ); |
|
94 | - add_filter( |
|
95 | - 'FHEE__EE_Registration__invoice_url__invoice_url', |
|
96 | - ['EED_Messages', 'registration_message_trigger_url'], |
|
97 | - 10, |
|
98 | - 4 |
|
99 | - ); |
|
100 | - // register routes |
|
101 | - self::_register_routes(); |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
107 | - * |
|
108 | - * @access public |
|
109 | - * @return void |
|
110 | - */ |
|
111 | - public static function set_hooks_admin() |
|
112 | - { |
|
113 | - // actions |
|
114 | - add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', ['EED_Messages', 'payment'], 10, 2); |
|
115 | - add_action( |
|
116 | - 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', |
|
117 | - ['EED_Messages', 'payment_reminder'], |
|
118 | - 10 |
|
119 | - ); |
|
120 | - add_action( |
|
121 | - 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
|
122 | - ['EED_Messages', 'maybe_registration'], |
|
123 | - 10, |
|
124 | - 3 |
|
125 | - ); |
|
126 | - add_action( |
|
127 | - 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
128 | - ['EED_Messages', 'send_newsletter_message'], |
|
129 | - 10, |
|
130 | - 2 |
|
131 | - ); |
|
132 | - add_action( |
|
133 | - 'AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', |
|
134 | - ['EED_Messages', 'cancelled_registration'], |
|
135 | - 10 |
|
136 | - ); |
|
137 | - add_action( |
|
138 | - 'AHEE__EE_Admin_Page___process_admin_payment_notification', |
|
139 | - ['EED_Messages', 'process_admin_payment'], |
|
140 | - 10, |
|
141 | - 1 |
|
142 | - ); |
|
143 | - // filters |
|
144 | - add_filter( |
|
145 | - 'FHEE__EE_Admin_Page___process_resend_registration__success', |
|
146 | - ['EED_Messages', 'process_resend'], |
|
147 | - 10, |
|
148 | - 2 |
|
149 | - ); |
|
150 | - add_filter( |
|
151 | - 'FHEE__EE_Registration__receipt_url__receipt_url', |
|
152 | - ['EED_Messages', 'registration_message_trigger_url'], |
|
153 | - 10, |
|
154 | - 4 |
|
155 | - ); |
|
156 | - add_filter( |
|
157 | - 'FHEE__EE_Registration__invoice_url__invoice_url', |
|
158 | - ['EED_Messages', 'registration_message_trigger_url'], |
|
159 | - 10, |
|
160 | - 4 |
|
161 | - ); |
|
162 | - } |
|
163 | - |
|
164 | - |
|
165 | - /** |
|
166 | - * All the message triggers done by route go in here. |
|
167 | - * |
|
168 | - * @return void |
|
169 | - * @since 4.5.0 |
|
170 | - */ |
|
171 | - protected static function _register_routes() |
|
172 | - { |
|
173 | - EE_Config::register_route('msg_url_trigger', 'Messages', 'run'); |
|
174 | - EE_Config::register_route('msg_cron_trigger', 'Messages', 'execute_batch_request'); |
|
175 | - EE_Config::register_route('msg_browser_trigger', 'Messages', 'browser_trigger'); |
|
176 | - EE_Config::register_route('msg_browser_error_trigger', 'Messages', 'browser_error_trigger'); |
|
177 | - do_action('AHEE__EED_Messages___register_routes'); |
|
178 | - } |
|
179 | - |
|
180 | - |
|
181 | - /** |
|
182 | - * This is called when a browser display trigger is executed. |
|
183 | - * The browser display trigger is typically used when a already generated message is displayed directly in the |
|
184 | - * browser. |
|
185 | - * |
|
186 | - * @param WP $WP |
|
187 | - * @throws EE_Error |
|
188 | - * @throws InvalidArgumentException |
|
189 | - * @throws ReflectionException |
|
190 | - * @throws InvalidDataTypeException |
|
191 | - * @throws InvalidInterfaceException |
|
192 | - * @since 4.9.0 |
|
193 | - */ |
|
194 | - public function browser_trigger($WP) |
|
195 | - { |
|
196 | - // ensure controller is loaded |
|
197 | - self::_load_controller(); |
|
198 | - $token = self::getRequest()->getRequestParam('token'); |
|
199 | - try { |
|
200 | - $mtg = new EE_Message_Generated_From_Token($token, 'html', self::$_message_resource_manager); |
|
201 | - self::$_MSG_PROCESSOR->generate_and_send_now($mtg); |
|
202 | - } catch (EE_Error $e) { |
|
203 | - $error_msg = esc_html__( |
|
204 | - 'Please note that a system message failed to send due to a technical issue.', |
|
205 | - 'event_espresso' |
|
206 | - ); |
|
207 | - // add specific message for developers if WP_DEBUG in on |
|
208 | - $error_msg .= '||' . $e->getMessage(); |
|
209 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
210 | - } |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - /** |
|
215 | - * This is called when a browser error trigger is executed. |
|
216 | - * When triggered this will grab the EE_Message matching the token in the request and use that to get the error |
|
217 | - * message and display it. |
|
218 | - * |
|
219 | - * @param $WP |
|
220 | - * @throws EE_Error |
|
221 | - * @throws InvalidArgumentException |
|
222 | - * @throws InvalidDataTypeException |
|
223 | - * @throws InvalidInterfaceException |
|
224 | - * @since 4.9.0 |
|
225 | - */ |
|
226 | - public function browser_error_trigger($WP) |
|
227 | - { |
|
228 | - $token = self::getRequest()->getRequestParam('token'); |
|
229 | - if ($token) { |
|
230 | - $message = EEM_Message::instance()->get_one_by_token($token); |
|
231 | - if ($message instanceof EE_Message) { |
|
232 | - header('HTTP/1.1 200 OK'); |
|
233 | - $error_msg = nl2br($message->error_message()); |
|
234 | - ?> |
|
19 | + /** |
|
20 | + * This holds the EE_messages controller |
|
21 | + * |
|
22 | + * @deprecated 4.9.0 |
|
23 | + * @var EE_messages $_EEMSG |
|
24 | + */ |
|
25 | + protected static $_EEMSG; |
|
26 | + |
|
27 | + /** |
|
28 | + * @type EE_Message_Resource_Manager $_message_resource_manager |
|
29 | + */ |
|
30 | + protected static $_message_resource_manager; |
|
31 | + |
|
32 | + /** |
|
33 | + * This holds the EE_Messages_Processor business class. |
|
34 | + * |
|
35 | + * @type EE_Messages_Processor |
|
36 | + */ |
|
37 | + protected static $_MSG_PROCESSOR; |
|
38 | + |
|
39 | + /** |
|
40 | + * holds all the paths for various messages components. |
|
41 | + * Utilized by autoloader registry |
|
42 | + * |
|
43 | + * @var array |
|
44 | + */ |
|
45 | + protected static $_MSG_PATHS; |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * This will hold an array of messages template packs that are registered in the messages system. |
|
50 | + * Format is: |
|
51 | + * array( |
|
52 | + * 'template_pack_dbref' => EE_Messages_Template_Pack (instance) |
|
53 | + * ) |
|
54 | + * |
|
55 | + * @var EE_Messages_Template_Pack[] |
|
56 | + */ |
|
57 | + protected static $_TMP_PACKS = []; |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * @return EED_Messages|EED_Module |
|
62 | + * @throws EE_Error |
|
63 | + * @throws ReflectionException |
|
64 | + */ |
|
65 | + public static function instance() |
|
66 | + { |
|
67 | + return parent::get_instance(__CLASS__); |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
73 | + * |
|
74 | + * @return void |
|
75 | + * @since 4.5.0 |
|
76 | + */ |
|
77 | + public static function set_hooks() |
|
78 | + { |
|
79 | + // actions |
|
80 | + add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', ['EED_Messages', 'payment'], 10, 2); |
|
81 | + add_action( |
|
82 | + 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
|
83 | + ['EED_Messages', 'maybe_registration'], |
|
84 | + 10, |
|
85 | + 2 |
|
86 | + ); |
|
87 | + // filters |
|
88 | + add_filter( |
|
89 | + 'FHEE__EE_Registration__receipt_url__receipt_url', |
|
90 | + ['EED_Messages', 'registration_message_trigger_url'], |
|
91 | + 10, |
|
92 | + 4 |
|
93 | + ); |
|
94 | + add_filter( |
|
95 | + 'FHEE__EE_Registration__invoice_url__invoice_url', |
|
96 | + ['EED_Messages', 'registration_message_trigger_url'], |
|
97 | + 10, |
|
98 | + 4 |
|
99 | + ); |
|
100 | + // register routes |
|
101 | + self::_register_routes(); |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
107 | + * |
|
108 | + * @access public |
|
109 | + * @return void |
|
110 | + */ |
|
111 | + public static function set_hooks_admin() |
|
112 | + { |
|
113 | + // actions |
|
114 | + add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', ['EED_Messages', 'payment'], 10, 2); |
|
115 | + add_action( |
|
116 | + 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', |
|
117 | + ['EED_Messages', 'payment_reminder'], |
|
118 | + 10 |
|
119 | + ); |
|
120 | + add_action( |
|
121 | + 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
|
122 | + ['EED_Messages', 'maybe_registration'], |
|
123 | + 10, |
|
124 | + 3 |
|
125 | + ); |
|
126 | + add_action( |
|
127 | + 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
128 | + ['EED_Messages', 'send_newsletter_message'], |
|
129 | + 10, |
|
130 | + 2 |
|
131 | + ); |
|
132 | + add_action( |
|
133 | + 'AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', |
|
134 | + ['EED_Messages', 'cancelled_registration'], |
|
135 | + 10 |
|
136 | + ); |
|
137 | + add_action( |
|
138 | + 'AHEE__EE_Admin_Page___process_admin_payment_notification', |
|
139 | + ['EED_Messages', 'process_admin_payment'], |
|
140 | + 10, |
|
141 | + 1 |
|
142 | + ); |
|
143 | + // filters |
|
144 | + add_filter( |
|
145 | + 'FHEE__EE_Admin_Page___process_resend_registration__success', |
|
146 | + ['EED_Messages', 'process_resend'], |
|
147 | + 10, |
|
148 | + 2 |
|
149 | + ); |
|
150 | + add_filter( |
|
151 | + 'FHEE__EE_Registration__receipt_url__receipt_url', |
|
152 | + ['EED_Messages', 'registration_message_trigger_url'], |
|
153 | + 10, |
|
154 | + 4 |
|
155 | + ); |
|
156 | + add_filter( |
|
157 | + 'FHEE__EE_Registration__invoice_url__invoice_url', |
|
158 | + ['EED_Messages', 'registration_message_trigger_url'], |
|
159 | + 10, |
|
160 | + 4 |
|
161 | + ); |
|
162 | + } |
|
163 | + |
|
164 | + |
|
165 | + /** |
|
166 | + * All the message triggers done by route go in here. |
|
167 | + * |
|
168 | + * @return void |
|
169 | + * @since 4.5.0 |
|
170 | + */ |
|
171 | + protected static function _register_routes() |
|
172 | + { |
|
173 | + EE_Config::register_route('msg_url_trigger', 'Messages', 'run'); |
|
174 | + EE_Config::register_route('msg_cron_trigger', 'Messages', 'execute_batch_request'); |
|
175 | + EE_Config::register_route('msg_browser_trigger', 'Messages', 'browser_trigger'); |
|
176 | + EE_Config::register_route('msg_browser_error_trigger', 'Messages', 'browser_error_trigger'); |
|
177 | + do_action('AHEE__EED_Messages___register_routes'); |
|
178 | + } |
|
179 | + |
|
180 | + |
|
181 | + /** |
|
182 | + * This is called when a browser display trigger is executed. |
|
183 | + * The browser display trigger is typically used when a already generated message is displayed directly in the |
|
184 | + * browser. |
|
185 | + * |
|
186 | + * @param WP $WP |
|
187 | + * @throws EE_Error |
|
188 | + * @throws InvalidArgumentException |
|
189 | + * @throws ReflectionException |
|
190 | + * @throws InvalidDataTypeException |
|
191 | + * @throws InvalidInterfaceException |
|
192 | + * @since 4.9.0 |
|
193 | + */ |
|
194 | + public function browser_trigger($WP) |
|
195 | + { |
|
196 | + // ensure controller is loaded |
|
197 | + self::_load_controller(); |
|
198 | + $token = self::getRequest()->getRequestParam('token'); |
|
199 | + try { |
|
200 | + $mtg = new EE_Message_Generated_From_Token($token, 'html', self::$_message_resource_manager); |
|
201 | + self::$_MSG_PROCESSOR->generate_and_send_now($mtg); |
|
202 | + } catch (EE_Error $e) { |
|
203 | + $error_msg = esc_html__( |
|
204 | + 'Please note that a system message failed to send due to a technical issue.', |
|
205 | + 'event_espresso' |
|
206 | + ); |
|
207 | + // add specific message for developers if WP_DEBUG in on |
|
208 | + $error_msg .= '||' . $e->getMessage(); |
|
209 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
210 | + } |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + /** |
|
215 | + * This is called when a browser error trigger is executed. |
|
216 | + * When triggered this will grab the EE_Message matching the token in the request and use that to get the error |
|
217 | + * message and display it. |
|
218 | + * |
|
219 | + * @param $WP |
|
220 | + * @throws EE_Error |
|
221 | + * @throws InvalidArgumentException |
|
222 | + * @throws InvalidDataTypeException |
|
223 | + * @throws InvalidInterfaceException |
|
224 | + * @since 4.9.0 |
|
225 | + */ |
|
226 | + public function browser_error_trigger($WP) |
|
227 | + { |
|
228 | + $token = self::getRequest()->getRequestParam('token'); |
|
229 | + if ($token) { |
|
230 | + $message = EEM_Message::instance()->get_one_by_token($token); |
|
231 | + if ($message instanceof EE_Message) { |
|
232 | + header('HTTP/1.1 200 OK'); |
|
233 | + $error_msg = nl2br($message->error_message()); |
|
234 | + ?> |
|
235 | 235 | <!DOCTYPE html> |
236 | 236 | <html> |
237 | 237 | <head></head> |
238 | 238 | <body> |
239 | 239 | <?php echo empty($error_msg) |
240 | - ? esc_html__( |
|
241 | - 'Unfortunately, we were unable to capture the error message for this message.', |
|
242 | - 'event_espresso' |
|
243 | - ) |
|
244 | - : wp_kses( |
|
245 | - $error_msg, |
|
246 | - [ |
|
247 | - 'a' => [ |
|
248 | - 'href' => [], |
|
249 | - 'title' => [], |
|
250 | - ], |
|
251 | - 'span' => [], |
|
252 | - 'div' => [], |
|
253 | - 'p' => [], |
|
254 | - 'strong' => [], |
|
255 | - 'em' => [], |
|
256 | - 'br' => [], |
|
257 | - ] |
|
258 | - ); ?> |
|
240 | + ? esc_html__( |
|
241 | + 'Unfortunately, we were unable to capture the error message for this message.', |
|
242 | + 'event_espresso' |
|
243 | + ) |
|
244 | + : wp_kses( |
|
245 | + $error_msg, |
|
246 | + [ |
|
247 | + 'a' => [ |
|
248 | + 'href' => [], |
|
249 | + 'title' => [], |
|
250 | + ], |
|
251 | + 'span' => [], |
|
252 | + 'div' => [], |
|
253 | + 'p' => [], |
|
254 | + 'strong' => [], |
|
255 | + 'em' => [], |
|
256 | + 'br' => [], |
|
257 | + ] |
|
258 | + ); ?> |
|
259 | 259 | </body> |
260 | 260 | </html> |
261 | 261 | <?php |
262 | - exit; |
|
263 | - } |
|
264 | - } |
|
265 | - } |
|
266 | - |
|
267 | - |
|
268 | - /** |
|
269 | - * This runs when the msg_url_trigger route has initiated. |
|
270 | - * |
|
271 | - * @param WP $WP |
|
272 | - * @throws EE_Error |
|
273 | - * @throws InvalidArgumentException |
|
274 | - * @throws ReflectionException |
|
275 | - * @throws InvalidDataTypeException |
|
276 | - * @throws InvalidInterfaceException |
|
277 | - * @since 4.5.0 |
|
278 | - */ |
|
279 | - public function run($WP) |
|
280 | - { |
|
281 | - // ensure controller is loaded |
|
282 | - self::_load_controller(); |
|
283 | - // attempt to process message |
|
284 | - try { |
|
285 | - /** @type EE_Message_To_Generate_From_Request $message_to_generate */ |
|
286 | - $message_to_generate = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
287 | - self::$_MSG_PROCESSOR->generate_and_send_now($message_to_generate); |
|
288 | - } catch (EE_Error $e) { |
|
289 | - $error_msg = esc_html__( |
|
290 | - 'Please note that a system message failed to send due to a technical issue.', |
|
291 | - 'event_espresso' |
|
292 | - ); |
|
293 | - // add specific message for developers if WP_DEBUG in on |
|
294 | - $error_msg .= '||' . $e->getMessage(); |
|
295 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
296 | - } |
|
297 | - } |
|
298 | - |
|
299 | - |
|
300 | - /** |
|
301 | - * This is triggered by the 'msg_cron_trigger' route. |
|
302 | - * |
|
303 | - * @param WP $WP |
|
304 | - */ |
|
305 | - public function execute_batch_request($WP) |
|
306 | - { |
|
307 | - $this->run_cron(); |
|
308 | - header('HTTP/1.1 200 OK'); |
|
309 | - exit(); |
|
310 | - } |
|
311 | - |
|
312 | - |
|
313 | - /** |
|
314 | - * This gets executed on wp_cron jobs or when a batch request is initiated on its own separate non regular wp |
|
315 | - * request. |
|
316 | - */ |
|
317 | - public function run_cron() |
|
318 | - { |
|
319 | - self::_load_controller(); |
|
320 | - $request = self::getRequest(); |
|
321 | - // get required vars |
|
322 | - $cron_type = $request->getRequestParam('type'); |
|
323 | - $transient_key = $request->getRequestParam('key'); |
|
324 | - |
|
325 | - // now let's verify transient, if not valid exit immediately |
|
326 | - if (! get_transient($transient_key)) { |
|
327 | - /** |
|
328 | - * trigger error so this gets in the error logs. This is important because it happens on a non-user |
|
329 | - * request. |
|
330 | - */ |
|
331 | - trigger_error(esc_attr__('Invalid Request (Transient does not exist)', 'event_espresso')); |
|
332 | - } |
|
333 | - |
|
334 | - // if made it here, lets' delete the transient to keep the db clean |
|
335 | - delete_transient($transient_key); |
|
336 | - |
|
337 | - if (apply_filters('FHEE__EED_Messages__run_cron__use_wp_cron', true)) { |
|
338 | - $method = 'batch_' . $cron_type . '_from_queue'; |
|
339 | - if (method_exists(self::$_MSG_PROCESSOR, $method)) { |
|
340 | - self::$_MSG_PROCESSOR->$method(); |
|
341 | - } else { |
|
342 | - // no matching task |
|
343 | - /** |
|
344 | - * trigger error so this gets in the error logs. This is important because it happens on a non user |
|
345 | - * request. |
|
346 | - */ |
|
347 | - trigger_error( |
|
348 | - esc_attr( |
|
349 | - sprintf( |
|
350 | - esc_html__('There is no task corresponding to this route %s', 'event_espresso'), |
|
351 | - $cron_type |
|
352 | - ) |
|
353 | - ) |
|
354 | - ); |
|
355 | - } |
|
356 | - } |
|
357 | - |
|
358 | - do_action('FHEE__EED_Messages__run_cron__end'); |
|
359 | - } |
|
360 | - |
|
361 | - |
|
362 | - /** |
|
363 | - * This is used to retrieve the template pack for the given name. |
|
364 | - * Retrieved packs are cached on the static $_TMP_PACKS array. If there is no class matching the given name then |
|
365 | - * the default template pack is returned. |
|
366 | - * |
|
367 | - * @param string $template_pack_name This should correspond to the dbref of the template pack (which is also used |
|
368 | - * in generating the Pack class name). |
|
369 | - * @return EE_Messages_Template_Pack |
|
370 | - * @throws EE_Error |
|
371 | - * @throws InvalidArgumentException |
|
372 | - * @throws ReflectionException |
|
373 | - * @throws InvalidDataTypeException |
|
374 | - * @throws InvalidInterfaceException |
|
375 | - * @deprecated 4.9.0 @see EEH_MSG_Template::get_template_pack() |
|
376 | - */ |
|
377 | - public static function get_template_pack($template_pack_name) |
|
378 | - { |
|
379 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
380 | - return EEH_MSG_Template::get_template_pack($template_pack_name); |
|
381 | - } |
|
382 | - |
|
383 | - |
|
384 | - /** |
|
385 | - * Retrieves an array of all template packs. |
|
386 | - * Array is in the format array( 'dbref' => EE_Messages_Template_Pack ) |
|
387 | - * |
|
388 | - * @return EE_Messages_Template_Pack[] |
|
389 | - * @throws EE_Error |
|
390 | - * @throws InvalidArgumentException |
|
391 | - * @throws ReflectionException |
|
392 | - * @throws InvalidDataTypeException |
|
393 | - * @throws InvalidInterfaceException |
|
394 | - * @deprecated 4.9.0 @see EEH_MSG_Template_Pack::get_template_pack_collection |
|
395 | - */ |
|
396 | - public static function get_template_packs() |
|
397 | - { |
|
398 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
399 | - |
|
400 | - // for backward compat, let's make sure this returns in the same format as originally. |
|
401 | - $template_pack_collection = EEH_MSG_Template::get_template_pack_collection(); |
|
402 | - $template_pack_collection->rewind(); |
|
403 | - $template_packs = []; |
|
404 | - while ($template_pack_collection->valid()) { |
|
405 | - $template_packs[ $template_pack_collection->current()->dbref ] = $template_pack_collection->current(); |
|
406 | - $template_pack_collection->next(); |
|
407 | - } |
|
408 | - return $template_packs; |
|
409 | - } |
|
410 | - |
|
411 | - |
|
412 | - /** |
|
413 | - * This simply makes sure the autoloaders are registered for the EE_messages system. |
|
414 | - * |
|
415 | - * @return void |
|
416 | - * @throws EE_Error |
|
417 | - * @since 4.5.0 |
|
418 | - */ |
|
419 | - public static function set_autoloaders() |
|
420 | - { |
|
421 | - if (empty(self::$_MSG_PATHS)) { |
|
422 | - self::_set_messages_paths(); |
|
423 | - foreach (self::$_MSG_PATHS as $path) { |
|
424 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path); |
|
425 | - } |
|
426 | - // add aliases |
|
427 | - EEH_Autoloader::add_alias('EE_messages', 'EE_messages'); |
|
428 | - EEH_Autoloader::add_alias('EE_messenger', 'EE_messenger'); |
|
429 | - } |
|
430 | - } |
|
431 | - |
|
432 | - |
|
433 | - /** |
|
434 | - * Take care of adding all the paths for the messages components to the $_MSG_PATHS property |
|
435 | - * for use by the Messages Autoloaders |
|
436 | - * |
|
437 | - * @return void. |
|
438 | - * @since 4.5.0 |
|
439 | - */ |
|
440 | - protected static function _set_messages_paths() |
|
441 | - { |
|
442 | - $dir_ref = [ |
|
443 | - 'messages/message_type', |
|
444 | - 'messages/messenger', |
|
445 | - 'messages/defaults', |
|
446 | - 'messages/defaults/email', |
|
447 | - 'messages/data_class', |
|
448 | - 'messages/validators', |
|
449 | - 'messages/validators/email', |
|
450 | - 'messages/validators/html', |
|
451 | - 'shortcodes', |
|
452 | - ]; |
|
453 | - $paths = []; |
|
454 | - foreach ($dir_ref as $index => $dir) { |
|
455 | - $paths[ $index ] = EE_LIBRARIES . $dir; |
|
456 | - } |
|
457 | - self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths); |
|
458 | - } |
|
459 | - |
|
460 | - |
|
461 | - /** |
|
462 | - * Takes care of loading dependencies |
|
463 | - * |
|
464 | - * @return void |
|
465 | - * @throws EE_Error |
|
466 | - * @throws InvalidArgumentException |
|
467 | - * @throws ReflectionException |
|
468 | - * @throws InvalidDataTypeException |
|
469 | - * @throws InvalidInterfaceException |
|
470 | - * @since 4.5.0 |
|
471 | - */ |
|
472 | - protected static function _load_controller() |
|
473 | - { |
|
474 | - if (! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) { |
|
475 | - EE_Registry::instance()->load_core('Request_Handler'); |
|
476 | - self::set_autoloaders(); |
|
477 | - self::$_EEMSG = EE_Registry::instance()->load_lib('messages'); |
|
478 | - self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
479 | - self::$_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
480 | - } |
|
481 | - } |
|
482 | - |
|
483 | - |
|
484 | - /** |
|
485 | - * @param EE_Transaction $transaction |
|
486 | - * @throws EE_Error |
|
487 | - * @throws InvalidArgumentException |
|
488 | - * @throws InvalidDataTypeException |
|
489 | - * @throws InvalidInterfaceException |
|
490 | - * @throws ReflectionException |
|
491 | - */ |
|
492 | - public static function payment_reminder(EE_Transaction $transaction) |
|
493 | - { |
|
494 | - self::_load_controller(); |
|
495 | - $data = [$transaction, null]; |
|
496 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers('payment_reminder', $data); |
|
497 | - } |
|
498 | - |
|
499 | - |
|
500 | - /** |
|
501 | - * Any messages triggers for after successful gateway payments should go in here. |
|
502 | - * |
|
503 | - * @param EE_Transaction $transaction object |
|
504 | - * @param EE_Payment|null $payment object |
|
505 | - * @return void |
|
506 | - * @throws EE_Error |
|
507 | - * @throws InvalidArgumentException |
|
508 | - * @throws ReflectionException |
|
509 | - * @throws InvalidDataTypeException |
|
510 | - * @throws InvalidInterfaceException |
|
511 | - */ |
|
512 | - public static function payment(EE_Transaction $transaction, EE_Payment $payment = null) |
|
513 | - { |
|
514 | - // if there's no payment object, then we cannot do a payment type message! |
|
515 | - if (! $payment instanceof EE_Payment) { |
|
516 | - return; |
|
517 | - } |
|
518 | - self::_load_controller(); |
|
519 | - $data = [$transaction, $payment]; |
|
520 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
521 | - $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
522 | - // if payment amount is less than 0 then switch to payment_refund message type. |
|
523 | - $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
|
524 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
525 | - } |
|
526 | - |
|
527 | - |
|
528 | - /** |
|
529 | - * @param EE_Transaction $transaction |
|
530 | - * @throws EE_Error |
|
531 | - * @throws InvalidArgumentException |
|
532 | - * @throws InvalidDataTypeException |
|
533 | - * @throws InvalidInterfaceException |
|
534 | - * @throws ReflectionException |
|
535 | - */ |
|
536 | - public static function cancelled_registration(EE_Transaction $transaction) |
|
537 | - { |
|
538 | - self::_load_controller(); |
|
539 | - $data = [$transaction, null]; |
|
540 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers('cancelled_registration', $data); |
|
541 | - } |
|
542 | - |
|
543 | - |
|
544 | - /** |
|
545 | - * Trigger for Registration messages |
|
546 | - * Note that what registration message type is sent depends on what the reg status is for the registrations on the |
|
547 | - * incoming transaction. |
|
548 | - * |
|
549 | - * @param EE_Registration $registration |
|
550 | - * @param array $extra_details |
|
551 | - * @return void |
|
552 | - * @throws EE_Error |
|
553 | - * @throws InvalidArgumentException |
|
554 | - * @throws InvalidDataTypeException |
|
555 | - * @throws InvalidInterfaceException |
|
556 | - * @throws ReflectionException |
|
557 | - * @throws EntityNotFoundException |
|
558 | - */ |
|
559 | - public static function maybe_registration(EE_Registration $registration, $extra_details = []) |
|
560 | - { |
|
561 | - |
|
562 | - if (! self::_verify_registration_notification_send($registration, $extra_details)) { |
|
563 | - // no messages please |
|
564 | - return; |
|
565 | - } |
|
566 | - |
|
567 | - // get all non-trashed registrations so we make sure we send messages for the right status. |
|
568 | - $all_registrations = $registration->transaction()->registrations( |
|
569 | - [ |
|
570 | - ['REG_deleted' => false], |
|
571 | - 'order_by' => [ |
|
572 | - 'Event.EVT_name' => 'ASC', |
|
573 | - 'Attendee.ATT_lname' => 'ASC', |
|
574 | - 'Attendee.ATT_fname' => 'ASC', |
|
575 | - ], |
|
576 | - ] |
|
577 | - ); |
|
578 | - // cached array of statuses so we only trigger messages once per status. |
|
579 | - $statuses_sent = []; |
|
580 | - self::_load_controller(); |
|
581 | - $mtgs = []; |
|
582 | - |
|
583 | - // loop through registrations and trigger messages once per status. |
|
584 | - foreach ($all_registrations as $reg) { |
|
585 | - // already triggered? |
|
586 | - if (in_array($reg->status_ID(), $statuses_sent)) { |
|
587 | - continue; |
|
588 | - } |
|
589 | - |
|
590 | - $message_type = EEH_MSG_Template::convert_reg_status_to_message_type($reg->status_ID()); |
|
591 | - $mtgs = array_merge( |
|
592 | - $mtgs, |
|
593 | - self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( |
|
594 | - $message_type, |
|
595 | - [$registration->transaction(), null, $reg->status_ID()] |
|
596 | - ) |
|
597 | - ); |
|
598 | - $statuses_sent[] = $reg->status_ID(); |
|
599 | - } |
|
600 | - |
|
601 | - if (count($statuses_sent) > 1) { |
|
602 | - $mtgs = array_merge( |
|
603 | - $mtgs, |
|
604 | - self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( |
|
605 | - 'registration_summary', |
|
606 | - [$registration->transaction(), null] |
|
607 | - ) |
|
608 | - ); |
|
609 | - } |
|
610 | - |
|
611 | - // batch queue and initiate request |
|
612 | - self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($mtgs); |
|
613 | - self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
|
614 | - } |
|
615 | - |
|
616 | - |
|
617 | - /** |
|
618 | - * This is a helper method used to very whether a registration notification should be sent or |
|
619 | - * not. Prevents duplicate notifications going out for registration context notifications. |
|
620 | - * |
|
621 | - * @param EE_Registration $registration [description] |
|
622 | - * @param array $extra_details [description] |
|
623 | - * @return bool true = send away, false = nope halt the presses. |
|
624 | - */ |
|
625 | - protected static function _verify_registration_notification_send( |
|
626 | - EE_Registration $registration, |
|
627 | - $extra_details = [] |
|
628 | - ) { |
|
629 | - $request = self::getRequest(); |
|
630 | - if ( |
|
631 | - ! $request->getRequestParam('non_primary_reg_notification', 0, 'int') |
|
632 | - && ! $registration->is_primary_registrant() |
|
633 | - ) { |
|
634 | - return false; |
|
635 | - } |
|
636 | - // first we check if we're in admin and not doing front ajax |
|
637 | - if ( |
|
638 | - ($request->isAdmin() || $request->isAdminAjax()) |
|
639 | - && ! $request->isFrontAjax() |
|
640 | - ) { |
|
641 | - $status_change = $request->getRequestParam('txn_reg_status_change', [], 'int', true); |
|
642 | - // make sure appropriate admin params are set for sending messages |
|
643 | - if ( |
|
644 | - ! isset($status_change['send_notifications']) |
|
645 | - || (isset($status_change['send_notifications']) && ! $status_change['send_notifications']) |
|
646 | - ) { |
|
647 | - // no messages sent please. |
|
648 | - return false; |
|
649 | - } |
|
650 | - } else { |
|
651 | - // frontend request (either regular or via AJAX) |
|
652 | - // TXN is NOT finalized ? |
|
653 | - if (! isset($extra_details['finalized']) || $extra_details['finalized'] === false) { |
|
654 | - return false; |
|
655 | - } |
|
656 | - // return visit but nothing changed ??? |
|
657 | - if ( |
|
658 | - isset($extra_details['revisit'], $extra_details['status_updates']) |
|
659 | - && $extra_details['revisit'] |
|
660 | - && ! $extra_details['status_updates'] |
|
661 | - ) { |
|
662 | - return false; |
|
663 | - } |
|
664 | - // NOT sending messages && reg status is something other than "Not-Approved" |
|
665 | - if ( |
|
666 | - ! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) |
|
667 | - && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
|
668 | - ) { |
|
669 | - return false; |
|
670 | - } |
|
671 | - } |
|
672 | - // release the kraken |
|
673 | - return true; |
|
674 | - } |
|
675 | - |
|
676 | - |
|
677 | - /** |
|
678 | - * Simply returns an array indexed by Registration Status ID and the related message_type name associated with that |
|
679 | - * status id. |
|
680 | - * |
|
681 | - * @param string $reg_status |
|
682 | - * @return array |
|
683 | - * @throws EE_Error |
|
684 | - * @throws InvalidArgumentException |
|
685 | - * @throws ReflectionException |
|
686 | - * @throws InvalidDataTypeException |
|
687 | - * @throws InvalidInterfaceException |
|
688 | - * @deprecated 4.9.0 Use EEH_MSG_Template::reg_status_to_message_type_array() |
|
689 | - * or EEH_MSG_Template::convert_reg_status_to_message_type |
|
690 | - */ |
|
691 | - protected static function _get_reg_status_array($reg_status = '') |
|
692 | - { |
|
693 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
694 | - return EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
695 | - ? EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
696 | - : EEH_MSG_Template::reg_status_to_message_type_array(); |
|
697 | - } |
|
698 | - |
|
699 | - |
|
700 | - /** |
|
701 | - * Simply returns the payment message type for the given payment status. |
|
702 | - * |
|
703 | - * @param string $payment_status The payment status being matched. |
|
704 | - * @return bool|string The payment message type slug matching the status or false if no match. |
|
705 | - * @throws EE_Error |
|
706 | - * @throws InvalidArgumentException |
|
707 | - * @throws ReflectionException |
|
708 | - * @throws InvalidDataTypeException |
|
709 | - * @throws InvalidInterfaceException |
|
710 | - * @deprecated 4.9.0 Use EEH_MSG_Template::payment_status_to_message_type_array |
|
711 | - * or EEH_MSG_Template::convert_payment_status_to_message_type |
|
712 | - */ |
|
713 | - protected static function _get_payment_message_type($payment_status) |
|
714 | - { |
|
715 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
716 | - return EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
717 | - ? EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
718 | - : false; |
|
719 | - } |
|
720 | - |
|
721 | - |
|
722 | - /** |
|
723 | - * Message triggers for a resending already sent message(s) (via EE_Message list table) |
|
724 | - * |
|
725 | - * @access public |
|
726 | - * @param array $req_data This is the $_POST & $_GET data sent from EE_Admin Pages |
|
727 | - * @return bool success/fail |
|
728 | - * @throws EE_Error |
|
729 | - * @throws InvalidArgumentException |
|
730 | - * @throws InvalidDataTypeException |
|
731 | - * @throws InvalidInterfaceException |
|
732 | - * @throws ReflectionException |
|
733 | - */ |
|
734 | - public static function process_resend(array $req_data = []) |
|
735 | - { |
|
736 | - self::_load_controller(); |
|
737 | - $request = self::getRequest(); |
|
738 | - // if $msgID in this request then skip to the new resend_message |
|
739 | - if ($request->getRequestParam('MSG_ID')) { |
|
740 | - return self::resend_message(); |
|
741 | - } |
|
742 | - |
|
743 | - // make sure any incoming request data is set on the request so that it gets picked up later. |
|
744 | - foreach ((array) $req_data as $request_key => $request_value) { |
|
745 | - if (! $request->requestParamIsSet($request_key)) { |
|
746 | - $request->setRequestParam($request_key, $request_value); |
|
747 | - } |
|
748 | - } |
|
749 | - |
|
750 | - if ( |
|
751 | - ! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request() |
|
752 | - ) { |
|
753 | - return false; |
|
754 | - } |
|
755 | - |
|
756 | - try { |
|
757 | - self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($messages_to_send); |
|
758 | - self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
|
759 | - } catch (EE_Error $e) { |
|
760 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
761 | - return false; |
|
762 | - } |
|
763 | - EE_Error::add_success( |
|
764 | - esc_html__('Messages have been successfully queued for generation and sending.', 'event_espresso') |
|
765 | - ); |
|
766 | - return true; // everything got queued. |
|
767 | - } |
|
768 | - |
|
769 | - |
|
770 | - /** |
|
771 | - * Message triggers for a resending already sent message(s) (via EE_Message list table) |
|
772 | - * |
|
773 | - * @return bool |
|
774 | - * @throws EE_Error |
|
775 | - * @throws InvalidArgumentException |
|
776 | - * @throws InvalidDataTypeException |
|
777 | - * @throws InvalidInterfaceException |
|
778 | - * @throws ReflectionException |
|
779 | - */ |
|
780 | - public static function resend_message() |
|
781 | - { |
|
782 | - self::_load_controller(); |
|
783 | - |
|
784 | - $msgID = self::getRequest()->getRequestParam('MSG_ID', 0, 'int'); |
|
785 | - if (! $msgID) { |
|
786 | - EE_Error::add_error( |
|
787 | - esc_html__( |
|
788 | - 'Something went wrong because there is no "MSG_ID" value in the request', |
|
789 | - 'event_espresso' |
|
790 | - ), |
|
791 | - __FILE__, |
|
792 | - __FUNCTION__, |
|
793 | - __LINE__ |
|
794 | - ); |
|
795 | - return false; |
|
796 | - } |
|
797 | - |
|
798 | - self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array) $msgID); |
|
799 | - |
|
800 | - // setup success message. |
|
801 | - $count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
802 | - EE_Error::add_success( |
|
803 | - sprintf( |
|
804 | - _n( |
|
805 | - 'There was %d message queued for resending.', |
|
806 | - 'There were %d messages queued for resending.', |
|
807 | - $count_ready_for_resend, |
|
808 | - 'event_espresso' |
|
809 | - ), |
|
810 | - $count_ready_for_resend |
|
811 | - ) |
|
812 | - ); |
|
813 | - return true; |
|
814 | - } |
|
815 | - |
|
816 | - |
|
817 | - /** |
|
818 | - * Message triggers for manual payment applied by admin |
|
819 | - * |
|
820 | - * @param EE_Payment $payment EE_payment object |
|
821 | - * @return bool success/fail |
|
822 | - * @throws EE_Error |
|
823 | - * @throws InvalidArgumentException |
|
824 | - * @throws ReflectionException |
|
825 | - * @throws InvalidDataTypeException |
|
826 | - * @throws InvalidInterfaceException |
|
827 | - */ |
|
828 | - public static function process_admin_payment(EE_Payment $payment) |
|
829 | - { |
|
830 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
831 | - // we need to get the transaction object |
|
832 | - $transaction = $payment->transaction(); |
|
833 | - if ($transaction instanceof EE_Transaction) { |
|
834 | - $data = [$transaction, $payment]; |
|
835 | - $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
836 | - |
|
837 | - // if payment amount is less than 0 then switch to payment_refund message type. |
|
838 | - $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
|
839 | - |
|
840 | - // if payment_refund is selected, but the status is NOT accepted. Then change message type to false so NO message notification goes out. |
|
841 | - $message_type = $message_type == 'payment_refund' && $payment->STS_ID() != EEM_Payment::status_id_approved |
|
842 | - ? false : $message_type; |
|
843 | - |
|
844 | - self::_load_controller(); |
|
845 | - |
|
846 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
847 | - |
|
848 | - // get count of queued for generation |
|
849 | - $count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( |
|
850 | - [ |
|
851 | - EEM_Message::status_incomplete, |
|
852 | - EEM_Message::status_idle, |
|
853 | - ] |
|
854 | - ); |
|
855 | - |
|
856 | - if ($count_to_generate > 0 && self::$_MSG_PROCESSOR->get_queue()->get_message_repository()->count() !== 0) { |
|
857 | - add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true'); |
|
858 | - return true; |
|
859 | - } else { |
|
860 | - $count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( |
|
861 | - EEM_Message::instance()->stati_indicating_failed_sending() |
|
862 | - ); |
|
863 | - /** |
|
864 | - * Verify that there are actually errors. If not then we return a success message because the queue might have been emptied due to successful |
|
865 | - * IMMEDIATE generation. |
|
866 | - */ |
|
867 | - if ($count_failed > 0) { |
|
868 | - EE_Error::add_error( |
|
869 | - sprintf( |
|
870 | - _n( |
|
871 | - 'The payment notification generation failed.', |
|
872 | - '%d payment notifications failed being sent.', |
|
873 | - $count_failed, |
|
874 | - 'event_espresso' |
|
875 | - ), |
|
876 | - $count_failed |
|
877 | - ), |
|
878 | - __FILE__, |
|
879 | - __FUNCTION__, |
|
880 | - __LINE__ |
|
881 | - ); |
|
882 | - |
|
883 | - return false; |
|
884 | - } else { |
|
885 | - add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true'); |
|
886 | - return true; |
|
887 | - } |
|
888 | - } |
|
889 | - } else { |
|
890 | - EE_Error::add_error( |
|
891 | - 'Unable to generate the payment notification because the given value for the transaction is invalid.', |
|
892 | - 'event_espresso' |
|
893 | - ); |
|
894 | - return false; |
|
895 | - } |
|
896 | - } |
|
897 | - |
|
898 | - |
|
899 | - /** |
|
900 | - * Callback for AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send_with_registrations trigger |
|
901 | - * |
|
902 | - * @param EE_Registration[] $registrations an array of EE_Registration objects |
|
903 | - * @param int $grp_id a specific message template group id. |
|
904 | - * @return void |
|
905 | - * @throws EE_Error |
|
906 | - * @throws InvalidArgumentException |
|
907 | - * @throws InvalidDataTypeException |
|
908 | - * @throws InvalidInterfaceException |
|
909 | - * @throws ReflectionException |
|
910 | - * @since 4.3.0 |
|
911 | - */ |
|
912 | - public static function send_newsletter_message($registrations, $grp_id) |
|
913 | - { |
|
914 | - // make sure mtp is id and set it in the request later messages setup. |
|
915 | - self::getRequest()->setRequestParam('GRP_ID', (int) $grp_id); |
|
916 | - self::_load_controller(); |
|
917 | - self::$_MSG_PROCESSOR->generate_for_all_active_messengers('newsletter', $registrations); |
|
918 | - } |
|
919 | - |
|
920 | - |
|
921 | - /** |
|
922 | - * Callback for FHEE__EE_Registration__invoice_url__invoice_url or FHEE__EE_Registration__receipt_url__receipt_url |
|
923 | - * |
|
924 | - * @param string $registration_message_trigger_url |
|
925 | - * @param EE_Registration $registration |
|
926 | - * @param string $messenger |
|
927 | - * @param string $message_type |
|
928 | - * @return string |
|
929 | - * @throws EE_Error |
|
930 | - * @throws InvalidArgumentException |
|
931 | - * @throws InvalidDataTypeException |
|
932 | - * @throws InvalidInterfaceException |
|
933 | - * @since 4.3.0 |
|
934 | - */ |
|
935 | - public static function registration_message_trigger_url( |
|
936 | - $registration_message_trigger_url, |
|
937 | - EE_Registration $registration, |
|
938 | - $messenger = 'html', |
|
939 | - $message_type = 'invoice' |
|
940 | - ) { |
|
941 | - // whitelist $messenger |
|
942 | - switch ($messenger) { |
|
943 | - case 'pdf': |
|
944 | - $sending_messenger = 'pdf'; |
|
945 | - $generating_messenger = 'html'; |
|
946 | - break; |
|
947 | - case 'html': |
|
948 | - default: |
|
949 | - $sending_messenger = 'html'; |
|
950 | - $generating_messenger = 'html'; |
|
951 | - break; |
|
952 | - } |
|
953 | - // whitelist $message_type |
|
954 | - switch ($message_type) { |
|
955 | - case 'receipt': |
|
956 | - $message_type = 'receipt'; |
|
957 | - break; |
|
958 | - case 'invoice': |
|
959 | - default: |
|
960 | - $message_type = 'invoice'; |
|
961 | - break; |
|
962 | - } |
|
963 | - // verify that both the messenger AND the message type are active |
|
964 | - if ( |
|
965 | - EEH_MSG_Template::is_messenger_active($sending_messenger) |
|
966 | - && EEH_MSG_Template::is_mt_active($message_type) |
|
967 | - ) { |
|
968 | - // need to get the correct message template group for this (i.e. is there a custom invoice for the event this registration is registered for?) |
|
969 | - $template_query_params = [ |
|
970 | - 'MTP_is_active' => true, |
|
971 | - 'MTP_messenger' => $generating_messenger, |
|
972 | - 'MTP_message_type' => $message_type, |
|
973 | - 'Event.EVT_ID' => $registration->event_ID(), |
|
974 | - ]; |
|
975 | - // get the message template group. |
|
976 | - $msg_template_group = EEM_Message_Template_Group::instance()->get_one([$template_query_params]); |
|
977 | - // if we don't have an EE_Message_Template_Group then return |
|
978 | - if (! $msg_template_group instanceof EE_Message_Template_Group) { |
|
979 | - // remove EVT_ID from query params so that global templates get picked up |
|
980 | - unset($template_query_params['Event.EVT_ID']); |
|
981 | - // get global template as the fallback |
|
982 | - $msg_template_group = EEM_Message_Template_Group::instance()->get_one([$template_query_params]); |
|
983 | - } |
|
984 | - // if we don't have an EE_Message_Template_Group then return |
|
985 | - if (! $msg_template_group instanceof EE_Message_Template_Group) { |
|
986 | - return ''; |
|
987 | - } |
|
988 | - // generate the URL |
|
989 | - $registration_message_trigger_url = EEH_MSG_Template::generate_url_trigger( |
|
990 | - $sending_messenger, |
|
991 | - $generating_messenger, |
|
992 | - 'purchaser', |
|
993 | - $message_type, |
|
994 | - $registration, |
|
995 | - $msg_template_group->ID(), |
|
996 | - $registration->transaction_ID() |
|
997 | - ); |
|
998 | - } |
|
999 | - return $registration_message_trigger_url; |
|
1000 | - } |
|
1001 | - |
|
1002 | - |
|
1003 | - /** |
|
1004 | - * Use to generate and return a message preview! |
|
1005 | - * |
|
1006 | - * @param string $type This should correspond with a valid message type |
|
1007 | - * @param string $context This should correspond with a valid context for the message type |
|
1008 | - * @param string $messenger This should correspond with a valid messenger. |
|
1009 | - * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular |
|
1010 | - * preview |
|
1011 | - * @return bool|string The body of the message or if send is requested, sends. |
|
1012 | - * @throws EE_Error |
|
1013 | - * @throws InvalidArgumentException |
|
1014 | - * @throws InvalidDataTypeException |
|
1015 | - * @throws InvalidInterfaceException |
|
1016 | - * @throws ReflectionException |
|
1017 | - */ |
|
1018 | - public static function preview_message($type, $context, $messenger, $send = false) |
|
1019 | - { |
|
1020 | - self::_load_controller(); |
|
1021 | - $message_to_generate = new EE_Message_To_Generate( |
|
1022 | - $messenger, |
|
1023 | - $type, |
|
1024 | - [], |
|
1025 | - $context, |
|
1026 | - true |
|
1027 | - ); |
|
1028 | - $generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview($message_to_generate, $send); |
|
1029 | - |
|
1030 | - if ($generated_preview_queue instanceof EE_Messages_Queue) { |
|
1031 | - // loop through all content for the preview and remove any persisted records. |
|
1032 | - $content = ''; |
|
1033 | - foreach ($generated_preview_queue->get_message_repository() as $message) { |
|
1034 | - $content = $message->content(); |
|
1035 | - if ($message->ID() > 0 && $message->STS_ID() !== EEM_Message::status_failed) { |
|
1036 | - $message->delete(); |
|
1037 | - } |
|
1038 | - } |
|
1039 | - return $content; |
|
1040 | - } |
|
1041 | - return $generated_preview_queue; |
|
1042 | - } |
|
1043 | - |
|
1044 | - |
|
1045 | - /** |
|
1046 | - * This is a method that allows for sending a message using a messenger matching the string given and the provided |
|
1047 | - * EE_Message_Queue object. The EE_Message_Queue object is used to create a single aggregate EE_Message via the |
|
1048 | - * content found in the EE_Message objects in the queue. |
|
1049 | - * |
|
1050 | - * @param string $messenger a string matching a valid active messenger in the system |
|
1051 | - * @param string $message_type Although it seems contrary to the name of the method, a message |
|
1052 | - * type name is still required to send along the message type to the |
|
1053 | - * messenger because this is used for determining what specific |
|
1054 | - * variations might be loaded for the generated message. |
|
1055 | - * @param EE_Messages_Queue $queue |
|
1056 | - * @param string $custom_subject Can be used to set what the custom subject string will be on the |
|
1057 | - * aggregate EE_Message object. |
|
1058 | - * @return bool success or fail. |
|
1059 | - * @throws EE_Error |
|
1060 | - * @throws InvalidArgumentException |
|
1061 | - * @throws ReflectionException |
|
1062 | - * @throws InvalidDataTypeException |
|
1063 | - * @throws InvalidInterfaceException |
|
1064 | - * @since 4.9.0 |
|
1065 | - */ |
|
1066 | - public static function send_message_with_messenger_only( |
|
1067 | - $messenger, |
|
1068 | - $message_type, |
|
1069 | - EE_Messages_Queue $queue, |
|
1070 | - $custom_subject = '' |
|
1071 | - ) { |
|
1072 | - self::_load_controller(); |
|
1073 | - /** @type EE_Message_To_Generate_From_Queue $message_to_generate */ |
|
1074 | - $message_to_generate = EE_Registry::instance()->load_lib( |
|
1075 | - 'Message_To_Generate_From_Queue', |
|
1076 | - [ |
|
1077 | - $messenger, |
|
1078 | - $message_type, |
|
1079 | - $queue, |
|
1080 | - $custom_subject, |
|
1081 | - ] |
|
1082 | - ); |
|
1083 | - return self::$_MSG_PROCESSOR->queue_for_sending($message_to_generate); |
|
1084 | - } |
|
1085 | - |
|
1086 | - |
|
1087 | - /** |
|
1088 | - * Generates Messages immediately for EE_Message IDs (but only for the correct status for generation) |
|
1089 | - * |
|
1090 | - * @param array $message_ids An array of message ids |
|
1091 | - * @return bool|EE_Messages_Queue false if nothing was generated, EE_Messages_Queue containing generated |
|
1092 | - * messages. |
|
1093 | - * @throws EE_Error |
|
1094 | - * @throws InvalidArgumentException |
|
1095 | - * @throws InvalidDataTypeException |
|
1096 | - * @throws InvalidInterfaceException |
|
1097 | - * @throws ReflectionException |
|
1098 | - * @since 4.9.0 |
|
1099 | - */ |
|
1100 | - public static function generate_now($message_ids) |
|
1101 | - { |
|
1102 | - self::_load_controller(); |
|
1103 | - $messages = EEM_Message::instance()->get_all( |
|
1104 | - [ |
|
1105 | - 0 => [ |
|
1106 | - 'MSG_ID' => ['IN', $message_ids], |
|
1107 | - 'STS_ID' => EEM_Message::status_incomplete, |
|
1108 | - ], |
|
1109 | - ] |
|
1110 | - ); |
|
1111 | - $generated_queue = false; |
|
1112 | - if ($messages) { |
|
1113 | - $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages); |
|
1114 | - } |
|
1115 | - |
|
1116 | - if (! $generated_queue instanceof EE_Messages_Queue) { |
|
1117 | - EE_Error::add_error( |
|
1118 | - esc_html__( |
|
1119 | - 'The messages were not generated. This could mean there is already a batch being generated on a separate request, or because the selected messages are not ready for generation. Please wait a minute or two and try again.', |
|
1120 | - 'event_espresso' |
|
1121 | - ), |
|
1122 | - __FILE__, |
|
1123 | - __FUNCTION__, |
|
1124 | - __LINE__ |
|
1125 | - ); |
|
1126 | - } |
|
1127 | - return $generated_queue; |
|
1128 | - } |
|
1129 | - |
|
1130 | - |
|
1131 | - /** |
|
1132 | - * Sends messages immediately for the incoming message_ids that have the status of EEM_Message::status_resend or, |
|
1133 | - * EEM_Message::status_idle |
|
1134 | - * |
|
1135 | - * @param $message_ids |
|
1136 | - * @return bool|EE_Messages_Queue false if no messages sent. |
|
1137 | - * @throws EE_Error |
|
1138 | - * @throws InvalidArgumentException |
|
1139 | - * @throws InvalidDataTypeException |
|
1140 | - * @throws InvalidInterfaceException |
|
1141 | - * @throws ReflectionException |
|
1142 | - * @since 4.9.0 |
|
1143 | - */ |
|
1144 | - public static function send_now($message_ids) |
|
1145 | - { |
|
1146 | - self::_load_controller(); |
|
1147 | - $messages = EEM_Message::instance()->get_all( |
|
1148 | - [ |
|
1149 | - 0 => [ |
|
1150 | - 'MSG_ID' => ['IN', $message_ids], |
|
1151 | - 'STS_ID' => [ |
|
1152 | - 'IN', |
|
1153 | - [EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry], |
|
1154 | - ], |
|
1155 | - ], |
|
1156 | - ] |
|
1157 | - ); |
|
1158 | - $sent_queue = false; |
|
1159 | - if ($messages) { |
|
1160 | - $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages); |
|
1161 | - } |
|
1162 | - |
|
1163 | - if (! $sent_queue instanceof EE_Messages_Queue) { |
|
1164 | - EE_Error::add_error( |
|
1165 | - esc_html__( |
|
1166 | - 'The messages were not sent. This could mean there is already a batch being sent on a separate request, or because the selected messages are not sendable. Please wait a minute or two and try again.', |
|
1167 | - 'event_espresso' |
|
1168 | - ), |
|
1169 | - __FILE__, |
|
1170 | - __FUNCTION__, |
|
1171 | - __LINE__ |
|
1172 | - ); |
|
1173 | - } else { |
|
1174 | - // can count how many sent by using the messages in the queue |
|
1175 | - $sent_count = $sent_queue->count_STS_in_queue(EEM_Message::instance()->stati_indicating_sent()); |
|
1176 | - if ($sent_count > 0) { |
|
1177 | - EE_Error::add_success( |
|
1178 | - sprintf( |
|
1179 | - _n( |
|
1180 | - 'There was %d message successfully sent.', |
|
1181 | - 'There were %d messages successfully sent.', |
|
1182 | - $sent_count, |
|
1183 | - 'event_espresso' |
|
1184 | - ), |
|
1185 | - $sent_count |
|
1186 | - ) |
|
1187 | - ); |
|
1188 | - } else { |
|
1189 | - EE_Error::overwrite_errors(); |
|
1190 | - EE_Error::add_error( |
|
1191 | - esc_html__( |
|
1192 | - 'No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, they were ALREADY sent on a different scheduled task, or there was an error. |
|
262 | + exit; |
|
263 | + } |
|
264 | + } |
|
265 | + } |
|
266 | + |
|
267 | + |
|
268 | + /** |
|
269 | + * This runs when the msg_url_trigger route has initiated. |
|
270 | + * |
|
271 | + * @param WP $WP |
|
272 | + * @throws EE_Error |
|
273 | + * @throws InvalidArgumentException |
|
274 | + * @throws ReflectionException |
|
275 | + * @throws InvalidDataTypeException |
|
276 | + * @throws InvalidInterfaceException |
|
277 | + * @since 4.5.0 |
|
278 | + */ |
|
279 | + public function run($WP) |
|
280 | + { |
|
281 | + // ensure controller is loaded |
|
282 | + self::_load_controller(); |
|
283 | + // attempt to process message |
|
284 | + try { |
|
285 | + /** @type EE_Message_To_Generate_From_Request $message_to_generate */ |
|
286 | + $message_to_generate = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
287 | + self::$_MSG_PROCESSOR->generate_and_send_now($message_to_generate); |
|
288 | + } catch (EE_Error $e) { |
|
289 | + $error_msg = esc_html__( |
|
290 | + 'Please note that a system message failed to send due to a technical issue.', |
|
291 | + 'event_espresso' |
|
292 | + ); |
|
293 | + // add specific message for developers if WP_DEBUG in on |
|
294 | + $error_msg .= '||' . $e->getMessage(); |
|
295 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
296 | + } |
|
297 | + } |
|
298 | + |
|
299 | + |
|
300 | + /** |
|
301 | + * This is triggered by the 'msg_cron_trigger' route. |
|
302 | + * |
|
303 | + * @param WP $WP |
|
304 | + */ |
|
305 | + public function execute_batch_request($WP) |
|
306 | + { |
|
307 | + $this->run_cron(); |
|
308 | + header('HTTP/1.1 200 OK'); |
|
309 | + exit(); |
|
310 | + } |
|
311 | + |
|
312 | + |
|
313 | + /** |
|
314 | + * This gets executed on wp_cron jobs or when a batch request is initiated on its own separate non regular wp |
|
315 | + * request. |
|
316 | + */ |
|
317 | + public function run_cron() |
|
318 | + { |
|
319 | + self::_load_controller(); |
|
320 | + $request = self::getRequest(); |
|
321 | + // get required vars |
|
322 | + $cron_type = $request->getRequestParam('type'); |
|
323 | + $transient_key = $request->getRequestParam('key'); |
|
324 | + |
|
325 | + // now let's verify transient, if not valid exit immediately |
|
326 | + if (! get_transient($transient_key)) { |
|
327 | + /** |
|
328 | + * trigger error so this gets in the error logs. This is important because it happens on a non-user |
|
329 | + * request. |
|
330 | + */ |
|
331 | + trigger_error(esc_attr__('Invalid Request (Transient does not exist)', 'event_espresso')); |
|
332 | + } |
|
333 | + |
|
334 | + // if made it here, lets' delete the transient to keep the db clean |
|
335 | + delete_transient($transient_key); |
|
336 | + |
|
337 | + if (apply_filters('FHEE__EED_Messages__run_cron__use_wp_cron', true)) { |
|
338 | + $method = 'batch_' . $cron_type . '_from_queue'; |
|
339 | + if (method_exists(self::$_MSG_PROCESSOR, $method)) { |
|
340 | + self::$_MSG_PROCESSOR->$method(); |
|
341 | + } else { |
|
342 | + // no matching task |
|
343 | + /** |
|
344 | + * trigger error so this gets in the error logs. This is important because it happens on a non user |
|
345 | + * request. |
|
346 | + */ |
|
347 | + trigger_error( |
|
348 | + esc_attr( |
|
349 | + sprintf( |
|
350 | + esc_html__('There is no task corresponding to this route %s', 'event_espresso'), |
|
351 | + $cron_type |
|
352 | + ) |
|
353 | + ) |
|
354 | + ); |
|
355 | + } |
|
356 | + } |
|
357 | + |
|
358 | + do_action('FHEE__EED_Messages__run_cron__end'); |
|
359 | + } |
|
360 | + |
|
361 | + |
|
362 | + /** |
|
363 | + * This is used to retrieve the template pack for the given name. |
|
364 | + * Retrieved packs are cached on the static $_TMP_PACKS array. If there is no class matching the given name then |
|
365 | + * the default template pack is returned. |
|
366 | + * |
|
367 | + * @param string $template_pack_name This should correspond to the dbref of the template pack (which is also used |
|
368 | + * in generating the Pack class name). |
|
369 | + * @return EE_Messages_Template_Pack |
|
370 | + * @throws EE_Error |
|
371 | + * @throws InvalidArgumentException |
|
372 | + * @throws ReflectionException |
|
373 | + * @throws InvalidDataTypeException |
|
374 | + * @throws InvalidInterfaceException |
|
375 | + * @deprecated 4.9.0 @see EEH_MSG_Template::get_template_pack() |
|
376 | + */ |
|
377 | + public static function get_template_pack($template_pack_name) |
|
378 | + { |
|
379 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
380 | + return EEH_MSG_Template::get_template_pack($template_pack_name); |
|
381 | + } |
|
382 | + |
|
383 | + |
|
384 | + /** |
|
385 | + * Retrieves an array of all template packs. |
|
386 | + * Array is in the format array( 'dbref' => EE_Messages_Template_Pack ) |
|
387 | + * |
|
388 | + * @return EE_Messages_Template_Pack[] |
|
389 | + * @throws EE_Error |
|
390 | + * @throws InvalidArgumentException |
|
391 | + * @throws ReflectionException |
|
392 | + * @throws InvalidDataTypeException |
|
393 | + * @throws InvalidInterfaceException |
|
394 | + * @deprecated 4.9.0 @see EEH_MSG_Template_Pack::get_template_pack_collection |
|
395 | + */ |
|
396 | + public static function get_template_packs() |
|
397 | + { |
|
398 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
399 | + |
|
400 | + // for backward compat, let's make sure this returns in the same format as originally. |
|
401 | + $template_pack_collection = EEH_MSG_Template::get_template_pack_collection(); |
|
402 | + $template_pack_collection->rewind(); |
|
403 | + $template_packs = []; |
|
404 | + while ($template_pack_collection->valid()) { |
|
405 | + $template_packs[ $template_pack_collection->current()->dbref ] = $template_pack_collection->current(); |
|
406 | + $template_pack_collection->next(); |
|
407 | + } |
|
408 | + return $template_packs; |
|
409 | + } |
|
410 | + |
|
411 | + |
|
412 | + /** |
|
413 | + * This simply makes sure the autoloaders are registered for the EE_messages system. |
|
414 | + * |
|
415 | + * @return void |
|
416 | + * @throws EE_Error |
|
417 | + * @since 4.5.0 |
|
418 | + */ |
|
419 | + public static function set_autoloaders() |
|
420 | + { |
|
421 | + if (empty(self::$_MSG_PATHS)) { |
|
422 | + self::_set_messages_paths(); |
|
423 | + foreach (self::$_MSG_PATHS as $path) { |
|
424 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path); |
|
425 | + } |
|
426 | + // add aliases |
|
427 | + EEH_Autoloader::add_alias('EE_messages', 'EE_messages'); |
|
428 | + EEH_Autoloader::add_alias('EE_messenger', 'EE_messenger'); |
|
429 | + } |
|
430 | + } |
|
431 | + |
|
432 | + |
|
433 | + /** |
|
434 | + * Take care of adding all the paths for the messages components to the $_MSG_PATHS property |
|
435 | + * for use by the Messages Autoloaders |
|
436 | + * |
|
437 | + * @return void. |
|
438 | + * @since 4.5.0 |
|
439 | + */ |
|
440 | + protected static function _set_messages_paths() |
|
441 | + { |
|
442 | + $dir_ref = [ |
|
443 | + 'messages/message_type', |
|
444 | + 'messages/messenger', |
|
445 | + 'messages/defaults', |
|
446 | + 'messages/defaults/email', |
|
447 | + 'messages/data_class', |
|
448 | + 'messages/validators', |
|
449 | + 'messages/validators/email', |
|
450 | + 'messages/validators/html', |
|
451 | + 'shortcodes', |
|
452 | + ]; |
|
453 | + $paths = []; |
|
454 | + foreach ($dir_ref as $index => $dir) { |
|
455 | + $paths[ $index ] = EE_LIBRARIES . $dir; |
|
456 | + } |
|
457 | + self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths); |
|
458 | + } |
|
459 | + |
|
460 | + |
|
461 | + /** |
|
462 | + * Takes care of loading dependencies |
|
463 | + * |
|
464 | + * @return void |
|
465 | + * @throws EE_Error |
|
466 | + * @throws InvalidArgumentException |
|
467 | + * @throws ReflectionException |
|
468 | + * @throws InvalidDataTypeException |
|
469 | + * @throws InvalidInterfaceException |
|
470 | + * @since 4.5.0 |
|
471 | + */ |
|
472 | + protected static function _load_controller() |
|
473 | + { |
|
474 | + if (! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) { |
|
475 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
476 | + self::set_autoloaders(); |
|
477 | + self::$_EEMSG = EE_Registry::instance()->load_lib('messages'); |
|
478 | + self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
479 | + self::$_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
480 | + } |
|
481 | + } |
|
482 | + |
|
483 | + |
|
484 | + /** |
|
485 | + * @param EE_Transaction $transaction |
|
486 | + * @throws EE_Error |
|
487 | + * @throws InvalidArgumentException |
|
488 | + * @throws InvalidDataTypeException |
|
489 | + * @throws InvalidInterfaceException |
|
490 | + * @throws ReflectionException |
|
491 | + */ |
|
492 | + public static function payment_reminder(EE_Transaction $transaction) |
|
493 | + { |
|
494 | + self::_load_controller(); |
|
495 | + $data = [$transaction, null]; |
|
496 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('payment_reminder', $data); |
|
497 | + } |
|
498 | + |
|
499 | + |
|
500 | + /** |
|
501 | + * Any messages triggers for after successful gateway payments should go in here. |
|
502 | + * |
|
503 | + * @param EE_Transaction $transaction object |
|
504 | + * @param EE_Payment|null $payment object |
|
505 | + * @return void |
|
506 | + * @throws EE_Error |
|
507 | + * @throws InvalidArgumentException |
|
508 | + * @throws ReflectionException |
|
509 | + * @throws InvalidDataTypeException |
|
510 | + * @throws InvalidInterfaceException |
|
511 | + */ |
|
512 | + public static function payment(EE_Transaction $transaction, EE_Payment $payment = null) |
|
513 | + { |
|
514 | + // if there's no payment object, then we cannot do a payment type message! |
|
515 | + if (! $payment instanceof EE_Payment) { |
|
516 | + return; |
|
517 | + } |
|
518 | + self::_load_controller(); |
|
519 | + $data = [$transaction, $payment]; |
|
520 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
521 | + $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
522 | + // if payment amount is less than 0 then switch to payment_refund message type. |
|
523 | + $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
|
524 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
525 | + } |
|
526 | + |
|
527 | + |
|
528 | + /** |
|
529 | + * @param EE_Transaction $transaction |
|
530 | + * @throws EE_Error |
|
531 | + * @throws InvalidArgumentException |
|
532 | + * @throws InvalidDataTypeException |
|
533 | + * @throws InvalidInterfaceException |
|
534 | + * @throws ReflectionException |
|
535 | + */ |
|
536 | + public static function cancelled_registration(EE_Transaction $transaction) |
|
537 | + { |
|
538 | + self::_load_controller(); |
|
539 | + $data = [$transaction, null]; |
|
540 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('cancelled_registration', $data); |
|
541 | + } |
|
542 | + |
|
543 | + |
|
544 | + /** |
|
545 | + * Trigger for Registration messages |
|
546 | + * Note that what registration message type is sent depends on what the reg status is for the registrations on the |
|
547 | + * incoming transaction. |
|
548 | + * |
|
549 | + * @param EE_Registration $registration |
|
550 | + * @param array $extra_details |
|
551 | + * @return void |
|
552 | + * @throws EE_Error |
|
553 | + * @throws InvalidArgumentException |
|
554 | + * @throws InvalidDataTypeException |
|
555 | + * @throws InvalidInterfaceException |
|
556 | + * @throws ReflectionException |
|
557 | + * @throws EntityNotFoundException |
|
558 | + */ |
|
559 | + public static function maybe_registration(EE_Registration $registration, $extra_details = []) |
|
560 | + { |
|
561 | + |
|
562 | + if (! self::_verify_registration_notification_send($registration, $extra_details)) { |
|
563 | + // no messages please |
|
564 | + return; |
|
565 | + } |
|
566 | + |
|
567 | + // get all non-trashed registrations so we make sure we send messages for the right status. |
|
568 | + $all_registrations = $registration->transaction()->registrations( |
|
569 | + [ |
|
570 | + ['REG_deleted' => false], |
|
571 | + 'order_by' => [ |
|
572 | + 'Event.EVT_name' => 'ASC', |
|
573 | + 'Attendee.ATT_lname' => 'ASC', |
|
574 | + 'Attendee.ATT_fname' => 'ASC', |
|
575 | + ], |
|
576 | + ] |
|
577 | + ); |
|
578 | + // cached array of statuses so we only trigger messages once per status. |
|
579 | + $statuses_sent = []; |
|
580 | + self::_load_controller(); |
|
581 | + $mtgs = []; |
|
582 | + |
|
583 | + // loop through registrations and trigger messages once per status. |
|
584 | + foreach ($all_registrations as $reg) { |
|
585 | + // already triggered? |
|
586 | + if (in_array($reg->status_ID(), $statuses_sent)) { |
|
587 | + continue; |
|
588 | + } |
|
589 | + |
|
590 | + $message_type = EEH_MSG_Template::convert_reg_status_to_message_type($reg->status_ID()); |
|
591 | + $mtgs = array_merge( |
|
592 | + $mtgs, |
|
593 | + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( |
|
594 | + $message_type, |
|
595 | + [$registration->transaction(), null, $reg->status_ID()] |
|
596 | + ) |
|
597 | + ); |
|
598 | + $statuses_sent[] = $reg->status_ID(); |
|
599 | + } |
|
600 | + |
|
601 | + if (count($statuses_sent) > 1) { |
|
602 | + $mtgs = array_merge( |
|
603 | + $mtgs, |
|
604 | + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( |
|
605 | + 'registration_summary', |
|
606 | + [$registration->transaction(), null] |
|
607 | + ) |
|
608 | + ); |
|
609 | + } |
|
610 | + |
|
611 | + // batch queue and initiate request |
|
612 | + self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($mtgs); |
|
613 | + self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
|
614 | + } |
|
615 | + |
|
616 | + |
|
617 | + /** |
|
618 | + * This is a helper method used to very whether a registration notification should be sent or |
|
619 | + * not. Prevents duplicate notifications going out for registration context notifications. |
|
620 | + * |
|
621 | + * @param EE_Registration $registration [description] |
|
622 | + * @param array $extra_details [description] |
|
623 | + * @return bool true = send away, false = nope halt the presses. |
|
624 | + */ |
|
625 | + protected static function _verify_registration_notification_send( |
|
626 | + EE_Registration $registration, |
|
627 | + $extra_details = [] |
|
628 | + ) { |
|
629 | + $request = self::getRequest(); |
|
630 | + if ( |
|
631 | + ! $request->getRequestParam('non_primary_reg_notification', 0, 'int') |
|
632 | + && ! $registration->is_primary_registrant() |
|
633 | + ) { |
|
634 | + return false; |
|
635 | + } |
|
636 | + // first we check if we're in admin and not doing front ajax |
|
637 | + if ( |
|
638 | + ($request->isAdmin() || $request->isAdminAjax()) |
|
639 | + && ! $request->isFrontAjax() |
|
640 | + ) { |
|
641 | + $status_change = $request->getRequestParam('txn_reg_status_change', [], 'int', true); |
|
642 | + // make sure appropriate admin params are set for sending messages |
|
643 | + if ( |
|
644 | + ! isset($status_change['send_notifications']) |
|
645 | + || (isset($status_change['send_notifications']) && ! $status_change['send_notifications']) |
|
646 | + ) { |
|
647 | + // no messages sent please. |
|
648 | + return false; |
|
649 | + } |
|
650 | + } else { |
|
651 | + // frontend request (either regular or via AJAX) |
|
652 | + // TXN is NOT finalized ? |
|
653 | + if (! isset($extra_details['finalized']) || $extra_details['finalized'] === false) { |
|
654 | + return false; |
|
655 | + } |
|
656 | + // return visit but nothing changed ??? |
|
657 | + if ( |
|
658 | + isset($extra_details['revisit'], $extra_details['status_updates']) |
|
659 | + && $extra_details['revisit'] |
|
660 | + && ! $extra_details['status_updates'] |
|
661 | + ) { |
|
662 | + return false; |
|
663 | + } |
|
664 | + // NOT sending messages && reg status is something other than "Not-Approved" |
|
665 | + if ( |
|
666 | + ! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) |
|
667 | + && $registration->status_ID() !== EEM_Registration::status_id_not_approved |
|
668 | + ) { |
|
669 | + return false; |
|
670 | + } |
|
671 | + } |
|
672 | + // release the kraken |
|
673 | + return true; |
|
674 | + } |
|
675 | + |
|
676 | + |
|
677 | + /** |
|
678 | + * Simply returns an array indexed by Registration Status ID and the related message_type name associated with that |
|
679 | + * status id. |
|
680 | + * |
|
681 | + * @param string $reg_status |
|
682 | + * @return array |
|
683 | + * @throws EE_Error |
|
684 | + * @throws InvalidArgumentException |
|
685 | + * @throws ReflectionException |
|
686 | + * @throws InvalidDataTypeException |
|
687 | + * @throws InvalidInterfaceException |
|
688 | + * @deprecated 4.9.0 Use EEH_MSG_Template::reg_status_to_message_type_array() |
|
689 | + * or EEH_MSG_Template::convert_reg_status_to_message_type |
|
690 | + */ |
|
691 | + protected static function _get_reg_status_array($reg_status = '') |
|
692 | + { |
|
693 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
694 | + return EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
695 | + ? EEH_MSG_Template::convert_reg_status_to_message_type($reg_status) |
|
696 | + : EEH_MSG_Template::reg_status_to_message_type_array(); |
|
697 | + } |
|
698 | + |
|
699 | + |
|
700 | + /** |
|
701 | + * Simply returns the payment message type for the given payment status. |
|
702 | + * |
|
703 | + * @param string $payment_status The payment status being matched. |
|
704 | + * @return bool|string The payment message type slug matching the status or false if no match. |
|
705 | + * @throws EE_Error |
|
706 | + * @throws InvalidArgumentException |
|
707 | + * @throws ReflectionException |
|
708 | + * @throws InvalidDataTypeException |
|
709 | + * @throws InvalidInterfaceException |
|
710 | + * @deprecated 4.9.0 Use EEH_MSG_Template::payment_status_to_message_type_array |
|
711 | + * or EEH_MSG_Template::convert_payment_status_to_message_type |
|
712 | + */ |
|
713 | + protected static function _get_payment_message_type($payment_status) |
|
714 | + { |
|
715 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
716 | + return EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
717 | + ? EEH_MSG_Template::convert_payment_status_to_message_type($payment_status) |
|
718 | + : false; |
|
719 | + } |
|
720 | + |
|
721 | + |
|
722 | + /** |
|
723 | + * Message triggers for a resending already sent message(s) (via EE_Message list table) |
|
724 | + * |
|
725 | + * @access public |
|
726 | + * @param array $req_data This is the $_POST & $_GET data sent from EE_Admin Pages |
|
727 | + * @return bool success/fail |
|
728 | + * @throws EE_Error |
|
729 | + * @throws InvalidArgumentException |
|
730 | + * @throws InvalidDataTypeException |
|
731 | + * @throws InvalidInterfaceException |
|
732 | + * @throws ReflectionException |
|
733 | + */ |
|
734 | + public static function process_resend(array $req_data = []) |
|
735 | + { |
|
736 | + self::_load_controller(); |
|
737 | + $request = self::getRequest(); |
|
738 | + // if $msgID in this request then skip to the new resend_message |
|
739 | + if ($request->getRequestParam('MSG_ID')) { |
|
740 | + return self::resend_message(); |
|
741 | + } |
|
742 | + |
|
743 | + // make sure any incoming request data is set on the request so that it gets picked up later. |
|
744 | + foreach ((array) $req_data as $request_key => $request_value) { |
|
745 | + if (! $request->requestParamIsSet($request_key)) { |
|
746 | + $request->setRequestParam($request_key, $request_value); |
|
747 | + } |
|
748 | + } |
|
749 | + |
|
750 | + if ( |
|
751 | + ! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request() |
|
752 | + ) { |
|
753 | + return false; |
|
754 | + } |
|
755 | + |
|
756 | + try { |
|
757 | + self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($messages_to_send); |
|
758 | + self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority(); |
|
759 | + } catch (EE_Error $e) { |
|
760 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
761 | + return false; |
|
762 | + } |
|
763 | + EE_Error::add_success( |
|
764 | + esc_html__('Messages have been successfully queued for generation and sending.', 'event_espresso') |
|
765 | + ); |
|
766 | + return true; // everything got queued. |
|
767 | + } |
|
768 | + |
|
769 | + |
|
770 | + /** |
|
771 | + * Message triggers for a resending already sent message(s) (via EE_Message list table) |
|
772 | + * |
|
773 | + * @return bool |
|
774 | + * @throws EE_Error |
|
775 | + * @throws InvalidArgumentException |
|
776 | + * @throws InvalidDataTypeException |
|
777 | + * @throws InvalidInterfaceException |
|
778 | + * @throws ReflectionException |
|
779 | + */ |
|
780 | + public static function resend_message() |
|
781 | + { |
|
782 | + self::_load_controller(); |
|
783 | + |
|
784 | + $msgID = self::getRequest()->getRequestParam('MSG_ID', 0, 'int'); |
|
785 | + if (! $msgID) { |
|
786 | + EE_Error::add_error( |
|
787 | + esc_html__( |
|
788 | + 'Something went wrong because there is no "MSG_ID" value in the request', |
|
789 | + 'event_espresso' |
|
790 | + ), |
|
791 | + __FILE__, |
|
792 | + __FUNCTION__, |
|
793 | + __LINE__ |
|
794 | + ); |
|
795 | + return false; |
|
796 | + } |
|
797 | + |
|
798 | + self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array) $msgID); |
|
799 | + |
|
800 | + // setup success message. |
|
801 | + $count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
802 | + EE_Error::add_success( |
|
803 | + sprintf( |
|
804 | + _n( |
|
805 | + 'There was %d message queued for resending.', |
|
806 | + 'There were %d messages queued for resending.', |
|
807 | + $count_ready_for_resend, |
|
808 | + 'event_espresso' |
|
809 | + ), |
|
810 | + $count_ready_for_resend |
|
811 | + ) |
|
812 | + ); |
|
813 | + return true; |
|
814 | + } |
|
815 | + |
|
816 | + |
|
817 | + /** |
|
818 | + * Message triggers for manual payment applied by admin |
|
819 | + * |
|
820 | + * @param EE_Payment $payment EE_payment object |
|
821 | + * @return bool success/fail |
|
822 | + * @throws EE_Error |
|
823 | + * @throws InvalidArgumentException |
|
824 | + * @throws ReflectionException |
|
825 | + * @throws InvalidDataTypeException |
|
826 | + * @throws InvalidInterfaceException |
|
827 | + */ |
|
828 | + public static function process_admin_payment(EE_Payment $payment) |
|
829 | + { |
|
830 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
831 | + // we need to get the transaction object |
|
832 | + $transaction = $payment->transaction(); |
|
833 | + if ($transaction instanceof EE_Transaction) { |
|
834 | + $data = [$transaction, $payment]; |
|
835 | + $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID()); |
|
836 | + |
|
837 | + // if payment amount is less than 0 then switch to payment_refund message type. |
|
838 | + $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type; |
|
839 | + |
|
840 | + // if payment_refund is selected, but the status is NOT accepted. Then change message type to false so NO message notification goes out. |
|
841 | + $message_type = $message_type == 'payment_refund' && $payment->STS_ID() != EEM_Payment::status_id_approved |
|
842 | + ? false : $message_type; |
|
843 | + |
|
844 | + self::_load_controller(); |
|
845 | + |
|
846 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data); |
|
847 | + |
|
848 | + // get count of queued for generation |
|
849 | + $count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( |
|
850 | + [ |
|
851 | + EEM_Message::status_incomplete, |
|
852 | + EEM_Message::status_idle, |
|
853 | + ] |
|
854 | + ); |
|
855 | + |
|
856 | + if ($count_to_generate > 0 && self::$_MSG_PROCESSOR->get_queue()->get_message_repository()->count() !== 0) { |
|
857 | + add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true'); |
|
858 | + return true; |
|
859 | + } else { |
|
860 | + $count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( |
|
861 | + EEM_Message::instance()->stati_indicating_failed_sending() |
|
862 | + ); |
|
863 | + /** |
|
864 | + * Verify that there are actually errors. If not then we return a success message because the queue might have been emptied due to successful |
|
865 | + * IMMEDIATE generation. |
|
866 | + */ |
|
867 | + if ($count_failed > 0) { |
|
868 | + EE_Error::add_error( |
|
869 | + sprintf( |
|
870 | + _n( |
|
871 | + 'The payment notification generation failed.', |
|
872 | + '%d payment notifications failed being sent.', |
|
873 | + $count_failed, |
|
874 | + 'event_espresso' |
|
875 | + ), |
|
876 | + $count_failed |
|
877 | + ), |
|
878 | + __FILE__, |
|
879 | + __FUNCTION__, |
|
880 | + __LINE__ |
|
881 | + ); |
|
882 | + |
|
883 | + return false; |
|
884 | + } else { |
|
885 | + add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true'); |
|
886 | + return true; |
|
887 | + } |
|
888 | + } |
|
889 | + } else { |
|
890 | + EE_Error::add_error( |
|
891 | + 'Unable to generate the payment notification because the given value for the transaction is invalid.', |
|
892 | + 'event_espresso' |
|
893 | + ); |
|
894 | + return false; |
|
895 | + } |
|
896 | + } |
|
897 | + |
|
898 | + |
|
899 | + /** |
|
900 | + * Callback for AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send_with_registrations trigger |
|
901 | + * |
|
902 | + * @param EE_Registration[] $registrations an array of EE_Registration objects |
|
903 | + * @param int $grp_id a specific message template group id. |
|
904 | + * @return void |
|
905 | + * @throws EE_Error |
|
906 | + * @throws InvalidArgumentException |
|
907 | + * @throws InvalidDataTypeException |
|
908 | + * @throws InvalidInterfaceException |
|
909 | + * @throws ReflectionException |
|
910 | + * @since 4.3.0 |
|
911 | + */ |
|
912 | + public static function send_newsletter_message($registrations, $grp_id) |
|
913 | + { |
|
914 | + // make sure mtp is id and set it in the request later messages setup. |
|
915 | + self::getRequest()->setRequestParam('GRP_ID', (int) $grp_id); |
|
916 | + self::_load_controller(); |
|
917 | + self::$_MSG_PROCESSOR->generate_for_all_active_messengers('newsletter', $registrations); |
|
918 | + } |
|
919 | + |
|
920 | + |
|
921 | + /** |
|
922 | + * Callback for FHEE__EE_Registration__invoice_url__invoice_url or FHEE__EE_Registration__receipt_url__receipt_url |
|
923 | + * |
|
924 | + * @param string $registration_message_trigger_url |
|
925 | + * @param EE_Registration $registration |
|
926 | + * @param string $messenger |
|
927 | + * @param string $message_type |
|
928 | + * @return string |
|
929 | + * @throws EE_Error |
|
930 | + * @throws InvalidArgumentException |
|
931 | + * @throws InvalidDataTypeException |
|
932 | + * @throws InvalidInterfaceException |
|
933 | + * @since 4.3.0 |
|
934 | + */ |
|
935 | + public static function registration_message_trigger_url( |
|
936 | + $registration_message_trigger_url, |
|
937 | + EE_Registration $registration, |
|
938 | + $messenger = 'html', |
|
939 | + $message_type = 'invoice' |
|
940 | + ) { |
|
941 | + // whitelist $messenger |
|
942 | + switch ($messenger) { |
|
943 | + case 'pdf': |
|
944 | + $sending_messenger = 'pdf'; |
|
945 | + $generating_messenger = 'html'; |
|
946 | + break; |
|
947 | + case 'html': |
|
948 | + default: |
|
949 | + $sending_messenger = 'html'; |
|
950 | + $generating_messenger = 'html'; |
|
951 | + break; |
|
952 | + } |
|
953 | + // whitelist $message_type |
|
954 | + switch ($message_type) { |
|
955 | + case 'receipt': |
|
956 | + $message_type = 'receipt'; |
|
957 | + break; |
|
958 | + case 'invoice': |
|
959 | + default: |
|
960 | + $message_type = 'invoice'; |
|
961 | + break; |
|
962 | + } |
|
963 | + // verify that both the messenger AND the message type are active |
|
964 | + if ( |
|
965 | + EEH_MSG_Template::is_messenger_active($sending_messenger) |
|
966 | + && EEH_MSG_Template::is_mt_active($message_type) |
|
967 | + ) { |
|
968 | + // need to get the correct message template group for this (i.e. is there a custom invoice for the event this registration is registered for?) |
|
969 | + $template_query_params = [ |
|
970 | + 'MTP_is_active' => true, |
|
971 | + 'MTP_messenger' => $generating_messenger, |
|
972 | + 'MTP_message_type' => $message_type, |
|
973 | + 'Event.EVT_ID' => $registration->event_ID(), |
|
974 | + ]; |
|
975 | + // get the message template group. |
|
976 | + $msg_template_group = EEM_Message_Template_Group::instance()->get_one([$template_query_params]); |
|
977 | + // if we don't have an EE_Message_Template_Group then return |
|
978 | + if (! $msg_template_group instanceof EE_Message_Template_Group) { |
|
979 | + // remove EVT_ID from query params so that global templates get picked up |
|
980 | + unset($template_query_params['Event.EVT_ID']); |
|
981 | + // get global template as the fallback |
|
982 | + $msg_template_group = EEM_Message_Template_Group::instance()->get_one([$template_query_params]); |
|
983 | + } |
|
984 | + // if we don't have an EE_Message_Template_Group then return |
|
985 | + if (! $msg_template_group instanceof EE_Message_Template_Group) { |
|
986 | + return ''; |
|
987 | + } |
|
988 | + // generate the URL |
|
989 | + $registration_message_trigger_url = EEH_MSG_Template::generate_url_trigger( |
|
990 | + $sending_messenger, |
|
991 | + $generating_messenger, |
|
992 | + 'purchaser', |
|
993 | + $message_type, |
|
994 | + $registration, |
|
995 | + $msg_template_group->ID(), |
|
996 | + $registration->transaction_ID() |
|
997 | + ); |
|
998 | + } |
|
999 | + return $registration_message_trigger_url; |
|
1000 | + } |
|
1001 | + |
|
1002 | + |
|
1003 | + /** |
|
1004 | + * Use to generate and return a message preview! |
|
1005 | + * |
|
1006 | + * @param string $type This should correspond with a valid message type |
|
1007 | + * @param string $context This should correspond with a valid context for the message type |
|
1008 | + * @param string $messenger This should correspond with a valid messenger. |
|
1009 | + * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular |
|
1010 | + * preview |
|
1011 | + * @return bool|string The body of the message or if send is requested, sends. |
|
1012 | + * @throws EE_Error |
|
1013 | + * @throws InvalidArgumentException |
|
1014 | + * @throws InvalidDataTypeException |
|
1015 | + * @throws InvalidInterfaceException |
|
1016 | + * @throws ReflectionException |
|
1017 | + */ |
|
1018 | + public static function preview_message($type, $context, $messenger, $send = false) |
|
1019 | + { |
|
1020 | + self::_load_controller(); |
|
1021 | + $message_to_generate = new EE_Message_To_Generate( |
|
1022 | + $messenger, |
|
1023 | + $type, |
|
1024 | + [], |
|
1025 | + $context, |
|
1026 | + true |
|
1027 | + ); |
|
1028 | + $generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview($message_to_generate, $send); |
|
1029 | + |
|
1030 | + if ($generated_preview_queue instanceof EE_Messages_Queue) { |
|
1031 | + // loop through all content for the preview and remove any persisted records. |
|
1032 | + $content = ''; |
|
1033 | + foreach ($generated_preview_queue->get_message_repository() as $message) { |
|
1034 | + $content = $message->content(); |
|
1035 | + if ($message->ID() > 0 && $message->STS_ID() !== EEM_Message::status_failed) { |
|
1036 | + $message->delete(); |
|
1037 | + } |
|
1038 | + } |
|
1039 | + return $content; |
|
1040 | + } |
|
1041 | + return $generated_preview_queue; |
|
1042 | + } |
|
1043 | + |
|
1044 | + |
|
1045 | + /** |
|
1046 | + * This is a method that allows for sending a message using a messenger matching the string given and the provided |
|
1047 | + * EE_Message_Queue object. The EE_Message_Queue object is used to create a single aggregate EE_Message via the |
|
1048 | + * content found in the EE_Message objects in the queue. |
|
1049 | + * |
|
1050 | + * @param string $messenger a string matching a valid active messenger in the system |
|
1051 | + * @param string $message_type Although it seems contrary to the name of the method, a message |
|
1052 | + * type name is still required to send along the message type to the |
|
1053 | + * messenger because this is used for determining what specific |
|
1054 | + * variations might be loaded for the generated message. |
|
1055 | + * @param EE_Messages_Queue $queue |
|
1056 | + * @param string $custom_subject Can be used to set what the custom subject string will be on the |
|
1057 | + * aggregate EE_Message object. |
|
1058 | + * @return bool success or fail. |
|
1059 | + * @throws EE_Error |
|
1060 | + * @throws InvalidArgumentException |
|
1061 | + * @throws ReflectionException |
|
1062 | + * @throws InvalidDataTypeException |
|
1063 | + * @throws InvalidInterfaceException |
|
1064 | + * @since 4.9.0 |
|
1065 | + */ |
|
1066 | + public static function send_message_with_messenger_only( |
|
1067 | + $messenger, |
|
1068 | + $message_type, |
|
1069 | + EE_Messages_Queue $queue, |
|
1070 | + $custom_subject = '' |
|
1071 | + ) { |
|
1072 | + self::_load_controller(); |
|
1073 | + /** @type EE_Message_To_Generate_From_Queue $message_to_generate */ |
|
1074 | + $message_to_generate = EE_Registry::instance()->load_lib( |
|
1075 | + 'Message_To_Generate_From_Queue', |
|
1076 | + [ |
|
1077 | + $messenger, |
|
1078 | + $message_type, |
|
1079 | + $queue, |
|
1080 | + $custom_subject, |
|
1081 | + ] |
|
1082 | + ); |
|
1083 | + return self::$_MSG_PROCESSOR->queue_for_sending($message_to_generate); |
|
1084 | + } |
|
1085 | + |
|
1086 | + |
|
1087 | + /** |
|
1088 | + * Generates Messages immediately for EE_Message IDs (but only for the correct status for generation) |
|
1089 | + * |
|
1090 | + * @param array $message_ids An array of message ids |
|
1091 | + * @return bool|EE_Messages_Queue false if nothing was generated, EE_Messages_Queue containing generated |
|
1092 | + * messages. |
|
1093 | + * @throws EE_Error |
|
1094 | + * @throws InvalidArgumentException |
|
1095 | + * @throws InvalidDataTypeException |
|
1096 | + * @throws InvalidInterfaceException |
|
1097 | + * @throws ReflectionException |
|
1098 | + * @since 4.9.0 |
|
1099 | + */ |
|
1100 | + public static function generate_now($message_ids) |
|
1101 | + { |
|
1102 | + self::_load_controller(); |
|
1103 | + $messages = EEM_Message::instance()->get_all( |
|
1104 | + [ |
|
1105 | + 0 => [ |
|
1106 | + 'MSG_ID' => ['IN', $message_ids], |
|
1107 | + 'STS_ID' => EEM_Message::status_incomplete, |
|
1108 | + ], |
|
1109 | + ] |
|
1110 | + ); |
|
1111 | + $generated_queue = false; |
|
1112 | + if ($messages) { |
|
1113 | + $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages); |
|
1114 | + } |
|
1115 | + |
|
1116 | + if (! $generated_queue instanceof EE_Messages_Queue) { |
|
1117 | + EE_Error::add_error( |
|
1118 | + esc_html__( |
|
1119 | + 'The messages were not generated. This could mean there is already a batch being generated on a separate request, or because the selected messages are not ready for generation. Please wait a minute or two and try again.', |
|
1120 | + 'event_espresso' |
|
1121 | + ), |
|
1122 | + __FILE__, |
|
1123 | + __FUNCTION__, |
|
1124 | + __LINE__ |
|
1125 | + ); |
|
1126 | + } |
|
1127 | + return $generated_queue; |
|
1128 | + } |
|
1129 | + |
|
1130 | + |
|
1131 | + /** |
|
1132 | + * Sends messages immediately for the incoming message_ids that have the status of EEM_Message::status_resend or, |
|
1133 | + * EEM_Message::status_idle |
|
1134 | + * |
|
1135 | + * @param $message_ids |
|
1136 | + * @return bool|EE_Messages_Queue false if no messages sent. |
|
1137 | + * @throws EE_Error |
|
1138 | + * @throws InvalidArgumentException |
|
1139 | + * @throws InvalidDataTypeException |
|
1140 | + * @throws InvalidInterfaceException |
|
1141 | + * @throws ReflectionException |
|
1142 | + * @since 4.9.0 |
|
1143 | + */ |
|
1144 | + public static function send_now($message_ids) |
|
1145 | + { |
|
1146 | + self::_load_controller(); |
|
1147 | + $messages = EEM_Message::instance()->get_all( |
|
1148 | + [ |
|
1149 | + 0 => [ |
|
1150 | + 'MSG_ID' => ['IN', $message_ids], |
|
1151 | + 'STS_ID' => [ |
|
1152 | + 'IN', |
|
1153 | + [EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry], |
|
1154 | + ], |
|
1155 | + ], |
|
1156 | + ] |
|
1157 | + ); |
|
1158 | + $sent_queue = false; |
|
1159 | + if ($messages) { |
|
1160 | + $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages); |
|
1161 | + } |
|
1162 | + |
|
1163 | + if (! $sent_queue instanceof EE_Messages_Queue) { |
|
1164 | + EE_Error::add_error( |
|
1165 | + esc_html__( |
|
1166 | + 'The messages were not sent. This could mean there is already a batch being sent on a separate request, or because the selected messages are not sendable. Please wait a minute or two and try again.', |
|
1167 | + 'event_espresso' |
|
1168 | + ), |
|
1169 | + __FILE__, |
|
1170 | + __FUNCTION__, |
|
1171 | + __LINE__ |
|
1172 | + ); |
|
1173 | + } else { |
|
1174 | + // can count how many sent by using the messages in the queue |
|
1175 | + $sent_count = $sent_queue->count_STS_in_queue(EEM_Message::instance()->stati_indicating_sent()); |
|
1176 | + if ($sent_count > 0) { |
|
1177 | + EE_Error::add_success( |
|
1178 | + sprintf( |
|
1179 | + _n( |
|
1180 | + 'There was %d message successfully sent.', |
|
1181 | + 'There were %d messages successfully sent.', |
|
1182 | + $sent_count, |
|
1183 | + 'event_espresso' |
|
1184 | + ), |
|
1185 | + $sent_count |
|
1186 | + ) |
|
1187 | + ); |
|
1188 | + } else { |
|
1189 | + EE_Error::overwrite_errors(); |
|
1190 | + EE_Error::add_error( |
|
1191 | + esc_html__( |
|
1192 | + 'No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, they were ALREADY sent on a different scheduled task, or there was an error. |
|
1193 | 1193 | If there was an error, you can look at the messages in the message activity list table for any error messages.', |
1194 | - 'event_espresso' |
|
1195 | - ), |
|
1196 | - __FILE__, |
|
1197 | - __FUNCTION__, |
|
1198 | - __LINE__ |
|
1199 | - ); |
|
1200 | - } |
|
1201 | - } |
|
1202 | - return $sent_queue; |
|
1203 | - } |
|
1204 | - |
|
1205 | - |
|
1206 | - /** |
|
1207 | - * Generate and send immediately from the given $message_ids |
|
1208 | - * |
|
1209 | - * @param array $message_ids EE_Message entity ids. |
|
1210 | - * @throws EE_Error |
|
1211 | - * @throws InvalidArgumentException |
|
1212 | - * @throws InvalidDataTypeException |
|
1213 | - * @throws InvalidInterfaceException |
|
1214 | - * @throws ReflectionException |
|
1215 | - */ |
|
1216 | - public static function generate_and_send_now(array $message_ids) |
|
1217 | - { |
|
1218 | - $generated_queue = self::generate_now($message_ids); |
|
1219 | - // now let's just trigger sending immediately from this queue. |
|
1220 | - $messages_sent = $generated_queue instanceof EE_Messages_Queue |
|
1221 | - ? $generated_queue->execute() |
|
1222 | - : 0; |
|
1223 | - if ($messages_sent) { |
|
1224 | - EE_Error::add_success( |
|
1225 | - esc_html( |
|
1226 | - sprintf( |
|
1227 | - _n( |
|
1228 | - 'There was %d message successfully generated and sent.', |
|
1229 | - 'There were %d messages successfully generated and sent.', |
|
1230 | - $messages_sent, |
|
1231 | - 'event_espresso' |
|
1232 | - ), |
|
1233 | - $messages_sent |
|
1234 | - ) |
|
1235 | - ) |
|
1236 | - ); |
|
1237 | - // errors would be added via the generate_now method. |
|
1238 | - } |
|
1239 | - } |
|
1240 | - |
|
1241 | - |
|
1242 | - /** |
|
1243 | - * This will queue the incoming message ids for resending. |
|
1244 | - * Note, only message_ids corresponding to messages with the status of EEM_Message::sent will be queued. |
|
1245 | - * |
|
1246 | - * @param array $message_ids An array of EE_Message IDs |
|
1247 | - * @return bool true means messages were successfully queued for resending, false means none were queued for |
|
1248 | - * resending. |
|
1249 | - * @throws EE_Error |
|
1250 | - * @throws InvalidArgumentException |
|
1251 | - * @throws InvalidDataTypeException |
|
1252 | - * @throws InvalidInterfaceException |
|
1253 | - * @throws ReflectionException |
|
1254 | - * @since 4.9.0 |
|
1255 | - */ |
|
1256 | - public static function queue_for_resending($message_ids) |
|
1257 | - { |
|
1258 | - self::_load_controller(); |
|
1259 | - self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send($message_ids); |
|
1260 | - |
|
1261 | - // get queue and count |
|
1262 | - $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
1263 | - |
|
1264 | - if ( |
|
1265 | - $queue_count > 0 |
|
1266 | - ) { |
|
1267 | - EE_Error::add_success( |
|
1268 | - sprintf( |
|
1269 | - _n( |
|
1270 | - '%d message successfully queued for resending.', |
|
1271 | - '%d messages successfully queued for resending.', |
|
1272 | - $queue_count, |
|
1273 | - 'event_espresso' |
|
1274 | - ), |
|
1275 | - $queue_count |
|
1276 | - ) |
|
1277 | - ); |
|
1278 | - /** |
|
1279 | - * @see filter usage in EE_Messages_Queue::initiate_request_by_priority |
|
1280 | - */ |
|
1281 | - } elseif ( |
|
1282 | - apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', true) |
|
1283 | - || EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
|
1284 | - ) { |
|
1285 | - $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_sent); |
|
1286 | - if ($queue_count > 0) { |
|
1287 | - EE_Error::add_success( |
|
1288 | - sprintf( |
|
1289 | - _n( |
|
1290 | - '%d message successfully sent.', |
|
1291 | - '%d messages successfully sent.', |
|
1292 | - $queue_count, |
|
1293 | - 'event_espresso' |
|
1294 | - ), |
|
1295 | - $queue_count |
|
1296 | - ) |
|
1297 | - ); |
|
1298 | - } else { |
|
1299 | - EE_Error::add_error( |
|
1300 | - esc_html__( |
|
1301 | - 'No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.', |
|
1302 | - 'event_espresso' |
|
1303 | - ), |
|
1304 | - __FILE__, |
|
1305 | - __FUNCTION__, |
|
1306 | - __LINE__ |
|
1307 | - ); |
|
1308 | - } |
|
1309 | - } else { |
|
1310 | - EE_Error::add_error( |
|
1311 | - esc_html__( |
|
1312 | - 'No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.', |
|
1313 | - 'event_espresso' |
|
1314 | - ), |
|
1315 | - __FILE__, |
|
1316 | - __FUNCTION__, |
|
1317 | - __LINE__ |
|
1318 | - ); |
|
1319 | - } |
|
1320 | - return (bool) $queue_count; |
|
1321 | - } |
|
1322 | - |
|
1323 | - |
|
1324 | - /** |
|
1325 | - * debug |
|
1326 | - * |
|
1327 | - * @param string $class |
|
1328 | - * @param string $func |
|
1329 | - * @param string $line |
|
1330 | - * @param \EE_Transaction $transaction |
|
1331 | - * @param array $info |
|
1332 | - * @param bool $display_request |
|
1333 | - * @throws EE_Error |
|
1334 | - * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
|
1335 | - */ |
|
1336 | - protected static function log( |
|
1337 | - $class = '', |
|
1338 | - $func = '', |
|
1339 | - $line = '', |
|
1340 | - EE_Transaction $transaction, |
|
1341 | - $info = [], |
|
1342 | - $display_request = false |
|
1343 | - ) { |
|
1344 | - if (defined('EE_DEBUG') && EE_DEBUG) { |
|
1345 | - if ($transaction instanceof EE_Transaction) { |
|
1346 | - // don't serialize objects |
|
1347 | - $info = EEH_Debug_Tools::strip_objects($info); |
|
1348 | - $info['TXN_status'] = $transaction->status_ID(); |
|
1349 | - $info['TXN_reg_steps'] = $transaction->reg_steps(); |
|
1350 | - if ($transaction->ID()) { |
|
1351 | - $index = 'EE_Transaction: ' . $transaction->ID(); |
|
1352 | - EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index); |
|
1353 | - } |
|
1354 | - } |
|
1355 | - } |
|
1356 | - } |
|
1357 | - |
|
1358 | - |
|
1359 | - /** |
|
1360 | - * Resets all the static properties in this class when called. |
|
1361 | - */ |
|
1362 | - public static function reset() |
|
1363 | - { |
|
1364 | - self::$_EEMSG = null; |
|
1365 | - self::$_message_resource_manager = null; |
|
1366 | - self::$_MSG_PROCESSOR = null; |
|
1367 | - self::$_MSG_PATHS = null; |
|
1368 | - self::$_TMP_PACKS = []; |
|
1369 | - } |
|
1194 | + 'event_espresso' |
|
1195 | + ), |
|
1196 | + __FILE__, |
|
1197 | + __FUNCTION__, |
|
1198 | + __LINE__ |
|
1199 | + ); |
|
1200 | + } |
|
1201 | + } |
|
1202 | + return $sent_queue; |
|
1203 | + } |
|
1204 | + |
|
1205 | + |
|
1206 | + /** |
|
1207 | + * Generate and send immediately from the given $message_ids |
|
1208 | + * |
|
1209 | + * @param array $message_ids EE_Message entity ids. |
|
1210 | + * @throws EE_Error |
|
1211 | + * @throws InvalidArgumentException |
|
1212 | + * @throws InvalidDataTypeException |
|
1213 | + * @throws InvalidInterfaceException |
|
1214 | + * @throws ReflectionException |
|
1215 | + */ |
|
1216 | + public static function generate_and_send_now(array $message_ids) |
|
1217 | + { |
|
1218 | + $generated_queue = self::generate_now($message_ids); |
|
1219 | + // now let's just trigger sending immediately from this queue. |
|
1220 | + $messages_sent = $generated_queue instanceof EE_Messages_Queue |
|
1221 | + ? $generated_queue->execute() |
|
1222 | + : 0; |
|
1223 | + if ($messages_sent) { |
|
1224 | + EE_Error::add_success( |
|
1225 | + esc_html( |
|
1226 | + sprintf( |
|
1227 | + _n( |
|
1228 | + 'There was %d message successfully generated and sent.', |
|
1229 | + 'There were %d messages successfully generated and sent.', |
|
1230 | + $messages_sent, |
|
1231 | + 'event_espresso' |
|
1232 | + ), |
|
1233 | + $messages_sent |
|
1234 | + ) |
|
1235 | + ) |
|
1236 | + ); |
|
1237 | + // errors would be added via the generate_now method. |
|
1238 | + } |
|
1239 | + } |
|
1240 | + |
|
1241 | + |
|
1242 | + /** |
|
1243 | + * This will queue the incoming message ids for resending. |
|
1244 | + * Note, only message_ids corresponding to messages with the status of EEM_Message::sent will be queued. |
|
1245 | + * |
|
1246 | + * @param array $message_ids An array of EE_Message IDs |
|
1247 | + * @return bool true means messages were successfully queued for resending, false means none were queued for |
|
1248 | + * resending. |
|
1249 | + * @throws EE_Error |
|
1250 | + * @throws InvalidArgumentException |
|
1251 | + * @throws InvalidDataTypeException |
|
1252 | + * @throws InvalidInterfaceException |
|
1253 | + * @throws ReflectionException |
|
1254 | + * @since 4.9.0 |
|
1255 | + */ |
|
1256 | + public static function queue_for_resending($message_ids) |
|
1257 | + { |
|
1258 | + self::_load_controller(); |
|
1259 | + self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send($message_ids); |
|
1260 | + |
|
1261 | + // get queue and count |
|
1262 | + $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend); |
|
1263 | + |
|
1264 | + if ( |
|
1265 | + $queue_count > 0 |
|
1266 | + ) { |
|
1267 | + EE_Error::add_success( |
|
1268 | + sprintf( |
|
1269 | + _n( |
|
1270 | + '%d message successfully queued for resending.', |
|
1271 | + '%d messages successfully queued for resending.', |
|
1272 | + $queue_count, |
|
1273 | + 'event_espresso' |
|
1274 | + ), |
|
1275 | + $queue_count |
|
1276 | + ) |
|
1277 | + ); |
|
1278 | + /** |
|
1279 | + * @see filter usage in EE_Messages_Queue::initiate_request_by_priority |
|
1280 | + */ |
|
1281 | + } elseif ( |
|
1282 | + apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', true) |
|
1283 | + || EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
|
1284 | + ) { |
|
1285 | + $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_sent); |
|
1286 | + if ($queue_count > 0) { |
|
1287 | + EE_Error::add_success( |
|
1288 | + sprintf( |
|
1289 | + _n( |
|
1290 | + '%d message successfully sent.', |
|
1291 | + '%d messages successfully sent.', |
|
1292 | + $queue_count, |
|
1293 | + 'event_espresso' |
|
1294 | + ), |
|
1295 | + $queue_count |
|
1296 | + ) |
|
1297 | + ); |
|
1298 | + } else { |
|
1299 | + EE_Error::add_error( |
|
1300 | + esc_html__( |
|
1301 | + 'No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.', |
|
1302 | + 'event_espresso' |
|
1303 | + ), |
|
1304 | + __FILE__, |
|
1305 | + __FUNCTION__, |
|
1306 | + __LINE__ |
|
1307 | + ); |
|
1308 | + } |
|
1309 | + } else { |
|
1310 | + EE_Error::add_error( |
|
1311 | + esc_html__( |
|
1312 | + 'No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.', |
|
1313 | + 'event_espresso' |
|
1314 | + ), |
|
1315 | + __FILE__, |
|
1316 | + __FUNCTION__, |
|
1317 | + __LINE__ |
|
1318 | + ); |
|
1319 | + } |
|
1320 | + return (bool) $queue_count; |
|
1321 | + } |
|
1322 | + |
|
1323 | + |
|
1324 | + /** |
|
1325 | + * debug |
|
1326 | + * |
|
1327 | + * @param string $class |
|
1328 | + * @param string $func |
|
1329 | + * @param string $line |
|
1330 | + * @param \EE_Transaction $transaction |
|
1331 | + * @param array $info |
|
1332 | + * @param bool $display_request |
|
1333 | + * @throws EE_Error |
|
1334 | + * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
|
1335 | + */ |
|
1336 | + protected static function log( |
|
1337 | + $class = '', |
|
1338 | + $func = '', |
|
1339 | + $line = '', |
|
1340 | + EE_Transaction $transaction, |
|
1341 | + $info = [], |
|
1342 | + $display_request = false |
|
1343 | + ) { |
|
1344 | + if (defined('EE_DEBUG') && EE_DEBUG) { |
|
1345 | + if ($transaction instanceof EE_Transaction) { |
|
1346 | + // don't serialize objects |
|
1347 | + $info = EEH_Debug_Tools::strip_objects($info); |
|
1348 | + $info['TXN_status'] = $transaction->status_ID(); |
|
1349 | + $info['TXN_reg_steps'] = $transaction->reg_steps(); |
|
1350 | + if ($transaction->ID()) { |
|
1351 | + $index = 'EE_Transaction: ' . $transaction->ID(); |
|
1352 | + EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index); |
|
1353 | + } |
|
1354 | + } |
|
1355 | + } |
|
1356 | + } |
|
1357 | + |
|
1358 | + |
|
1359 | + /** |
|
1360 | + * Resets all the static properties in this class when called. |
|
1361 | + */ |
|
1362 | + public static function reset() |
|
1363 | + { |
|
1364 | + self::$_EEMSG = null; |
|
1365 | + self::$_message_resource_manager = null; |
|
1366 | + self::$_MSG_PROCESSOR = null; |
|
1367 | + self::$_MSG_PATHS = null; |
|
1368 | + self::$_TMP_PACKS = []; |
|
1369 | + } |
|
1370 | 1370 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | 'event_espresso' |
206 | 206 | ); |
207 | 207 | // add specific message for developers if WP_DEBUG in on |
208 | - $error_msg .= '||' . $e->getMessage(); |
|
208 | + $error_msg .= '||'.$e->getMessage(); |
|
209 | 209 | EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
210 | 210 | } |
211 | 211 | } |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | 'event_espresso' |
292 | 292 | ); |
293 | 293 | // add specific message for developers if WP_DEBUG in on |
294 | - $error_msg .= '||' . $e->getMessage(); |
|
294 | + $error_msg .= '||'.$e->getMessage(); |
|
295 | 295 | EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
296 | 296 | } |
297 | 297 | } |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | $transient_key = $request->getRequestParam('key'); |
324 | 324 | |
325 | 325 | // now let's verify transient, if not valid exit immediately |
326 | - if (! get_transient($transient_key)) { |
|
326 | + if ( ! get_transient($transient_key)) { |
|
327 | 327 | /** |
328 | 328 | * trigger error so this gets in the error logs. This is important because it happens on a non-user |
329 | 329 | * request. |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | delete_transient($transient_key); |
336 | 336 | |
337 | 337 | if (apply_filters('FHEE__EED_Messages__run_cron__use_wp_cron', true)) { |
338 | - $method = 'batch_' . $cron_type . '_from_queue'; |
|
338 | + $method = 'batch_'.$cron_type.'_from_queue'; |
|
339 | 339 | if (method_exists(self::$_MSG_PROCESSOR, $method)) { |
340 | 340 | self::$_MSG_PROCESSOR->$method(); |
341 | 341 | } else { |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | $template_pack_collection->rewind(); |
403 | 403 | $template_packs = []; |
404 | 404 | while ($template_pack_collection->valid()) { |
405 | - $template_packs[ $template_pack_collection->current()->dbref ] = $template_pack_collection->current(); |
|
405 | + $template_packs[$template_pack_collection->current()->dbref] = $template_pack_collection->current(); |
|
406 | 406 | $template_pack_collection->next(); |
407 | 407 | } |
408 | 408 | return $template_packs; |
@@ -450,9 +450,9 @@ discard block |
||
450 | 450 | 'messages/validators/html', |
451 | 451 | 'shortcodes', |
452 | 452 | ]; |
453 | - $paths = []; |
|
453 | + $paths = []; |
|
454 | 454 | foreach ($dir_ref as $index => $dir) { |
455 | - $paths[ $index ] = EE_LIBRARIES . $dir; |
|
455 | + $paths[$index] = EE_LIBRARIES.$dir; |
|
456 | 456 | } |
457 | 457 | self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths); |
458 | 458 | } |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | */ |
472 | 472 | protected static function _load_controller() |
473 | 473 | { |
474 | - if (! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) { |
|
474 | + if ( ! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) { |
|
475 | 475 | EE_Registry::instance()->load_core('Request_Handler'); |
476 | 476 | self::set_autoloaders(); |
477 | 477 | self::$_EEMSG = EE_Registry::instance()->load_lib('messages'); |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | public static function payment(EE_Transaction $transaction, EE_Payment $payment = null) |
513 | 513 | { |
514 | 514 | // if there's no payment object, then we cannot do a payment type message! |
515 | - if (! $payment instanceof EE_Payment) { |
|
515 | + if ( ! $payment instanceof EE_Payment) { |
|
516 | 516 | return; |
517 | 517 | } |
518 | 518 | self::_load_controller(); |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | public static function maybe_registration(EE_Registration $registration, $extra_details = []) |
560 | 560 | { |
561 | 561 | |
562 | - if (! self::_verify_registration_notification_send($registration, $extra_details)) { |
|
562 | + if ( ! self::_verify_registration_notification_send($registration, $extra_details)) { |
|
563 | 563 | // no messages please |
564 | 564 | return; |
565 | 565 | } |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | } else { |
651 | 651 | // frontend request (either regular or via AJAX) |
652 | 652 | // TXN is NOT finalized ? |
653 | - if (! isset($extra_details['finalized']) || $extra_details['finalized'] === false) { |
|
653 | + if ( ! isset($extra_details['finalized']) || $extra_details['finalized'] === false) { |
|
654 | 654 | return false; |
655 | 655 | } |
656 | 656 | // return visit but nothing changed ??? |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | |
743 | 743 | // make sure any incoming request data is set on the request so that it gets picked up later. |
744 | 744 | foreach ((array) $req_data as $request_key => $request_value) { |
745 | - if (! $request->requestParamIsSet($request_key)) { |
|
745 | + if ( ! $request->requestParamIsSet($request_key)) { |
|
746 | 746 | $request->setRequestParam($request_key, $request_value); |
747 | 747 | } |
748 | 748 | } |
@@ -782,7 +782,7 @@ discard block |
||
782 | 782 | self::_load_controller(); |
783 | 783 | |
784 | 784 | $msgID = self::getRequest()->getRequestParam('MSG_ID', 0, 'int'); |
785 | - if (! $msgID) { |
|
785 | + if ( ! $msgID) { |
|
786 | 786 | EE_Error::add_error( |
787 | 787 | esc_html__( |
788 | 788 | 'Something went wrong because there is no "MSG_ID" value in the request', |
@@ -975,14 +975,14 @@ discard block |
||
975 | 975 | // get the message template group. |
976 | 976 | $msg_template_group = EEM_Message_Template_Group::instance()->get_one([$template_query_params]); |
977 | 977 | // if we don't have an EE_Message_Template_Group then return |
978 | - if (! $msg_template_group instanceof EE_Message_Template_Group) { |
|
978 | + if ( ! $msg_template_group instanceof EE_Message_Template_Group) { |
|
979 | 979 | // remove EVT_ID from query params so that global templates get picked up |
980 | 980 | unset($template_query_params['Event.EVT_ID']); |
981 | 981 | // get global template as the fallback |
982 | 982 | $msg_template_group = EEM_Message_Template_Group::instance()->get_one([$template_query_params]); |
983 | 983 | } |
984 | 984 | // if we don't have an EE_Message_Template_Group then return |
985 | - if (! $msg_template_group instanceof EE_Message_Template_Group) { |
|
985 | + if ( ! $msg_template_group instanceof EE_Message_Template_Group) { |
|
986 | 986 | return ''; |
987 | 987 | } |
988 | 988 | // generate the URL |
@@ -1018,7 +1018,7 @@ discard block |
||
1018 | 1018 | public static function preview_message($type, $context, $messenger, $send = false) |
1019 | 1019 | { |
1020 | 1020 | self::_load_controller(); |
1021 | - $message_to_generate = new EE_Message_To_Generate( |
|
1021 | + $message_to_generate = new EE_Message_To_Generate( |
|
1022 | 1022 | $messenger, |
1023 | 1023 | $type, |
1024 | 1024 | [], |
@@ -1100,7 +1100,7 @@ discard block |
||
1100 | 1100 | public static function generate_now($message_ids) |
1101 | 1101 | { |
1102 | 1102 | self::_load_controller(); |
1103 | - $messages = EEM_Message::instance()->get_all( |
|
1103 | + $messages = EEM_Message::instance()->get_all( |
|
1104 | 1104 | [ |
1105 | 1105 | 0 => [ |
1106 | 1106 | 'MSG_ID' => ['IN', $message_ids], |
@@ -1113,7 +1113,7 @@ discard block |
||
1113 | 1113 | $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages); |
1114 | 1114 | } |
1115 | 1115 | |
1116 | - if (! $generated_queue instanceof EE_Messages_Queue) { |
|
1116 | + if ( ! $generated_queue instanceof EE_Messages_Queue) { |
|
1117 | 1117 | EE_Error::add_error( |
1118 | 1118 | esc_html__( |
1119 | 1119 | 'The messages were not generated. This could mean there is already a batch being generated on a separate request, or because the selected messages are not ready for generation. Please wait a minute or two and try again.', |
@@ -1144,7 +1144,7 @@ discard block |
||
1144 | 1144 | public static function send_now($message_ids) |
1145 | 1145 | { |
1146 | 1146 | self::_load_controller(); |
1147 | - $messages = EEM_Message::instance()->get_all( |
|
1147 | + $messages = EEM_Message::instance()->get_all( |
|
1148 | 1148 | [ |
1149 | 1149 | 0 => [ |
1150 | 1150 | 'MSG_ID' => ['IN', $message_ids], |
@@ -1160,7 +1160,7 @@ discard block |
||
1160 | 1160 | $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages); |
1161 | 1161 | } |
1162 | 1162 | |
1163 | - if (! $sent_queue instanceof EE_Messages_Queue) { |
|
1163 | + if ( ! $sent_queue instanceof EE_Messages_Queue) { |
|
1164 | 1164 | EE_Error::add_error( |
1165 | 1165 | esc_html__( |
1166 | 1166 | 'The messages were not sent. This could mean there is already a batch being sent on a separate request, or because the selected messages are not sendable. Please wait a minute or two and try again.', |
@@ -1348,7 +1348,7 @@ discard block |
||
1348 | 1348 | $info['TXN_status'] = $transaction->status_ID(); |
1349 | 1349 | $info['TXN_reg_steps'] = $transaction->reg_steps(); |
1350 | 1350 | if ($transaction->ID()) { |
1351 | - $index = 'EE_Transaction: ' . $transaction->ID(); |
|
1351 | + $index = 'EE_Transaction: '.$transaction->ID(); |
|
1352 | 1352 | EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index); |
1353 | 1353 | } |
1354 | 1354 | } |