1
|
|
|
<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2
|
|
|
/** |
3
|
|
|
* Event Espresso |
4
|
|
|
* |
5
|
|
|
* Event Registration and Management Plugin for WordPress |
6
|
|
|
* |
7
|
|
|
* @ package Event Espresso |
8
|
|
|
* @ author Seth Shoultes |
9
|
|
|
* @ copyright (c) 2008-2011 Event Espresso All Rights Reserved. |
10
|
|
|
* @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing * |
11
|
|
|
* @ link http://www.eventespresso.com |
12
|
|
|
* @ version 4.0 |
13
|
|
|
* |
14
|
|
|
* ------------------------------------------------------------------------ |
15
|
|
|
* |
16
|
|
|
* EED_Recaptcha |
17
|
|
|
* |
18
|
|
|
* @package Event Espresso |
19
|
|
|
* @subpackage /modules/recaptcha/ |
20
|
|
|
* @author Brent Christensen |
21
|
|
|
* |
22
|
|
|
* ------------------------------------------------------------------------ |
23
|
|
|
*/ |
24
|
|
|
class EED_Recaptcha extends EED_Module { |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @type bool $_not_a_robot |
30
|
|
|
*/ |
31
|
|
|
private static $_not_a_robot; |
32
|
|
|
|
33
|
|
|
|
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @type string $_recaptcha_response |
37
|
|
|
*/ |
38
|
|
|
private static $_recaptcha_response; |
39
|
|
|
|
40
|
|
|
|
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @return EED_Recaptcha |
44
|
|
|
*/ |
45
|
|
|
public static function instance() { |
46
|
|
|
return parent::get_instance( __CLASS__ ); |
|
|
|
|
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* set_hooks - for hooking into EE Core, other modules, etc |
53
|
|
|
* |
54
|
|
|
* @access public |
55
|
|
|
* @return void |
56
|
|
|
*/ |
57
|
|
|
public static function set_hooks() { |
58
|
|
|
// use_captcha ? |
59
|
|
|
if ( |
60
|
|
|
EE_Registry::instance()->CFG->registration->use_captcha |
61
|
|
|
&& ! ( |
62
|
|
|
EE_Registry::instance()->REQ->get( 'step', '' ) === 'payment_options' |
63
|
|
|
&& (boolean) EE_Registry::instance()->REQ->get( 'revisit', false ) === true |
64
|
|
|
) |
65
|
|
|
) { |
66
|
|
|
EED_Recaptcha::set_definitions(); |
67
|
|
|
EED_Recaptcha::enqueue_styles_and_scripts(); |
68
|
|
|
add_action( 'wp', array( 'EED_Recaptcha', 'set_late_hooks' ), 1, 0 ); |
69
|
|
|
add_action( |
70
|
|
|
'AHEE__before_spco_whats_next_buttons', |
71
|
|
|
array( 'EED_Recaptcha', 'display_recaptcha' ), 10, 0 |
72
|
|
|
); |
73
|
|
|
add_filter( |
74
|
|
|
'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
75
|
|
|
array( 'EED_Recaptcha', 'not_a_robot' ), 10 |
76
|
|
|
); |
77
|
|
|
add_filter( |
78
|
|
|
'FHEE__EE_SPCO_Reg_Step__set_completed___completed', |
79
|
|
|
array( 'EED_Recaptcha', 'not_a_robot' ), 10 |
80
|
|
|
); |
81
|
|
|
add_filter( |
82
|
|
|
'FHEE__EE_SPCO_JSON_Response___toString__JSON_response', |
83
|
|
|
array( 'EED_Recaptcha', 'recaptcha_response' ), 10, 1 |
84
|
|
|
); |
85
|
|
|
add_filter( |
86
|
|
|
'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
87
|
|
|
array( 'EED_Recaptcha', 'bypass_recaptcha_for_spco_load_payment_method' ), 10, 1 |
88
|
|
|
); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
|
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
96
|
|
|
* |
97
|
|
|
* @access public |
98
|
|
|
* @return void |
99
|
|
|
*/ |
100
|
|
|
public static function set_hooks_admin() { |
101
|
|
|
EED_Recaptcha::set_definitions(); |
102
|
|
|
// use_captcha ? |
103
|
|
|
if ( |
104
|
|
|
EE_Registry::instance()->CFG->registration->use_captcha |
105
|
|
|
&& ! ( |
106
|
|
|
EE_Registry::instance()->REQ->get( 'step', '' ) === 'payment_options' |
107
|
|
|
&& (boolean) EE_Registry::instance()->REQ->get( 'revisit', false ) === true |
108
|
|
|
) |
109
|
|
|
) { |
110
|
|
|
EED_Recaptcha::enqueue_styles_and_scripts(); |
111
|
|
|
add_filter( 'FHEE__EED_Single_Page_Checkout__init___continue_reg', array( 'EED_Recaptcha', 'not_a_robot' ), 10 ); |
112
|
|
|
add_filter( 'FHEE__EE_SPCO_Reg_Step__set_completed___completed', array( 'EED_Recaptcha', 'not_a_robot' ), 10 ); |
113
|
|
|
add_filter( 'FHEE__EE_SPCO_JSON_Response___toString__JSON_response', array( 'EED_Recaptcha', 'recaptcha_response' ), 10, 1 ); |
114
|
|
|
} |
115
|
|
|
// admin settings |
116
|
|
|
add_action( 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', array( 'EED_Recaptcha', 'admin_settings' ), 10, 1 ); |
117
|
|
|
add_filter( 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', array( 'EED_Recaptcha', 'update_admin_settings' ), 10, 1 ); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
|
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* set_definitions |
124
|
|
|
* |
125
|
|
|
* @access public |
126
|
|
|
* @return void |
127
|
|
|
*/ |
128
|
|
|
public static function set_definitions() { |
129
|
|
|
if ( is_user_logged_in() ) { |
130
|
|
|
EED_Recaptcha::$_not_a_robot = true; |
131
|
|
|
} |
132
|
|
|
define( 'RECAPTCHA_BASE_PATH', rtrim( str_replace( array( '\\', '/' ), DS, plugin_dir_path( __FILE__ )), DS ) . DS ); |
133
|
|
|
define( 'RECAPTCHA_BASE_URL', plugin_dir_url( __FILE__ )); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
|
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* set_late_hooks |
140
|
|
|
* |
141
|
|
|
* @access public |
142
|
|
|
* @return void |
143
|
|
|
*/ |
144
|
|
|
public static function set_late_hooks() { |
145
|
|
|
add_filter( |
146
|
|
|
'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', |
147
|
|
|
array( 'EED_Recaptcha', 'not_a_robot' ) |
148
|
|
|
); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
|
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* enqueue_styles_and_scripts |
155
|
|
|
* |
156
|
|
|
* @access public |
157
|
|
|
* @return void |
158
|
|
|
*/ |
159
|
|
|
public static function enqueue_styles_and_scripts() { |
160
|
|
|
wp_register_script( 'espresso_recaptcha', RECAPTCHA_BASE_URL . 'scripts' . DS . 'espresso_recaptcha.js', array( 'single_page_checkout' ), EVENT_ESPRESSO_VERSION, TRUE ); |
161
|
|
|
wp_register_script( 'google_recaptcha', 'https://www.google.com/recaptcha/api.js?hl=' . EE_Registry::instance()->CFG->registration->recaptcha_language, array( 'espresso_recaptcha' ), EVENT_ESPRESSO_VERSION, TRUE ); |
162
|
|
|
EE_Registry::$i18n_js_strings['no_SPCO_error'] = __( 'It appears the Single Page Checkout javascript was not loaded properly! Please refresh the page and try again or contact support.', 'event_espresso' ); |
163
|
|
|
EE_Registry::$i18n_js_strings['no_recaptcha_error'] = __( 'There appears to be a problem with the reCAPTCHA configuration! Please check the admin settings or contact support.', 'event_espresso' ); |
164
|
|
|
EE_Registry::$i18n_js_strings['recaptcha_fail'] = __( 'Please complete the anti-spam test before proceeding.', 'event_espresso' ); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
|
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* run |
171
|
|
|
* |
172
|
|
|
* @access public |
173
|
|
|
* @param \WP $WP |
174
|
|
|
*/ |
175
|
|
|
public function run( $WP ) { |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
|
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* not_a_robot |
182
|
|
|
* @return boolean |
183
|
|
|
*/ |
184
|
|
|
public static function not_a_robot() { |
185
|
|
|
$not_a_robot = is_bool( EED_Recaptcha::$_not_a_robot ) ? EED_Recaptcha::$_not_a_robot : |
186
|
|
|
EED_Recaptcha::recaptcha_passed(); |
187
|
|
|
return $not_a_robot; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
|
191
|
|
|
|
192
|
|
|
|
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* display_recaptcha |
196
|
|
|
* |
197
|
|
|
* @access public |
198
|
|
|
* @return void |
199
|
|
|
*/ |
200
|
|
|
public static function display_recaptcha() { |
201
|
|
|
// logged in means you have already passed a turing test of sorts |
202
|
|
|
if ( is_user_logged_in() ) { |
203
|
|
|
return; |
204
|
|
|
} |
205
|
|
|
// don't display if not using recaptcha or user is logged in |
206
|
|
|
if ( EE_Registry::instance()->CFG->registration->use_captcha ) { |
207
|
|
|
// only display if they have NOT passed the test yet |
208
|
|
|
if ( ! EED_Recaptcha::$_not_a_robot ) { |
209
|
|
|
EEH_Template::display_template( |
210
|
|
|
RECAPTCHA_BASE_PATH . DS . 'templates' . DS . 'recaptcha.template.php', |
211
|
|
|
array( |
212
|
|
|
'recaptcha_publickey' => EE_Registry::instance()->CFG->registration->recaptcha_publickey, |
213
|
|
|
'recaptcha_theme' => EE_Registry::instance()->CFG->registration->recaptcha_theme, |
214
|
|
|
'recaptcha_type' => EE_Registry::instance()->CFG->registration->recaptcha_type |
215
|
|
|
) |
216
|
|
|
); |
217
|
|
|
wp_enqueue_script( 'google_recaptcha' ); |
218
|
|
|
} |
219
|
|
|
} |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
|
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* bypass_recaptcha_for_spco_load_payment_method |
226
|
|
|
* |
227
|
|
|
* @access public |
228
|
|
|
* @return string |
229
|
|
|
*/ |
230
|
|
|
public static function bypass_recaptcha_for_spco_load_payment_method() { |
231
|
|
|
return array( |
232
|
|
|
'EESID' => EE_Registry::instance()->SSN->id(), |
233
|
|
|
'step' => 'payment_options', |
234
|
|
|
'action' => 'switch_spco_billing_form' |
235
|
|
|
); |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
|
239
|
|
|
|
240
|
|
|
/** |
241
|
|
|
* recaptcha_passed |
242
|
|
|
* |
243
|
|
|
* @access public |
244
|
|
|
* @return boolean |
245
|
|
|
*/ |
246
|
|
|
public static function recaptcha_passed() { |
247
|
|
|
// logged in means you have already passed a turing test of sorts |
248
|
|
|
if ( is_user_logged_in() || EED_Recaptcha::_bypass_recaptcha() ) { |
249
|
|
|
return TRUE; |
250
|
|
|
} |
251
|
|
|
// was test already passed? |
252
|
|
|
$recaptcha_passed = EE_Registry::instance()->SSN->get_session_data( 'recaptcha_passed' ); |
253
|
|
|
$recaptcha_passed = filter_var( $recaptcha_passed, FILTER_VALIDATE_BOOLEAN ); |
254
|
|
|
// verify recaptcha |
255
|
|
|
EED_Recaptcha::_get_recaptcha_response(); |
256
|
|
|
if ( ! $recaptcha_passed && EED_Recaptcha::$_recaptcha_response ) { |
257
|
|
|
$recaptcha_passed = EED_Recaptcha::_process_recaptcha_response(); |
258
|
|
|
EE_Registry::instance()->SSN->set_session_data( array( 'recaptcha_passed' => $recaptcha_passed )); |
259
|
|
|
EE_Registry::instance()->SSN->update(); |
260
|
|
|
} |
261
|
|
|
EED_Recaptcha::$_not_a_robot = $recaptcha_passed; |
262
|
|
|
return $recaptcha_passed; |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
|
266
|
|
|
|
267
|
|
|
/** |
268
|
|
|
* recaptcha_response |
269
|
|
|
* |
270
|
|
|
* @access public |
271
|
|
|
* @param array $recaptcha_response |
272
|
|
|
* @return boolean |
273
|
|
|
*/ |
274
|
|
|
public static function recaptcha_response( $recaptcha_response = array() ) { |
275
|
|
|
if ( EED_Recaptcha::_bypass_recaptcha() ) { |
276
|
|
|
$recaptcha_response['bypass_recaptcha'] = TRUE; |
277
|
|
|
$recaptcha_response['recaptcha_passed'] = TRUE; |
278
|
|
|
} else { |
279
|
|
|
$recaptcha_response['recaptcha_passed'] = EED_Recaptcha::$_not_a_robot; |
280
|
|
|
} |
281
|
|
|
return $recaptcha_response; |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
|
285
|
|
|
|
286
|
|
|
|
287
|
|
|
/** |
288
|
|
|
* _bypass_recaptcha |
289
|
|
|
* |
290
|
|
|
* @access private |
291
|
|
|
* @return boolean |
292
|
|
|
*/ |
293
|
|
|
private static function _bypass_recaptcha() { |
294
|
|
|
// an array of key value pairs that must match exactly with the incoming request, in order to bypass recaptcha for the current request ONLY |
295
|
|
|
$bypass_request_params_array = apply_filters( 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', array() ); |
296
|
|
|
// does $bypass_request_params_array have any values ? |
297
|
|
|
if ( empty( $bypass_request_params_array )) { |
298
|
|
|
return FALSE; |
299
|
|
|
} |
300
|
|
|
// initially set bypass to TRUE |
301
|
|
|
$bypass_recaptcha = TRUE; |
302
|
|
|
foreach ( $bypass_request_params_array as $key => $value ) { |
303
|
|
|
// if $key is not found or value doesn't match exactly, then toggle bypass to FALSE, otherwise carry over it's value. This way, one missed setting results in no bypass |
304
|
|
|
$bypass_recaptcha = isset( $_REQUEST[ $key ] ) && $_REQUEST[ $key ] === $value ? $bypass_recaptcha : FALSE; |
305
|
|
|
} |
306
|
|
|
return $bypass_recaptcha; |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
|
310
|
|
|
|
311
|
|
|
|
312
|
|
|
/** |
313
|
|
|
* process_recaptcha |
314
|
|
|
* |
315
|
|
|
* @access private |
316
|
|
|
* @return boolean |
317
|
|
|
*/ |
318
|
|
|
private static function _get_recaptcha_response() { |
319
|
|
|
EED_Recaptcha::$_recaptcha_response = EE_Registry::instance()->REQ->get( 'g-recaptcha-response', false ); |
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
|
323
|
|
|
|
324
|
|
|
|
325
|
|
|
/** |
326
|
|
|
* process_recaptcha |
327
|
|
|
* |
328
|
|
|
* @access private |
329
|
|
|
* @return boolean |
330
|
|
|
*/ |
331
|
|
|
private static function _process_recaptcha_response() { |
332
|
|
|
// verify library is loaded |
333
|
|
|
if ( ! class_exists( '\\ReCaptcha\\ReCaptcha' )) { |
334
|
|
|
require_once( RECAPTCHA_BASE_PATH . DS . 'autoload.php' ); |
335
|
|
|
} |
336
|
|
|
// The response from reCAPTCHA |
337
|
|
|
EED_Recaptcha::_get_recaptcha_response(); |
338
|
|
|
$recaptcha_response = EED_Recaptcha::$_recaptcha_response; |
339
|
|
|
// Was there a reCAPTCHA response? |
340
|
|
|
if ( $recaptcha_response ) { |
341
|
|
|
// if allow_url_fopen is Off, then set a different request method |
342
|
|
|
$request_method = ! ini_get( 'allow_url_fopen' ) ? new \ReCaptcha\RequestMethod\SocketPost() : null; |
343
|
|
|
$recaptcha = new \ReCaptcha\ReCaptcha( |
344
|
|
|
EE_Registry::instance()->CFG->registration->recaptcha_privatekey, |
345
|
|
|
$request_method |
346
|
|
|
); |
347
|
|
|
$recaptcha_response = $recaptcha->verify( |
348
|
|
|
EED_Recaptcha::$_recaptcha_response, |
349
|
|
|
$_SERVER[ 'REMOTE_ADDR' ] |
350
|
|
|
); |
351
|
|
|
} |
352
|
|
|
if ( $recaptcha_response instanceof \ReCaptcha\Response && $recaptcha_response->isSuccess() ) { |
353
|
|
|
return TRUE; |
354
|
|
|
} |
355
|
|
|
// sorry... it appears you can't don't know what soup or hamburgers are !!! |
356
|
|
|
return FALSE; |
357
|
|
|
} |
358
|
|
|
|
359
|
|
|
|
360
|
|
|
|
361
|
|
|
|
362
|
|
|
|
363
|
|
|
/*************************************** reCAPTCHA ADMIN SETTINGS ***************************************/ |
364
|
|
|
|
365
|
|
|
|
366
|
|
|
|
367
|
|
|
/** |
368
|
|
|
* admin_settings |
369
|
|
|
* |
370
|
|
|
* @access public |
371
|
|
|
* @return array |
372
|
|
|
*/ |
373
|
|
|
public static function admin_settings() { |
374
|
|
|
echo EED_Recaptcha::_recaptcha_settings_form()->get_html_and_js(); |
375
|
|
|
} |
376
|
|
|
|
377
|
|
|
|
378
|
|
|
|
379
|
|
|
/** |
380
|
|
|
* _recaptcha_main_settings |
381
|
|
|
* |
382
|
|
|
* @access protected |
383
|
|
|
* @return EE_Form_Section_Proper |
384
|
|
|
*/ |
385
|
|
|
protected static function _recaptcha_settings_form() { |
386
|
|
|
|
387
|
|
|
|
388
|
|
|
return new EE_Form_Section_Proper( |
389
|
|
|
array( |
390
|
|
|
'name' => 'recaptcha_settings_form', |
391
|
|
|
'html_id' => 'recaptcha_settings_form', |
392
|
|
|
'layout_strategy' => new EE_Div_Per_Section_Layout(), |
393
|
|
|
'subsections' => apply_filters( |
394
|
|
|
'FHEE__EED_Recaptcha___recaptcha_settings_form__form_subsections', |
395
|
|
|
array( |
396
|
|
|
'main_settings_hdr' => new EE_Form_Section_HTML( EEH_HTML::h2( __( 'reCAPTCHA Anti-spam Settings', 'event_espresso' ) . EEH_Template::get_help_tab_link( 'recaptcha_info' ))), |
397
|
|
|
'main_settings' => EED_Recaptcha::_recaptcha_main_settings(), |
398
|
|
|
'appearance_settings_hdr' => new EE_Form_Section_HTML( EEH_HTML::h2( __( 'reCAPTCHA Appearance', 'event_espresso' ) )), |
399
|
|
|
'appearance_settings' => EED_Recaptcha::_recaptcha_appearance_settings(), |
400
|
|
|
// 'recaptcha_example' => new EE_Form_Section_HTML( EED_Recaptcha::display_recaptcha() ), |
401
|
|
|
'required_fields_note' => new EE_Form_Section_HTML( EEH_HTML::p( __( 'All fields marked with a * are required fields', 'event_espresso' ), '', 'grey-text' )) |
402
|
|
|
) |
403
|
|
|
) |
404
|
|
|
) |
405
|
|
|
); |
406
|
|
|
} |
407
|
|
|
|
408
|
|
|
|
409
|
|
|
|
410
|
|
|
/** |
411
|
|
|
* _recaptcha_main_settings |
412
|
|
|
* |
413
|
|
|
* @access protected |
414
|
|
|
* @return EE_Form_Section_Proper |
415
|
|
|
*/ |
416
|
|
|
protected static function _recaptcha_main_settings() { |
417
|
|
|
return new EE_Form_Section_Proper( |
418
|
|
|
array( |
419
|
|
|
'name' => 'recaptcha_settings_tbl', |
420
|
|
|
'html_id' => 'recaptcha_settings_tbl', |
421
|
|
|
'html_class' => 'form-table', |
422
|
|
|
'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
423
|
|
|
'subsections' => apply_filters( |
424
|
|
|
'FHEE__EED_Recaptcha___recaptcha_main_settings__form_subsections', |
425
|
|
|
array( |
426
|
|
|
'use_captcha' => new EE_Yes_No_Input( |
427
|
|
|
array( |
428
|
|
|
'html_label_text' => __( 'Use reCAPTCHA', 'event_espresso' ), |
429
|
|
|
'html_help_text' => sprintf( |
430
|
|
|
__( 'reCAPTCHA is a free service that protects your website from spam and abuse. It employs advanced risk analysis technology to separate humans from abusive actors. Sign up %1$shere%2$s to receive your Public and Private keys.', 'event_espresso' ), |
431
|
|
|
'<a href="https://www.google.com/recaptcha/intro/index.html">', |
432
|
|
|
'</a>' |
433
|
|
|
), |
434
|
|
|
'default' => isset( EE_Registry::instance()->CFG->registration->use_captcha ) ? EE_Registry::instance()->CFG->registration->use_captcha : FALSE, |
435
|
|
|
'display_html_label_text' => FALSE |
436
|
|
|
) |
437
|
|
|
), |
438
|
|
|
'recaptcha_publickey' => new EE_Text_Input( |
439
|
|
|
array( |
440
|
|
|
'html_label_text' => __( 'Site Key', 'event_espresso' ), |
441
|
|
|
'html_help_text' => __( 'The site key is used to display the widget on your site.', 'event_espresso' ), |
442
|
|
|
'default' => isset( EE_Registry::instance()->CFG->registration->recaptcha_publickey ) ? stripslashes( EE_Registry::instance()->CFG->registration->recaptcha_publickey ) : '' |
443
|
|
|
) |
444
|
|
|
), |
445
|
|
|
'recaptcha_privatekey' => new EE_Text_Input( |
446
|
|
|
array( |
447
|
|
|
'html_label_text' => __( 'Secret Key', 'event_espresso' ), |
448
|
|
|
'html_help_text' => __( 'The secret key authorizes communication between your application backend and the reCAPTCHA server to verify the user\'s response. The secret key needs to be kept safe for security purposes.', 'event_espresso' ), |
449
|
|
|
'default' => isset( EE_Registry::instance()->CFG->registration->recaptcha_privatekey ) ? stripslashes( EE_Registry::instance()->CFG->registration->recaptcha_privatekey ) : '' |
450
|
|
|
) |
451
|
|
|
) |
452
|
|
|
) |
453
|
|
|
) |
454
|
|
|
) |
455
|
|
|
); |
456
|
|
|
} |
457
|
|
|
|
458
|
|
|
|
459
|
|
|
|
460
|
|
|
|
461
|
|
|
|
462
|
|
|
|
463
|
|
|
/** |
464
|
|
|
* _recaptcha_appearance_settings |
465
|
|
|
* |
466
|
|
|
* @access protected |
467
|
|
|
* @return EE_Form_Section_Proper |
468
|
|
|
*/ |
469
|
|
|
protected static function _recaptcha_appearance_settings() { |
470
|
|
|
return new EE_Form_Section_Proper( |
471
|
|
|
array( |
472
|
|
|
'name' => 'recaptcha_appearance_settings_tbl', |
473
|
|
|
'html_id' => 'recaptcha_appearance_settings_tbl', |
474
|
|
|
'html_class' => 'form-table', |
475
|
|
|
'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
476
|
|
|
'subsections' => apply_filters( |
477
|
|
|
'FHEE__EED_Recaptcha___recaptcha_appearance_settings__form_subsections', |
478
|
|
|
array( |
479
|
|
|
'recaptcha_theme' => new EE_Radio_Button_Input( |
480
|
|
|
array( |
481
|
|
|
'light' => __( 'Light', 'event_espresso' ), |
482
|
|
|
'dark' => __( 'Dark', 'event_espresso' ) |
483
|
|
|
), |
484
|
|
|
array( |
485
|
|
|
'html_label_text' => __( 'Theme', 'event_espresso' ), |
486
|
|
|
'html_help_text' => __( 'The color theme of the widget.', 'event_espresso' ), |
487
|
|
|
'default' => isset( EE_Registry::instance()->CFG->registration->recaptcha_theme ) ? EE_Registry::instance()->CFG->registration->recaptcha_theme : 'light', |
488
|
|
|
'display_html_label_text' => FALSE |
489
|
|
|
) |
490
|
|
|
), |
491
|
|
|
'recaptcha_type' => new EE_Radio_Button_Input( |
492
|
|
|
array( |
493
|
|
|
'image' => __( 'Image', 'event_espresso' ), |
494
|
|
|
'audio' => __( 'Audio', 'event_espresso' ) |
495
|
|
|
), |
496
|
|
|
array( |
497
|
|
|
'html_label_text' => __( 'Type', 'event_espresso' ), |
498
|
|
|
'html_help_text' => __( 'The type of CAPTCHA to serve.', 'event_espresso' ), |
499
|
|
|
'default' => isset( EE_Registry::instance()->CFG->registration->recaptcha_type ) ? EE_Registry::instance()->CFG->registration->recaptcha_type : 'image', |
500
|
|
|
'display_html_label_text' =>FALSE |
501
|
|
|
) |
502
|
|
|
), |
503
|
|
|
'recaptcha_language' => new EE_Select_Input( |
504
|
|
|
array( |
505
|
|
|
'ar' => __( 'Arabic', 'event_espresso' ), |
506
|
|
|
'bg' => __( 'Bulgarian', 'event_espresso' ), |
507
|
|
|
'ca' => __( 'Catalan', 'event_espresso' ), |
508
|
|
|
'zh-CN' => __( 'Chinese (Simplified)', 'event_espresso' ), |
509
|
|
|
'zh-TW' => __( 'Chinese (Traditional) ', 'event_espresso' ), |
510
|
|
|
'hr' => __( 'Croatian', 'event_espresso' ), |
511
|
|
|
'cs' => __( 'Czech', 'event_espresso' ), |
512
|
|
|
'da' => __( 'Danish', 'event_espresso' ), |
513
|
|
|
'nl' => __( 'Dutch', 'event_espresso' ), |
514
|
|
|
'en-GB' => __( 'English (UK)', 'event_espresso' ), |
515
|
|
|
'en' => __( 'English (US)', 'event_espresso' ), |
516
|
|
|
'fil' => __( 'Filipino', 'event_espresso' ), |
517
|
|
|
'fi' => __( 'Finnish', 'event_espresso' ), |
518
|
|
|
'fr' => __( 'French', 'event_espresso' ), |
519
|
|
|
'fr-CA' => __( 'French (Canadian)', 'event_espresso' ), |
520
|
|
|
'de' => __( 'German', 'event_espresso' ), |
521
|
|
|
'de-AT' => __( 'German (Austria)', 'event_espresso' ), |
522
|
|
|
'de-CH' => __( 'German (Switzerland)', 'event_espresso' ), |
523
|
|
|
'el' => __( 'Greek', 'event_espresso' ), |
524
|
|
|
'iw' => __( 'Hebrew', 'event_espresso' ), |
525
|
|
|
'hi' => __( 'Hindi', 'event_espresso' ), |
526
|
|
|
'hu' => __( 'Hungarian', 'event_espresso' ), |
527
|
|
|
'id' => __( 'Indonesian', 'event_espresso' ), |
528
|
|
|
'it' => __( 'Italian', 'event_espresso' ), |
529
|
|
|
'ja' => __( 'Japanese', 'event_espresso' ), |
530
|
|
|
'ko' => __( 'Korean', 'event_espresso' ), |
531
|
|
|
'lv' => __( 'Latvian', 'event_espresso' ), |
532
|
|
|
'lt' => __( 'Lithuanian', 'event_espresso' ), |
533
|
|
|
'no' => __( 'Norwegian', 'event_espresso' ), |
534
|
|
|
'fa' => __( 'Persian', 'event_espresso' ), |
535
|
|
|
'pl' => __( 'Polish', 'event_espresso' ), |
536
|
|
|
'pt' => __( 'Portuguese', 'event_espresso' ), |
537
|
|
|
'pt-BR' => __( 'Portuguese (Brazil)', 'event_espresso' ), |
538
|
|
|
'pt-PT' => __( 'Portuguese (Portugal)', 'event_espresso' ), |
539
|
|
|
'ro' => __( 'Romanian', 'event_espresso' ), |
540
|
|
|
'ru' => __( 'Russian', 'event_espresso' ), |
541
|
|
|
'sr' => __( 'Serbian', 'event_espresso' ), |
542
|
|
|
'sk' => __( 'Slovak', 'event_espresso' ), |
543
|
|
|
'sl' => __( 'Slovenian', 'event_espresso' ), |
544
|
|
|
'es' => __( 'Spanish', 'event_espresso' ), |
545
|
|
|
'es-419' => __( 'Spanish (Latin America)', 'event_espresso' ), |
546
|
|
|
'sv' => __( 'Swedish', 'event_espresso' ), |
547
|
|
|
'th' => __( 'Thai', 'event_espresso' ), |
548
|
|
|
'tr' => __( 'Turkish', 'event_espresso' ), |
549
|
|
|
'uk' => __( 'Ukrainian', 'event_espresso' ), |
550
|
|
|
'vi' => __( 'Vietnamese', 'event_espresso') |
551
|
|
|
), |
552
|
|
|
array( |
553
|
|
|
'html_label_text' => __( 'Language', 'event_espresso' ), |
554
|
|
|
'html_help_text' => __( 'Forces the widget to render in a specific language.', 'event_espresso' ), |
555
|
|
|
'default' => isset( EE_Registry::instance()->CFG->registration->recaptcha_language ) ? EE_Registry::instance()->CFG->registration->recaptcha_language : 'en' |
556
|
|
|
) |
557
|
|
|
) |
558
|
|
|
) |
559
|
|
|
) |
560
|
|
|
) |
561
|
|
|
); |
562
|
|
|
} |
563
|
|
|
|
564
|
|
|
|
565
|
|
|
|
566
|
|
|
|
567
|
|
|
|
568
|
|
|
/** |
569
|
|
|
* _recaptcha_example |
570
|
|
|
* |
571
|
|
|
* @access protected |
572
|
|
|
* @return EE_Form_Section_Proper |
573
|
|
|
*/ |
574
|
|
|
protected static function _recaptcha_example() { |
575
|
|
|
// if ( !empty( $recaptcha_example ) ) { ?> |
576
|
|
|
<!-- --> |
577
|
|
|
<!-- <h2 class="ee-admin-settings-hdr admin-recaptcha-settings-hdr">--> |
578
|
|
|
<!-- --><?php //_e('reCAPTCHA Example', 'event_espresso'); ?> |
579
|
|
|
<!-- </h2>--> |
580
|
|
|
<!-- <p class="description">--><?php //_e('A reCAPTCHA displaying here means that you have a valid public key entered for the reCAPTCHA settings and this is how the reCAPTCHA will look with the currently set appearance settings. If you do not see a reCAPTCHA then please doublecheck the key you entered for a public key.', 'event_espresso'); ?><!--</p>--> |
581
|
|
|
<!-- <table class="form-table">--> |
582
|
|
|
<!-- <tbody>--> |
583
|
|
|
<!-- --> |
584
|
|
|
<!-- <tr class="admin-recaptcha-settings-tr">--> |
585
|
|
|
<!-- <td>--> |
586
|
|
|
<!-- --><?php //echo $recaptcha_example; ?> |
587
|
|
|
<!-- </td>--> |
588
|
|
|
<!-- </tr>--> |
589
|
|
|
<!-- --> |
590
|
|
|
<!-- </tbody>--> |
591
|
|
|
<!-- </table>--> |
592
|
|
|
<!-- --><?php //} |
593
|
|
|
} |
594
|
|
|
|
595
|
|
|
|
596
|
|
|
/** |
597
|
|
|
* admin_settings_template |
598
|
|
|
* |
599
|
|
|
* @access public |
600
|
|
|
* @param EE_Registration_Config $EE_Registration_Config |
601
|
|
|
* @return array |
602
|
|
|
*/ |
603
|
|
|
public static function update_admin_settings( EE_Registration_Config $EE_Registration_Config ) { |
604
|
|
|
try { |
605
|
|
|
$recaptcha_settings_form = EED_Recaptcha::_recaptcha_settings_form(); |
606
|
|
|
// if not displaying a form, then check for form submission |
607
|
|
|
if ( $recaptcha_settings_form->was_submitted() ) { |
608
|
|
|
// capture form data |
609
|
|
|
$recaptcha_settings_form->receive_form_submission(); |
610
|
|
|
// validate form data |
611
|
|
|
if ( $recaptcha_settings_form->is_valid() ) { |
612
|
|
|
// grab validated data from form |
613
|
|
|
$valid_data = $recaptcha_settings_form->valid_data(); |
614
|
|
|
// user proofing recaptcha: If Use reCAPTCHA is set to yes but we dont' have site or secret keys then set Use reCAPTCHA to FALSE and give error message. |
615
|
|
|
if ( |
616
|
|
|
apply_filters( 'FHEE__Extend_Registration_Form_Admin_Page__check_for_recaptcha_keys', TRUE, $EE_Registration_Config ) |
617
|
|
|
&& $valid_data['main_settings']['use_captcha'] |
618
|
|
|
&& ( ! $EE_Registration_Config->use_captcha && ( empty( $valid_data['main_settings']['recaptcha_publickey'] ) || empty( $valid_data['main_settings']['recaptcha_privatekey'] ))) |
619
|
|
|
) { |
620
|
|
|
$valid_data['main_settings']['use_captcha'] = FALSE; |
621
|
|
|
EE_Error::add_error( __('The use reCAPTCHA setting has been reset to "no". In order to enable the reCAPTCHA service, you must enter a Site Key and Secret Key.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
622
|
|
|
} |
623
|
|
|
$EE_Registration_Config->use_captcha = $valid_data['main_settings']['use_captcha']; |
624
|
|
|
$EE_Registration_Config->recaptcha_publickey = $valid_data['main_settings']['recaptcha_publickey']; |
625
|
|
|
$EE_Registration_Config->recaptcha_privatekey = $valid_data['main_settings']['recaptcha_privatekey']; |
626
|
|
|
$EE_Registration_Config->recaptcha_type = $valid_data['appearance_settings']['recaptcha_type']; |
627
|
|
|
$EE_Registration_Config->recaptcha_theme = $valid_data['appearance_settings']['recaptcha_theme']; |
628
|
|
|
$EE_Registration_Config->recaptcha_language = $valid_data['appearance_settings']['recaptcha_language']; |
629
|
|
|
} else { |
630
|
|
|
if ( $recaptcha_settings_form->submission_error_message() != '' ) { |
631
|
|
|
EE_Error::add_error( $recaptcha_settings_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
632
|
|
|
} |
633
|
|
|
} |
634
|
|
|
} |
635
|
|
|
} catch( EE_Error $e ) { |
636
|
|
|
$e->get_error(); |
637
|
|
|
} |
638
|
|
|
|
639
|
|
|
// d( $EE_Registration_Config ); |
640
|
|
|
// die(); |
641
|
|
|
return $EE_Registration_Config; |
642
|
|
|
} |
643
|
|
|
|
644
|
|
|
|
645
|
|
|
} |
646
|
|
|
// End of file EED_Recaptcha.module.php |
647
|
|
|
// Location: /modules/recaptcha/EED_Recaptcha.module.php |
648
|
|
|
|
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.