Completed
Branch ENH/failed-batch-job-message-i... (35a222)
by
unknown
18:54 queued 09:32
created
modules/bot_trap/EED_Bot_Trap.module.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public static function set_trap()
55 55
     {
56
-        define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS);
56
+        define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__).DS);
57 57
         add_action(
58 58
             'AHEE__ticket_selector_chart__template__after_ticket_selector',
59 59
             array('EED_Bot_Trap', 'generate_bot_trap'),
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
         $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso');
120 120
         $time = microtime(true);
121 121
         $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">';
122
-        $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>';
122
+        $html .= '<label for="tkt-slctr-request-processor-email-'.$time.'">'.$do_not_enter.'</label>';
123 123
         $html .= '<input type="email" id="tkt-slctr-request-processor-email-';
124
-        $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>';
124
+        $html .= $time.'" name="tkt-slctr-request-processor-email" value=""/>';
125 125
         $html .= '</div><!-- .tkt-slctr-request-processor-dv -->';
126 126
         echo $html;
127 127
     }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
             return;
148 148
         }
149 149
         // check the given callback is valid first before executing
150
-        if (! is_callable($triggered_trap_callback)) {
150
+        if ( ! is_callable($triggered_trap_callback)) {
151 151
             // invalid callback so lets just sub in our default.
152 152
             $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response');
153 153
         }
Please login to merge, or discard this patch.
Indentation   +275 added lines, -275 removed lines patch added patch discarded remove patch
@@ -16,304 +16,304 @@
 block discarded – undo
16 16
 class EED_Bot_Trap extends EED_Module
17 17
 {
18 18
 
19
-    /**
20
-     * @return EED_Bot_Trap|EED_Module
21
-     */
22
-    public static function instance()
23
-    {
24
-        return parent::get_instance(__CLASS__);
25
-    }
19
+	/**
20
+	 * @return EED_Bot_Trap|EED_Module
21
+	 */
22
+	public static function instance()
23
+	{
24
+		return parent::get_instance(__CLASS__);
25
+	}
26 26
 
27 27
 
28
-    /**
29
-     * set_hooks - for hooking into EE Core, other modules, etc
30
-     *
31
-     * @return void
32
-     */
33
-    public static function set_hooks()
34
-    {
35
-        if (apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) &&
36
-            EE_Registry::instance()->CFG->registration->use_bot_trap
37
-        ) {
38
-            EED_Bot_Trap::set_trap();
39
-            // redirect bots to bogus success page
40
-            EE_Config::register_route(
41
-                'ticket_selection_received',
42
-                'EED_Bot_Trap',
43
-                'display_bot_trap_success'
44
-            );
45
-        }
46
-    }
28
+	/**
29
+	 * set_hooks - for hooking into EE Core, other modules, etc
30
+	 *
31
+	 * @return void
32
+	 */
33
+	public static function set_hooks()
34
+	{
35
+		if (apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) &&
36
+			EE_Registry::instance()->CFG->registration->use_bot_trap
37
+		) {
38
+			EED_Bot_Trap::set_trap();
39
+			// redirect bots to bogus success page
40
+			EE_Config::register_route(
41
+				'ticket_selection_received',
42
+				'EED_Bot_Trap',
43
+				'display_bot_trap_success'
44
+			);
45
+		}
46
+	}
47 47
 
48 48
 
49
-    /**
50
-     * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
51
-     *
52
-     * @return void
53
-     */
54
-    public static function set_trap()
55
-    {
56
-        define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS);
57
-        add_action(
58
-            'AHEE__ticket_selector_chart__template__after_ticket_selector',
59
-            array('EED_Bot_Trap', 'generate_bot_trap'),
60
-            10,
61
-            2
62
-        );
63
-        add_action(
64
-            'EED_Ticket_Selector__process_ticket_selections__before',
65
-            array('EED_Bot_Trap', 'process_bot_trap'),
66
-            1,
67
-            2
68
-        );
69
-    }
49
+	/**
50
+	 * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
51
+	 *
52
+	 * @return void
53
+	 */
54
+	public static function set_trap()
55
+	{
56
+		define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS);
57
+		add_action(
58
+			'AHEE__ticket_selector_chart__template__after_ticket_selector',
59
+			array('EED_Bot_Trap', 'generate_bot_trap'),
60
+			10,
61
+			2
62
+		);
63
+		add_action(
64
+			'EED_Ticket_Selector__process_ticket_selections__before',
65
+			array('EED_Bot_Trap', 'process_bot_trap'),
66
+			1,
67
+			2
68
+		);
69
+	}
70 70
 
71 71
 
72
-    /**
73
-     * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
74
-     *
75
-     * @return void
76
-     */
77
-    public static function set_hooks_admin()
78
-    {
79
-        if (defined('DOING_AJAX')
80
-            && DOING_AJAX
81
-            && apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true)
82
-            && EE_Registry::instance()->CFG->registration->use_bot_trap
83
-        ) {
84
-            EED_Bot_Trap::set_trap();
85
-        }
86
-        add_action(
87
-            'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
88
-            array('EED_Bot_Trap', 'bot_trap_settings_form'),
89
-            5
90
-        );
91
-        add_filter(
92
-            'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
93
-            array('EED_Bot_Trap', 'update_bot_trap_settings_form'),
94
-            10,
95
-            1
96
-        );
97
-    }
72
+	/**
73
+	 * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
74
+	 *
75
+	 * @return void
76
+	 */
77
+	public static function set_hooks_admin()
78
+	{
79
+		if (defined('DOING_AJAX')
80
+			&& DOING_AJAX
81
+			&& apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true)
82
+			&& EE_Registry::instance()->CFG->registration->use_bot_trap
83
+		) {
84
+			EED_Bot_Trap::set_trap();
85
+		}
86
+		add_action(
87
+			'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
88
+			array('EED_Bot_Trap', 'bot_trap_settings_form'),
89
+			5
90
+		);
91
+		add_filter(
92
+			'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
93
+			array('EED_Bot_Trap', 'update_bot_trap_settings_form'),
94
+			10,
95
+			1
96
+		);
97
+	}
98 98
 
