@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php ?> |
2 | -<h1><?php _e( 'Doing job...', 'event_espresso' );?></h1> |
|
2 | +<h1><?php _e('Doing job...', 'event_espresso'); ?></h1> |
|
3 | 3 | <div id="batch-progress" class="progress-responsive"></div> |
4 | 4 | <br/> |
5 | -<div id='message-area'><?php _e( 'You will be redirected automatically when job is complete.', 'event_espresso');?></div> |
|
5 | +<div id='message-area'><?php _e('You will be redirected automatically when job is complete.', 'event_espresso'); ?></div> |
|
6 | 6 | <div id='progress-area'></div> |
@@ -4,5 +4,5 @@ |
||
4 | 4 | if( $batch_request_type == EED_Batch::batch_job ) { |
5 | 5 | require( 'batch_runner.template.php' ); |
6 | 6 | } elseif( $batch_request_type == EED_Batch::batch_file_job ) { |
7 | - require( 'batch_file_runner.template.php' ); |
|
7 | + require( 'batch_file_runner.template.php' ); |
|
8 | 8 | } |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | //just makes the template conditional on the batch request type |
3 | 3 | $batch_request_type = EED_Batch::instance()->batch_request_type(); |
4 | -if( $batch_request_type == EED_Batch::batch_job ) { |
|
5 | - require( 'batch_runner.template.php' ); |
|
6 | -} elseif( $batch_request_type == EED_Batch::batch_file_job ) { |
|
7 | - require( 'batch_file_runner.template.php' ); |
|
4 | +if ($batch_request_type == EED_Batch::batch_job) { |
|
5 | + require('batch_runner.template.php'); |
|
6 | +} elseif ($batch_request_type == EED_Batch::batch_file_job) { |
|
7 | + require('batch_file_runner.template.php'); |
|
8 | 8 | } |
@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | 2 | $job_step_response = EED_Batch::instance()->job_step_response(); |
3 | 3 | $filename = null; |
4 | - if( $job_step_response instanceof \EventEspressoBatchRequest\Helpers\JobStepResponse ) { |
|
5 | - $filename = EEH_File::get_filename_from_filepath( $job_step_response->job_parameters()->extra_datum( 'filepath' ) ); |
|
4 | + if ($job_step_response instanceof \EventEspressoBatchRequest\Helpers\JobStepResponse) { |
|
5 | + $filename = EEH_File::get_filename_from_filepath($job_step_response->job_parameters()->extra_datum('filepath')); |
|
6 | 6 | } |
7 | - if( ! $filename) { |
|
8 | - $filename = __( 'Unknown', 'event_espresso' ); |
|
7 | + if ( ! $filename) { |
|
8 | + $filename = __('Unknown', 'event_espresso'); |
|
9 | 9 | } |
10 | 10 | ?> |
11 | -<h1><?php printf( __( 'Generating file %1$s...', 'event_espresso' ), $filename );?></h1> |
|
11 | +<h1><?php printf(__('Generating file %1$s...', 'event_espresso'), $filename); ?></h1> |
|
12 | 12 | <div id="batch-progress" class="progress-responsive"></div> |
13 | 13 | <br/> |
14 | -<div id='message-area'><?php _e( 'The file will download automatically when done, and then you will be redirected.', 'event_espresso');?></div> |
|
14 | +<div id='message-area'><?php _e('The file will download automatically when done, and then you will be redirected.', 'event_espresso'); ?></div> |
|
15 | 15 | <div id='progress-area'></div> |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | 2 | //wraps the template in the typical wordpress header and footer |
3 | 3 | get_header(); |
4 | -require( 'batch_wrapper.template.php'); |
|
4 | +require('batch_wrapper.template.php'); |
|
5 | 5 | get_footer(); |
6 | 6 | \ No newline at end of file |
@@ -17,13 +17,13 @@ discard block |
||
17 | 17 | * @since 4.8.30.rc.007 |
18 | 18 | * |
19 | 19 | */ |
20 | -if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
21 | - exit( 'No direct script access allowed' ); |
|
20 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
21 | + exit('No direct script access allowed'); |
|
22 | 22 | } |
23 | 23 | |
24 | -define( 'BATCH_URL', plugin_dir_url( __FILE__ ) ); |
|
24 | +define('BATCH_URL', plugin_dir_url(__FILE__)); |
|
25 | 25 | |
26 | -class EED_Batch extends EED_Module{ |
|
26 | +class EED_Batch extends EED_Module { |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | public static function set_hooks() { |
71 | 71 | //because this is a possibel attack vector, let's have this disabled until |
72 | 72 | //we at least have a real use for it on the frontend |
73 | - if( apply_filters( 'FHEE__EED_Batch__set_hooks__enable_frontend_batch', false ) ) { |
|
74 | - add_action( 'wp_enqueue_scripts', array( self::instance(), 'enqueue_scripts' ) ); |
|
75 | - add_filter( 'template_include', array( self::instance(), 'override_template' ), 99 ); |
|
73 | + if (apply_filters('FHEE__EED_Batch__set_hooks__enable_frontend_batch', false)) { |
|
74 | + add_action('wp_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
75 | + add_filter('template_include', array(self::instance(), 'override_template'), 99); |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
@@ -80,28 +80,28 @@ discard block |
||
80 | 80 | * Initializes some hooks for the admin in order to run batch jobs |
81 | 81 | */ |
82 | 82 | public static function set_hooks_admin() { |
83 | - add_action( 'admin_menu', array( self::instance(), 'register_admin_pages' ) ); |
|
84 | - add_action( 'admin_enqueue_scripts', array( self::instance(), 'enqueue_scripts' ) ); |
|
83 | + add_action('admin_menu', array(self::instance(), 'register_admin_pages')); |
|
84 | + add_action('admin_enqueue_scripts', array(self::instance(), 'enqueue_scripts')); |
|
85 | 85 | |
86 | 86 | //ajax |
87 | - add_action('wp_ajax_espresso_batch_continue',array(self::instance(),'batch_continue')); |
|
88 | - add_action('wp_ajax_espresso_batch_cleanup',array(self::instance(),'batch_cleanup')); |
|
89 | - add_action('wp_ajax_nopriv_espresso_batch_continue',array(self::instance(),'batch_continue')); |
|
90 | - add_action('wp_ajax_nopriv_espresso_batch_cleanup',array(self::instance(),'batch_cleanup')); |
|
87 | + add_action('wp_ajax_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
88 | + add_action('wp_ajax_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
89 | + add_action('wp_ajax_nopriv_espresso_batch_continue', array(self::instance(), 'batch_continue')); |
|
90 | + add_action('wp_ajax_nopriv_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup')); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
94 | 94 | * Enqueues batch scripts on the frontend or admin, and creates a job |
95 | 95 | */ |
96 | 96 | public function enqueue_scripts() { |
97 | - if( isset( $_REQUEST[ 'espresso_batch' ] ) |
|
97 | + if (isset($_REQUEST['espresso_batch']) |
|
98 | 98 | || |
99 | 99 | ( |
100 | - isset( $_REQUEST[ 'page' ] ) |
|
101 | - && $_REQUEST[ 'page' ] == 'espresso_batch' |
|
100 | + isset($_REQUEST['page']) |
|
101 | + && $_REQUEST['page'] == 'espresso_batch' |
|
102 | 102 | ) |
103 | 103 | ) { |
104 | - switch( $this->batch_request_type() ) { |
|
104 | + switch ($this->batch_request_type()) { |
|
105 | 105 | case self::batch_job: |
106 | 106 | $this->enqueue_scripts_styles_batch_create(); |
107 | 107 | break; |
@@ -117,11 +117,11 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function enqueue_scripts_styles_batch_create() { |
119 | 119 | $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
120 | - wp_enqueue_script( 'batch_runner_init', BATCH_URL . '/assets/batch_runner_init.js', array( 'batch_runner' ), EVENT_ESPRESSO_VERSION, true ); |
|
121 | - wp_localize_script( 'batch_runner_init', 'ee_job_response', $job_response->to_array() ); |
|
122 | - wp_localize_script( 'batch_runner_init', 'ee_job_i18n', |
|
120 | + wp_enqueue_script('batch_runner_init', BATCH_URL.'/assets/batch_runner_init.js', array('batch_runner'), EVENT_ESPRESSO_VERSION, true); |
|
121 | + wp_localize_script('batch_runner_init', 'ee_job_response', $job_response->to_array()); |
|
122 | + wp_localize_script('batch_runner_init', 'ee_job_i18n', |
|
123 | 123 | array( |
124 | - 'return_url' => $_REQUEST['return_url' ], |
|
124 | + 'return_url' => $_REQUEST['return_url'], |
|
125 | 125 | )); |
126 | 126 | } |
127 | 127 | |
@@ -131,15 +131,15 @@ discard block |
||
131 | 131 | public function enqueue_scripts_styles_batch_file_create() { |
132 | 132 | //creates a job based on the request variable |
133 | 133 | $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
134 | - wp_enqueue_script( 'batch_file_runner_init', BATCH_URL . '/assets/batch_file_runner_init.js', array( 'batch_runner' ), EVENT_ESPRESSO_VERSION, true ); |
|
135 | - wp_localize_script( 'batch_file_runner_init', 'ee_job_response', $job_response->to_array() ); |
|
136 | - wp_localize_script( 'batch_file_runner_init', 'ee_job_i18n', |
|
134 | + wp_enqueue_script('batch_file_runner_init', BATCH_URL.'/assets/batch_file_runner_init.js', array('batch_runner'), EVENT_ESPRESSO_VERSION, true); |
|
135 | + wp_localize_script('batch_file_runner_init', 'ee_job_response', $job_response->to_array()); |
|
136 | + wp_localize_script('batch_file_runner_init', 'ee_job_i18n', |
|
137 | 137 | array( |
138 | 138 | 'download_and_redirecting' => sprintf( |
139 | 139 | __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'), |
140 | - '<a href="' . $_REQUEST['return_url' ] .'">', |
|
140 | + '<a href="'.$_REQUEST['return_url'].'">', |
|
141 | 141 | '</a>' ), |
142 | - 'return_url' => $_REQUEST['return_url' ], |
|
142 | + 'return_url' => $_REQUEST['return_url'], |
|
143 | 143 | )); |
144 | 144 | } |
145 | 145 | |
@@ -150,18 +150,18 @@ discard block |
||
150 | 150 | * @return \EventEspressoBatchRequest\Helpers\JobStepResponse |
151 | 151 | */ |
152 | 152 | protected function _enqueue_batch_job_scripts_and_styles_and_start_job() { |
153 | - wp_register_script( 'progress_bar', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', array( 'jquery' ) ); |
|
154 | - wp_enqueue_style( 'progress_bar', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', array(), EVENT_ESPRESSO_VERSION ); |
|
155 | - wp_enqueue_script( 'batch_runner', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', array( 'progress_bar' )); |
|
153 | + wp_register_script('progress_bar', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.js', array('jquery')); |
|
154 | + wp_enqueue_style('progress_bar', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.css', array(), EVENT_ESPRESSO_VERSION); |
|
155 | + wp_enqueue_script('batch_runner', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/batch_runner.js', array('progress_bar')); |
|
156 | 156 | //just copy the bits of EE admin's eei18n that we need in the JS |
157 | - wp_localize_script( 'batch_runner', 'eei18n', array( 'ajax_url' => WP_AJAX_URL, 'is_admin' => (bool)is_admin() ) ); |
|
158 | - $job_handler_classname = stripslashes( $_GET[ 'job_handler' ] ); |
|
157 | + wp_localize_script('batch_runner', 'eei18n', array('ajax_url' => WP_AJAX_URL, 'is_admin' => (bool) is_admin())); |
|
158 | + $job_handler_classname = stripslashes($_GET['job_handler']); |
|
159 | 159 | $request_data = array_diff_key( |
160 | 160 | $_REQUEST, |
161 | - array_flip( array( 'action', 'page', 'ee', 'batch' ) ) ); |
|
161 | + array_flip(array('action', 'page', 'ee', 'batch')) ); |
|
162 | 162 | $batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor(); |
163 | 163 | //eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' |
164 | - $job_response = $batch_runner->create_job( $job_handler_classname, $request_data ); |
|
164 | + $job_response = $batch_runner->create_job($job_handler_classname, $request_data); |
|
165 | 165 | //remember the response for later. We need it to display the page body |
166 | 166 | $this->_job_step_response = $job_response; |
167 | 167 | return $job_response; |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | * @param string $template |
173 | 173 | * @return string |
174 | 174 | */ |
175 | - public function override_template( $template ) { |
|
176 | - if( isset( $_REQUEST[ 'espresso_batch' ] ) && isset( $_REQUEST[ 'batch' ] ) ) { |
|
177 | - return EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_frontend_wrapper.template.php'; |
|
175 | + public function override_template($template) { |
|
176 | + if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) { |
|
177 | + return EE_MODULES.'batch'.DS.'templates'.DS.'batch_frontend_wrapper.template.php'; |
|
178 | 178 | } |
179 | 179 | return $template; |
180 | 180 | } |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | public function register_admin_pages() { |
186 | 186 | add_submenu_page( |
187 | 187 | '', //parent slug. we don't want this to actually appear in the menu |
188 | - __( 'Batch Job', 'event_espresso' ), //page title |
|
188 | + __('Batch Job', 'event_espresso'), //page title |
|
189 | 189 | 'n/a', //menu title |
190 | 190 | 'read', //we want this page to actually be accessible to anyone, |
191 | 191 | 'espresso_batch', //menu slug |
192 | - array( self::instance(), 'show_admin_page' ) |
|
192 | + array(self::instance(), 'show_admin_page') |
|
193 | 193 | ); |
194 | 194 | } |
195 | 195 | |
@@ -199,8 +199,8 @@ discard block |
||
199 | 199 | */ |
200 | 200 | public function show_admin_page() { |
201 | 201 | echo EEH_Template::locate_template( |
202 | - EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_wrapper.template.php', |
|
203 | - array( 'batch_request_type' => $this->batch_request_type() ) |
|
202 | + EE_MODULES.'batch'.DS.'templates'.DS.'batch_wrapper.template.php', |
|
203 | + array('batch_request_type' => $this->batch_request_type()) |
|
204 | 204 | ); |
205 | 205 | } |
206 | 206 | |
@@ -208,10 +208,10 @@ discard block |
||
208 | 208 | * Receives ajax calls for continuing a job |
209 | 209 | */ |
210 | 210 | public function batch_continue() { |
211 | - $job_id = sanitize_text_field( $_REQUEST[ 'job_id' ] ); |
|
211 | + $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
212 | 212 | $batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor(); |
213 | - $response_obj = $batch_runner->continue_job( $job_id); |
|
214 | - $this->_return_json( $response_obj->to_array() ); |
|
213 | + $response_obj = $batch_runner->continue_job($job_id); |
|
214 | + $this->_return_json($response_obj->to_array()); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -219,10 +219,10 @@ discard block |
||
219 | 219 | * @return type |
220 | 220 | */ |
221 | 221 | public function batch_cleanup() { |
222 | - $job_id = sanitize_text_field( $_REQUEST[ 'job_id' ] ); |
|
222 | + $job_id = sanitize_text_field($_REQUEST['job_id']); |
|
223 | 223 | $batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor(); |
224 | - $response_obj = $batch_runner->cleanup_job( $job_id ); |
|
225 | - $this->_return_json( $response_obj->to_array() ); |
|
224 | + $response_obj = $batch_runner->cleanup_job($job_id); |
|
225 | + $this->_return_json($response_obj->to_array()); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | * 'isEEajax' => true,//indicates this is a response from EE |
239 | 239 | * ) |
240 | 240 | */ |
241 | - protected function _return_json( $data ) { |
|
241 | + protected function _return_json($data) { |
|
242 | 242 | $json = array( |
243 | 243 | 'notices' => EE_Error::get_notices(), |
244 | 244 | 'data' => $data, |
@@ -247,13 +247,13 @@ discard block |
||
247 | 247 | |
248 | 248 | |
249 | 249 | // make sure there are no php errors or headers_sent. Then we can set correct json header. |
250 | - if ( NULL === error_get_last() || ! headers_sent() ) { |
|
250 | + if (NULL === error_get_last() || ! headers_sent()) { |
|
251 | 251 | header('Content-Type: application/json; charset=UTF-8'); |
252 | 252 | } |
253 | - if( function_exists( 'wp_json_encode' ) ) { |
|
254 | - echo wp_json_encode( $json ); |
|
253 | + if (function_exists('wp_json_encode')) { |
|
254 | + echo wp_json_encode($json); |
|
255 | 255 | } else { |
256 | - echo json_encode( $json ); |
|
256 | + echo json_encode($json); |
|
257 | 257 | } |
258 | 258 | exit(); |
259 | 259 | } |
@@ -270,16 +270,16 @@ discard block |
||
270 | 270 | * @return string: EED_Batch::batch_job, EED_Batch::batch_file_job, EED_Batch::batch_not_job |
271 | 271 | */ |
272 | 272 | public function batch_request_type() { |
273 | - if( $this->_batch_request_type === null ) { |
|
274 | - if( isset( $_GET[ 'batch' ] ) ) { |
|
275 | - if( $_GET[ 'batch' ] == self::batch_job ) { |
|
273 | + if ($this->_batch_request_type === null) { |
|
274 | + if (isset($_GET['batch'])) { |
|
275 | + if ($_GET['batch'] == self::batch_job) { |
|
276 | 276 | $this->_batch_request_type = self::batch_job; |
277 | - } elseif( $_GET[ 'batch' ] == self::batch_file_job ) { |
|
277 | + } elseif ($_GET['batch'] == self::batch_file_job) { |
|
278 | 278 | $this->_batch_request_type = self::batch_file_job; |
279 | 279 | } |
280 | 280 | } |
281 | 281 | //if we didn't find that it was a batch request, indicate it wasn't |
282 | - if( $this->_batch_request_type === null ) { |
|
282 | + if ($this->_batch_request_type === null) { |
|
283 | 283 | $this->_batch_request_type = self::batch_not_job; |
284 | 284 | } |
285 | 285 | } |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * Unnecessary |
291 | 291 | * @param type $WP |
292 | 292 | */ |
293 | - public function run( $WP ) { |
|
293 | + public function run($WP) { |
|
294 | 294 | |
295 | 295 | } |
296 | 296 |