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