99 99
 
100
-    /**
101
-     * run - initial module setup
102
-     *
103
-     * @param WP $WP
104
-     * @return void
105
-     */
106
-    public function run($WP)
107
-    {
108
-    }
100
+	/**
101
+	 * run - initial module setup
102
+	 *
103
+	 * @param WP $WP
104
+	 * @return void
105
+	 */
106
+	public function run($WP)
107
+	{
108
+	}
109 109
 
110 110
 
111
-    /**
112
-     * generate_bot_trap
113
-     *
114
-     * @return void
115
-     * @throws RuntimeException
116
-     */
117
-    public static function generate_bot_trap()
118
-    {
119
-        $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso');
120
-        $time = microtime(true);
121
-        $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">';
122
-        $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>';
123
-        $html .= '<input type="email" id="tkt-slctr-request-processor-email-';
124
-        $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>';
125
-        $html .= '</div><!-- .tkt-slctr-request-processor-dv -->';
126
-        echo $html;
127
-    }
111
+	/**
112
+	 * generate_bot_trap
113
+	 *
114
+	 * @return void
115
+	 * @throws RuntimeException
116
+	 */
117
+	public static function generate_bot_trap()
118
+	{
119
+		$do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso');
120
+		$time = microtime(true);
121
+		$html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">';
122
+		$html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>';
123
+		$html .= '<input type="email" id="tkt-slctr-request-processor-email-';
124
+		$html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>';
125
+		$html .= '</div><!-- .tkt-slctr-request-processor-dv -->';
126
+		echo $html;
127
+	}
128 128
 
129 129
 
130
-    /**
131
-     * process_bot_trap
132
-     *
133
-     * @param array|string $triggered_trap_callback Callback that will be executed for handling the
134
-     *                                              response if the bot trap is triggered.
135
-     *                                              It should receive one argument: a boolean indicating
136
-     *                                              whether the trap was triggered by suspicious timing or not.
137
-     * @throws RuntimeException
138
-     */
139
-    public static function process_bot_trap($triggered_trap_callback = array())
140
-    {
141
-        // what's your email address Mr. Bot ?
142
-        $empty_trap = isset($_REQUEST['tkt-slctr-request-processor-email'])
143
-                      && $_REQUEST['tkt-slctr-request-processor-email'] === '';
144
-        // are we human ?
145
-        if ($empty_trap) {
146
-            do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered');
147
-            return;
148
-        }
149
-        // check the given callback is valid first before executing
150
-        if (! is_callable($triggered_trap_callback)) {
151
-            // invalid callback so lets just sub in our default.
152
-            $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response');
153
-        }
154
-        call_user_func($triggered_trap_callback);
155
-    }
130
+	/**
131
+	 * process_bot_trap
132
+	 *
133
+	 * @param array|string $triggered_trap_callback Callback that will be executed for handling the
134
+	 *                                              response if the bot trap is triggered.
135
+	 *                                              It should receive one argument: a boolean indicating
136
+	 *                                              whether the trap was triggered by suspicious timing or not.
137
+	 * @throws RuntimeException
138
+	 */
139
+	public static function process_bot_trap($triggered_trap_callback = array())
140
+	{
141
+		// what's your email address Mr. Bot ?
142
+		$empty_trap = isset($_REQUEST['tkt-slctr-request-processor-email'])
143
+					  && $_REQUEST['tkt-slctr-request-processor-email'] === '';
144
+		// are we human ?
145
+		if ($empty_trap) {
146
+			do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered');
147
+			return;
148
+		}
149
+		// check the given callback is valid first before executing
150
+		if (! is_callable($triggered_trap_callback)) {
151
+			// invalid callback so lets just sub in our default.
152
+			$triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response');
153
+		}
154
+		call_user_func($triggered_trap_callback);
155
+	}
156 156
 
157 157
 
158
-    /**
159
-     * This is the default callback executed by EED_Bot_Trap::process_bot_trap that handles the response.
160
-     *
161
-     * @throws InvalidArgumentException
162
-     * @throws InvalidDataTypeException
163
-     * @throws InvalidInterfaceException
164
-     */
165
-    public static function triggered_trap_response()
166
-    {
167
-        // UH OH...
168
-        $redirect_url = apply_filters(
169
-            'FHEE__EED_Bot_Trap__process_bot_trap__redirect_url',
170
-            add_query_arg(
171
-                array('ee' => 'ticket_selection_received'),
172
-                EE_Registry::instance()->CFG->core->reg_page_url()
173
-            )
174
-        );
175
-        // if AJAX, return the redirect URL
176
-        if (defined('DOING_AJAX') && DOING_AJAX) {
177
-            echo wp_json_encode(
178
-                array_merge(
179
-                    EE_Error::get_notices(false),
180
-                    array(
181
-                        'redirect_url' => $redirect_url,
182
-                    )
183
-                )
184
-            );
185
-            exit();
186
-        }
187
-        wp_safe_redirect($redirect_url);
188
-        exit();
189
-    }
158
+	/**
159
+	 * This is the default callback executed by EED_Bot_Trap::process_bot_trap that handles the response.
160
+	 *
161
+	 * @throws InvalidArgumentException
162
+	 * @throws InvalidDataTypeException
163
+	 * @throws InvalidInterfaceException
164
+	 */
165
+	public static function triggered_trap_response()
166
+	{
167
+		// UH OH...
168
+		$redirect_url = apply_filters(
169
+			'FHEE__EED_Bot_Trap__process_bot_trap__redirect_url',
170
+			add_query_arg(
171
+				array('ee' => 'ticket_selection_received'),
172
+				EE_Registry::instance()->CFG->core->reg_page_url()
173
+			)
174
+		);
175
+		// if AJAX, return the redirect URL
176
+		if (defined('DOING_AJAX') && DOING_AJAX) {
177
+			echo wp_json_encode(
178
+				array_merge(
179
+					EE_Error::get_notices(false),
180
+					array(
181
+						'redirect_url' => $redirect_url,
182
+					)
183
+				)
184
+			);
185
+			exit();
186
+		}
187
+		wp_safe_redirect($redirect_url);
188
+		exit();
189
+	}
190 190
 
