@@ -12,270 +12,270 @@ |
||
12 | 12 | class EEH_URL |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * _add_query_arg |
|
17 | - * adds nonce to array of arguments then calls WP add_query_arg function |
|
18 | - * |
|
19 | - * @access public |
|
20 | - * @param array $args |
|
21 | - * @param string $url |
|
22 | - * @param bool $exclude_nonce If true then the nonce will be excluded from the generated url. |
|
23 | - * @return string |
|
24 | - */ |
|
25 | - public static function add_query_args_and_nonce($args = array(), $url = '', $exclude_nonce = false) |
|
26 | - { |
|
27 | - // check that an action exists and add nonce |
|
28 | - if (! $exclude_nonce) { |
|
29 | - if (isset($args['action']) && ! empty($args['action'])) { |
|
30 | - $args = array_merge( |
|
31 | - $args, |
|
32 | - array( |
|
33 | - $args['action'] . '_nonce' => wp_create_nonce($args['action'] . '_nonce') |
|
34 | - ) |
|
35 | - ); |
|
36 | - } else { |
|
37 | - $args = array_merge( |
|
38 | - $args, |
|
39 | - array( |
|
40 | - 'action' => 'default', 'default_nonce' => wp_create_nonce('default_nonce') |
|
41 | - ) |
|
42 | - ); |
|
43 | - } |
|
44 | - } |
|
15 | + /** |
|
16 | + * _add_query_arg |
|
17 | + * adds nonce to array of arguments then calls WP add_query_arg function |
|
18 | + * |
|
19 | + * @access public |
|
20 | + * @param array $args |
|
21 | + * @param string $url |
|
22 | + * @param bool $exclude_nonce If true then the nonce will be excluded from the generated url. |
|
23 | + * @return string |
|
24 | + */ |
|
25 | + public static function add_query_args_and_nonce($args = array(), $url = '', $exclude_nonce = false) |
|
26 | + { |
|
27 | + // check that an action exists and add nonce |
|
28 | + if (! $exclude_nonce) { |
|
29 | + if (isset($args['action']) && ! empty($args['action'])) { |
|
30 | + $args = array_merge( |
|
31 | + $args, |
|
32 | + array( |
|
33 | + $args['action'] . '_nonce' => wp_create_nonce($args['action'] . '_nonce') |
|
34 | + ) |
|
35 | + ); |
|
36 | + } else { |
|
37 | + $args = array_merge( |
|
38 | + $args, |
|
39 | + array( |
|
40 | + 'action' => 'default', 'default_nonce' => wp_create_nonce('default_nonce') |
|
41 | + ) |
|
42 | + ); |
|
43 | + } |
|
44 | + } |
|
45 | 45 | |
46 | - // finally, let's always add a return address (if present) :) |
|
47 | - $args = ! empty($_REQUEST['action']) && ! isset($_REQUEST['return']) |
|
48 | - ? array_merge($args, array('return' => $_REQUEST['action'])) |
|
49 | - : $args; |
|
46 | + // finally, let's always add a return address (if present) :) |
|
47 | + $args = ! empty($_REQUEST['action']) && ! isset($_REQUEST['return']) |
|
48 | + ? array_merge($args, array('return' => $_REQUEST['action'])) |
|
49 | + : $args; |
|
50 | 50 | |
51 | - return add_query_arg($args, $url); |
|
52 | - } |
|
51 | + return add_query_arg($args, $url); |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Returns whether not the remote file exists. |
|
57 | - * Checking via GET because HEAD requests are blocked on some server configurations. |
|
58 | - * |
|
59 | - * @param string $url |
|
60 | - * @param array $args the arguments that should be passed through to the wp_remote_request call. |
|
61 | - * @return boolean |
|
62 | - */ |
|
63 | - public static function remote_file_exists($url, $args = array()) |
|
64 | - { |
|
65 | - $results = wp_remote_request( |
|
66 | - $url, |
|
67 | - array_merge( |
|
68 | - array( |
|
69 | - 'method' => 'GET', |
|
70 | - 'redirection' => 1, |
|
71 | - ), |
|
72 | - $args |
|
73 | - ) |
|
74 | - ); |
|
75 | - if (! $results instanceof WP_Error && |
|
76 | - isset($results['response']) && |
|
77 | - isset($results['response']['code']) && |
|
78 | - $results['response']['code'] == '200') { |
|
79 | - return true; |
|
80 | - } else { |
|
81 | - return false; |
|
82 | - } |
|
83 | - } |
|
55 | + /** |
|
56 | + * Returns whether not the remote file exists. |
|
57 | + * Checking via GET because HEAD requests are blocked on some server configurations. |
|
58 | + * |
|
59 | + * @param string $url |
|
60 | + * @param array $args the arguments that should be passed through to the wp_remote_request call. |
|
61 | + * @return boolean |
|
62 | + */ |
|
63 | + public static function remote_file_exists($url, $args = array()) |
|
64 | + { |
|
65 | + $results = wp_remote_request( |
|
66 | + $url, |
|
67 | + array_merge( |
|
68 | + array( |
|
69 | + 'method' => 'GET', |
|
70 | + 'redirection' => 1, |
|
71 | + ), |
|
72 | + $args |
|
73 | + ) |
|
74 | + ); |
|
75 | + if (! $results instanceof WP_Error && |
|
76 | + isset($results['response']) && |
|
77 | + isset($results['response']['code']) && |
|
78 | + $results['response']['code'] == '200') { |
|
79 | + return true; |
|
80 | + } else { |
|
81 | + return false; |
|
82 | + } |
|
83 | + } |
|
84 | 84 | |
85 | 85 | |
86 | - /** |
|
87 | - * refactor_url |
|
88 | - * primarily used for removing the query string from a URL |
|
89 | - * |
|
90 | - * @param string $url |
|
91 | - * @param bool $remove_query - TRUE (default) will strip off any URL params, ie: ?this=1&that=2 |
|
92 | - * @param bool $base_url_only - TRUE will only return the scheme and host with no other parameters |
|
93 | - * @return string |
|
94 | - */ |
|
95 | - public static function refactor_url($url = '', $remove_query = true, $base_url_only = false) |
|
96 | - { |
|
97 | - // break apart incoming URL |
|
98 | - $url_bits = parse_url($url); |
|
99 | - // HTTP or HTTPS ? |
|
100 | - $scheme = isset($url_bits['scheme']) ? $url_bits['scheme'] . '://' : 'http://'; |
|
101 | - // domain |
|
102 | - $host = isset($url_bits['host']) ? $url_bits['host'] : ''; |
|
103 | - // if only the base URL is requested, then return that now |
|
104 | - if ($base_url_only) { |
|
105 | - return $scheme . $host; |
|
106 | - } |
|
107 | - $port = isset($url_bits['port']) ? ':' . $url_bits['port'] : ''; |
|
108 | - $user = isset($url_bits['user']) ? $url_bits['user'] : ''; |
|
109 | - $pass = isset($url_bits['pass']) ? ':' . $url_bits['pass'] : ''; |
|
110 | - $pass = ($user || $pass) ? $pass . '@' : ''; |
|
111 | - $path = isset($url_bits['path']) ? $url_bits['path'] : ''; |
|
112 | - // if the query string is not required, then return what we have so far |
|
113 | - if ($remove_query) { |
|
114 | - return $scheme . $user . $pass . $host . $port . $path; |
|
115 | - } |
|
116 | - $query = isset($url_bits['query']) ? '?' . $url_bits['query'] : ''; |
|
117 | - $fragment = isset($url_bits['fragment']) ? '#' . $url_bits['fragment'] : ''; |
|
118 | - return $scheme . $user . $pass . $host . $port . $path . $query . $fragment; |
|
119 | - } |
|
86 | + /** |
|
87 | + * refactor_url |
|
88 | + * primarily used for removing the query string from a URL |
|
89 | + * |
|
90 | + * @param string $url |
|
91 | + * @param bool $remove_query - TRUE (default) will strip off any URL params, ie: ?this=1&that=2 |
|
92 | + * @param bool $base_url_only - TRUE will only return the scheme and host with no other parameters |
|
93 | + * @return string |
|
94 | + */ |
|
95 | + public static function refactor_url($url = '', $remove_query = true, $base_url_only = false) |
|
96 | + { |
|
97 | + // break apart incoming URL |
|
98 | + $url_bits = parse_url($url); |
|
99 | + // HTTP or HTTPS ? |
|
100 | + $scheme = isset($url_bits['scheme']) ? $url_bits['scheme'] . '://' : 'http://'; |
|
101 | + // domain |
|
102 | + $host = isset($url_bits['host']) ? $url_bits['host'] : ''; |
|
103 | + // if only the base URL is requested, then return that now |
|
104 | + if ($base_url_only) { |
|
105 | + return $scheme . $host; |
|
106 | + } |
|
107 | + $port = isset($url_bits['port']) ? ':' . $url_bits['port'] : ''; |
|
108 | + $user = isset($url_bits['user']) ? $url_bits['user'] : ''; |
|
109 | + $pass = isset($url_bits['pass']) ? ':' . $url_bits['pass'] : ''; |
|
110 | + $pass = ($user || $pass) ? $pass . '@' : ''; |
|
111 | + $path = isset($url_bits['path']) ? $url_bits['path'] : ''; |
|
112 | + // if the query string is not required, then return what we have so far |
|
113 | + if ($remove_query) { |
|
114 | + return $scheme . $user . $pass . $host . $port . $path; |
|
115 | + } |
|
116 | + $query = isset($url_bits['query']) ? '?' . $url_bits['query'] : ''; |
|
117 | + $fragment = isset($url_bits['fragment']) ? '#' . $url_bits['fragment'] : ''; |
|
118 | + return $scheme . $user . $pass . $host . $port . $path . $query . $fragment; |
|
119 | + } |
|
120 | 120 | |
121 | 121 | |
122 | - /** |
|
123 | - * get_query_string |
|
124 | - * returns just the query string from a URL, formatted by default into an array of key value pairs |
|
125 | - * |
|
126 | - * @param string $url |
|
127 | - * @param bool $as_array TRUE (default) will return query params as an array of key value pairs, FALSE will |
|
128 | - * simply return the query string |
|
129 | - * @return string|array |
|
130 | - */ |
|
131 | - public static function get_query_string($url = '', $as_array = true) |
|
132 | - { |
|
133 | - // decode, then break apart incoming URL |
|
134 | - $url_bits = parse_url(html_entity_decode($url)); |
|
135 | - // grab query string from URL |
|
136 | - $query = isset($url_bits['query']) ? $url_bits['query'] : ''; |
|
137 | - // if we don't want the query string formatted into an array of key => value pairs, then just return it as is |
|
138 | - if (! $as_array) { |
|
139 | - return $query; |
|
140 | - } |
|
141 | - // if no query string exists then just return an empty array now |
|
142 | - if (empty($query)) { |
|
143 | - return array(); |
|
144 | - } |
|
145 | - // empty array to hold results |
|
146 | - $query_params = array(); |
|
147 | - // now break apart the query string into separate params |
|
148 | - $query = explode('&', $query); |
|
149 | - // loop thru our query params |
|
150 | - foreach ($query as $query_args) { |
|
151 | - // break apart the key value pairs |
|
152 | - $query_args = explode('=', $query_args); |
|
153 | - // and add to our results array |
|
154 | - $query_params[ $query_args[0] ] = $query_args[1]; |
|
155 | - } |
|
156 | - return $query_params; |
|
157 | - } |
|
122 | + /** |
|
123 | + * get_query_string |
|
124 | + * returns just the query string from a URL, formatted by default into an array of key value pairs |
|
125 | + * |
|
126 | + * @param string $url |
|
127 | + * @param bool $as_array TRUE (default) will return query params as an array of key value pairs, FALSE will |
|
128 | + * simply return the query string |
|
129 | + * @return string|array |
|
130 | + */ |
|
131 | + public static function get_query_string($url = '', $as_array = true) |
|
132 | + { |
|
133 | + // decode, then break apart incoming URL |
|
134 | + $url_bits = parse_url(html_entity_decode($url)); |
|
135 | + // grab query string from URL |
|
136 | + $query = isset($url_bits['query']) ? $url_bits['query'] : ''; |
|
137 | + // if we don't want the query string formatted into an array of key => value pairs, then just return it as is |
|
138 | + if (! $as_array) { |
|
139 | + return $query; |
|
140 | + } |
|
141 | + // if no query string exists then just return an empty array now |
|
142 | + if (empty($query)) { |
|
143 | + return array(); |
|
144 | + } |
|
145 | + // empty array to hold results |
|
146 | + $query_params = array(); |
|
147 | + // now break apart the query string into separate params |
|
148 | + $query = explode('&', $query); |
|
149 | + // loop thru our query params |
|
150 | + foreach ($query as $query_args) { |
|
151 | + // break apart the key value pairs |
|
152 | + $query_args = explode('=', $query_args); |
|
153 | + // and add to our results array |
|
154 | + $query_params[ $query_args[0] ] = $query_args[1]; |
|
155 | + } |
|
156 | + return $query_params; |
|
157 | + } |
|
158 | 158 | |
159 | 159 | |
160 | - /** |
|
161 | - * prevent_prefetching |
|
162 | - * |
|
163 | - * @return void |
|
164 | - */ |
|
165 | - public static function prevent_prefetching() |
|
166 | - { |
|
167 | - // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes |
|
168 | - // with the registration process |
|
169 | - remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
170 | - } |
|
160 | + /** |
|
161 | + * prevent_prefetching |
|
162 | + * |
|
163 | + * @return void |
|
164 | + */ |
|
165 | + public static function prevent_prefetching() |
|
166 | + { |
|
167 | + // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes |
|
168 | + // with the registration process |
|
169 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
170 | + } |
|
171 | 171 | |
172 | 172 | |
173 | - /** |
|
174 | - * This generates a unique site-specific string. |
|
175 | - * An example usage for this string would be to save as a unique identifier for a record in the db for usage in |
|
176 | - * urls. |
|
177 | - * |
|
178 | - * @param string $prefix Use this to prefix the string with something. |
|
179 | - * @return string |
|
180 | - */ |
|
181 | - public static function generate_unique_token($prefix = '') |
|
182 | - { |
|
183 | - $token = md5(uniqid() . mt_rand()); |
|
184 | - return $prefix ? $prefix . '_' . $token : $token; |
|
185 | - } |
|
173 | + /** |
|
174 | + * This generates a unique site-specific string. |
|
175 | + * An example usage for this string would be to save as a unique identifier for a record in the db for usage in |
|
176 | + * urls. |
|
177 | + * |
|
178 | + * @param string $prefix Use this to prefix the string with something. |
|
179 | + * @return string |
|
180 | + */ |
|
181 | + public static function generate_unique_token($prefix = '') |
|
182 | + { |
|
183 | + $token = md5(uniqid() . mt_rand()); |
|
184 | + return $prefix ? $prefix . '_' . $token : $token; |
|
185 | + } |
|
186 | 186 | |
187 | 187 | |
188 | - /** |
|
189 | - * filter_input_server_url |
|
190 | - * uses filter_input() to sanitize one of the INPUT_SERVER URL values |
|
191 | - * but adds a backup in case filter_input() returns nothing, which can erringly happen on some servers |
|
192 | - * |
|
193 | - * @param string $server_variable |
|
194 | - * @return string |
|
195 | - */ |
|
196 | - public static function filter_input_server_url($server_variable = 'REQUEST_URI') |
|
197 | - { |
|
198 | - $URL = ''; |
|
199 | - $server_variables = array( |
|
200 | - 'REQUEST_URI' => 1, |
|
201 | - 'HTTP_HOST' => 1, |
|
202 | - 'PHP_SELF' => 1, |
|
203 | - ); |
|
204 | - $server_variable = strtoupper($server_variable); |
|
205 | - // whitelist INPUT_SERVER var |
|
206 | - if (isset($server_variables[ $server_variable ])) { |
|
207 | - $URL = filter_input(INPUT_SERVER, $server_variable, FILTER_SANITIZE_URL, FILTER_NULL_ON_FAILURE); |
|
208 | - if (empty($URL)) { |
|
209 | - // fallback sanitization if the above fails |
|
210 | - $URL = wp_sanitize_redirect($_SERVER[ $server_variable ]); |
|
211 | - } |
|
212 | - } |
|
213 | - return $URL; |
|
214 | - } |
|
188 | + /** |
|
189 | + * filter_input_server_url |
|
190 | + * uses filter_input() to sanitize one of the INPUT_SERVER URL values |
|
191 | + * but adds a backup in case filter_input() returns nothing, which can erringly happen on some servers |
|
192 | + * |
|
193 | + * @param string $server_variable |
|
194 | + * @return string |
|
195 | + */ |
|
196 | + public static function filter_input_server_url($server_variable = 'REQUEST_URI') |
|
197 | + { |
|
198 | + $URL = ''; |
|
199 | + $server_variables = array( |
|
200 | + 'REQUEST_URI' => 1, |
|
201 | + 'HTTP_HOST' => 1, |
|
202 | + 'PHP_SELF' => 1, |
|
203 | + ); |
|
204 | + $server_variable = strtoupper($server_variable); |
|
205 | + // whitelist INPUT_SERVER var |
|
206 | + if (isset($server_variables[ $server_variable ])) { |
|
207 | + $URL = filter_input(INPUT_SERVER, $server_variable, FILTER_SANITIZE_URL, FILTER_NULL_ON_FAILURE); |
|
208 | + if (empty($URL)) { |
|
209 | + // fallback sanitization if the above fails |
|
210 | + $URL = wp_sanitize_redirect($_SERVER[ $server_variable ]); |
|
211 | + } |
|
212 | + } |
|
213 | + return $URL; |
|
214 | + } |
|
215 | 215 | |
216 | 216 | |
217 | - /** |
|
218 | - * Gets the current page's full URL. |
|
219 | - * |
|
220 | - * @return string |
|
221 | - */ |
|
222 | - public static function current_url() |
|
223 | - { |
|
224 | - $url = ''; |
|
225 | - if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) { |
|
226 | - $url = is_ssl() ? 'https://' : 'http://'; |
|
227 | - $url .= \EEH_URL::filter_input_server_url('HTTP_HOST'); |
|
228 | - $url .= \EEH_URL::filter_input_server_url('REQUEST_URI'); |
|
229 | - } |
|
230 | - return $url; |
|
231 | - } |
|
217 | + /** |
|
218 | + * Gets the current page's full URL. |
|
219 | + * |
|
220 | + * @return string |
|
221 | + */ |
|
222 | + public static function current_url() |
|
223 | + { |
|
224 | + $url = ''; |
|
225 | + if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) { |
|
226 | + $url = is_ssl() ? 'https://' : 'http://'; |
|
227 | + $url .= \EEH_URL::filter_input_server_url('HTTP_HOST'); |
|
228 | + $url .= \EEH_URL::filter_input_server_url('REQUEST_URI'); |
|
229 | + } |
|
230 | + return $url; |
|
231 | + } |
|
232 | 232 | |
233 | 233 | |
234 | - /** |
|
235 | - * Identical in functionality to EEH_current_url except it removes any provided query_parameters from it. |
|
236 | - * |
|
237 | - * @param array $query_parameters An array of query_parameters to remove from the current url. |
|
238 | - * @since 4.9.46.rc.029 |
|
239 | - * @return string |
|
240 | - */ |
|
241 | - public static function current_url_without_query_paramaters(array $query_parameters) |
|
242 | - { |
|
243 | - return remove_query_arg($query_parameters, EEH_URL::current_url()); |
|
244 | - } |
|
234 | + /** |
|
235 | + * Identical in functionality to EEH_current_url except it removes any provided query_parameters from it. |
|
236 | + * |
|
237 | + * @param array $query_parameters An array of query_parameters to remove from the current url. |
|
238 | + * @since 4.9.46.rc.029 |
|
239 | + * @return string |
|
240 | + */ |
|
241 | + public static function current_url_without_query_paramaters(array $query_parameters) |
|
242 | + { |
|
243 | + return remove_query_arg($query_parameters, EEH_URL::current_url()); |
|
244 | + } |
|
245 | 245 | |
246 | 246 | |
247 | - /** |
|
248 | - * @param string $location |
|
249 | - * @param int $status |
|
250 | - * @param string $exit_notice |
|
251 | - */ |
|
252 | - public static function safeRedirectAndExit($location, $status = 302, $exit_notice = '') |
|
253 | - { |
|
254 | - EE_Error::get_notices(false, true); |
|
255 | - wp_safe_redirect($location, $status); |
|
256 | - exit($exit_notice); |
|
257 | - } |
|
247 | + /** |
|
248 | + * @param string $location |
|
249 | + * @param int $status |
|
250 | + * @param string $exit_notice |
|
251 | + */ |
|
252 | + public static function safeRedirectAndExit($location, $status = 302, $exit_notice = '') |
|
253 | + { |
|
254 | + EE_Error::get_notices(false, true); |
|
255 | + wp_safe_redirect($location, $status); |
|
256 | + exit($exit_notice); |
|
257 | + } |
|
258 | 258 | |
259 | - /** |
|
260 | - * Slugifies text for usage in a URL. |
|
261 | - * |
|
262 | - * Currently, this isn't just calling `sanitize_title()` on it, because that percent-encodes unicode characters, |
|
263 | - * and WordPress chokes on them when used as CPT and custom taxonomy slugs. |
|
264 | - * |
|
265 | - * @since 4.9.66.p |
|
266 | - * @param string $text |
|
267 | - * @param string $fallback |
|
268 | - * @return string which can be used in a URL |
|
269 | - */ |
|
270 | - public static function slugify($text, $fallback) |
|
271 | - { |
|
272 | - // url decode after sanitizing title to restore unicode characters, |
|
273 | - // see https://github.com/eventespresso/event-espresso-core/issues/575 |
|
274 | - return urldecode( |
|
275 | - sanitize_title( |
|
276 | - $text, |
|
277 | - $fallback |
|
278 | - ) |
|
279 | - ); |
|
280 | - } |
|
259 | + /** |
|
260 | + * Slugifies text for usage in a URL. |
|
261 | + * |
|
262 | + * Currently, this isn't just calling `sanitize_title()` on it, because that percent-encodes unicode characters, |
|
263 | + * and WordPress chokes on them when used as CPT and custom taxonomy slugs. |
|
264 | + * |
|
265 | + * @since 4.9.66.p |
|
266 | + * @param string $text |
|
267 | + * @param string $fallback |
|
268 | + * @return string which can be used in a URL |
|
269 | + */ |
|
270 | + public static function slugify($text, $fallback) |
|
271 | + { |
|
272 | + // url decode after sanitizing title to restore unicode characters, |
|
273 | + // see https://github.com/eventespresso/event-espresso-core/issues/575 |
|
274 | + return urldecode( |
|
275 | + sanitize_title( |
|
276 | + $text, |
|
277 | + $fallback |
|
278 | + ) |
|
279 | + ); |
|
280 | + } |
|
281 | 281 | } |
@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | public static function add_query_args_and_nonce($args = array(), $url = '', $exclude_nonce = false) |
26 | 26 | { |
27 | 27 | // check that an action exists and add nonce |
28 | - if (! $exclude_nonce) { |
|
28 | + if ( ! $exclude_nonce) { |
|
29 | 29 | if (isset($args['action']) && ! empty($args['action'])) { |
30 | 30 | $args = array_merge( |
31 | 31 | $args, |
32 | 32 | array( |
33 | - $args['action'] . '_nonce' => wp_create_nonce($args['action'] . '_nonce') |
|
33 | + $args['action'].'_nonce' => wp_create_nonce($args['action'].'_nonce') |
|
34 | 34 | ) |
35 | 35 | ); |
36 | 36 | } else { |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | $args |
73 | 73 | ) |
74 | 74 | ); |
75 | - if (! $results instanceof WP_Error && |
|
75 | + if ( ! $results instanceof WP_Error && |
|
76 | 76 | isset($results['response']) && |
77 | 77 | isset($results['response']['code']) && |
78 | 78 | $results['response']['code'] == '200') { |
@@ -97,25 +97,25 @@ discard block |
||
97 | 97 | // break apart incoming URL |
98 | 98 | $url_bits = parse_url($url); |
99 | 99 | // HTTP or HTTPS ? |
100 | - $scheme = isset($url_bits['scheme']) ? $url_bits['scheme'] . '://' : 'http://'; |
|
100 | + $scheme = isset($url_bits['scheme']) ? $url_bits['scheme'].'://' : 'http://'; |
|
101 | 101 | // domain |
102 | 102 | $host = isset($url_bits['host']) ? $url_bits['host'] : ''; |
103 | 103 | // if only the base URL is requested, then return that now |
104 | 104 | if ($base_url_only) { |
105 | - return $scheme . $host; |
|
105 | + return $scheme.$host; |
|
106 | 106 | } |
107 | - $port = isset($url_bits['port']) ? ':' . $url_bits['port'] : ''; |
|
107 | + $port = isset($url_bits['port']) ? ':'.$url_bits['port'] : ''; |
|
108 | 108 | $user = isset($url_bits['user']) ? $url_bits['user'] : ''; |
109 | - $pass = isset($url_bits['pass']) ? ':' . $url_bits['pass'] : ''; |
|
110 | - $pass = ($user || $pass) ? $pass . '@' : ''; |
|
109 | + $pass = isset($url_bits['pass']) ? ':'.$url_bits['pass'] : ''; |
|
110 | + $pass = ($user || $pass) ? $pass.'@' : ''; |
|
111 | 111 | $path = isset($url_bits['path']) ? $url_bits['path'] : ''; |
112 | 112 | // if the query string is not required, then return what we have so far |
113 | 113 | if ($remove_query) { |
114 | - return $scheme . $user . $pass . $host . $port . $path; |
|
114 | + return $scheme.$user.$pass.$host.$port.$path; |
|
115 | 115 | } |
116 | - $query = isset($url_bits['query']) ? '?' . $url_bits['query'] : ''; |
|
117 | - $fragment = isset($url_bits['fragment']) ? '#' . $url_bits['fragment'] : ''; |
|
118 | - return $scheme . $user . $pass . $host . $port . $path . $query . $fragment; |
|
116 | + $query = isset($url_bits['query']) ? '?'.$url_bits['query'] : ''; |
|
117 | + $fragment = isset($url_bits['fragment']) ? '#'.$url_bits['fragment'] : ''; |
|
118 | + return $scheme.$user.$pass.$host.$port.$path.$query.$fragment; |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | // grab query string from URL |
136 | 136 | $query = isset($url_bits['query']) ? $url_bits['query'] : ''; |
137 | 137 | // if we don't want the query string formatted into an array of key => value pairs, then just return it as is |
138 | - if (! $as_array) { |
|
138 | + if ( ! $as_array) { |
|
139 | 139 | return $query; |
140 | 140 | } |
141 | 141 | // if no query string exists then just return an empty array now |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | // break apart the key value pairs |
152 | 152 | $query_args = explode('=', $query_args); |
153 | 153 | // and add to our results array |
154 | - $query_params[ $query_args[0] ] = $query_args[1]; |
|
154 | + $query_params[$query_args[0]] = $query_args[1]; |
|
155 | 155 | } |
156 | 156 | return $query_params; |
157 | 157 | } |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public static function generate_unique_token($prefix = '') |
182 | 182 | { |
183 | - $token = md5(uniqid() . mt_rand()); |
|
184 | - return $prefix ? $prefix . '_' . $token : $token; |
|
183 | + $token = md5(uniqid().mt_rand()); |
|
184 | + return $prefix ? $prefix.'_'.$token : $token; |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | |
@@ -201,13 +201,13 @@ discard block |
||
201 | 201 | 'HTTP_HOST' => 1, |
202 | 202 | 'PHP_SELF' => 1, |
203 | 203 | ); |
204 | - $server_variable = strtoupper($server_variable); |
|
204 | + $server_variable = strtoupper($server_variable); |
|
205 | 205 | // whitelist INPUT_SERVER var |
206 | - if (isset($server_variables[ $server_variable ])) { |
|
206 | + if (isset($server_variables[$server_variable])) { |
|
207 | 207 | $URL = filter_input(INPUT_SERVER, $server_variable, FILTER_SANITIZE_URL, FILTER_NULL_ON_FAILURE); |
208 | 208 | if (empty($URL)) { |
209 | 209 | // fallback sanitization if the above fails |
210 | - $URL = wp_sanitize_redirect($_SERVER[ $server_variable ]); |
|
210 | + $URL = wp_sanitize_redirect($_SERVER[$server_variable]); |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 | return $URL; |
@@ -29,358 +29,358 @@ |
||
29 | 29 | class EED_Batch extends EED_Module |
30 | 30 | { |
31 | 31 | |
32 | - /** |
|
33 | - * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
|
34 | - * processes data only |
|
35 | - */ |
|
36 | - const batch_job = 'job'; |
|
37 | - /** |
|
38 | - * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
|
39 | - * produces a file for download |
|
40 | - */ |
|
41 | - const batch_file_job = 'file'; |
|
42 | - /** |
|
43 | - * Possibly value for $_REQUEST[ 'batch' ]. Indicates this request is NOT |
|
44 | - * for a batch job. It's the same as not providing the $_REQUEST[ 'batch' ] |
|
45 | - * at all |
|
46 | - */ |
|
47 | - const batch_not_job = 'none'; |
|
32 | + /** |
|
33 | + * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
|
34 | + * processes data only |
|
35 | + */ |
|
36 | + const batch_job = 'job'; |
|
37 | + /** |
|
38 | + * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
|
39 | + * produces a file for download |
|
40 | + */ |
|
41 | + const batch_file_job = 'file'; |
|
42 | + /** |
|
43 | + * Possibly value for $_REQUEST[ 'batch' ]. Indicates this request is NOT |
|
44 | + * for a batch job. It's the same as not providing the $_REQUEST[ 'batch' ] |
|
45 | + * at all |
|
46 | + */ |
|
47 | + const batch_not_job = 'none'; |
|
48 | 48 | |
49 | - /** |
|
50 | - * |
|
51 | - * @var string 'file', or 'job', or false to indicate its not a batch request at all |
|
52 | - */ |
|
53 | - protected $_batch_request_type = null; |
|
49 | + /** |
|
50 | + * |
|
51 | + * @var string 'file', or 'job', or false to indicate its not a batch request at all |
|
52 | + */ |
|
53 | + protected $_batch_request_type = null; |
|
54 | 54 | |
55 | - /** |
|
56 | - * Because we want to use the response in both the localized JS and in the body |
|
57 | - * we need to make this response available between method calls |
|
58 | - * |
|
59 | - * @var \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
60 | - */ |
|
61 | - protected $_job_step_response = null; |
|
55 | + /** |
|
56 | + * Because we want to use the response in both the localized JS and in the body |
|
57 | + * we need to make this response available between method calls |
|
58 | + * |
|
59 | + * @var \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
60 | + */ |
|
61 | + protected $_job_step_response = null; |
|
62 | 62 | |
63 | - /** |
|
64 | - * @var LoaderInterface |
|
65 | - */ |
|
66 | - protected $loader; |
|
63 | + /** |
|
64 | + * @var LoaderInterface |
|
65 | + */ |
|
66 | + protected $loader; |
|
67 | 67 | |
68 | - /** |
|
69 | - * Gets the batch instance |
|
70 | - * |
|
71 | - * @return EED_Batch |
|
72 | - */ |
|
73 | - public static function instance() |
|
74 | - { |
|
75 | - return self::get_instance(); |
|
76 | - } |
|
68 | + /** |
|
69 | + * Gets the batch instance |
|
70 | + * |
|
71 | + * @return EED_Batch |
|
72 | + */ |
|
73 | + public static function instance() |
|
74 | + { |
|
75 | + return self::get_instance(); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * Sets hooks to enable batch jobs on the frontend. Disabled by default |
|
80 | - * because it's an attack vector and there are currently no implementations |
|
81 | - */ |
|
82 | - public static function set_hooks() |
|
83 | - { |
|
84 | - // because this is a possibel attack vector, let's have this disabled until |
|
85 | - // we at least have a real use for it on the frontend |
|
86 | - if (apply_filters('FHEE__EED_Batch__set_hooks__enable_frontend_batch', false)) { |
|
87 | - add_action('wp_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
88 | - add_filter('template_include', array(self::instance(), 'override_template'), 99); |
|
89 | - } |
|
90 | - } |
|
78 | + /** |
|
79 | + * Sets hooks to enable batch jobs on the frontend. Disabled by default |
|
80 | + * because it's an attack vector and there are currently no implementations |
|
81 | + */ |
|
82 | + public static function set_hooks() |
|
83 | + { |
|
84 | + // because this is a possibel attack vector, let's have this disabled until |
|
85 | + // we at least have a real use for it on the frontend |
|
86 | + if (apply_filters('FHEE__EED_Batch__set_hooks__enable_frontend_batch', false)) { |
|
87 | + add_action('wp_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
88 | + add_filter('template_include', array(self::instance(), 'override_template'), 99); |
|
89 | + } |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * Initializes some hooks for the admin in order to run batch jobs |
|
94 | - */ |
|
95 | - public static function set_hooks_admin() |
|
96 | - { |
|
97 | - add_action('admin_menu', array(self::instance(), 'register_admin_pages')); |
|
98 | - add_action('admin_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
92 | + /** |
|
93 | + * Initializes some hooks for the admin in order to run batch jobs |
|
94 | + */ |
|
95 | + public static function set_hooks_admin() |
|
96 | + { |
|
97 | + add_action('admin_menu', array(self::instance(), 'register_admin_pages')); |
|
98 | + add_action('admin_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
99 | 99 | |
100 | - // ajax |
|
101 | - add_action('wp_ajax_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
102 | - add_action('wp_ajax_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
103 | - add_action('wp_ajax_nopriv_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
104 | - add_action('wp_ajax_nopriv_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
105 | - } |
|
100 | + // ajax |
|
101 | + add_action('wp_ajax_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
102 | + add_action('wp_ajax_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
103 | + add_action('wp_ajax_nopriv_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
104 | + add_action('wp_ajax_nopriv_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * @since 4.9.80.p |
|
109 | - * @return LoaderInterface |
|
110 | - * @throws InvalidArgumentException |
|
111 | - * @throws InvalidDataTypeException |
|
112 | - * @throws InvalidInterfaceException |
|
113 | - */ |
|
114 | - protected function getLoader() |
|
115 | - { |
|
116 | - if (!$this->loader instanceof LoaderInterface) { |
|
117 | - $this->loader = LoaderFactory::getLoader(); |
|
118 | - } |
|
119 | - return $this->loader; |
|
120 | - } |
|
107 | + /** |
|
108 | + * @since 4.9.80.p |
|
109 | + * @return LoaderInterface |
|
110 | + * @throws InvalidArgumentException |
|
111 | + * @throws InvalidDataTypeException |
|
112 | + * @throws InvalidInterfaceException |
|
113 | + */ |
|
114 | + protected function getLoader() |
|
115 | + { |
|
116 | + if (!$this->loader instanceof LoaderInterface) { |
|
117 | + $this->loader = LoaderFactory::getLoader(); |
|
118 | + } |
|
119 | + return $this->loader; |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * Enqueues batch scripts on the frontend or admin, and creates a job |
|
124 | - */ |
|
125 | - public function enqueue_scripts() |
|
126 | - { |
|
127 | - if (isset($_REQUEST['espresso_batch']) |
|
128 | - || |
|
129 | - ( |
|
130 | - isset($_REQUEST['page']) |
|
131 | - && $_REQUEST['page'] == 'espresso_batch' |
|
132 | - ) |
|
133 | - ) { |
|
134 | - if (! isset($_REQUEST['default_nonce']) || ! wp_verify_nonce($_REQUEST['default_nonce'], 'default_nonce')) { |
|
135 | - wp_die(esc_html__('The link you clicked to start the batch job has expired. Please go back and refresh the previous page.', 'event_espresso')); |
|
136 | - } |
|
137 | - switch ($this->batch_request_type()) { |
|
138 | - case self::batch_job: |
|
139 | - $this->enqueue_scripts_styles_batch_create(); |
|
140 | - break; |
|
141 | - case self::batch_file_job: |
|
142 | - $this->enqueue_scripts_styles_batch_file_create(); |
|
143 | - break; |
|
144 | - } |
|
145 | - } |
|
146 | - } |
|
122 | + /** |
|
123 | + * Enqueues batch scripts on the frontend or admin, and creates a job |
|
124 | + */ |
|
125 | + public function enqueue_scripts() |
|
126 | + { |
|
127 | + if (isset($_REQUEST['espresso_batch']) |
|
128 | + || |
|
129 | + ( |
|
130 | + isset($_REQUEST['page']) |
|
131 | + && $_REQUEST['page'] == 'espresso_batch' |
|
132 | + ) |
|
133 | + ) { |
|
134 | + if (! isset($_REQUEST['default_nonce']) || ! wp_verify_nonce($_REQUEST['default_nonce'], 'default_nonce')) { |
|
135 | + wp_die(esc_html__('The link you clicked to start the batch job has expired. Please go back and refresh the previous page.', 'event_espresso')); |
|
136 | + } |
|
137 | + switch ($this->batch_request_type()) { |
|
138 | + case self::batch_job: |
|
139 | + $this->enqueue_scripts_styles_batch_create(); |
|
140 | + break; |
|
141 | + case self::batch_file_job: |
|
142 | + $this->enqueue_scripts_styles_batch_file_create(); |
|
143 | + break; |
|
144 | + } |
|
145 | + } |
|
146 | + } |
|
147 | 147 | |
148 | - /** |
|
149 | - * Create a batch job, enqueues a script to run it, and localizes some data for it |
|
150 | - */ |
|
151 | - public function enqueue_scripts_styles_batch_create() |
|
152 | - { |
|
153 | - $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
154 | - wp_enqueue_script( |
|
155 | - 'batch_runner_init', |
|
156 | - BATCH_URL . 'assets/batch_runner_init.js', |
|
157 | - array('batch_runner'), |
|
158 | - EVENT_ESPRESSO_VERSION, |
|
159 | - true |
|
160 | - ); |
|
161 | - wp_localize_script('batch_runner_init', 'ee_job_response', $job_response->to_array()); |
|
162 | - wp_localize_script( |
|
163 | - 'batch_runner_init', |
|
164 | - 'ee_job_i18n', |
|
165 | - array( |
|
166 | - 'return_url' => $_REQUEST['return_url'], |
|
167 | - ) |
|
168 | - ); |
|
169 | - } |
|
148 | + /** |
|
149 | + * Create a batch job, enqueues a script to run it, and localizes some data for it |
|
150 | + */ |
|
151 | + public function enqueue_scripts_styles_batch_create() |
|
152 | + { |
|
153 | + $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
154 | + wp_enqueue_script( |
|
155 | + 'batch_runner_init', |
|
156 | + BATCH_URL . 'assets/batch_runner_init.js', |
|
157 | + array('batch_runner'), |
|
158 | + EVENT_ESPRESSO_VERSION, |
|
159 | + true |
|
160 | + ); |
|
161 | + wp_localize_script('batch_runner_init', 'ee_job_response', $job_response->to_array()); |
|
162 | + wp_localize_script( |
|
163 | + 'batch_runner_init', |
|
164 | + 'ee_job_i18n', |
|
165 | + array( |
|
166 | + 'return_url' => $_REQUEST['return_url'], |
|
167 | + ) |
|
168 | + ); |
|
169 | + } |
|
170 | 170 | |
171 | - /** |
|
172 | - * Creates a batch job which will download a file, enqueues a script to run the job, and localizes some data for it |
|
173 | - */ |
|
174 | - public function enqueue_scripts_styles_batch_file_create() |
|
175 | - { |
|
176 | - // creates a job based on the request variable |
|
177 | - $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
178 | - wp_enqueue_script( |
|
179 | - 'batch_file_runner_init', |
|
180 | - BATCH_URL . 'assets/batch_file_runner_init.js', |
|
181 | - array('batch_runner'), |
|
182 | - EVENT_ESPRESSO_VERSION, |
|
183 | - true |
|
184 | - ); |
|
185 | - wp_localize_script('batch_file_runner_init', 'ee_job_response', $job_response->to_array()); |
|
186 | - wp_localize_script( |
|
187 | - 'batch_file_runner_init', |
|
188 | - 'ee_job_i18n', |
|
189 | - array( |
|
190 | - 'download_and_redirecting' => sprintf( |
|
191 | - __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'), |
|
192 | - '<a href="' . $_REQUEST['return_url'] . '">', |
|
193 | - '</a>' |
|
194 | - ), |
|
195 | - 'return_url' => $_REQUEST['return_url'], |
|
196 | - ) |
|
197 | - ); |
|
198 | - } |
|
171 | + /** |
|
172 | + * Creates a batch job which will download a file, enqueues a script to run the job, and localizes some data for it |
|
173 | + */ |
|
174 | + public function enqueue_scripts_styles_batch_file_create() |
|
175 | + { |
|
176 | + // creates a job based on the request variable |
|
177 | + $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
178 | + wp_enqueue_script( |
|
179 | + 'batch_file_runner_init', |
|
180 | + BATCH_URL . 'assets/batch_file_runner_init.js', |
|
181 | + array('batch_runner'), |
|
182 | + EVENT_ESPRESSO_VERSION, |
|
183 | + true |
|
184 | + ); |
|
185 | + wp_localize_script('batch_file_runner_init', 'ee_job_response', $job_response->to_array()); |
|
186 | + wp_localize_script( |
|
187 | + 'batch_file_runner_init', |
|
188 | + 'ee_job_i18n', |
|
189 | + array( |
|
190 | + 'download_and_redirecting' => sprintf( |
|
191 | + __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'), |
|
192 | + '<a href="' . $_REQUEST['return_url'] . '">', |
|
193 | + '</a>' |
|
194 | + ), |
|
195 | + 'return_url' => $_REQUEST['return_url'], |
|
196 | + ) |
|
197 | + ); |
|
198 | + } |
|
199 | 199 | |
200 | - /** |
|
201 | - * Enqueues scripts and styles common to any batch job, and creates |
|
202 | - * a job from the request data, and stores the response in the |
|
203 | - * $this->_job_step_response property |
|
204 | - * |
|
205 | - * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
206 | - */ |
|
207 | - protected function _enqueue_batch_job_scripts_and_styles_and_start_job() |
|
208 | - { |
|
209 | - // just copy the bits of EE admin's eei18n that we need in the JS |
|
210 | - EE_Registry::$i18n_js_strings['batchJobError'] = esc_html__( |
|
211 | - 'An error occurred and the job has been stopped. Please refresh the page to try again.', |
|
212 | - 'event_espresso' |
|
213 | - ); |
|
214 | - wp_register_script( |
|
215 | - 'progress_bar', |
|
216 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', |
|
217 | - array('jquery'), |
|
218 | - EVENT_ESPRESSO_VERSION, |
|
219 | - true |
|
220 | - ); |
|
221 | - wp_enqueue_style( |
|
222 | - 'progress_bar', |
|
223 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', |
|
224 | - array(), |
|
225 | - EVENT_ESPRESSO_VERSION |
|
226 | - ); |
|
227 | - wp_enqueue_script( |
|
228 | - 'batch_runner', |
|
229 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', |
|
230 | - array('progress_bar', CoreAssetManager::JS_HANDLE_CORE), |
|
231 | - EVENT_ESPRESSO_VERSION, |
|
232 | - true |
|
233 | - ); |
|
234 | - $job_handler_classname = stripslashes($_GET['job_handler']); |
|
235 | - $request_data = array_diff_key( |
|
236 | - $_REQUEST, |
|
237 | - array_flip(array('action', 'page', 'ee', 'batch')) |
|
238 | - ); |
|
239 | - $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
240 | - // eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' |
|
241 | - $job_response = $batch_runner->create_job($job_handler_classname, $request_data); |
|
242 | - // remember the response for later. We need it to display the page body |
|
243 | - $this->_job_step_response = $job_response; |
|
244 | - return $job_response; |
|
245 | - } |
|
200 | + /** |
|
201 | + * Enqueues scripts and styles common to any batch job, and creates |
|
202 | + * a job from the request data, and stores the response in the |
|
203 | + * $this->_job_step_response property |
|
204 | + * |
|
205 | + * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
206 | + */ |
|
207 | + protected function _enqueue_batch_job_scripts_and_styles_and_start_job() |
|
208 | + { |
|
209 | + // just copy the bits of EE admin's eei18n that we need in the JS |
|
210 | + EE_Registry::$i18n_js_strings['batchJobError'] = esc_html__( |
|
211 | + 'An error occurred and the job has been stopped. Please refresh the page to try again.', |
|
212 | + 'event_espresso' |
|
213 | + ); |
|
214 | + wp_register_script( |
|
215 | + 'progress_bar', |
|
216 | + EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', |
|
217 | + array('jquery'), |
|
218 | + EVENT_ESPRESSO_VERSION, |
|
219 | + true |
|
220 | + ); |
|
221 | + wp_enqueue_style( |
|
222 | + 'progress_bar', |
|
223 | + EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', |
|
224 | + array(), |
|
225 | + EVENT_ESPRESSO_VERSION |
|
226 | + ); |
|
227 | + wp_enqueue_script( |
|
228 | + 'batch_runner', |
|
229 | + EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', |
|
230 | + array('progress_bar', CoreAssetManager::JS_HANDLE_CORE), |
|
231 | + EVENT_ESPRESSO_VERSION, |
|
232 | + true |
|
233 | + ); |
|
234 | + $job_handler_classname = stripslashes($_GET['job_handler']); |
|
235 | + $request_data = array_diff_key( |
|
236 | + $_REQUEST, |
|
237 | + array_flip(array('action', 'page', 'ee', 'batch')) |
|
238 | + ); |
|
239 | + $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
240 | + // eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' |
|
241 | + $job_response = $batch_runner->create_job($job_handler_classname, $request_data); |
|
242 | + // remember the response for later. We need it to display the page body |
|
243 | + $this->_job_step_response = $job_response; |
|
244 | + return $job_response; |
|
245 | + } |
|
246 | 246 | |
247 | - /** |
|
248 | - * If we are doing a frontend batch job, this makes it so WP shows our template's HTML |
|
249 | - * |
|
250 | - * @param string $template |
|
251 | - * @return string |
|
252 | - */ |
|
253 | - public function override_template($template) |
|
254 | - { |
|
255 | - if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) { |
|
256 | - return EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_frontend_wrapper.template.html'; |
|
257 | - } |
|
258 | - return $template; |
|
259 | - } |
|
247 | + /** |
|
248 | + * If we are doing a frontend batch job, this makes it so WP shows our template's HTML |
|
249 | + * |
|
250 | + * @param string $template |
|
251 | + * @return string |
|
252 | + */ |
|
253 | + public function override_template($template) |
|
254 | + { |
|
255 | + if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) { |
|
256 | + return EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_frontend_wrapper.template.html'; |
|
257 | + } |
|
258 | + return $template; |
|
259 | + } |
|
260 | 260 | |
261 | - /** |
|
262 | - * Adds an admin page which doesn't appear in the admin menu |
|
263 | - */ |
|
264 | - public function register_admin_pages() |
|
265 | - { |
|
266 | - add_submenu_page( |
|
267 | - '', // parent slug. we don't want this to actually appear in the menu |
|
268 | - __('Batch Job', 'event_espresso'), // page title |
|
269 | - 'n/a', // menu title |
|
270 | - 'read', // we want this page to actually be accessible to anyone, |
|
271 | - 'espresso_batch', // menu slug |
|
272 | - array(self::instance(), 'show_admin_page') |
|
273 | - ); |
|
274 | - } |
|
261 | + /** |
|
262 | + * Adds an admin page which doesn't appear in the admin menu |
|
263 | + */ |
|
264 | + public function register_admin_pages() |
|
265 | + { |
|
266 | + add_submenu_page( |
|
267 | + '', // parent slug. we don't want this to actually appear in the menu |
|
268 | + __('Batch Job', 'event_espresso'), // page title |
|
269 | + 'n/a', // menu title |
|
270 | + 'read', // we want this page to actually be accessible to anyone, |
|
271 | + 'espresso_batch', // menu slug |
|
272 | + array(self::instance(), 'show_admin_page') |
|
273 | + ); |
|
274 | + } |
|
275 | 275 | |
276 | - /** |
|
277 | - * Renders the admin page, after most of the work was already done during enqueuing scripts |
|
278 | - * of creating the job and localizing some data |
|
279 | - */ |
|
280 | - public function show_admin_page() |
|
281 | - { |
|
282 | - echo EEH_Template::locate_template( |
|
283 | - EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_wrapper.template.html', |
|
284 | - array('batch_request_type' => $this->batch_request_type()) |
|
285 | - ); |
|
286 | - } |
|
276 | + /** |
|
277 | + * Renders the admin page, after most of the work was already done during enqueuing scripts |
|
278 | + * of creating the job and localizing some data |
|
279 | + */ |
|
280 | + public function show_admin_page() |
|
281 | + { |
|
282 | + echo EEH_Template::locate_template( |
|
283 | + EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_wrapper.template.html', |
|
284 | + array('batch_request_type' => $this->batch_request_type()) |
|
285 | + ); |
|
286 | + } |
|
287 | 287 | |
288 | - /** |
|
289 | - * Receives ajax calls for continuing a job |
|
290 | - */ |
|
291 | - public function batch_continue() |
|
292 | - { |
|
293 | - $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
294 | - $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
295 | - $response_obj = $batch_runner->continue_job($job_id); |
|
296 | - $this->_return_json($response_obj->to_array()); |
|
297 | - } |
|
288 | + /** |
|
289 | + * Receives ajax calls for continuing a job |
|
290 | + */ |
|
291 | + public function batch_continue() |
|
292 | + { |
|
293 | + $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
294 | + $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
295 | + $response_obj = $batch_runner->continue_job($job_id); |
|
296 | + $this->_return_json($response_obj->to_array()); |
|
297 | + } |
|
298 | 298 | |
299 | - /** |
|
300 | - * Receives the ajax call to cleanup a job |
|
301 | - * |
|
302 | - * @return type |
|
303 | - */ |
|
304 | - public function batch_cleanup() |
|
305 | - { |
|
306 | - $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
307 | - $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
308 | - $response_obj = $batch_runner->cleanup_job($job_id); |
|
309 | - $this->_return_json($response_obj->to_array()); |
|
310 | - } |
|
299 | + /** |
|
300 | + * Receives the ajax call to cleanup a job |
|
301 | + * |
|
302 | + * @return type |
|
303 | + */ |
|
304 | + public function batch_cleanup() |
|
305 | + { |
|
306 | + $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
307 | + $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
308 | + $response_obj = $batch_runner->cleanup_job($job_id); |
|
309 | + $this->_return_json($response_obj->to_array()); |
|
310 | + } |
|
311 | 311 | |
312 | 312 | |
313 | - /** |
|
314 | - * Returns a json response |
|
315 | - * |
|
316 | - * @param array $data The data we want to send echo via in the JSON response's "data" element |
|
317 | - * |
|
318 | - * The returned json object is created from an array in the following format: |
|
319 | - * array( |
|
320 | - * 'notices' => '', // - contains any EE_Error formatted notices |
|
321 | - * 'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. |
|
322 | - * We're also going to include the template args with every package (so js can pick out any specific template |
|
323 | - * args that might be included in here) |
|
324 | - * 'isEEajax' => true,//indicates this is a response from EE |
|
325 | - * ) |
|
326 | - */ |
|
327 | - protected function _return_json($data) |
|
328 | - { |
|
329 | - $json = array( |
|
330 | - 'notices' => EE_Error::get_notices(), |
|
331 | - 'data' => $data, |
|
332 | - 'isEEajax' => true |
|
333 | - // special flag so any ajax.Success methods in js can identify this return package as a EEajax package. |
|
334 | - ); |
|
313 | + /** |
|
314 | + * Returns a json response |
|
315 | + * |
|
316 | + * @param array $data The data we want to send echo via in the JSON response's "data" element |
|
317 | + * |
|
318 | + * The returned json object is created from an array in the following format: |
|
319 | + * array( |
|
320 | + * 'notices' => '', // - contains any EE_Error formatted notices |
|
321 | + * 'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. |
|
322 | + * We're also going to include the template args with every package (so js can pick out any specific template |
|
323 | + * args that might be included in here) |
|
324 | + * 'isEEajax' => true,//indicates this is a response from EE |
|
325 | + * ) |
|
326 | + */ |
|
327 | + protected function _return_json($data) |
|
328 | + { |
|
329 | + $json = array( |
|
330 | + 'notices' => EE_Error::get_notices(), |
|
331 | + 'data' => $data, |
|
332 | + 'isEEajax' => true |
|
333 | + // special flag so any ajax.Success methods in js can identify this return package as a EEajax package. |
|
334 | + ); |
|
335 | 335 | |
336 | 336 | |
337 | - // make sure there are no php errors or headers_sent. Then we can set correct json header. |
|
338 | - if (null === error_get_last() || ! headers_sent()) { |
|
339 | - header('Content-Type: application/json; charset=UTF-8'); |
|
340 | - } |
|
341 | - echo wp_json_encode($json); |
|
342 | - exit(); |
|
343 | - } |
|
337 | + // make sure there are no php errors or headers_sent. Then we can set correct json header. |
|
338 | + if (null === error_get_last() || ! headers_sent()) { |
|
339 | + header('Content-Type: application/json; charset=UTF-8'); |
|
340 | + } |
|
341 | + echo wp_json_encode($json); |
|
342 | + exit(); |
|
343 | + } |
|
344 | 344 | |
345 | - /** |
|
346 | - * Gets the job step response which was done during the enqueuing of scripts |
|
347 | - * |
|
348 | - * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
349 | - */ |
|
350 | - public function job_step_response() |
|
351 | - { |
|
352 | - return $this->_job_step_response; |
|
353 | - } |
|
345 | + /** |
|
346 | + * Gets the job step response which was done during the enqueuing of scripts |
|
347 | + * |
|
348 | + * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
349 | + */ |
|
350 | + public function job_step_response() |
|
351 | + { |
|
352 | + return $this->_job_step_response; |
|
353 | + } |
|
354 | 354 | |
355 | - /** |
|
356 | - * Gets the batch request type indicated in the $_REQUEST |
|
357 | - * |
|
358 | - * @return string: EED_Batch::batch_job, EED_Batch::batch_file_job, EED_Batch::batch_not_job |
|
359 | - */ |
|
360 | - public function batch_request_type() |
|
361 | - { |
|
362 | - if ($this->_batch_request_type === null) { |
|
363 | - if (isset($_GET['batch'])) { |
|
364 | - if ($_GET['batch'] == self::batch_job) { |
|
365 | - $this->_batch_request_type = self::batch_job; |
|
366 | - } elseif ($_GET['batch'] == self::batch_file_job) { |
|
367 | - $this->_batch_request_type = self::batch_file_job; |
|
368 | - } |
|
369 | - } |
|
370 | - // if we didn't find that it was a batch request, indicate it wasn't |
|
371 | - if ($this->_batch_request_type === null) { |
|
372 | - $this->_batch_request_type = self::batch_not_job; |
|
373 | - } |
|
374 | - } |
|
375 | - return $this->_batch_request_type; |
|
376 | - } |
|
355 | + /** |
|
356 | + * Gets the batch request type indicated in the $_REQUEST |
|
357 | + * |
|
358 | + * @return string: EED_Batch::batch_job, EED_Batch::batch_file_job, EED_Batch::batch_not_job |
|
359 | + */ |
|
360 | + public function batch_request_type() |
|
361 | + { |
|
362 | + if ($this->_batch_request_type === null) { |
|
363 | + if (isset($_GET['batch'])) { |
|
364 | + if ($_GET['batch'] == self::batch_job) { |
|
365 | + $this->_batch_request_type = self::batch_job; |
|
366 | + } elseif ($_GET['batch'] == self::batch_file_job) { |
|
367 | + $this->_batch_request_type = self::batch_file_job; |
|
368 | + } |
|
369 | + } |
|
370 | + // if we didn't find that it was a batch request, indicate it wasn't |
|
371 | + if ($this->_batch_request_type === null) { |
|
372 | + $this->_batch_request_type = self::batch_not_job; |
|
373 | + } |
|
374 | + } |
|
375 | + return $this->_batch_request_type; |
|
376 | + } |
|
377 | 377 | |
378 | - /** |
|
379 | - * Unnecessary |
|
380 | - * |
|
381 | - * @param type $WP |
|
382 | - */ |
|
383 | - public function run($WP) |
|
384 | - { |
|
385 | - } |
|
378 | + /** |
|
379 | + * Unnecessary |
|
380 | + * |
|
381 | + * @param type $WP |
|
382 | + */ |
|
383 | + public function run($WP) |
|
384 | + { |
|
385 | + } |
|
386 | 386 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | */ |
114 | 114 | protected function getLoader() |
115 | 115 | { |
116 | - if (!$this->loader instanceof LoaderInterface) { |
|
116 | + if ( ! $this->loader instanceof LoaderInterface) { |
|
117 | 117 | $this->loader = LoaderFactory::getLoader(); |
118 | 118 | } |
119 | 119 | return $this->loader; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | && $_REQUEST['page'] == 'espresso_batch' |
132 | 132 | ) |
133 | 133 | ) { |
134 | - if (! isset($_REQUEST['default_nonce']) || ! wp_verify_nonce($_REQUEST['default_nonce'], 'default_nonce')) { |
|
134 | + if ( ! isset($_REQUEST['default_nonce']) || ! wp_verify_nonce($_REQUEST['default_nonce'], 'default_nonce')) { |
|
135 | 135 | wp_die(esc_html__('The link you clicked to start the batch job has expired. Please go back and refresh the previous page.', 'event_espresso')); |
136 | 136 | } |
137 | 137 | switch ($this->batch_request_type()) { |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
154 | 154 | wp_enqueue_script( |
155 | 155 | 'batch_runner_init', |
156 | - BATCH_URL . 'assets/batch_runner_init.js', |
|
156 | + BATCH_URL.'assets/batch_runner_init.js', |
|
157 | 157 | array('batch_runner'), |
158 | 158 | EVENT_ESPRESSO_VERSION, |
159 | 159 | true |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
178 | 178 | wp_enqueue_script( |
179 | 179 | 'batch_file_runner_init', |
180 | - BATCH_URL . 'assets/batch_file_runner_init.js', |
|
180 | + BATCH_URL.'assets/batch_file_runner_init.js', |
|
181 | 181 | array('batch_runner'), |
182 | 182 | EVENT_ESPRESSO_VERSION, |
183 | 183 | true |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | array( |
190 | 190 | 'download_and_redirecting' => sprintf( |
191 | 191 | __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'), |
192 | - '<a href="' . $_REQUEST['return_url'] . '">', |
|
192 | + '<a href="'.$_REQUEST['return_url'].'">', |
|
193 | 193 | '</a>' |
194 | 194 | ), |
195 | 195 | 'return_url' => $_REQUEST['return_url'], |
@@ -207,26 +207,26 @@ discard block |
||
207 | 207 | protected function _enqueue_batch_job_scripts_and_styles_and_start_job() |
208 | 208 | { |
209 | 209 | // just copy the bits of EE admin's eei18n that we need in the JS |
210 | - EE_Registry::$i18n_js_strings['batchJobError'] = esc_html__( |
|
210 | + EE_Registry::$i18n_js_strings['batchJobError'] = esc_html__( |
|
211 | 211 | 'An error occurred and the job has been stopped. Please refresh the page to try again.', |
212 | 212 | 'event_espresso' |
213 | 213 | ); |
214 | 214 | wp_register_script( |
215 | 215 | 'progress_bar', |
216 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', |
|
216 | + EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.js', |
|
217 | 217 | array('jquery'), |
218 | 218 | EVENT_ESPRESSO_VERSION, |
219 | 219 | true |
220 | 220 | ); |
221 | 221 | wp_enqueue_style( |
222 | 222 | 'progress_bar', |
223 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', |
|
223 | + EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.css', |
|
224 | 224 | array(), |
225 | 225 | EVENT_ESPRESSO_VERSION |
226 | 226 | ); |
227 | 227 | wp_enqueue_script( |
228 | 228 | 'batch_runner', |
229 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', |
|
229 | + EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/batch_runner.js', |
|
230 | 230 | array('progress_bar', CoreAssetManager::JS_HANDLE_CORE), |
231 | 231 | EVENT_ESPRESSO_VERSION, |
232 | 232 | true |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | public function override_template($template) |
254 | 254 | { |
255 | 255 | if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) { |
256 | - return EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_frontend_wrapper.template.html'; |
|
256 | + return EE_MODULES.'batch'.DS.'templates'.DS.'batch_frontend_wrapper.template.html'; |
|
257 | 257 | } |
258 | 258 | return $template; |
259 | 259 | } |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | public function show_admin_page() |
281 | 281 | { |
282 | 282 | echo EEH_Template::locate_template( |
283 | - EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_wrapper.template.html', |
|
283 | + EE_MODULES.'batch'.DS.'templates'.DS.'batch_wrapper.template.html', |
|
284 | 284 | array('batch_request_type' => $this->batch_request_type()) |
285 | 285 | ); |
286 | 286 | } |
@@ -38,103 +38,103 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.83.rc.003'); |
|
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.9.83.rc.003'); |
|
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 | } |