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