191 191
 
192
-    /**
193
-     * display_bot_trap_success
194
-     * shows a "success" screen to bots so that they (ie: the ppl managing them)
195
-     * think the form was submitted successfully
196
-     *
197
-     * @return void
198
-     */
199
-    public static function display_bot_trap_success()
200
-    {
201
-        add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false');
202
-        $bot_notice = esc_html__(
203
-            'Thank you so much. Your ticket selections have been received for consideration.',
204
-            'event_espresso'
205
-        );
206
-        $bot_notice = isset($_REQUEST['ee-notice']) && $_REQUEST['ee-notice'] !== ''
207
-            ? sanitize_text_field(stripslashes($_REQUEST['ee-notice']))
208
-            : $bot_notice;
209
-        EE_Registry::instance()->REQ->add_output(EEH_HTML::div($bot_notice, '', 'ee-attention'));
210
-    }
192
+	/**
193
+	 * display_bot_trap_success
194
+	 * shows a "success" screen to bots so that they (ie: the ppl managing them)
195
+	 * think the form was submitted successfully
196
+	 *
197
+	 * @return void
198
+	 */
199
+	public static function display_bot_trap_success()
200
+	{
201
+		add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false');
202
+		$bot_notice = esc_html__(
203
+			'Thank you so much. Your ticket selections have been received for consideration.',
204
+			'event_espresso'
205
+		);
206
+		$bot_notice = isset($_REQUEST['ee-notice']) && $_REQUEST['ee-notice'] !== ''
207
+			? sanitize_text_field(stripslashes($_REQUEST['ee-notice']))
208
+			: $bot_notice;
209
+		EE_Registry::instance()->REQ->add_output(EEH_HTML::div($bot_notice, '', 'ee-attention'));
210
+	}
211 211
 
212 212
 
213 213
 
214
-    /***********************************    ADMIN    **********************************/
214
+	/***********************************    ADMIN    **********************************/
215 215
 
216 216
 
217
-    /**
218
-     * bot_trap_settings_form
219
-     *
220
-     * @return void
221
-     * @throws EE_Error
222
-     * @throws InvalidArgumentException
223
-     * @throws InvalidDataTypeException
224
-     * @throws InvalidInterfaceException
225
-     */
226
-    public static function bot_trap_settings_form()
227
-    {
228
-        EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js();
229
-        echo EED_Bot_Trap::_bot_trap_settings_form()->get_html();
230
-    }
217
+	/**
218
+	 * bot_trap_settings_form
219
+	 *
220
+	 * @return void
221
+	 * @throws EE_Error
222
+	 * @throws InvalidArgumentException
223
+	 * @throws InvalidDataTypeException
224
+	 * @throws InvalidInterfaceException
225
+	 */
226
+	public static function bot_trap_settings_form()
227
+	{
228
+		EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js();
229
+		echo EED_Bot_Trap::_bot_trap_settings_form()->get_html();
230
+	}
231 231
 
232 232
 
233
-    /**
234
-     * _bot_trap_settings_form
235
-     *
236
-     * @return EE_Form_Section_Proper
237
-     * @throws EE_Error
238
-     */
239
-    protected static function _bot_trap_settings_form()
240
-    {
241
-        return new EE_Form_Section_Proper(
242
-            array(
243
-                'name'            => 'bot_trap_settings',
244
-                'html_id'         => 'bot_trap_settings',
245
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
246
-                'subsections'     => array(
247
-                    'bot_trap_hdr' => new EE_Form_Section_HTML(
248
-                        EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso'))
249
-                    ),
250
-                    'use_bot_trap' => new EE_Yes_No_Input(
251
-                        array(
252
-                            'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'),
253
-                            'html_help_text'  => esc_html__(
254
-                                'The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.',
255
-                                'event_espresso'
256
-                            ),
257
-                            'default'         => EE_Registry::instance()->CFG->registration->use_bot_trap !== null
258
-                                ? EE_Registry::instance()->CFG->registration->use_bot_trap
259
-                                : true,
260
-                            'required'        => false,
261
-                        )
262
-                    ),
263
-                ),
264
-            )
265
-        );
266
-    }
233
+	/**
234
+	 * _bot_trap_settings_form
235
+	 *
236
+	 * @return EE_Form_Section_Proper
237
+	 * @throws EE_Error
238
+	 */
239
+	protected static function _bot_trap_settings_form()
240
+	{
241
+		return new EE_Form_Section_Proper(
242
+			array(
243
+				'name'            => 'bot_trap_settings',
244
+				'html_id'         => 'bot_trap_settings',
245
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
246
+				'subsections'     => array(
247
+					'bot_trap_hdr' => new EE_Form_Section_HTML(
248
+						EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso'))
249
+					),
250
+					'use_bot_trap' => new EE_Yes_No_Input(
251
+						array(
252
+							'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'),
253
+							'html_help_text'  => esc_html__(
254
+								'The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.',
255
+								'event_espresso'
256
+							),
257
+							'default'         => EE_Registry::instance()->CFG->registration->use_bot_trap !== null
258
+								? EE_Registry::instance()->CFG->registration->use_bot_trap
259
+								: true,
260
+							'required'        => false,
261
+						)
262
+					),
263
+				),
264
+			)
265
+		);
266
+	}
267 267
 
