@@ -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; |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
151 | 151 | wp_enqueue_script( |
152 | 152 | 'batch_runner_init', |
153 | - BATCH_URL . 'assets/batch_runner_init.js', |
|
153 | + BATCH_URL.'assets/batch_runner_init.js', |
|
154 | 154 | array('batch_runner'), |
155 | 155 | EVENT_ESPRESSO_VERSION, |
156 | 156 | true |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
175 | 175 | wp_enqueue_script( |
176 | 176 | 'batch_file_runner_init', |
177 | - BATCH_URL . 'assets/batch_file_runner_init.js', |
|
177 | + BATCH_URL.'assets/batch_file_runner_init.js', |
|
178 | 178 | array('batch_runner'), |
179 | 179 | EVENT_ESPRESSO_VERSION, |
180 | 180 | true |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | array( |
187 | 187 | 'download_and_redirecting' => sprintf( |
188 | 188 | __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'), |
189 | - '<a href="' . $_REQUEST['return_url'] . '">', |
|
189 | + '<a href="'.$_REQUEST['return_url'].'">', |
|
190 | 190 | '</a>' |
191 | 191 | ), |
192 | 192 | 'return_url' => $_REQUEST['return_url'], |
@@ -204,26 +204,26 @@ discard block |
||
204 | 204 | protected function _enqueue_batch_job_scripts_and_styles_and_start_job() |
205 | 205 | { |
206 | 206 | // just copy the bits of EE admin's eei18n that we need in the JS |
207 | - EE_Registry::$i18n_js_strings['batchJobError'] = esc_html__( |
|
207 | + EE_Registry::$i18n_js_strings['batchJobError'] = esc_html__( |
|
208 | 208 | 'An error occurred and the job has been stopped. Please refresh the page to try again.', |
209 | 209 | 'event_espresso' |
210 | 210 | ); |
211 | 211 | wp_register_script( |
212 | 212 | 'progress_bar', |
213 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', |
|
213 | + EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.js', |
|
214 | 214 | array('jquery'), |
215 | 215 | EVENT_ESPRESSO_VERSION, |
216 | 216 | true |
217 | 217 | ); |
218 | 218 | wp_enqueue_style( |
219 | 219 | 'progress_bar', |
220 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', |
|
220 | + EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.css', |
|
221 | 221 | array(), |
222 | 222 | EVENT_ESPRESSO_VERSION |
223 | 223 | ); |
224 | 224 | wp_enqueue_script( |
225 | 225 | 'batch_runner', |
226 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', |
|
226 | + EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/batch_runner.js', |
|
227 | 227 | array('progress_bar', CoreAssetManager::JS_HANDLE_CORE), |
228 | 228 | EVENT_ESPRESSO_VERSION, |
229 | 229 | true |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | public function override_template($template) |
251 | 251 | { |
252 | 252 | if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) { |
253 | - return EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_frontend_wrapper.template.html'; |
|
253 | + return EE_MODULES.'batch'.DS.'templates'.DS.'batch_frontend_wrapper.template.html'; |
|
254 | 254 | } |
255 | 255 | return $template; |
256 | 256 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | public function show_admin_page() |
278 | 278 | { |
279 | 279 | echo EEH_Template::locate_template( |
280 | - EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_wrapper.template.html', |
|
280 | + EE_MODULES.'batch'.DS.'templates'.DS.'batch_wrapper.template.html', |
|
281 | 281 | array('batch_request_type' => $this->batch_request_type()) |
282 | 282 | ); |
283 | 283 | } |
@@ -29,355 +29,355 @@ |
||
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 | - switch ($this->batch_request_type()) { |
|
135 | - case self::batch_job: |
|
136 | - $this->enqueue_scripts_styles_batch_create(); |
|
137 | - break; |
|
138 | - case self::batch_file_job: |
|
139 | - $this->enqueue_scripts_styles_batch_file_create(); |
|
140 | - break; |
|
141 | - } |
|
142 | - } |
|
143 | - } |
|
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 | + switch ($this->batch_request_type()) { |
|
135 | + case self::batch_job: |
|
136 | + $this->enqueue_scripts_styles_batch_create(); |
|
137 | + break; |
|
138 | + case self::batch_file_job: |
|
139 | + $this->enqueue_scripts_styles_batch_file_create(); |
|
140 | + break; |
|
141 | + } |
|
142 | + } |
|
143 | + } |
|
144 | 144 | |
145 | - /** |
|
146 | - * Create a batch job, enqueues a script to run it, and localizes some data for it |
|
147 | - */ |
|
148 | - public function enqueue_scripts_styles_batch_create() |
|
149 | - { |
|
150 | - $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
151 | - wp_enqueue_script( |
|
152 | - 'batch_runner_init', |
|
153 | - BATCH_URL . 'assets/batch_runner_init.js', |
|
154 | - array('batch_runner'), |
|
155 | - EVENT_ESPRESSO_VERSION, |
|
156 | - true |
|
157 | - ); |
|
158 | - wp_localize_script('batch_runner_init', 'ee_job_response', $job_response->to_array()); |
|
159 | - wp_localize_script( |
|
160 | - 'batch_runner_init', |
|
161 | - 'ee_job_i18n', |
|
162 | - array( |
|
163 | - 'return_url' => $_REQUEST['return_url'], |
|
164 | - ) |
|
165 | - ); |
|
166 | - } |
|
145 | + /** |
|
146 | + * Create a batch job, enqueues a script to run it, and localizes some data for it |
|
147 | + */ |
|
148 | + public function enqueue_scripts_styles_batch_create() |
|
149 | + { |
|
150 | + $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
151 | + wp_enqueue_script( |
|
152 | + 'batch_runner_init', |
|
153 | + BATCH_URL . 'assets/batch_runner_init.js', |
|
154 | + array('batch_runner'), |
|
155 | + EVENT_ESPRESSO_VERSION, |
|
156 | + true |
|
157 | + ); |
|
158 | + wp_localize_script('batch_runner_init', 'ee_job_response', $job_response->to_array()); |
|
159 | + wp_localize_script( |
|
160 | + 'batch_runner_init', |
|
161 | + 'ee_job_i18n', |
|
162 | + array( |
|
163 | + 'return_url' => $_REQUEST['return_url'], |
|
164 | + ) |
|
165 | + ); |
|
166 | + } |
|
167 | 167 | |
168 | - /** |
|
169 | - * Creates a batch job which will download a file, enqueues a script to run the job, and localizes some data for it |
|
170 | - */ |
|
171 | - public function enqueue_scripts_styles_batch_file_create() |
|
172 | - { |
|
173 | - // creates a job based on the request variable |
|
174 | - $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
175 | - wp_enqueue_script( |
|
176 | - 'batch_file_runner_init', |
|
177 | - BATCH_URL . 'assets/batch_file_runner_init.js', |
|
178 | - array('batch_runner'), |
|
179 | - EVENT_ESPRESSO_VERSION, |
|
180 | - true |
|
181 | - ); |
|
182 | - wp_localize_script('batch_file_runner_init', 'ee_job_response', $job_response->to_array()); |
|
183 | - wp_localize_script( |
|
184 | - 'batch_file_runner_init', |
|
185 | - 'ee_job_i18n', |
|
186 | - array( |
|
187 | - 'download_and_redirecting' => sprintf( |
|
188 | - __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'), |
|
189 | - '<a href="' . $_REQUEST['return_url'] . '">', |
|
190 | - '</a>' |
|
191 | - ), |
|
192 | - 'return_url' => $_REQUEST['return_url'], |
|
193 | - ) |
|
194 | - ); |
|
195 | - } |
|
168 | + /** |
|
169 | + * Creates a batch job which will download a file, enqueues a script to run the job, and localizes some data for it |
|
170 | + */ |
|
171 | + public function enqueue_scripts_styles_batch_file_create() |
|
172 | + { |
|
173 | + // creates a job based on the request variable |
|
174 | + $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
175 | + wp_enqueue_script( |
|
176 | + 'batch_file_runner_init', |
|
177 | + BATCH_URL . 'assets/batch_file_runner_init.js', |
|
178 | + array('batch_runner'), |
|
179 | + EVENT_ESPRESSO_VERSION, |
|
180 | + true |
|
181 | + ); |
|
182 | + wp_localize_script('batch_file_runner_init', 'ee_job_response', $job_response->to_array()); |
|
183 | + wp_localize_script( |
|
184 | + 'batch_file_runner_init', |
|
185 | + 'ee_job_i18n', |
|
186 | + array( |
|
187 | + 'download_and_redirecting' => sprintf( |
|
188 | + __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'), |
|
189 | + '<a href="' . $_REQUEST['return_url'] . '">', |
|
190 | + '</a>' |
|
191 | + ), |
|
192 | + 'return_url' => $_REQUEST['return_url'], |
|
193 | + ) |
|
194 | + ); |
|
195 | + } |
|
196 | 196 | |
197 | - /** |
|
198 | - * Enqueues scripts and styles common to any batch job, and creates |
|
199 | - * a job from the request data, and stores the response in the |
|
200 | - * $this->_job_step_response property |
|
201 | - * |
|
202 | - * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
203 | - */ |
|
204 | - protected function _enqueue_batch_job_scripts_and_styles_and_start_job() |
|
205 | - { |
|
206 | - // just copy the bits of EE admin's eei18n that we need in the JS |
|
207 | - EE_Registry::$i18n_js_strings['batchJobError'] = esc_html__( |
|
208 | - 'An error occurred and the job has been stopped. Please refresh the page to try again.', |
|
209 | - 'event_espresso' |
|
210 | - ); |
|
211 | - wp_register_script( |
|
212 | - 'progress_bar', |
|
213 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', |
|
214 | - array('jquery'), |
|
215 | - EVENT_ESPRESSO_VERSION, |
|
216 | - true |
|
217 | - ); |
|
218 | - wp_enqueue_style( |
|
219 | - 'progress_bar', |
|
220 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', |
|
221 | - array(), |
|
222 | - EVENT_ESPRESSO_VERSION |
|
223 | - ); |
|
224 | - wp_enqueue_script( |
|
225 | - 'batch_runner', |
|
226 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', |
|
227 | - array('progress_bar', CoreAssetManager::JS_HANDLE_CORE), |
|
228 | - EVENT_ESPRESSO_VERSION, |
|
229 | - true |
|
230 | - ); |
|
231 | - $job_handler_classname = stripslashes($_GET['job_handler']); |
|
232 | - $request_data = array_diff_key( |
|
233 | - $_REQUEST, |
|
234 | - array_flip(array('action', 'page', 'ee', 'batch')) |
|
235 | - ); |
|
236 | - $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
237 | - // eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' |
|
238 | - $job_response = $batch_runner->create_job($job_handler_classname, $request_data); |
|
239 | - // remember the response for later. We need it to display the page body |
|
240 | - $this->_job_step_response = $job_response; |
|
241 | - return $job_response; |
|
242 | - } |
|
197 | + /** |
|
198 | + * Enqueues scripts and styles common to any batch job, and creates |
|
199 | + * a job from the request data, and stores the response in the |
|
200 | + * $this->_job_step_response property |
|
201 | + * |
|
202 | + * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
203 | + */ |
|
204 | + protected function _enqueue_batch_job_scripts_and_styles_and_start_job() |
|
205 | + { |
|
206 | + // just copy the bits of EE admin's eei18n that we need in the JS |
|
207 | + EE_Registry::$i18n_js_strings['batchJobError'] = esc_html__( |
|
208 | + 'An error occurred and the job has been stopped. Please refresh the page to try again.', |
|
209 | + 'event_espresso' |
|
210 | + ); |
|
211 | + wp_register_script( |
|
212 | + 'progress_bar', |
|
213 | + EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', |
|
214 | + array('jquery'), |
|
215 | + EVENT_ESPRESSO_VERSION, |
|
216 | + true |
|
217 | + ); |
|
218 | + wp_enqueue_style( |
|
219 | + 'progress_bar', |
|
220 | + EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', |
|
221 | + array(), |
|
222 | + EVENT_ESPRESSO_VERSION |
|
223 | + ); |
|
224 | + wp_enqueue_script( |
|
225 | + 'batch_runner', |
|
226 | + EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', |
|
227 | + array('progress_bar', CoreAssetManager::JS_HANDLE_CORE), |
|
228 | + EVENT_ESPRESSO_VERSION, |
|
229 | + true |
|
230 | + ); |
|
231 | + $job_handler_classname = stripslashes($_GET['job_handler']); |
|
232 | + $request_data = array_diff_key( |
|
233 | + $_REQUEST, |
|
234 | + array_flip(array('action', 'page', 'ee', 'batch')) |
|
235 | + ); |
|
236 | + $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
237 | + // eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' |
|
238 | + $job_response = $batch_runner->create_job($job_handler_classname, $request_data); |
|
239 | + // remember the response for later. We need it to display the page body |
|
240 | + $this->_job_step_response = $job_response; |
|
241 | + return $job_response; |
|
242 | + } |
|
243 | 243 | |
244 | - /** |
|
245 | - * If we are doing a frontend batch job, this makes it so WP shows our template's HTML |
|
246 | - * |
|
247 | - * @param string $template |
|
248 | - * @return string |
|
249 | - */ |
|
250 | - public function override_template($template) |
|
251 | - { |
|
252 | - if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) { |
|
253 | - return EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_frontend_wrapper.template.html'; |
|
254 | - } |
|
255 | - return $template; |
|
256 | - } |
|
244 | + /** |
|
245 | + * If we are doing a frontend batch job, this makes it so WP shows our template's HTML |
|
246 | + * |
|
247 | + * @param string $template |
|
248 | + * @return string |
|
249 | + */ |
|
250 | + public function override_template($template) |
|
251 | + { |
|
252 | + if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) { |
|
253 | + return EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_frontend_wrapper.template.html'; |
|
254 | + } |
|
255 | + return $template; |
|
256 | + } |
|
257 | 257 | |
258 | - /** |
|
259 | - * Adds an admin page which doesn't appear in the admin menu |
|
260 | - */ |
|
261 | - public function register_admin_pages() |
|
262 | - { |
|
263 | - add_submenu_page( |
|
264 | - '', // parent slug. we don't want this to actually appear in the menu |
|
265 | - __('Batch Job', 'event_espresso'), // page title |
|
266 | - 'n/a', // menu title |
|
267 | - 'read', // we want this page to actually be accessible to anyone, |
|
268 | - 'espresso_batch', // menu slug |
|
269 | - array(self::instance(), 'show_admin_page') |
|
270 | - ); |
|
271 | - } |
|
258 | + /** |
|
259 | + * Adds an admin page which doesn't appear in the admin menu |
|
260 | + */ |
|
261 | + public function register_admin_pages() |
|
262 | + { |
|
263 | + add_submenu_page( |
|
264 | + '', // parent slug. we don't want this to actually appear in the menu |
|
265 | + __('Batch Job', 'event_espresso'), // page title |
|
266 | + 'n/a', // menu title |
|
267 | + 'read', // we want this page to actually be accessible to anyone, |
|
268 | + 'espresso_batch', // menu slug |
|
269 | + array(self::instance(), 'show_admin_page') |
|
270 | + ); |
|
271 | + } |
|
272 | 272 | |
273 | - /** |
|
274 | - * Renders the admin page, after most of the work was already done during enqueuing scripts |
|
275 | - * of creating the job and localizing some data |
|
276 | - */ |
|
277 | - public function show_admin_page() |
|
278 | - { |
|
279 | - echo EEH_Template::locate_template( |
|
280 | - EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_wrapper.template.html', |
|
281 | - array('batch_request_type' => $this->batch_request_type()) |
|
282 | - ); |
|
283 | - } |
|
273 | + /** |
|
274 | + * Renders the admin page, after most of the work was already done during enqueuing scripts |
|
275 | + * of creating the job and localizing some data |
|
276 | + */ |
|
277 | + public function show_admin_page() |
|
278 | + { |
|
279 | + echo EEH_Template::locate_template( |
|
280 | + EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_wrapper.template.html', |
|
281 | + array('batch_request_type' => $this->batch_request_type()) |
|
282 | + ); |
|
283 | + } |
|
284 | 284 | |
285 | - /** |
|
286 | - * Receives ajax calls for continuing a job |
|
287 | - */ |
|
288 | - public function batch_continue() |
|
289 | - { |
|
290 | - $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
291 | - $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
292 | - $response_obj = $batch_runner->continue_job($job_id); |
|
293 | - $this->_return_json($response_obj->to_array()); |
|
294 | - } |
|
285 | + /** |
|
286 | + * Receives ajax calls for continuing a job |
|
287 | + */ |
|
288 | + public function batch_continue() |
|
289 | + { |
|
290 | + $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
291 | + $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
292 | + $response_obj = $batch_runner->continue_job($job_id); |
|
293 | + $this->_return_json($response_obj->to_array()); |
|
294 | + } |
|
295 | 295 | |
296 | - /** |
|
297 | - * Receives the ajax call to cleanup a job |
|
298 | - * |
|
299 | - * @return type |
|
300 | - */ |
|
301 | - public function batch_cleanup() |
|
302 | - { |
|
303 | - $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
304 | - $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
305 | - $response_obj = $batch_runner->cleanup_job($job_id); |
|
306 | - $this->_return_json($response_obj->to_array()); |
|
307 | - } |
|
296 | + /** |
|
297 | + * Receives the ajax call to cleanup a job |
|
298 | + * |
|
299 | + * @return type |
|
300 | + */ |
|
301 | + public function batch_cleanup() |
|
302 | + { |
|
303 | + $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
304 | + $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
305 | + $response_obj = $batch_runner->cleanup_job($job_id); |
|
306 | + $this->_return_json($response_obj->to_array()); |
|
307 | + } |
|
308 | 308 | |
309 | 309 | |
310 | - /** |
|
311 | - * Returns a json response |
|
312 | - * |
|
313 | - * @param array $data The data we want to send echo via in the JSON response's "data" element |
|
314 | - * |
|
315 | - * The returned json object is created from an array in the following format: |
|
316 | - * array( |
|
317 | - * 'notices' => '', // - contains any EE_Error formatted notices |
|
318 | - * 'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. |
|
319 | - * We're also going to include the template args with every package (so js can pick out any specific template |
|
320 | - * args that might be included in here) |
|
321 | - * 'isEEajax' => true,//indicates this is a response from EE |
|
322 | - * ) |
|
323 | - */ |
|
324 | - protected function _return_json($data) |
|
325 | - { |
|
326 | - $json = array( |
|
327 | - 'notices' => EE_Error::get_notices(), |
|
328 | - 'data' => $data, |
|
329 | - 'isEEajax' => true |
|
330 | - // special flag so any ajax.Success methods in js can identify this return package as a EEajax package. |
|
331 | - ); |
|
310 | + /** |
|
311 | + * Returns a json response |
|
312 | + * |
|
313 | + * @param array $data The data we want to send echo via in the JSON response's "data" element |
|
314 | + * |
|
315 | + * The returned json object is created from an array in the following format: |
|
316 | + * array( |
|
317 | + * 'notices' => '', // - contains any EE_Error formatted notices |
|
318 | + * 'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. |
|
319 | + * We're also going to include the template args with every package (so js can pick out any specific template |
|
320 | + * args that might be included in here) |
|
321 | + * 'isEEajax' => true,//indicates this is a response from EE |
|
322 | + * ) |
|
323 | + */ |
|
324 | + protected function _return_json($data) |
|
325 | + { |
|
326 | + $json = array( |
|
327 | + 'notices' => EE_Error::get_notices(), |
|
328 | + 'data' => $data, |
|
329 | + 'isEEajax' => true |
|
330 | + // special flag so any ajax.Success methods in js can identify this return package as a EEajax package. |
|
331 | + ); |
|
332 | 332 | |
333 | 333 | |
334 | - // make sure there are no php errors or headers_sent. Then we can set correct json header. |
|
335 | - if (null === error_get_last() || ! headers_sent()) { |
|
336 | - header('Content-Type: application/json; charset=UTF-8'); |
|
337 | - } |
|
338 | - echo wp_json_encode($json); |
|
339 | - exit(); |
|
340 | - } |
|
334 | + // make sure there are no php errors or headers_sent. Then we can set correct json header. |
|
335 | + if (null === error_get_last() || ! headers_sent()) { |
|
336 | + header('Content-Type: application/json; charset=UTF-8'); |
|
337 | + } |
|
338 | + echo wp_json_encode($json); |
|
339 | + exit(); |
|
340 | + } |
|
341 | 341 | |
342 | - /** |
|
343 | - * Gets the job step response which was done during the enqueuing of scripts |
|
344 | - * |
|
345 | - * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
346 | - */ |
|
347 | - public function job_step_response() |
|
348 | - { |
|
349 | - return $this->_job_step_response; |
|
350 | - } |
|
342 | + /** |
|
343 | + * Gets the job step response which was done during the enqueuing of scripts |
|
344 | + * |
|
345 | + * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
|
346 | + */ |
|
347 | + public function job_step_response() |
|
348 | + { |
|
349 | + return $this->_job_step_response; |
|
350 | + } |
|
351 | 351 | |
352 | - /** |
|
353 | - * Gets the batch request type indicated in the $_REQUEST |
|
354 | - * |
|
355 | - * @return string: EED_Batch::batch_job, EED_Batch::batch_file_job, EED_Batch::batch_not_job |
|
356 | - */ |
|
357 | - public function batch_request_type() |
|
358 | - { |
|
359 | - if ($this->_batch_request_type === null) { |
|
360 | - if (isset($_GET['batch'])) { |
|
361 | - if ($_GET['batch'] == self::batch_job) { |
|
362 | - $this->_batch_request_type = self::batch_job; |
|
363 | - } elseif ($_GET['batch'] == self::batch_file_job) { |
|
364 | - $this->_batch_request_type = self::batch_file_job; |
|
365 | - } |
|
366 | - } |
|
367 | - // if we didn't find that it was a batch request, indicate it wasn't |
|
368 | - if ($this->_batch_request_type === null) { |
|
369 | - $this->_batch_request_type = self::batch_not_job; |
|
370 | - } |
|
371 | - } |
|
372 | - return $this->_batch_request_type; |
|
373 | - } |
|
352 | + /** |
|
353 | + * Gets the batch request type indicated in the $_REQUEST |
|
354 | + * |
|
355 | + * @return string: EED_Batch::batch_job, EED_Batch::batch_file_job, EED_Batch::batch_not_job |
|
356 | + */ |
|
357 | + public function batch_request_type() |
|
358 | + { |
|
359 | + if ($this->_batch_request_type === null) { |
|
360 | + if (isset($_GET['batch'])) { |
|
361 | + if ($_GET['batch'] == self::batch_job) { |
|
362 | + $this->_batch_request_type = self::batch_job; |
|
363 | + } elseif ($_GET['batch'] == self::batch_file_job) { |
|
364 | + $this->_batch_request_type = self::batch_file_job; |
|
365 | + } |
|
366 | + } |
|
367 | + // if we didn't find that it was a batch request, indicate it wasn't |
|
368 | + if ($this->_batch_request_type === null) { |
|
369 | + $this->_batch_request_type = self::batch_not_job; |
|
370 | + } |
|
371 | + } |
|
372 | + return $this->_batch_request_type; |
|
373 | + } |
|
374 | 374 | |
375 | - /** |
|
376 | - * Unnecessary |
|
377 | - * |
|
378 | - * @param type $WP |
|
379 | - */ |
|
380 | - public function run($WP) |
|
381 | - { |
|
382 | - } |
|
375 | + /** |
|
376 | + * Unnecessary |
|
377 | + * |
|
378 | + * @param type $WP |
|
379 | + */ |
|
380 | + public function run($WP) |
|
381 | + { |
|
382 | + } |
|
383 | 383 | } |
@@ -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.81.rc.027'); |
|
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.81.rc.027'); |
|
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 | } |