268 268
 
269
-    /**
270
-     * update_bot_trap_settings_form
271
-     *
272
-     * @param EE_Registration_Config $EE_Registration_Config
273
-     * @return EE_Registration_Config
274
-     * @throws EE_Error
275
-     * @throws InvalidArgumentException
276
-     * @throws ReflectionException
277
-     * @throws InvalidDataTypeException
278
-     * @throws InvalidInterfaceException
279
-     */
280
-    public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config)
281
-    {
282
-        try {
283
-            $bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form();
284
-            // if not displaying a form, then check for form submission
285
-            if ($bot_trap_settings_form->was_submitted()) {
286
-                // capture form data
287
-                $bot_trap_settings_form->receive_form_submission();
288
-                // validate form data
289
-                if ($bot_trap_settings_form->is_valid()) {
290
-                    // grab validated data from form
291
-                    $valid_data = $bot_trap_settings_form->valid_data();
292
-                    if (isset($valid_data['use_bot_trap'])) {
293
-                        $EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap'];
294
-                    } else {
295
-                        EE_Error::add_error(
296
-                            esc_html__(
297
-                                'Invalid or missing Bot Trap settings. Please refresh the form and try again.',
298
-                                'event_espresso'
299
-                            ),
300
-                            __FILE__,
301
-                            __FUNCTION__,
302
-                            __LINE__
303
-                        );
304
-                    }
305
-                } elseif ($bot_trap_settings_form->submission_error_message() !== '') {
306
-                    EE_Error::add_error(
307
-                        $bot_trap_settings_form->submission_error_message(),
308
-                        __FILE__,
309
-                        __FUNCTION__,
310
-                        __LINE__
311
-                    );
312
-                }
313
-            }
314
-        } catch (EE_Error $e) {
315
-            $e->get_error();
316
-        }
317
-        return $EE_Registration_Config;
318
-    }
269
+	/**
270
+	 * update_bot_trap_settings_form
271
+	 *
272
+	 * @param EE_Registration_Config $EE_Registration_Config
273
+	 * @return EE_Registration_Config
274
+	 * @throws EE_Error
275
+	 * @throws InvalidArgumentException
276
+	 * @throws ReflectionException
277
+	 * @throws InvalidDataTypeException
278
+	 * @throws InvalidInterfaceException
279
+	 */
280
+	public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config)
281
+	{
282
+		try {
283
+			$bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form();
284
+			// if not displaying a form, then check for form submission
285
+			if ($bot_trap_settings_form->was_submitted()) {
286
+				// capture form data
287
+				$bot_trap_settings_form->receive_form_submission();
288
+				// validate form data
289
+				if ($bot_trap_settings_form->is_valid()) {
290
+					// grab validated data from form
291
+					$valid_data = $bot_trap_settings_form->valid_data();
292
+					if (isset($valid_data['use_bot_trap'])) {
293
+						$EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap'];
294
+					} else {
295
+						EE_Error::add_error(
296
+							esc_html__(
297
+								'Invalid or missing Bot Trap settings. Please refresh the form and try again.',
298
+								'event_espresso'
299
+							),
300
+							__FILE__,
301
+							__FUNCTION__,
302
+							__LINE__
303
+						);
304
+					}
305
+				} elseif ($bot_trap_settings_form->submission_error_message() !== '') {
306
+					EE_Error::add_error(
307
+						$bot_trap_settings_form->submission_error_message(),
308
+						__FILE__,
309
+						__FUNCTION__,
310
+						__LINE__
311
+					);
312
+				}
313
+			}
314
+		} catch (EE_Error $e) {
315
+			$e->get_error();
316
+		}
317
+		return $EE_Registration_Config;
318
+	}
319 319
 }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
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.76.rc.015');
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.76.rc.015');
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
 }
Please login to merge, or discard this patch.
modules/batch/EED_Batch.module.php 1 patch
Indentation   +310 added lines, -310 removed lines patch added patch discarded remove patch
@@ -23,336 +23,336 @@
 block discarded – undo
23 23
 class EED_Batch extends EED_Module
24 24
 {
25 25
 
26
-    /**
27
-     * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that
28
-     * processes data only
29
-     */
30
-    const batch_job = 'job';
31
-    /**
32
-     * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that
33
-     * produces a file for download
34
-     */
35
-    const batch_file_job = 'file';
36
-    /**
37
-     * Possibly value for $_REQUEST[ 'batch' ]. Indicates this request is NOT
38
-     * for a batch job. It's the same as not providing the $_REQUEST[ 'batch' ]
39
-     * at all
40
-     */
41
-    const batch_not_job = 'none';
26
+	/**
27
+	 * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that
28
+	 * processes data only
29
+	 */
30
+	const batch_job = 'job';
31
+	/**
32
+	 * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that
33
+	 * produces a file for download
34
+	 */
35
+	const batch_file_job = 'file';
36
+	/**
37
+	 * Possibly value for $_REQUEST[ 'batch' ]. Indicates this request is NOT
38
+	 * for a batch job. It's the same as not providing the $_REQUEST[ 'batch' ]
39
+	 * at all
40
+	 */
41
+	const batch_not_job = 'none';
42 42
 
43
-    /**
44
-     *
45
-     * @var string 'file', or 'job', or false to indicate its not a batch request at all
46
-     */
47
-    protected $_batch_request_type = null;
43
+	/**
44
+	 *
45
+	 * @var string 'file', or 'job', or false to indicate its not a batch request at all
46
+	 */
47
+	protected $_batch_request_type = null;
48 48
 
49
-    /**
50
-     * Because we want to use the response in both the localized JS and in the body
51
-     * we need to make this response available between method calls
52
-     *
53
-     * @var \EventEspressoBatchRequest\Helpers\JobStepResponse
54
-     */
55
-    protected $_job_step_response = null;
49
+	/**
50
+	 * Because we want to use the response in both the localized JS and in the body
51
+	 * we need to make this response available between method calls
52
+	 *
53
+	 * @var \EventEspressoBatchRequest\Helpers\JobStepResponse
54
+	 */
55
+	protected $_job_step_response = null;
56 56
 
57
-    /**
58
-     * Gets the batch instance
59
-     *
60
-     * @return EED_Batch
61
-     */
62
-    public static function instance()
63
-    {
64
-        return self::get_instance();
65
-    }
57
+	/**
58
+	 * Gets the batch instance
59
+	 *
60
+	 * @return EED_Batch
61
+	 */
62
+	public static function instance()
63
+	{
64
+		return self::get_instance();
65
+	}
66 66
 
67
-    /**
68
-     * Sets hooks to enable batch jobs on the frontend. Disabled by default
69
-     * because it's an attack vector and there are currently no implementations
70
-     */
71
-    public static function set_hooks()
72
-    {
73
-        // because this is a possibel attack vector, let's have this disabled until
74
-        // we at least have a real use for it on the frontend
75
-        if (apply_filters('FHEE__EED_Batch__set_hooks__enable_frontend_batch', false)) {
76
-            add_action('wp_enqueue_scripts', array(self::instance(), 'enqueue_scripts'));
77
-            add_filter('template_include', array(self::instance(), 'override_template'), 99);
78
-        }
79
-    }
67
+	/**
68
+	 * Sets hooks to enable batch jobs on the frontend. Disabled by default
69
+	 * because it's an attack vector and there are currently no implementations
70
+	 */
71
+	public static function set_hooks()
72
+	{
73
+		// because this is a possibel attack vector, let's have this disabled until
74
+		// we at least have a real use for it on the frontend
75
+		if (apply_filters('FHEE__EED_Batch__set_hooks__enable_frontend_batch', false)) {
76
+			add_action('wp_enqueue_scripts', array(self::instance(), 'enqueue_scripts'));
77
+			add_filter('template_include', array(self::instance(), 'override_template'), 99);
78
+		}
79
+	}
80 80
 
81
-    /**
82
-     * Initializes some hooks for the admin in order to run batch jobs
83
-     */
84
-    public static function set_hooks_admin()
85
-    {
86
-        add_action('admin_menu', array(self::instance(), 'register_admin_pages'));
87
-        add_action('admin_enqueue_scripts', array(self::instance(), 'enqueue_scripts'));
81
+	/**
82
+	 * Initializes some hooks for the admin in order to run batch jobs
83
+	 */
84
+	public static function set_hooks_admin()
85
+	{
86
+		add_action('admin_menu', array(self::instance(), 'register_admin_pages'));
87
+		add_action('admin_enqueue_scripts', array(self::instance(), 'enqueue_scripts'));
88 88
 
89
-        // ajax
90
-        add_action('wp_ajax_espresso_batch_continue', array(self::instance(), 'batch_continue'));
91
-        add_action('wp_ajax_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup'));
92
-        add_action('wp_ajax_nopriv_espresso_batch_continue', array(self::instance(), 'batch_continue'));
93
-        add_action('wp_ajax_nopriv_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup'));
94
-    }
89
+		// ajax
90
+		add_action('wp_ajax_espresso_batch_continue', array(self::instance(), 'batch_continue'));
91
+		add_action('wp_ajax_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup'));
92
+		add_action('wp_ajax_nopriv_espresso_batch_continue', array(self::instance(), 'batch_continue'));
93
+		add_action('wp_ajax_nopriv_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup'));
94
+	}
95 95
 
96
-    /**
97
-     * Enqueues batch scripts on the frontend or admin, and creates a job
98
-     */
99
-    public function enqueue_scripts()
100
-    {
101
-        if (isset($_REQUEST['espresso_batch'])
102
-            ||
103
-            (
104
-                isset($_REQUEST['page'])
105
-                && $_REQUEST['page'] == 'espresso_batch'
106
-            )
107
-        ) {
108
-            switch ($this->batch_request_type()) {
109
-                case self::batch_job:
110
-                    $this->enqueue_scripts_styles_batch_create();
111
-                    break;
112
-                case self::batch_file_job:
113
-                    $this->enqueue_scripts_styles_batch_file_create();
114
-                    break;
115
-            }
116
-        }
117
-    }
96
+	/**
97
+	 * Enqueues batch scripts on the frontend or admin, and creates a job
98
+	 */
99
+	public function enqueue_scripts()
100
+	{
101
+		if (isset($_REQUEST['espresso_batch'])
102
+			||
103
+			(
104
+				isset($_REQUEST['page'])
105
+				&& $_REQUEST['page'] == 'espresso_batch'
106
+			)
107
+		) {
108
+			switch ($this->batch_request_type()) {
109
+				case self::batch_job:
110
+					$this->enqueue_scripts_styles_batch_create();
111
+					break;
112
+				case self::batch_file_job:
113
+					$this->enqueue_scripts_styles_batch_file_create();
114
+					break;
115
+			}
116
+		}
117
+	}
118 118
 
119
-    /**
120
-     * Create a batch job, enqueues a script to run it, and localizes some data for it
121
-     */
122
-    public function enqueue_scripts_styles_batch_create()
123
-    {
124
-        $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job();
125
-        wp_enqueue_script(
126
-            'batch_runner_init',
127
-            BATCH_URL . 'assets/batch_runner_init.js',
128
-            array('batch_runner'),
129
-            EVENT_ESPRESSO_VERSION,
130
-            true
131
-        );
132
-        wp_localize_script('batch_runner_init', 'ee_job_response', $job_response->to_array());
133
-        wp_localize_script(
134
-            'batch_runner_init',
135
-            'ee_job_i18n',
136
-            array(
137
-                'return_url' => $_REQUEST['return_url'],
138
-            )
139
-        );
140
-    }
119
+	/**
120
+	 * Create a batch job, enqueues a script to run it, and localizes some data for it
121
+	 */
122
+	public function enqueue_scripts_styles_batch_create()
123
+	{
124
+		$job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job();
125
+		wp_enqueue_script(
126
+			'batch_runner_init',
127
+			BATCH_URL . 'assets/batch_runner_init.js',
128
+			array('batch_runner'),
129
+			EVENT_ESPRESSO_VERSION,
130
+			true
131
+		);
132
+		wp_localize_script('batch_runner_init', 'ee_job_response', $job_response->to_array());
133
+		wp_localize_script(
134
+			'batch_runner_init',
135
+			'ee_job_i18n',
136
+			array(
137
+				'return_url' => $_REQUEST['return_url'],
138
+			)
139
+		);
140
+	}
141 141
 
142
-    /**
143
-     * Creates a batch job which will download a file, enqueues a script to run the job, and localizes some data for it
144
-     */
145
-    public function enqueue_scripts_styles_batch_file_create()
146
-    {
147
-        // creates a job based on the request variable
148
-        $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job();
149
-        wp_enqueue_script(
150
-            'batch_file_runner_init',
151
-            BATCH_URL . 'assets/batch_file_runner_init.js',
152
-            array('batch_runner'),
153
-            EVENT_ESPRESSO_VERSION,
154
-            true
155
-        );
156
-        wp_localize_script('batch_file_runner_init', 'ee_job_response', $job_response->to_array());
157
-        wp_localize_script(
158
-            'batch_file_runner_init',
159
-            'ee_job_i18n',
160
-            array(
161
-                'download_and_redirecting' => sprintf(
162
-                    __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'),
163
-                    '<a href="' . $_REQUEST['return_url'] . '">',
164
-                    '</a>'
165
-                ),
166
-                'return_url'               => $_REQUEST['return_url'],
167
-            )
168
-        );
169
-    }
142
+	/**
143
+	 * Creates a batch job which will download a file, enqueues a script to run the job, and localizes some data for it
144
+	 */
145
+	public function enqueue_scripts_styles_batch_file_create()
146
+	{
147
+		// creates a job based on the request variable
148
+		$job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job();
149
+		wp_enqueue_script(
150
+			'batch_file_runner_init',
151
+			BATCH_URL . 'assets/batch_file_runner_init.js',
152
+			array('batch_runner'),
153
+			EVENT_ESPRESSO_VERSION,
154
+			true
155
+		);
156
+		wp_localize_script('batch_file_runner_init', 'ee_job_response', $job_response->to_array());
157
+		wp_localize_script(
158
+			'batch_file_runner_init',
159
+			'ee_job_i18n',
160
+			array(
161
+				'download_and_redirecting' => sprintf(
162
+					__('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'),
163
+					'<a href="' . $_REQUEST['return_url'] . '">',
164
+					'</a>'
165
+				),
166
+				'return_url'               => $_REQUEST['return_url'],
167
+			)
168
+		);
169
+	}
170 170
 
171
-    /**
172
-     * Enqueues scripts and styles common to any batch job, and creates
173
-     * a job from the request data, and stores the response in the
174
-     * $this->_job_step_response property
175
-     *
176
-     * @return \EventEspressoBatchRequest\Helpers\JobStepResponse
177
-     */
178
-    protected function _enqueue_batch_job_scripts_and_styles_and_start_job()
179
-    {
180
-        wp_register_script(
181
-            'progress_bar',
182
-            EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js',
183
-            array('jquery')
184
-        );
185
-        wp_enqueue_style(
186
-            'progress_bar',
187
-            EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css',
188
-            array(),
189
-            EVENT_ESPRESSO_VERSION
190
-        );
191
-        wp_enqueue_script(
192
-            'batch_runner',
193
-            EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js',
194
-            array('progress_bar')
195
-        );
196
-        // just copy the bits of EE admin's eei18n that we need in the JS
197
-        wp_localize_script(
198
-            'batch_runner',
199
-            'eei18n',
200
-            array(
201
-                'ajax_url'      => WP_AJAX_URL,
202
-                'is_admin'      => (bool) is_admin(),
203
-                'error_message' => esc_html__('An error occurred and the job has been stopped. Please refresh the page to try again.', 'event_espresso'),
204
-            )
205
-        );
206
-        $job_handler_classname = stripslashes($_GET['job_handler']);
207
-        $request_data = array_diff_key(
208
-            $_REQUEST,
209
-            array_flip(array('action', 'page', 'ee', 'batch'))
210
-        );
211
-        $batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor();
212
-        // eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport'
213
-        $job_response = $batch_runner->create_job($job_handler_classname, $request_data);
214
-        // remember the response for later. We need it to display the page body
215
-        $this->_job_step_response = $job_response;
216
-        return $job_response;
217
-    }
171
+	/**
172
+	 * Enqueues scripts and styles common to any batch job, and creates
173
+	 * a job from the request data, and stores the response in the
174
+	 * $this->_job_step_response property
175
+	 *
176
+	 * @return \EventEspressoBatchRequest\Helpers\JobStepResponse
177
+	 */
178
+	protected function _enqueue_batch_job_scripts_and_styles_and_start_job()
179
+	{
180
+		wp_register_script(
181
+			'progress_bar',
182
+			EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js',
183
+			array('jquery')
184
+		);
185
+		wp_enqueue_style(
186
+			'progress_bar',
187
+			EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css',
188
+			array(),
189
+			EVENT_ESPRESSO_VERSION
190
+		);
191
+		wp_enqueue_script(
192
+			'batch_runner',
193
+			EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js',
194
+			array('progress_bar')
195
+		);
196
+		// just copy the bits of EE admin's eei18n that we need in the JS
197
+		wp_localize_script(
198
+			'batch_runner',
199
+			'eei18n',
200
+			array(
201
+				'ajax_url'      => WP_AJAX_URL,
202
+				'is_admin'      => (bool) is_admin(),
203
+				'error_message' => esc_html__('An error occurred and the job has been stopped. Please refresh the page to try again.', 'event_espresso'),
204
+			)
205
+		);
206
+		$job_handler_classname = stripslashes($_GET['job_handler']);
207
+		$request_data = array_diff_key(
208
+			$_REQUEST,
209
+			array_flip(array('action', 'page', 'ee', 'batch'))
210
+		);
211
+		$batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor();
212
+		// eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport'
213
+		$job_response = $batch_runner->create_job($job_handler_classname, $request_data);
214
+		// remember the response for later. We need it to display the page body
215
+		$this->_job_step_response = $job_response;
216
+		return $job_response;
217
+	}
218 218
 
219
-    /**
220
-     * If we are doing a frontend batch job, this makes it so WP shows our template's HTML
221
-     *
222
-     * @param string $template
223
-     * @return string
224
-     */
225
-    public function override_template($template)
226
-    {
227
-        if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) {
228
-            return EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_frontend_wrapper.template.html';
229
-        }
230
-        return $template;
231
-    }
219
+	/**
220
+	 * If we are doing a frontend batch job, this makes it so WP shows our template's HTML
221
+	 *
222
+	 * @param string $template
223
+	 * @return string
224
+	 */
225
+	public function override_template($template)
226
+	{
227
+		if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) {
228
+			return EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_frontend_wrapper.template.html';
229
+		}
230
+		return $template;
231
+	}
232 232
 
233
-    /**
234
-     * Adds an admin page which doesn't appear in the admin menu
235
-     */
236
-    public function register_admin_pages()
237
-    {
238
-        add_submenu_page(
239
-            '', // parent slug. we don't want this to actually appear in the menu
240
-            __('Batch Job', 'event_espresso'), // page title
241
-            'n/a', // menu title
242
-            'read', // we want this page to actually be accessible to anyone,
243
-            'espresso_batch', // menu slug
244
-            array(self::instance(), 'show_admin_page')
245
-        );
246
-    }
233
+	/**
234
+	 * Adds an admin page which doesn't appear in the admin menu
235
+	 */
236
+	public function register_admin_pages()
237
+	{
238
+		add_submenu_page(
239
+			'', // parent slug. we don't want this to actually appear in the menu
240
+			__('Batch Job', 'event_espresso'), // page title
241
+			'n/a', // menu title
242
+			'read', // we want this page to actually be accessible to anyone,
243
+			'espresso_batch', // menu slug
244
+			array(self::instance(), 'show_admin_page')
245
+		);
246
+	}
247 247
 
248
-    /**
249
-     * Renders the admin page, after most of the work was already done during enqueuing scripts
250
-     * of creating the job and localizing some data
251
-     */
252
-    public function show_admin_page()
253
-    {
254
-        echo EEH_Template::locate_template(
255
-            EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_wrapper.template.html',
256
-            array('batch_request_type' => $this->batch_request_type())
257
-        );
258
-    }
248
+	/**
249
+	 * Renders the admin page, after most of the work was already done during enqueuing scripts
250
+	 * of creating the job and localizing some data
251
+	 */
252
+	public function show_admin_page()
253
+	{
254
+		echo EEH_Template::locate_template(
255
+			EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_wrapper.template.html',
256
+			array('batch_request_type' => $this->batch_request_type())
257
+		);
258
+	}
259 259
 
260
-    /**
261
-     * Receives ajax calls for continuing a job
262
-     */
263
-    public function batch_continue()
264
-    {
265
-        $job_id = sanitize_text_field($_REQUEST['job_id']);
266
-        $batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor();
267
-        $response_obj = $batch_runner->continue_job($job_id);
268
-        $this->_return_json($response_obj->to_array());
269
-    }
260
+	/**
261
+	 * Receives ajax calls for continuing a job
262
+	 */
263
+	public function batch_continue()
264
+	{
265
+		$job_id = sanitize_text_field($_REQUEST['job_id']);
266
+		$batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor();
267
+		$response_obj = $batch_runner->continue_job($job_id);
268
+		$this->_return_json($response_obj->to_array());
269
+	}
270 270
 
271
-    /**
272
-     * Receives the ajax call to cleanup a job
273
-     *
274
-     * @return type
275
-     */
276
-    public function batch_cleanup()
277
-    {
278
-        $job_id = sanitize_text_field($_REQUEST['job_id']);
279
-        $batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor();
280
-        $response_obj = $batch_runner->cleanup_job($job_id);
281
-        $this->_return_json($response_obj->to_array());
282
-    }
271
+	/**
272
+	 * Receives the ajax call to cleanup a job
273
+	 *
274
+	 * @return type
275
+	 */
276
+	public function batch_cleanup()
277
+	{
278
+		$job_id = sanitize_text_field($_REQUEST['job_id']);
279
+		$batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor();
280
+		$response_obj = $batch_runner->cleanup_job($job_id);
281
+		$this->_return_json($response_obj->to_array());
282
+	}
283 283
 
284 284
 
285
-    /**
286
-     * Returns a json response
287
-     *
288
-     * @param array $data The data we want to send echo via in the JSON response's "data" element
289
-     *
290
-     * The returned json object is created from an array in the following format:
291
-     * array(
292
-     *    'notices' => '', // - contains any EE_Error formatted notices
293
-     *    'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
294
-     *    We're also going to include the template args with every package (so js can pick out any specific template
295
-     *    args that might be included in here)
296
-     *    'isEEajax' => true,//indicates this is a response from EE
297
-     * )
298
-     */
299
-    protected function _return_json($data)
300
-    {
301
-        $json = array(
302
-            'notices'  => EE_Error::get_notices(),
303
-            'data'     => $data,
304
-            'isEEajax' => true
305
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
306
-        );
285
+	/**
286
+	 * Returns a json response
287
+	 *
288
+	 * @param array $data The data we want to send echo via in the JSON response's "data" element
289
+	 *
290
+	 * The returned json object is created from an array in the following format:
291
+	 * array(
292
+	 *    'notices' => '', // - contains any EE_Error formatted notices
293
+	 *    'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
294
+	 *    We're also going to include the template args with every package (so js can pick out any specific template
295
+	 *    args that might be included in here)
296
+	 *    'isEEajax' => true,//indicates this is a response from EE
297
+	 * )
298
+	 */
299
+	protected function _return_json($data)
300
+	{
301
+		$json = array(
302
+			'notices'  => EE_Error::get_notices(),
303
+			'data'     => $data,
304
+			'isEEajax' => true
305
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
306
+		);
307 307
 
308 308
 
309
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
310
-        if (null === error_get_last() || ! headers_sent()) {
311
-            header('Content-Type: application/json; charset=UTF-8');
312
-        }
313
-        echo wp_json_encode($json);
314
-        exit();
315
-    }
309
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
310
+		if (null === error_get_last() || ! headers_sent()) {
311
+			header('Content-Type: application/json; charset=UTF-8');
312
+		}
313
+		echo wp_json_encode($json);
314
+		exit();
315
+	}
316 316
 
317
-    /**
318
-     * Gets the job step response which was done during the enqueuing of scripts
319
-     *
320
-     * @return \EventEspressoBatchRequest\Helpers\JobStepResponse
321
-     */
322
-    public function job_step_response()
323
-    {
324
-        return $this->_job_step_response;
325
-    }
317
+	/**
318
+	 * Gets the job step response which was done during the enqueuing of scripts
319
+	 *
320
+	 * @return \EventEspressoBatchRequest\Helpers\JobStepResponse
321
+	 */
322
+	public function job_step_response()
323
+	{
324
+		return $this->_job_step_response;
325
+	}
326 326
 
327
-    /**
328
-     * Gets the batch request type indicated in the $_REQUEST
329
-     *
330
-     * @return string: EED_Batch::batch_job, EED_Batch::batch_file_job, EED_Batch::batch_not_job
331
-     */
332
-    public function batch_request_type()
333
-    {
334
-        if ($this->_batch_request_type === null) {
335
-            if (isset($_GET['batch'])) {
336
-                if ($_GET['batch'] == self::batch_job) {
337
-                    $this->_batch_request_type = self::batch_job;
338
-                } elseif ($_GET['batch'] == self::batch_file_job) {
339
-                    $this->_batch_request_type = self::batch_file_job;
340
-                }
341
-            }
342
-            // if we didn't find that it was a batch request, indicate it wasn't
343
-            if ($this->_batch_request_type === null) {
344
-                $this->_batch_request_type = self::batch_not_job;
345
-            }
346
-        }
347
-        return $this->_batch_request_type;
348
-    }
327
+	/**
328
+	 * Gets the batch request type indicated in the $_REQUEST
329
+	 *
330
+	 * @return string: EED_Batch::batch_job, EED_Batch::batch_file_job, EED_Batch::batch_not_job
331
+	 */
332
+	public function batch_request_type()
333
+	{
334
+		if ($this->_batch_request_type === null) {
335
+			if (isset($_GET['batch'])) {
336
+				if ($_GET['batch'] == self::batch_job) {
337
+					$this->_batch_request_type = self::batch_job;
338
+				} elseif ($_GET['batch'] == self::batch_file_job) {
339
+					$this->_batch_request_type = self::batch_file_job;
340
+				}
341
+			}
342
+			// if we didn't find that it was a batch request, indicate it wasn't
343
+			if ($this->_batch_request_type === null) {
344
+				$this->_batch_request_type = self::batch_not_job;
345
+			}
346
+		}
347
+		return $this->_batch_request_type;
348
+	}
349 349
 
350
-    /**
351
-     * Unnecessary
352
-     *
353
-     * @param type $WP
354
-     */
355
-    public function run($WP)
356
-    {
357
-    }
350
+	/**
351
+	 * Unnecessary
352
+	 *
353
+	 * @param type $WP
354
+	 */
355
+	public function run($WP)
356
+	{
357
+	}
358 358
 }
Please login to merge, or discard this patch.