@@ -59,14 +59,14 @@ |
||
59 | 59 | $ee_bot_checkout = array(); |
60 | 60 | add_option(InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout, '', false); |
61 | 61 | } |
62 | - if (! isset($ee_bot_checkout[ $ip_address ])) { |
|
63 | - $ee_bot_checkout[ $ip_address ] = array(); |
|
62 | + if ( ! isset($ee_bot_checkout[$ip_address])) { |
|
63 | + $ee_bot_checkout[$ip_address] = array(); |
|
64 | 64 | } |
65 | 65 | $http_referer = esc_attr($request->getServerParam('HTTP_REFERER', 0)); |
66 | - if (! isset($ee_bot_checkout[ $ip_address ][ $http_referer ])) { |
|
67 | - $ee_bot_checkout[ $ip_address ][ $http_referer ] = 0; |
|
66 | + if ( ! isset($ee_bot_checkout[$ip_address][$http_referer])) { |
|
67 | + $ee_bot_checkout[$ip_address][$http_referer] = 0; |
|
68 | 68 | } |
69 | - $ee_bot_checkout[ $ip_address ][ $http_referer ]++; |
|
69 | + $ee_bot_checkout[$ip_address][$http_referer]++; |
|
70 | 70 | update_option(InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout); |
71 | 71 | if (WP_DEBUG) { |
72 | 72 | EE_Error::add_error( |
@@ -26,181 +26,181 @@ |
||
26 | 26 | */ |
27 | 27 | class InvalidCheckoutAccess |
28 | 28 | { |
29 | - /** |
|
30 | - * key used for saving invalid checkout access data to the wp_options table |
|
31 | - */ |
|
32 | - const OPTION_KEY = 'ee_invalid_checkout_access'; |
|
29 | + /** |
|
30 | + * key used for saving invalid checkout access data to the wp_options table |
|
31 | + */ |
|
32 | + const OPTION_KEY = 'ee_invalid_checkout_access'; |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * _block_bots |
|
37 | - * checks that the incoming request has either of the following set: |
|
38 | - * a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector |
|
39 | - * a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN |
|
40 | - * so if you're not coming from the Ticket Selector nor returning for a valid IP... |
|
41 | - * then where you coming from man? |
|
42 | - * |
|
43 | - * @param EE_Checkout $checkout |
|
44 | - * @return bool true if access to registration checkout appears to be invalid |
|
45 | - */ |
|
46 | - public function checkoutAccessIsInvalid(EE_Checkout $checkout) |
|
47 | - { |
|
48 | - if ( |
|
49 | - ! ($checkout->uts || $checkout->reg_url_link) |
|
50 | - && ! (defined('DOING_AJAX') && DOING_AJAX) |
|
51 | - && EE_Config::instance()->registration->track_invalid_checkout_access() |
|
52 | - ) { |
|
53 | - /** @var RequestInterface $request */ |
|
54 | - $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\RequestInterface'); |
|
55 | - $ip_address = $request->ipAddress(); |
|
56 | - $ee_bot_checkout = get_option(InvalidCheckoutAccess::OPTION_KEY); |
|
57 | - if ($ee_bot_checkout === false) { |
|
58 | - $ee_bot_checkout = array(); |
|
59 | - add_option(InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout, '', false); |
|
60 | - } |
|
61 | - if (! isset($ee_bot_checkout[ $ip_address ])) { |
|
62 | - $ee_bot_checkout[ $ip_address ] = array(); |
|
63 | - } |
|
64 | - $http_referer = esc_attr($request->getServerParam('HTTP_REFERER', 0)); |
|
65 | - if (! isset($ee_bot_checkout[ $ip_address ][ $http_referer ])) { |
|
66 | - $ee_bot_checkout[ $ip_address ][ $http_referer ] = 0; |
|
67 | - } |
|
68 | - $ee_bot_checkout[ $ip_address ][ $http_referer ]++; |
|
69 | - update_option(InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout); |
|
70 | - if (WP_DEBUG) { |
|
71 | - EE_Error::add_error( |
|
72 | - esc_html__('Direct access to the registration checkout page is not allowed.', 'event_espresso'), |
|
73 | - __FILE__, |
|
74 | - __FUNCTION__, |
|
75 | - __LINE__ |
|
76 | - ); |
|
77 | - } |
|
78 | - return true; |
|
79 | - } |
|
80 | - return false; |
|
81 | - } |
|
35 | + /** |
|
36 | + * _block_bots |
|
37 | + * checks that the incoming request has either of the following set: |
|
38 | + * a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector |
|
39 | + * a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN |
|
40 | + * so if you're not coming from the Ticket Selector nor returning for a valid IP... |
|
41 | + * then where you coming from man? |
|
42 | + * |
|
43 | + * @param EE_Checkout $checkout |
|
44 | + * @return bool true if access to registration checkout appears to be invalid |
|
45 | + */ |
|
46 | + public function checkoutAccessIsInvalid(EE_Checkout $checkout) |
|
47 | + { |
|
48 | + if ( |
|
49 | + ! ($checkout->uts || $checkout->reg_url_link) |
|
50 | + && ! (defined('DOING_AJAX') && DOING_AJAX) |
|
51 | + && EE_Config::instance()->registration->track_invalid_checkout_access() |
|
52 | + ) { |
|
53 | + /** @var RequestInterface $request */ |
|
54 | + $request = LoaderFactory::getLoader()->getShared('EventEspresso\core\services\request\RequestInterface'); |
|
55 | + $ip_address = $request->ipAddress(); |
|
56 | + $ee_bot_checkout = get_option(InvalidCheckoutAccess::OPTION_KEY); |
|
57 | + if ($ee_bot_checkout === false) { |
|
58 | + $ee_bot_checkout = array(); |
|
59 | + add_option(InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout, '', false); |
|
60 | + } |
|
61 | + if (! isset($ee_bot_checkout[ $ip_address ])) { |
|
62 | + $ee_bot_checkout[ $ip_address ] = array(); |
|
63 | + } |
|
64 | + $http_referer = esc_attr($request->getServerParam('HTTP_REFERER', 0)); |
|
65 | + if (! isset($ee_bot_checkout[ $ip_address ][ $http_referer ])) { |
|
66 | + $ee_bot_checkout[ $ip_address ][ $http_referer ] = 0; |
|
67 | + } |
|
68 | + $ee_bot_checkout[ $ip_address ][ $http_referer ]++; |
|
69 | + update_option(InvalidCheckoutAccess::OPTION_KEY, $ee_bot_checkout); |
|
70 | + if (WP_DEBUG) { |
|
71 | + EE_Error::add_error( |
|
72 | + esc_html__('Direct access to the registration checkout page is not allowed.', 'event_espresso'), |
|
73 | + __FILE__, |
|
74 | + __FUNCTION__, |
|
75 | + __LINE__ |
|
76 | + ); |
|
77 | + } |
|
78 | + return true; |
|
79 | + } |
|
80 | + return false; |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | - /** |
|
85 | - * _invalid_checkout_access_form |
|
86 | - * |
|
87 | - * @return EE_Form_Section_Proper |
|
88 | - * @throws EE_Error |
|
89 | - */ |
|
90 | - public function getForm() |
|
91 | - { |
|
92 | - return new EE_Form_Section_Proper( |
|
93 | - array( |
|
94 | - 'name' => 'invalid_checkout_access', |
|
95 | - 'html_id' => 'invalid_checkout_access', |
|
96 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
97 | - 'subsections' => array( |
|
98 | - 'invalid_checkout_access_hdr' => new EE_Form_Section_HTML( |
|
99 | - EEH_HTML::h2(esc_html__('Invalid Checkout Access', 'event_espresso')) |
|
100 | - ), |
|
101 | - 'ee_bot_checkout_data' => new EE_Text_Area_Input( |
|
102 | - array( |
|
103 | - 'html_label_text' => esc_html__('Invalid Checkout Data', 'event_espresso'), |
|
104 | - 'default' => var_export( |
|
105 | - get_option(InvalidCheckoutAccess::OPTION_KEY, array()), |
|
106 | - true |
|
107 | - ), |
|
108 | - 'required' => false, |
|
109 | - 'html_help_text' => esc_html__( |
|
110 | - 'Event Espresso blocks any attempt to directly access the registration checkout page, that is NOT from a Ticket Selector or for a return visit for a valid transaction. These are not valid requests accessing your checkout page, so we track the IP addresses, what web page they just came from, and the number of times that they have attempted to access your registration page. This information may help you with protecting your site by other means, such as firewalls, etc, but please note that IP addresses are almost guaranteed to be spoofed by malicious agents.', |
|
111 | - 'event_espresso' |
|
112 | - ), |
|
113 | - ) |
|
114 | - ), |
|
115 | - 'track_invalid_checkout_access' => new EE_Yes_No_Input( |
|
116 | - array( |
|
117 | - 'html_label_text' => esc_html__('Track Invalid Checkout Access?', 'event_espresso'), |
|
118 | - 'html_help_text' => esc_html__( |
|
119 | - 'Controls whether or not invalid attempts to directly access the registration checkout page should be tracked. Setting this to "No" means that the above data will no longer be collected.', |
|
120 | - 'event_espresso' |
|
121 | - ), |
|
122 | - 'default' => EE_Config::instance() |
|
123 | - ->registration |
|
124 | - ->track_invalid_checkout_access(), |
|
125 | - 'display_html_label_text' => false, |
|
126 | - ) |
|
127 | - ), |
|
128 | - 'delete_invalid_checkout_data' => new EE_Yes_No_Input( |
|
129 | - array( |
|
130 | - 'html_label_text' => esc_html__('Reset Invalid Checkout Data', 'event_espresso'), |
|
131 | - 'html_help_text' => esc_html__( |
|
132 | - 'Setting this to "Yes" will delete all existing invalid checkout access data.', |
|
133 | - 'event_espresso' |
|
134 | - ), |
|
135 | - 'default' => false, |
|
136 | - 'display_html_label_text' => false, |
|
137 | - ) |
|
138 | - ), |
|
139 | - ), |
|
140 | - ) |
|
141 | - ); |
|
142 | - } |
|
84 | + /** |
|
85 | + * _invalid_checkout_access_form |
|
86 | + * |
|
87 | + * @return EE_Form_Section_Proper |
|
88 | + * @throws EE_Error |
|
89 | + */ |
|
90 | + public function getForm() |
|
91 | + { |
|
92 | + return new EE_Form_Section_Proper( |
|
93 | + array( |
|
94 | + 'name' => 'invalid_checkout_access', |
|
95 | + 'html_id' => 'invalid_checkout_access', |
|
96 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
97 | + 'subsections' => array( |
|
98 | + 'invalid_checkout_access_hdr' => new EE_Form_Section_HTML( |
|
99 | + EEH_HTML::h2(esc_html__('Invalid Checkout Access', 'event_espresso')) |
|
100 | + ), |
|
101 | + 'ee_bot_checkout_data' => new EE_Text_Area_Input( |
|
102 | + array( |
|
103 | + 'html_label_text' => esc_html__('Invalid Checkout Data', 'event_espresso'), |
|
104 | + 'default' => var_export( |
|
105 | + get_option(InvalidCheckoutAccess::OPTION_KEY, array()), |
|
106 | + true |
|
107 | + ), |
|
108 | + 'required' => false, |
|
109 | + 'html_help_text' => esc_html__( |
|
110 | + 'Event Espresso blocks any attempt to directly access the registration checkout page, that is NOT from a Ticket Selector or for a return visit for a valid transaction. These are not valid requests accessing your checkout page, so we track the IP addresses, what web page they just came from, and the number of times that they have attempted to access your registration page. This information may help you with protecting your site by other means, such as firewalls, etc, but please note that IP addresses are almost guaranteed to be spoofed by malicious agents.', |
|
111 | + 'event_espresso' |
|
112 | + ), |
|
113 | + ) |
|
114 | + ), |
|
115 | + 'track_invalid_checkout_access' => new EE_Yes_No_Input( |
|
116 | + array( |
|
117 | + 'html_label_text' => esc_html__('Track Invalid Checkout Access?', 'event_espresso'), |
|
118 | + 'html_help_text' => esc_html__( |
|
119 | + 'Controls whether or not invalid attempts to directly access the registration checkout page should be tracked. Setting this to "No" means that the above data will no longer be collected.', |
|
120 | + 'event_espresso' |
|
121 | + ), |
|
122 | + 'default' => EE_Config::instance() |
|
123 | + ->registration |
|
124 | + ->track_invalid_checkout_access(), |
|
125 | + 'display_html_label_text' => false, |
|
126 | + ) |
|
127 | + ), |
|
128 | + 'delete_invalid_checkout_data' => new EE_Yes_No_Input( |
|
129 | + array( |
|
130 | + 'html_label_text' => esc_html__('Reset Invalid Checkout Data', 'event_espresso'), |
|
131 | + 'html_help_text' => esc_html__( |
|
132 | + 'Setting this to "Yes" will delete all existing invalid checkout access data.', |
|
133 | + 'event_espresso' |
|
134 | + ), |
|
135 | + 'default' => false, |
|
136 | + 'display_html_label_text' => false, |
|
137 | + ) |
|
138 | + ), |
|
139 | + ), |
|
140 | + ) |
|
141 | + ); |
|
142 | + } |
|
143 | 143 | |
144 | 144 | |
145 | - /** |
|
146 | - * update_invalid_checkout_access_form |
|
147 | - * |
|
148 | - * @param EE_Registration_Config $EE_Registration_Config |
|
149 | - * @return EE_Registration_Config |
|
150 | - * @throws EE_Error |
|
151 | - * @throws ReflectionException |
|
152 | - */ |
|
153 | - public function processForm(EE_Registration_Config $EE_Registration_Config) |
|
154 | - { |
|
155 | - try { |
|
156 | - $invalid_checkout_access_form = $this->getForm(); |
|
157 | - // if not displaying a form, then check for form submission |
|
158 | - if ($invalid_checkout_access_form->was_submitted()) { |
|
159 | - // capture form data |
|
160 | - $invalid_checkout_access_form->receive_form_submission(); |
|
161 | - // validate form data |
|
162 | - if ($invalid_checkout_access_form->is_valid()) { |
|
163 | - // grab validated data from form |
|
164 | - $valid_data = $invalid_checkout_access_form->valid_data(); |
|
165 | - // ensure form inputs we want are set |
|
166 | - if ( |
|
167 | - isset( |
|
168 | - $valid_data['track_invalid_checkout_access'], |
|
169 | - $valid_data['delete_invalid_checkout_data'] |
|
170 | - ) |
|
171 | - ) { |
|
172 | - $EE_Registration_Config->set_track_invalid_checkout_access( |
|
173 | - $valid_data['track_invalid_checkout_access'] |
|
174 | - ); |
|
175 | - // if deleting, then update option with empty array |
|
176 | - if (filter_var($valid_data['delete_invalid_checkout_data'], FILTER_VALIDATE_BOOLEAN)) { |
|
177 | - update_option(InvalidCheckoutAccess::OPTION_KEY, array()); |
|
178 | - } |
|
179 | - } else { |
|
180 | - EE_Error::add_error( |
|
181 | - esc_html__( |
|
182 | - 'Invalid or missing Invalid Checkout Access form data. Please refresh the form and try again.', |
|
183 | - 'event_espresso' |
|
184 | - ), |
|
185 | - __FILE__, |
|
186 | - __FUNCTION__, |
|
187 | - __LINE__ |
|
188 | - ); |
|
189 | - } |
|
190 | - } else { |
|
191 | - if ($invalid_checkout_access_form->submission_error_message() !== '') { |
|
192 | - EE_Error::add_error( |
|
193 | - $invalid_checkout_access_form->submission_error_message(), |
|
194 | - __FILE__, |
|
195 | - __FUNCTION__, |
|
196 | - __LINE__ |
|
197 | - ); |
|
198 | - } |
|
199 | - } |
|
200 | - } |
|
201 | - } catch (EE_Error $e) { |
|
202 | - $e->get_error(); |
|
203 | - } |
|
204 | - return $EE_Registration_Config; |
|
205 | - } |
|
145 | + /** |
|
146 | + * update_invalid_checkout_access_form |
|
147 | + * |
|
148 | + * @param EE_Registration_Config $EE_Registration_Config |
|
149 | + * @return EE_Registration_Config |
|
150 | + * @throws EE_Error |
|
151 | + * @throws ReflectionException |
|
152 | + */ |
|
153 | + public function processForm(EE_Registration_Config $EE_Registration_Config) |
|
154 | + { |
|
155 | + try { |
|
156 | + $invalid_checkout_access_form = $this->getForm(); |
|
157 | + // if not displaying a form, then check for form submission |
|
158 | + if ($invalid_checkout_access_form->was_submitted()) { |
|
159 | + // capture form data |
|
160 | + $invalid_checkout_access_form->receive_form_submission(); |
|
161 | + // validate form data |
|
162 | + if ($invalid_checkout_access_form->is_valid()) { |
|
163 | + // grab validated data from form |
|
164 | + $valid_data = $invalid_checkout_access_form->valid_data(); |
|
165 | + // ensure form inputs we want are set |
|
166 | + if ( |
|
167 | + isset( |
|
168 | + $valid_data['track_invalid_checkout_access'], |
|
169 | + $valid_data['delete_invalid_checkout_data'] |
|
170 | + ) |
|
171 | + ) { |
|
172 | + $EE_Registration_Config->set_track_invalid_checkout_access( |
|
173 | + $valid_data['track_invalid_checkout_access'] |
|
174 | + ); |
|
175 | + // if deleting, then update option with empty array |
|
176 | + if (filter_var($valid_data['delete_invalid_checkout_data'], FILTER_VALIDATE_BOOLEAN)) { |
|
177 | + update_option(InvalidCheckoutAccess::OPTION_KEY, array()); |
|
178 | + } |
|
179 | + } else { |
|
180 | + EE_Error::add_error( |
|
181 | + esc_html__( |
|
182 | + 'Invalid or missing Invalid Checkout Access form data. Please refresh the form and try again.', |
|
183 | + 'event_espresso' |
|
184 | + ), |
|
185 | + __FILE__, |
|
186 | + __FUNCTION__, |
|
187 | + __LINE__ |
|
188 | + ); |
|
189 | + } |
|
190 | + } else { |
|
191 | + if ($invalid_checkout_access_form->submission_error_message() !== '') { |
|
192 | + EE_Error::add_error( |
|
193 | + $invalid_checkout_access_form->submission_error_message(), |
|
194 | + __FILE__, |
|
195 | + __FUNCTION__, |
|
196 | + __LINE__ |
|
197 | + ); |
|
198 | + } |
|
199 | + } |
|
200 | + } |
|
201 | + } catch (EE_Error $e) { |
|
202 | + $e->get_error(); |
|
203 | + } |
|
204 | + return $EE_Registration_Config; |
|
205 | + } |
|
206 | 206 | } |
@@ -8,7 +8,7 @@ |
||
8 | 8 | <tr class="item"> |
9 | 9 | <td>[LINE_ITEM_NAME][LINE_ITEM_TAXABLE_*]</td> |
10 | 10 | <td colspan="2">[LINE_ITEM_DESCRIPTION] |
11 | - <p class="ticket-note"><?php echo sprintf(esc_html__('This ticket can be used once at %s of the dates/times below.', 'event_espresso'), '[TKT_USES_* schema=' . esc_html__('any', 'event_espresso') . ']'); ?></p> |
|
11 | + <p class="ticket-note"><?php echo sprintf(esc_html__('This ticket can be used once at %s of the dates/times below.', 'event_espresso'), '[TKT_USES_* schema='.esc_html__('any', 'event_espresso').']'); ?></p> |
|
12 | 12 | </td> |
13 | 13 | <td class="item_c">[LINE_ITEM_QUANTITY]</td> |
14 | 14 | <td class="item_c">[LINE_ITEM_AMOUNT]</td> |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | } |
134 | 134 | define( |
135 | 135 | 'RECAPTCHA_BASE_PATH', |
136 | - rtrim(str_replace(array('\\', '/'), '/', plugin_dir_path(__FILE__)), '/') . '/' |
|
136 | + rtrim(str_replace(array('\\', '/'), '/', plugin_dir_path(__FILE__)), '/').'/' |
|
137 | 137 | ); |
138 | 138 | define('RECAPTCHA_BASE_URL', plugin_dir_url(__FILE__)); |
139 | 139 | } |
@@ -187,14 +187,14 @@ discard block |
||
187 | 187 | { |
188 | 188 | wp_register_script( |
189 | 189 | 'espresso_recaptcha', |
190 | - RECAPTCHA_BASE_URL . 'scripts/espresso_recaptcha.js', |
|
190 | + RECAPTCHA_BASE_URL.'scripts/espresso_recaptcha.js', |
|
191 | 191 | array('single_page_checkout'), |
192 | 192 | EVENT_ESPRESSO_VERSION, |
193 | 193 | true |
194 | 194 | ); |
195 | 195 | wp_register_script( |
196 | 196 | 'google_recaptcha', |
197 | - 'https://www.google.com/recaptcha/api.js?hl=' . EED_Recaptcha::$config->recaptcha_language, |
|
197 | + 'https://www.google.com/recaptcha/api.js?hl='.EED_Recaptcha::$config->recaptcha_language, |
|
198 | 198 | array('espresso_recaptcha'), |
199 | 199 | EVENT_ESPRESSO_VERSION, |
200 | 200 | true |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | if (EED_Recaptcha::useRecaptcha() && ! EED_Recaptcha::$_not_a_robot) { |
254 | 254 | // only display if they have NOT passed the test yet |
255 | 255 | EEH_Template::display_template( |
256 | - RECAPTCHA_BASE_PATH . '/templates/recaptcha.template.php', |
|
256 | + RECAPTCHA_BASE_PATH.'/templates/recaptcha.template.php', |
|
257 | 257 | array( |
258 | 258 | 'recaptcha_publickey' => EED_Recaptcha::$config->recaptcha_publickey, |
259 | 259 | 'recaptcha_theme' => EED_Recaptcha::$config->recaptcha_theme, |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | $recaptcha_passed = filter_var($recaptcha_passed, FILTER_VALIDATE_BOOLEAN); |
299 | 299 | // verify recaptcha |
300 | 300 | EED_Recaptcha::_get_recaptcha_response(); |
301 | - if (! $recaptcha_passed && EED_Recaptcha::$_recaptcha_response) { |
|
301 | + if ( ! $recaptcha_passed && EED_Recaptcha::$_recaptcha_response) { |
|
302 | 302 | $recaptcha_passed = EED_Recaptcha::_process_recaptcha_response(); |
303 | 303 | EE_Registry::instance()->SSN->set_session_data(array('recaptcha_passed' => $recaptcha_passed)); |
304 | 304 | } |
@@ -375,8 +375,8 @@ discard block |
||
375 | 375 | private static function _process_recaptcha_response() |
376 | 376 | { |
377 | 377 | // verify library is loaded |
378 | - if (! class_exists('\ReCaptcha\ReCaptcha')) { |
|
379 | - require_once RECAPTCHA_BASE_PATH . '/autoload.php'; |
|
378 | + if ( ! class_exists('\ReCaptcha\ReCaptcha')) { |
|
379 | + require_once RECAPTCHA_BASE_PATH.'/autoload.php'; |
|
380 | 380 | } |
381 | 381 | // The response from reCAPTCHA |
382 | 382 | EED_Recaptcha::_get_recaptcha_response(); |
@@ -17,382 +17,382 @@ |
||
17 | 17 | */ |
18 | 18 | class EED_Recaptcha extends EED_Module |
19 | 19 | { |
20 | - /** |
|
21 | - * @var EE_Registration_Config $config |
|
22 | - */ |
|
23 | - private static $config; |
|
24 | - |
|
25 | - /** |
|
26 | - * @type bool $_not_a_robot |
|
27 | - */ |
|
28 | - private static $_not_a_robot; |
|
29 | - |
|
30 | - /** |
|
31 | - * @type string $_recaptcha_response |
|
32 | - */ |
|
33 | - private static $_recaptcha_response; |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * @return EED_Module|EED_Recaptcha |
|
38 | - */ |
|
39 | - public static function instance() |
|
40 | - { |
|
41 | - return parent::get_instance(__CLASS__); |
|
42 | - } |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
47 | - * |
|
48 | - * @return void |
|
49 | - * @throws InvalidArgumentException |
|
50 | - * @throws InvalidInterfaceException |
|
51 | - * @throws InvalidDataTypeException |
|
52 | - */ |
|
53 | - public static function set_hooks() |
|
54 | - { |
|
55 | - EED_Recaptcha::$config = EE_Registry::instance()->CFG->registration; |
|
56 | - // use_captcha ? |
|
57 | - if ( |
|
58 | - EED_Recaptcha::useRecaptcha() |
|
59 | - && EED_Recaptcha::notPaymentOptionsRevisit() |
|
60 | - ) { |
|
61 | - EED_Recaptcha::set_definitions(); |
|
62 | - EED_Recaptcha::enqueue_styles_and_scripts(); |
|
63 | - add_action('wp', array('EED_Recaptcha', 'set_late_hooks'), 1, 0); |
|
64 | - add_action( |
|
65 | - 'AHEE__before_spco_whats_next_buttons', |
|
66 | - array('EED_Recaptcha', 'display_recaptcha'), |
|
67 | - 10, |
|
68 | - 0 |
|
69 | - ); |
|
70 | - add_filter( |
|
71 | - 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
|
72 | - array('EED_Recaptcha', 'not_a_robot') |
|
73 | - ); |
|
74 | - add_filter( |
|
75 | - 'FHEE__EE_SPCO_Reg_Step__set_completed___completed', |
|
76 | - array('EED_Recaptcha', 'not_a_robot') |
|
77 | - ); |
|
78 | - add_filter( |
|
79 | - 'FHEE__EE_SPCO_JSON_Response___toString__JSON_response', |
|
80 | - array('EED_Recaptcha', 'recaptcha_response') |
|
81 | - ); |
|
82 | - add_filter( |
|
83 | - 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
|
84 | - array('EED_Recaptcha', 'bypass_recaptcha_for_spco_load_payment_method') |
|
85 | - ); |
|
86 | - } |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
92 | - * |
|
93 | - * @return void |
|
94 | - * @throws InvalidArgumentException |
|
95 | - * @throws InvalidInterfaceException |
|
96 | - * @throws InvalidDataTypeException |
|
97 | - */ |
|
98 | - public static function set_hooks_admin() |
|
99 | - { |
|
100 | - EED_Recaptcha::$config = EE_Registry::instance()->CFG->registration; |
|
101 | - EED_Recaptcha::set_definitions(); |
|
102 | - // use_captcha ? |
|
103 | - if ( |
|
104 | - EED_Recaptcha::useRecaptcha() |
|
105 | - && EED_Recaptcha::notPaymentOptionsRevisit() |
|
106 | - && EED_Recaptcha::getRequest()->getRequestParam('step', '') !== '' |
|
107 | - ) { |
|
108 | - EED_Recaptcha::enqueue_styles_and_scripts(); |
|
109 | - add_filter( |
|
110 | - 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
|
111 | - array('EED_Recaptcha', 'not_a_robot') |
|
112 | - ); |
|
113 | - add_filter( |
|
114 | - 'FHEE__EE_SPCO_Reg_Step__set_completed___completed', |
|
115 | - array('EED_Recaptcha', 'not_a_robot') |
|
116 | - ); |
|
117 | - add_filter( |
|
118 | - 'FHEE__EE_SPCO_JSON_Response___toString__JSON_response', |
|
119 | - array('EED_Recaptcha', 'recaptcha_response') |
|
120 | - ); |
|
121 | - } |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * @return void |
|
127 | - */ |
|
128 | - public static function set_definitions() |
|
129 | - { |
|
130 | - if (is_user_logged_in()) { |
|
131 | - EED_Recaptcha::$_not_a_robot = true; |
|
132 | - } |
|
133 | - define( |
|
134 | - 'RECAPTCHA_BASE_PATH', |
|
135 | - rtrim(str_replace(array('\\', '/'), '/', plugin_dir_path(__FILE__)), '/') . '/' |
|
136 | - ); |
|
137 | - define('RECAPTCHA_BASE_URL', plugin_dir_url(__FILE__)); |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - /** |
|
142 | - * @return void |
|
143 | - */ |
|
144 | - public static function set_late_hooks() |
|
145 | - { |
|
146 | - add_filter( |
|
147 | - 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', |
|
148 | - array('EED_Recaptcha', 'not_a_robot') |
|
149 | - ); |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * @return boolean |
|
155 | - */ |
|
156 | - public static function useRecaptcha() |
|
157 | - { |
|
158 | - return EED_Recaptcha::$config->use_captcha |
|
159 | - && EED_Recaptcha::$config->recaptcha_theme !== 'invisible'; |
|
160 | - } |
|
161 | - |
|
162 | - |
|
163 | - /** |
|
164 | - * @return boolean |
|
165 | - * @throws InvalidArgumentException |
|
166 | - * @throws InvalidInterfaceException |
|
167 | - * @throws InvalidDataTypeException |
|
168 | - */ |
|
169 | - public static function notPaymentOptionsRevisit() |
|
170 | - { |
|
171 | - $request = EED_Recaptcha::getRequest(); |
|
172 | - return ! ( |
|
173 | - $request->getRequestParam('step', '') === 'payment_options' |
|
174 | - && $request->getRequestParam('revisit', false, 'bool') === true |
|
175 | - ); |
|
176 | - } |
|
177 | - |
|
178 | - |
|
179 | - /** |
|
180 | - * @return void |
|
181 | - * @throws InvalidArgumentException |
|
182 | - * @throws InvalidInterfaceException |
|
183 | - * @throws InvalidDataTypeException |
|
184 | - */ |
|
185 | - public static function enqueue_styles_and_scripts() |
|
186 | - { |
|
187 | - wp_register_script( |
|
188 | - 'espresso_recaptcha', |
|
189 | - RECAPTCHA_BASE_URL . 'scripts/espresso_recaptcha.js', |
|
190 | - array('single_page_checkout'), |
|
191 | - EVENT_ESPRESSO_VERSION, |
|
192 | - true |
|
193 | - ); |
|
194 | - wp_register_script( |
|
195 | - 'google_recaptcha', |
|
196 | - 'https://www.google.com/recaptcha/api.js?hl=' . EED_Recaptcha::$config->recaptcha_language, |
|
197 | - array('espresso_recaptcha'), |
|
198 | - EVENT_ESPRESSO_VERSION, |
|
199 | - true |
|
200 | - ); |
|
201 | - EE_Registry::$i18n_js_strings['no_SPCO_error'] = __( |
|
202 | - 'It appears the Single Page Checkout javascript was not loaded properly! Please refresh the page and try again or contact support.', |
|
203 | - 'event_espresso' |
|
204 | - ); |
|
205 | - EE_Registry::$i18n_js_strings['no_recaptcha_error'] = __( |
|
206 | - 'There appears to be a problem with the reCAPTCHA configuration! Please check the admin settings or contact support.', |
|
207 | - 'event_espresso' |
|
208 | - ); |
|
209 | - EE_Registry::$i18n_js_strings['recaptcha_fail'] = __( |
|
210 | - 'Please complete the anti-spam test before proceeding.', |
|
211 | - 'event_espresso' |
|
212 | - ); |
|
213 | - } |
|
214 | - |
|
215 | - |
|
216 | - /** |
|
217 | - * @param WP $WP |
|
218 | - */ |
|
219 | - public function run($WP) |
|
220 | - { |
|
221 | - } |
|
222 | - |
|
223 | - |
|
224 | - /** |
|
225 | - * @return boolean |
|
226 | - * @throws InvalidArgumentException |
|
227 | - * @throws InvalidInterfaceException |
|
228 | - * @throws InvalidDataTypeException |
|
229 | - */ |
|
230 | - public static function not_a_robot() |
|
231 | - { |
|
232 | - return is_bool(EED_Recaptcha::$_not_a_robot) |
|
233 | - ? EED_Recaptcha::$_not_a_robot |
|
234 | - : EED_Recaptcha::recaptcha_passed(); |
|
235 | - } |
|
236 | - |
|
237 | - |
|
238 | - /** |
|
239 | - * @return void |
|
240 | - * @throws DomainException |
|
241 | - * @throws InvalidArgumentException |
|
242 | - * @throws InvalidInterfaceException |
|
243 | - * @throws InvalidDataTypeException |
|
244 | - */ |
|
245 | - public static function display_recaptcha() |
|
246 | - { |
|
247 | - // logged in means you have already passed a turing test of sorts |
|
248 | - if (is_user_logged_in()) { |
|
249 | - return; |
|
250 | - } |
|
251 | - // don't display if not using recaptcha or user is logged in |
|
252 | - if (EED_Recaptcha::useRecaptcha() && ! EED_Recaptcha::$_not_a_robot) { |
|
253 | - // only display if they have NOT passed the test yet |
|
254 | - EEH_Template::display_template( |
|
255 | - RECAPTCHA_BASE_PATH . '/templates/recaptcha.template.php', |
|
256 | - array( |
|
257 | - 'recaptcha_publickey' => EED_Recaptcha::$config->recaptcha_publickey, |
|
258 | - 'recaptcha_theme' => EED_Recaptcha::$config->recaptcha_theme, |
|
259 | - 'recaptcha_type' => EED_Recaptcha::$config->recaptcha_type, |
|
260 | - ) |
|
261 | - ); |
|
262 | - wp_enqueue_script('google_recaptcha'); |
|
263 | - } |
|
264 | - } |
|
265 | - |
|
266 | - |
|
267 | - /** |
|
268 | - * @return array |
|
269 | - * @throws InvalidArgumentException |
|
270 | - * @throws InvalidInterfaceException |
|
271 | - * @throws InvalidDataTypeException |
|
272 | - */ |
|
273 | - public static function bypass_recaptcha_for_spco_load_payment_method() |
|
274 | - { |
|
275 | - return array( |
|
276 | - 'EESID' => EE_Registry::instance()->SSN->id(), |
|
277 | - 'step' => 'payment_options', |
|
278 | - 'action' => 'switch_spco_billing_form', |
|
279 | - ); |
|
280 | - } |
|
281 | - |
|
282 | - |
|
283 | - /** |
|
284 | - * @return boolean |
|
285 | - * @throws InvalidArgumentException |
|
286 | - * @throws InvalidInterfaceException |
|
287 | - * @throws InvalidDataTypeException |
|
288 | - */ |
|
289 | - public static function recaptcha_passed() |
|
290 | - { |
|
291 | - // logged in means you have already passed a turing test of sorts |
|
292 | - if (is_user_logged_in() || EED_Recaptcha::_bypass_recaptcha()) { |
|
293 | - return true; |
|
294 | - } |
|
295 | - // was test already passed? |
|
296 | - $recaptcha_passed = EE_Registry::instance()->SSN->get_session_data('recaptcha_passed'); |
|
297 | - $recaptcha_passed = filter_var($recaptcha_passed, FILTER_VALIDATE_BOOLEAN); |
|
298 | - // verify recaptcha |
|
299 | - EED_Recaptcha::_get_recaptcha_response(); |
|
300 | - if (! $recaptcha_passed && EED_Recaptcha::$_recaptcha_response) { |
|
301 | - $recaptcha_passed = EED_Recaptcha::_process_recaptcha_response(); |
|
302 | - EE_Registry::instance()->SSN->set_session_data(array('recaptcha_passed' => $recaptcha_passed)); |
|
303 | - } |
|
304 | - EED_Recaptcha::$_not_a_robot = $recaptcha_passed; |
|
305 | - return $recaptcha_passed; |
|
306 | - } |
|
307 | - |
|
308 | - |
|
309 | - /** |
|
310 | - * @param array $recaptcha_response |
|
311 | - * @return array |
|
312 | - */ |
|
313 | - public static function recaptcha_response($recaptcha_response = array()) |
|
314 | - { |
|
315 | - if (EED_Recaptcha::_bypass_recaptcha()) { |
|
316 | - $recaptcha_response['bypass_recaptcha'] = true; |
|
317 | - $recaptcha_response['recaptcha_passed'] = true; |
|
318 | - } else { |
|
319 | - $recaptcha_response['recaptcha_passed'] = EED_Recaptcha::$_not_a_robot; |
|
320 | - } |
|
321 | - return $recaptcha_response; |
|
322 | - } |
|
323 | - |
|
324 | - |
|
325 | - /** |
|
326 | - * @return boolean |
|
327 | - */ |
|
328 | - private static function _bypass_recaptcha() |
|
329 | - { |
|
330 | - // an array of key value pairs that must match exactly with the incoming request, |
|
331 | - // in order to bypass recaptcha for the current request ONLY |
|
332 | - $bypass_request_params_array = (array) apply_filters( |
|
333 | - 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
|
334 | - array() |
|
335 | - ); |
|
336 | - // does $bypass_request_params_array have any values ? |
|
337 | - if (empty($bypass_request_params_array)) { |
|
338 | - return false; |
|
339 | - } |
|
340 | - $request = EED_Recaptcha::getRequest(); |
|
341 | - // initially set bypass to TRUE |
|
342 | - $bypass_recaptcha = true; |
|
343 | - foreach ($bypass_request_params_array as $key => $value) { |
|
344 | - // if $key is not found or value doesn't match exactly, then toggle bypass to FALSE, |
|
345 | - // otherwise carry over it's value. This way, one missed setting results in no bypass |
|
346 | - $bypass_recaptcha = $request->getRequestParam($key) === $value |
|
347 | - ? $bypass_recaptcha |
|
348 | - : false; |
|
349 | - } |
|
350 | - return $bypass_recaptcha; |
|
351 | - } |
|
352 | - |
|
353 | - |
|
354 | - /** |
|
355 | - * @return void |
|
356 | - * @throws InvalidArgumentException |
|
357 | - * @throws InvalidInterfaceException |
|
358 | - * @throws InvalidDataTypeException |
|
359 | - */ |
|
360 | - private static function _get_recaptcha_response() |
|
361 | - { |
|
362 | - EED_Recaptcha::$_recaptcha_response = EED_Recaptcha::getRequest()->getRequestParam( |
|
363 | - 'g-recaptcha-response' |
|
364 | - ); |
|
365 | - } |
|
366 | - |
|
367 | - |
|
368 | - /** |
|
369 | - * @return boolean |
|
370 | - * @throws InvalidArgumentException |
|
371 | - * @throws InvalidInterfaceException |
|
372 | - * @throws InvalidDataTypeException |
|
373 | - */ |
|
374 | - private static function _process_recaptcha_response() |
|
375 | - { |
|
376 | - // verify library is loaded |
|
377 | - if (! class_exists('\ReCaptcha\ReCaptcha')) { |
|
378 | - require_once RECAPTCHA_BASE_PATH . '/autoload.php'; |
|
379 | - } |
|
380 | - // The response from reCAPTCHA |
|
381 | - EED_Recaptcha::_get_recaptcha_response(); |
|
382 | - $recaptcha_response = EED_Recaptcha::$_recaptcha_response; |
|
383 | - // Was there a reCAPTCHA response? |
|
384 | - if ($recaptcha_response) { |
|
385 | - // if allow_url_fopen is Off, then set a different request method |
|
386 | - $request_method = ! ini_get('allow_url_fopen') ? new SocketPost() : null; |
|
387 | - $recaptcha = new ReCaptcha( |
|
388 | - EED_Recaptcha::$config->recaptcha_privatekey, |
|
389 | - $request_method |
|
390 | - ); |
|
391 | - $recaptcha_response = $recaptcha->verify( |
|
392 | - EED_Recaptcha::$_recaptcha_response, |
|
393 | - EED_Recaptcha::getRequest()->getServerParam('REMOTE_ADDR') |
|
394 | - ); |
|
395 | - } |
|
396 | - return $recaptcha_response instanceof Response && $recaptcha_response->isSuccess(); |
|
397 | - } |
|
20 | + /** |
|
21 | + * @var EE_Registration_Config $config |
|
22 | + */ |
|
23 | + private static $config; |
|
24 | + |
|
25 | + /** |
|
26 | + * @type bool $_not_a_robot |
|
27 | + */ |
|
28 | + private static $_not_a_robot; |
|
29 | + |
|
30 | + /** |
|
31 | + * @type string $_recaptcha_response |
|
32 | + */ |
|
33 | + private static $_recaptcha_response; |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * @return EED_Module|EED_Recaptcha |
|
38 | + */ |
|
39 | + public static function instance() |
|
40 | + { |
|
41 | + return parent::get_instance(__CLASS__); |
|
42 | + } |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
47 | + * |
|
48 | + * @return void |
|
49 | + * @throws InvalidArgumentException |
|
50 | + * @throws InvalidInterfaceException |
|
51 | + * @throws InvalidDataTypeException |
|
52 | + */ |
|
53 | + public static function set_hooks() |
|
54 | + { |
|
55 | + EED_Recaptcha::$config = EE_Registry::instance()->CFG->registration; |
|
56 | + // use_captcha ? |
|
57 | + if ( |
|
58 | + EED_Recaptcha::useRecaptcha() |
|
59 | + && EED_Recaptcha::notPaymentOptionsRevisit() |
|
60 | + ) { |
|
61 | + EED_Recaptcha::set_definitions(); |
|
62 | + EED_Recaptcha::enqueue_styles_and_scripts(); |
|
63 | + add_action('wp', array('EED_Recaptcha', 'set_late_hooks'), 1, 0); |
|
64 | + add_action( |
|
65 | + 'AHEE__before_spco_whats_next_buttons', |
|
66 | + array('EED_Recaptcha', 'display_recaptcha'), |
|
67 | + 10, |
|
68 | + 0 |
|
69 | + ); |
|
70 | + add_filter( |
|
71 | + 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
|
72 | + array('EED_Recaptcha', 'not_a_robot') |
|
73 | + ); |
|
74 | + add_filter( |
|
75 | + 'FHEE__EE_SPCO_Reg_Step__set_completed___completed', |
|
76 | + array('EED_Recaptcha', 'not_a_robot') |
|
77 | + ); |
|
78 | + add_filter( |
|
79 | + 'FHEE__EE_SPCO_JSON_Response___toString__JSON_response', |
|
80 | + array('EED_Recaptcha', 'recaptcha_response') |
|
81 | + ); |
|
82 | + add_filter( |
|
83 | + 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
|
84 | + array('EED_Recaptcha', 'bypass_recaptcha_for_spco_load_payment_method') |
|
85 | + ); |
|
86 | + } |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
92 | + * |
|
93 | + * @return void |
|
94 | + * @throws InvalidArgumentException |
|
95 | + * @throws InvalidInterfaceException |
|
96 | + * @throws InvalidDataTypeException |
|
97 | + */ |
|
98 | + public static function set_hooks_admin() |
|
99 | + { |
|
100 | + EED_Recaptcha::$config = EE_Registry::instance()->CFG->registration; |
|
101 | + EED_Recaptcha::set_definitions(); |
|
102 | + // use_captcha ? |
|
103 | + if ( |
|
104 | + EED_Recaptcha::useRecaptcha() |
|
105 | + && EED_Recaptcha::notPaymentOptionsRevisit() |
|
106 | + && EED_Recaptcha::getRequest()->getRequestParam('step', '') !== '' |
|
107 | + ) { |
|
108 | + EED_Recaptcha::enqueue_styles_and_scripts(); |
|
109 | + add_filter( |
|
110 | + 'FHEE__EED_Single_Page_Checkout__init___continue_reg', |
|
111 | + array('EED_Recaptcha', 'not_a_robot') |
|
112 | + ); |
|
113 | + add_filter( |
|
114 | + 'FHEE__EE_SPCO_Reg_Step__set_completed___completed', |
|
115 | + array('EED_Recaptcha', 'not_a_robot') |
|
116 | + ); |
|
117 | + add_filter( |
|
118 | + 'FHEE__EE_SPCO_JSON_Response___toString__JSON_response', |
|
119 | + array('EED_Recaptcha', 'recaptcha_response') |
|
120 | + ); |
|
121 | + } |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * @return void |
|
127 | + */ |
|
128 | + public static function set_definitions() |
|
129 | + { |
|
130 | + if (is_user_logged_in()) { |
|
131 | + EED_Recaptcha::$_not_a_robot = true; |
|
132 | + } |
|
133 | + define( |
|
134 | + 'RECAPTCHA_BASE_PATH', |
|
135 | + rtrim(str_replace(array('\\', '/'), '/', plugin_dir_path(__FILE__)), '/') . '/' |
|
136 | + ); |
|
137 | + define('RECAPTCHA_BASE_URL', plugin_dir_url(__FILE__)); |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + /** |
|
142 | + * @return void |
|
143 | + */ |
|
144 | + public static function set_late_hooks() |
|
145 | + { |
|
146 | + add_filter( |
|
147 | + 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', |
|
148 | + array('EED_Recaptcha', 'not_a_robot') |
|
149 | + ); |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * @return boolean |
|
155 | + */ |
|
156 | + public static function useRecaptcha() |
|
157 | + { |
|
158 | + return EED_Recaptcha::$config->use_captcha |
|
159 | + && EED_Recaptcha::$config->recaptcha_theme !== 'invisible'; |
|
160 | + } |
|
161 | + |
|
162 | + |
|
163 | + /** |
|
164 | + * @return boolean |
|
165 | + * @throws InvalidArgumentException |
|
166 | + * @throws InvalidInterfaceException |
|
167 | + * @throws InvalidDataTypeException |
|
168 | + */ |
|
169 | + public static function notPaymentOptionsRevisit() |
|
170 | + { |
|
171 | + $request = EED_Recaptcha::getRequest(); |
|
172 | + return ! ( |
|
173 | + $request->getRequestParam('step', '') === 'payment_options' |
|
174 | + && $request->getRequestParam('revisit', false, 'bool') === true |
|
175 | + ); |
|
176 | + } |
|
177 | + |
|
178 | + |
|
179 | + /** |
|
180 | + * @return void |
|
181 | + * @throws InvalidArgumentException |
|
182 | + * @throws InvalidInterfaceException |
|
183 | + * @throws InvalidDataTypeException |
|
184 | + */ |
|
185 | + public static function enqueue_styles_and_scripts() |
|
186 | + { |
|
187 | + wp_register_script( |
|
188 | + 'espresso_recaptcha', |
|
189 | + RECAPTCHA_BASE_URL . 'scripts/espresso_recaptcha.js', |
|
190 | + array('single_page_checkout'), |
|
191 | + EVENT_ESPRESSO_VERSION, |
|
192 | + true |
|
193 | + ); |
|
194 | + wp_register_script( |
|
195 | + 'google_recaptcha', |
|
196 | + 'https://www.google.com/recaptcha/api.js?hl=' . EED_Recaptcha::$config->recaptcha_language, |
|
197 | + array('espresso_recaptcha'), |
|
198 | + EVENT_ESPRESSO_VERSION, |
|
199 | + true |
|
200 | + ); |
|
201 | + EE_Registry::$i18n_js_strings['no_SPCO_error'] = __( |
|
202 | + 'It appears the Single Page Checkout javascript was not loaded properly! Please refresh the page and try again or contact support.', |
|
203 | + 'event_espresso' |
|
204 | + ); |
|
205 | + EE_Registry::$i18n_js_strings['no_recaptcha_error'] = __( |
|
206 | + 'There appears to be a problem with the reCAPTCHA configuration! Please check the admin settings or contact support.', |
|
207 | + 'event_espresso' |
|
208 | + ); |
|
209 | + EE_Registry::$i18n_js_strings['recaptcha_fail'] = __( |
|
210 | + 'Please complete the anti-spam test before proceeding.', |
|
211 | + 'event_espresso' |
|
212 | + ); |
|
213 | + } |
|
214 | + |
|
215 | + |
|
216 | + /** |
|
217 | + * @param WP $WP |
|
218 | + */ |
|
219 | + public function run($WP) |
|
220 | + { |
|
221 | + } |
|
222 | + |
|
223 | + |
|
224 | + /** |
|
225 | + * @return boolean |
|
226 | + * @throws InvalidArgumentException |
|
227 | + * @throws InvalidInterfaceException |
|
228 | + * @throws InvalidDataTypeException |
|
229 | + */ |
|
230 | + public static function not_a_robot() |
|
231 | + { |
|
232 | + return is_bool(EED_Recaptcha::$_not_a_robot) |
|
233 | + ? EED_Recaptcha::$_not_a_robot |
|
234 | + : EED_Recaptcha::recaptcha_passed(); |
|
235 | + } |
|
236 | + |
|
237 | + |
|
238 | + /** |
|
239 | + * @return void |
|
240 | + * @throws DomainException |
|
241 | + * @throws InvalidArgumentException |
|
242 | + * @throws InvalidInterfaceException |
|
243 | + * @throws InvalidDataTypeException |
|
244 | + */ |
|
245 | + public static function display_recaptcha() |
|
246 | + { |
|
247 | + // logged in means you have already passed a turing test of sorts |
|
248 | + if (is_user_logged_in()) { |
|
249 | + return; |
|
250 | + } |
|
251 | + // don't display if not using recaptcha or user is logged in |
|
252 | + if (EED_Recaptcha::useRecaptcha() && ! EED_Recaptcha::$_not_a_robot) { |
|
253 | + // only display if they have NOT passed the test yet |
|
254 | + EEH_Template::display_template( |
|
255 | + RECAPTCHA_BASE_PATH . '/templates/recaptcha.template.php', |
|
256 | + array( |
|
257 | + 'recaptcha_publickey' => EED_Recaptcha::$config->recaptcha_publickey, |
|
258 | + 'recaptcha_theme' => EED_Recaptcha::$config->recaptcha_theme, |
|
259 | + 'recaptcha_type' => EED_Recaptcha::$config->recaptcha_type, |
|
260 | + ) |
|
261 | + ); |
|
262 | + wp_enqueue_script('google_recaptcha'); |
|
263 | + } |
|
264 | + } |
|
265 | + |
|
266 | + |
|
267 | + /** |
|
268 | + * @return array |
|
269 | + * @throws InvalidArgumentException |
|
270 | + * @throws InvalidInterfaceException |
|
271 | + * @throws InvalidDataTypeException |
|
272 | + */ |
|
273 | + public static function bypass_recaptcha_for_spco_load_payment_method() |
|
274 | + { |
|
275 | + return array( |
|
276 | + 'EESID' => EE_Registry::instance()->SSN->id(), |
|
277 | + 'step' => 'payment_options', |
|
278 | + 'action' => 'switch_spco_billing_form', |
|
279 | + ); |
|
280 | + } |
|
281 | + |
|
282 | + |
|
283 | + /** |
|
284 | + * @return boolean |
|
285 | + * @throws InvalidArgumentException |
|
286 | + * @throws InvalidInterfaceException |
|
287 | + * @throws InvalidDataTypeException |
|
288 | + */ |
|
289 | + public static function recaptcha_passed() |
|
290 | + { |
|
291 | + // logged in means you have already passed a turing test of sorts |
|
292 | + if (is_user_logged_in() || EED_Recaptcha::_bypass_recaptcha()) { |
|
293 | + return true; |
|
294 | + } |
|
295 | + // was test already passed? |
|
296 | + $recaptcha_passed = EE_Registry::instance()->SSN->get_session_data('recaptcha_passed'); |
|
297 | + $recaptcha_passed = filter_var($recaptcha_passed, FILTER_VALIDATE_BOOLEAN); |
|
298 | + // verify recaptcha |
|
299 | + EED_Recaptcha::_get_recaptcha_response(); |
|
300 | + if (! $recaptcha_passed && EED_Recaptcha::$_recaptcha_response) { |
|
301 | + $recaptcha_passed = EED_Recaptcha::_process_recaptcha_response(); |
|
302 | + EE_Registry::instance()->SSN->set_session_data(array('recaptcha_passed' => $recaptcha_passed)); |
|
303 | + } |
|
304 | + EED_Recaptcha::$_not_a_robot = $recaptcha_passed; |
|
305 | + return $recaptcha_passed; |
|
306 | + } |
|
307 | + |
|
308 | + |
|
309 | + /** |
|
310 | + * @param array $recaptcha_response |
|
311 | + * @return array |
|
312 | + */ |
|
313 | + public static function recaptcha_response($recaptcha_response = array()) |
|
314 | + { |
|
315 | + if (EED_Recaptcha::_bypass_recaptcha()) { |
|
316 | + $recaptcha_response['bypass_recaptcha'] = true; |
|
317 | + $recaptcha_response['recaptcha_passed'] = true; |
|
318 | + } else { |
|
319 | + $recaptcha_response['recaptcha_passed'] = EED_Recaptcha::$_not_a_robot; |
|
320 | + } |
|
321 | + return $recaptcha_response; |
|
322 | + } |
|
323 | + |
|
324 | + |
|
325 | + /** |
|
326 | + * @return boolean |
|
327 | + */ |
|
328 | + private static function _bypass_recaptcha() |
|
329 | + { |
|
330 | + // an array of key value pairs that must match exactly with the incoming request, |
|
331 | + // in order to bypass recaptcha for the current request ONLY |
|
332 | + $bypass_request_params_array = (array) apply_filters( |
|
333 | + 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', |
|
334 | + array() |
|
335 | + ); |
|
336 | + // does $bypass_request_params_array have any values ? |
|
337 | + if (empty($bypass_request_params_array)) { |
|
338 | + return false; |
|
339 | + } |
|
340 | + $request = EED_Recaptcha::getRequest(); |
|
341 | + // initially set bypass to TRUE |
|
342 | + $bypass_recaptcha = true; |
|
343 | + foreach ($bypass_request_params_array as $key => $value) { |
|
344 | + // if $key is not found or value doesn't match exactly, then toggle bypass to FALSE, |
|
345 | + // otherwise carry over it's value. This way, one missed setting results in no bypass |
|
346 | + $bypass_recaptcha = $request->getRequestParam($key) === $value |
|
347 | + ? $bypass_recaptcha |
|
348 | + : false; |
|
349 | + } |
|
350 | + return $bypass_recaptcha; |
|
351 | + } |
|
352 | + |
|
353 | + |
|
354 | + /** |
|
355 | + * @return void |
|
356 | + * @throws InvalidArgumentException |
|
357 | + * @throws InvalidInterfaceException |
|
358 | + * @throws InvalidDataTypeException |
|
359 | + */ |
|
360 | + private static function _get_recaptcha_response() |
|
361 | + { |
|
362 | + EED_Recaptcha::$_recaptcha_response = EED_Recaptcha::getRequest()->getRequestParam( |
|
363 | + 'g-recaptcha-response' |
|
364 | + ); |
|
365 | + } |
|
366 | + |
|
367 | + |
|
368 | + /** |
|
369 | + * @return boolean |
|
370 | + * @throws InvalidArgumentException |
|
371 | + * @throws InvalidInterfaceException |
|
372 | + * @throws InvalidDataTypeException |
|
373 | + */ |
|
374 | + private static function _process_recaptcha_response() |
|
375 | + { |
|
376 | + // verify library is loaded |
|
377 | + if (! class_exists('\ReCaptcha\ReCaptcha')) { |
|
378 | + require_once RECAPTCHA_BASE_PATH . '/autoload.php'; |
|
379 | + } |
|
380 | + // The response from reCAPTCHA |
|
381 | + EED_Recaptcha::_get_recaptcha_response(); |
|
382 | + $recaptcha_response = EED_Recaptcha::$_recaptcha_response; |
|
383 | + // Was there a reCAPTCHA response? |
|
384 | + if ($recaptcha_response) { |
|
385 | + // if allow_url_fopen is Off, then set a different request method |
|
386 | + $request_method = ! ini_get('allow_url_fopen') ? new SocketPost() : null; |
|
387 | + $recaptcha = new ReCaptcha( |
|
388 | + EED_Recaptcha::$config->recaptcha_privatekey, |
|
389 | + $request_method |
|
390 | + ); |
|
391 | + $recaptcha_response = $recaptcha->verify( |
|
392 | + EED_Recaptcha::$_recaptcha_response, |
|
393 | + EED_Recaptcha::getRequest()->getServerParam('REMOTE_ADDR') |
|
394 | + ); |
|
395 | + } |
|
396 | + return $recaptcha_response instanceof Response && $recaptcha_response->isSuccess(); |
|
397 | + } |
|
398 | 398 | } |
@@ -38,8 +38,8 @@ |
||
38 | 38 | { |
39 | 39 | return [ |
40 | 40 | 'fromType' => 'RootQuery', |
41 | - 'toType' => $this->namespace . 'State', |
|
42 | - 'fromFieldName' => lcfirst($this->namespace) . 'States', |
|
41 | + 'toType' => $this->namespace.'State', |
|
42 | + 'fromFieldName' => lcfirst($this->namespace).'States', |
|
43 | 43 | 'connectionTypeName' => "{$this->namespace}RootQueryStatesConnection", |
44 | 44 | 'connectionArgs' => self::get_connection_args(), |
45 | 45 | 'resolve' => [$this, 'resolveConnection'], |
@@ -18,95 +18,95 @@ |
||
18 | 18 | */ |
19 | 19 | class RootQueryStatesConnection extends AbstractRootQueryConnection |
20 | 20 | { |
21 | - /** |
|
22 | - * StateConnection constructor. |
|
23 | - * |
|
24 | - * @param EEM_State $model |
|
25 | - */ |
|
26 | - public function __construct(EEM_State $model) |
|
27 | - { |
|
28 | - parent::__construct($model); |
|
29 | - } |
|
21 | + /** |
|
22 | + * StateConnection constructor. |
|
23 | + * |
|
24 | + * @param EEM_State $model |
|
25 | + */ |
|
26 | + public function __construct(EEM_State $model) |
|
27 | + { |
|
28 | + parent::__construct($model); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * @return array |
|
34 | - */ |
|
35 | - public function config(): array |
|
36 | - { |
|
37 | - return [ |
|
38 | - 'fromType' => 'RootQuery', |
|
39 | - 'toType' => $this->namespace . 'State', |
|
40 | - 'fromFieldName' => lcfirst($this->namespace) . 'States', |
|
41 | - 'connectionTypeName' => "{$this->namespace}RootQueryStatesConnection", |
|
42 | - 'connectionArgs' => self::get_connection_args(), |
|
43 | - 'resolve' => [$this, 'resolveConnection'], |
|
44 | - ]; |
|
45 | - } |
|
32 | + /** |
|
33 | + * @return array |
|
34 | + */ |
|
35 | + public function config(): array |
|
36 | + { |
|
37 | + return [ |
|
38 | + 'fromType' => 'RootQuery', |
|
39 | + 'toType' => $this->namespace . 'State', |
|
40 | + 'fromFieldName' => lcfirst($this->namespace) . 'States', |
|
41 | + 'connectionTypeName' => "{$this->namespace}RootQueryStatesConnection", |
|
42 | + 'connectionArgs' => self::get_connection_args(), |
|
43 | + 'resolve' => [$this, 'resolveConnection'], |
|
44 | + ]; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * @param $entity |
|
50 | - * @param $args |
|
51 | - * @param $context |
|
52 | - * @param $info |
|
53 | - * @return StateConnectionResolver |
|
54 | - * @throws Exception |
|
55 | - */ |
|
56 | - public function getConnectionResolver($entity, $args, $context, $info): AbstractConnectionResolver |
|
57 | - { |
|
58 | - return new StateConnectionResolver($entity, $args, $context, $info); |
|
59 | - } |
|
48 | + /** |
|
49 | + * @param $entity |
|
50 | + * @param $args |
|
51 | + * @param $context |
|
52 | + * @param $info |
|
53 | + * @return StateConnectionResolver |
|
54 | + * @throws Exception |
|
55 | + */ |
|
56 | + public function getConnectionResolver($entity, $args, $context, $info): AbstractConnectionResolver |
|
57 | + { |
|
58 | + return new StateConnectionResolver($entity, $args, $context, $info); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Given an optional array of args, this returns the args to be used in the connection |
|
63 | - * |
|
64 | - * @param array $args The args to modify the defaults |
|
65 | - * @return array |
|
66 | - */ |
|
67 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
68 | - public static function get_connection_args(array $args = []): array |
|
69 | - { |
|
70 | - $newArgs = [ |
|
71 | - 'orderby' => [ |
|
72 | - 'type' => ['list_of' => 'EspressoCountriesConnectionOrderbyInput'], |
|
73 | - 'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), |
|
74 | - ], |
|
75 | - 'in' => [ |
|
76 | - 'type' => ['list_of' => 'ID'], |
|
77 | - 'description' => esc_html__( |
|
78 | - 'Limit the result to the set of given state IDs.', |
|
79 | - 'event_espresso' |
|
80 | - ), |
|
81 | - ], |
|
82 | - 'countryIsoIn' => [ |
|
83 | - 'type' => ['list_of' => 'String'], |
|
84 | - 'description' => esc_html__( |
|
85 | - 'Limit the result to the set of given country ISOs.', |
|
86 | - 'event_espresso' |
|
87 | - ), |
|
88 | - ], |
|
89 | - 'search' => [ |
|
90 | - 'type' => 'String', |
|
91 | - 'description' => esc_html__('The search keywords', 'event_espresso'), |
|
92 | - ], |
|
93 | - 'activeOnly' => [ |
|
94 | - 'type' => 'Boolean', |
|
95 | - 'description' => esc_html__( |
|
96 | - 'Limit the result to the active states.', |
|
97 | - 'event_espresso' |
|
98 | - ), |
|
99 | - ], |
|
100 | - ]; |
|
61 | + /** |
|
62 | + * Given an optional array of args, this returns the args to be used in the connection |
|
63 | + * |
|
64 | + * @param array $args The args to modify the defaults |
|
65 | + * @return array |
|
66 | + */ |
|
67 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
68 | + public static function get_connection_args(array $args = []): array |
|
69 | + { |
|
70 | + $newArgs = [ |
|
71 | + 'orderby' => [ |
|
72 | + 'type' => ['list_of' => 'EspressoCountriesConnectionOrderbyInput'], |
|
73 | + 'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), |
|
74 | + ], |
|
75 | + 'in' => [ |
|
76 | + 'type' => ['list_of' => 'ID'], |
|
77 | + 'description' => esc_html__( |
|
78 | + 'Limit the result to the set of given state IDs.', |
|
79 | + 'event_espresso' |
|
80 | + ), |
|
81 | + ], |
|
82 | + 'countryIsoIn' => [ |
|
83 | + 'type' => ['list_of' => 'String'], |
|
84 | + 'description' => esc_html__( |
|
85 | + 'Limit the result to the set of given country ISOs.', |
|
86 | + 'event_espresso' |
|
87 | + ), |
|
88 | + ], |
|
89 | + 'search' => [ |
|
90 | + 'type' => 'String', |
|
91 | + 'description' => esc_html__('The search keywords', 'event_espresso'), |
|
92 | + ], |
|
93 | + 'activeOnly' => [ |
|
94 | + 'type' => 'Boolean', |
|
95 | + 'description' => esc_html__( |
|
96 | + 'Limit the result to the active states.', |
|
97 | + 'event_espresso' |
|
98 | + ), |
|
99 | + ], |
|
100 | + ]; |
|
101 | 101 | |
102 | - $newArgs = apply_filters( |
|
103 | - 'FHEE__EventEspresso_core_domain_services_graphql_connections__state_args', |
|
104 | - $newArgs, |
|
105 | - $args |
|
106 | - ); |
|
107 | - return array_merge( |
|
108 | - $newArgs, |
|
109 | - $args |
|
110 | - ); |
|
111 | - } |
|
102 | + $newArgs = apply_filters( |
|
103 | + 'FHEE__EventEspresso_core_domain_services_graphql_connections__state_args', |
|
104 | + $newArgs, |
|
105 | + $args |
|
106 | + ); |
|
107 | + return array_merge( |
|
108 | + $newArgs, |
|
109 | + $args |
|
110 | + ); |
|
111 | + } |
|
112 | 112 | } |
@@ -38,8 +38,8 @@ |
||
38 | 38 | { |
39 | 39 | return [ |
40 | 40 | 'fromType' => 'RootQuery', |
41 | - 'toType' => $this->namespace . 'Country', |
|
42 | - 'fromFieldName' => lcfirst($this->namespace . 'Countries'), |
|
41 | + 'toType' => $this->namespace.'Country', |
|
42 | + 'fromFieldName' => lcfirst($this->namespace.'Countries'), |
|
43 | 43 | 'connectionTypeName' => "{$this->namespace}RootQueryCountriesConnection", |
44 | 44 | 'connectionArgs' => RootQueryCountriesConnection::get_connection_args(), |
45 | 45 | 'resolve' => [$this, 'resolveConnection'], |
@@ -18,105 +18,105 @@ |
||
18 | 18 | */ |
19 | 19 | class RootQueryCountriesConnection extends AbstractRootQueryConnection |
20 | 20 | { |
21 | - /** |
|
22 | - * CountryConnection constructor. |
|
23 | - * |
|
24 | - * @param EEM_Country $model |
|
25 | - */ |
|
26 | - public function __construct(EEM_Country $model) |
|
27 | - { |
|
28 | - parent::__construct($model); |
|
29 | - } |
|
21 | + /** |
|
22 | + * CountryConnection constructor. |
|
23 | + * |
|
24 | + * @param EEM_Country $model |
|
25 | + */ |
|
26 | + public function __construct(EEM_Country $model) |
|
27 | + { |
|
28 | + parent::__construct($model); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * @return array |
|
34 | - */ |
|
35 | - public function config(): array |
|
36 | - { |
|
37 | - return [ |
|
38 | - 'fromType' => 'RootQuery', |
|
39 | - 'toType' => $this->namespace . 'Country', |
|
40 | - 'fromFieldName' => lcfirst($this->namespace . 'Countries'), |
|
41 | - 'connectionTypeName' => "{$this->namespace}RootQueryCountriesConnection", |
|
42 | - 'connectionArgs' => RootQueryCountriesConnection::get_connection_args(), |
|
43 | - 'resolve' => [$this, 'resolveConnection'], |
|
44 | - ]; |
|
45 | - } |
|
32 | + /** |
|
33 | + * @return array |
|
34 | + */ |
|
35 | + public function config(): array |
|
36 | + { |
|
37 | + return [ |
|
38 | + 'fromType' => 'RootQuery', |
|
39 | + 'toType' => $this->namespace . 'Country', |
|
40 | + 'fromFieldName' => lcfirst($this->namespace . 'Countries'), |
|
41 | + 'connectionTypeName' => "{$this->namespace}RootQueryCountriesConnection", |
|
42 | + 'connectionArgs' => RootQueryCountriesConnection::get_connection_args(), |
|
43 | + 'resolve' => [$this, 'resolveConnection'], |
|
44 | + ]; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * @param $entity |
|
50 | - * @param $args |
|
51 | - * @param $context |
|
52 | - * @param $info |
|
53 | - * @return CountryConnectionResolver |
|
54 | - * @throws Exception |
|
55 | - */ |
|
56 | - public function getConnectionResolver($entity, $args, $context, $info): AbstractConnectionResolver |
|
57 | - { |
|
58 | - return new CountryConnectionResolver($entity, $args, $context, $info); |
|
59 | - } |
|
48 | + /** |
|
49 | + * @param $entity |
|
50 | + * @param $args |
|
51 | + * @param $context |
|
52 | + * @param $info |
|
53 | + * @return CountryConnectionResolver |
|
54 | + * @throws Exception |
|
55 | + */ |
|
56 | + public function getConnectionResolver($entity, $args, $context, $info): AbstractConnectionResolver |
|
57 | + { |
|
58 | + return new CountryConnectionResolver($entity, $args, $context, $info); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Given an optional array of args, this returns the args to be used in the connection |
|
63 | - * |
|
64 | - * @param array $args The args to modify the defaults |
|
65 | - * @return array |
|
66 | - */ |
|
67 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
68 | - public static function get_connection_args(array $args = []): array |
|
69 | - { |
|
70 | - $newArgs = [ |
|
71 | - 'orderby' => [ |
|
72 | - 'type' => ['list_of' => 'EspressoCountriesConnectionOrderbyInput'], |
|
73 | - 'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), |
|
74 | - ], |
|
75 | - 'in' => [ |
|
76 | - 'type' => ['list_of' => 'ID'], |
|
77 | - 'description' => esc_html__( |
|
78 | - 'Limit the result to the set of given country IDs.', |
|
79 | - 'event_espresso' |
|
80 | - ), |
|
81 | - ], |
|
82 | - 'isoIn' => [ |
|
83 | - 'type' => ['list_of' => 'String'], |
|
84 | - 'description' => esc_html__( |
|
85 | - 'Limit the result to the set of given country ISOs.', |
|
86 | - 'event_espresso' |
|
87 | - ), |
|
88 | - ], |
|
89 | - 'iso3In' => [ |
|
90 | - 'type' => ['list_of' => 'String'], |
|
91 | - 'description' => esc_html__( |
|
92 | - 'Limit the result to the set of given country ISO3s.', |
|
93 | - 'event_espresso' |
|
94 | - ), |
|
95 | - ], |
|
96 | - 'search' => [ |
|
97 | - 'type' => 'String', |
|
98 | - 'description' => esc_html__( |
|
99 | - 'Limit the result to the given search query.', |
|
100 | - 'event_espresso' |
|
101 | - ), |
|
102 | - ], |
|
103 | - 'activeOnly' => [ |
|
104 | - 'type' => 'Boolean', |
|
105 | - 'description' => esc_html__( |
|
106 | - 'Limit the result to the active countries.', |
|
107 | - 'event_espresso' |
|
108 | - ), |
|
109 | - ], |
|
110 | - ]; |
|
61 | + /** |
|
62 | + * Given an optional array of args, this returns the args to be used in the connection |
|
63 | + * |
|
64 | + * @param array $args The args to modify the defaults |
|
65 | + * @return array |
|
66 | + */ |
|
67 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
68 | + public static function get_connection_args(array $args = []): array |
|
69 | + { |
|
70 | + $newArgs = [ |
|
71 | + 'orderby' => [ |
|
72 | + 'type' => ['list_of' => 'EspressoCountriesConnectionOrderbyInput'], |
|
73 | + 'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), |
|
74 | + ], |
|
75 | + 'in' => [ |
|
76 | + 'type' => ['list_of' => 'ID'], |
|
77 | + 'description' => esc_html__( |
|
78 | + 'Limit the result to the set of given country IDs.', |
|
79 | + 'event_espresso' |
|
80 | + ), |
|
81 | + ], |
|
82 | + 'isoIn' => [ |
|
83 | + 'type' => ['list_of' => 'String'], |
|
84 | + 'description' => esc_html__( |
|
85 | + 'Limit the result to the set of given country ISOs.', |
|
86 | + 'event_espresso' |
|
87 | + ), |
|
88 | + ], |
|
89 | + 'iso3In' => [ |
|
90 | + 'type' => ['list_of' => 'String'], |
|
91 | + 'description' => esc_html__( |
|
92 | + 'Limit the result to the set of given country ISO3s.', |
|
93 | + 'event_espresso' |
|
94 | + ), |
|
95 | + ], |
|
96 | + 'search' => [ |
|
97 | + 'type' => 'String', |
|
98 | + 'description' => esc_html__( |
|
99 | + 'Limit the result to the given search query.', |
|
100 | + 'event_espresso' |
|
101 | + ), |
|
102 | + ], |
|
103 | + 'activeOnly' => [ |
|
104 | + 'type' => 'Boolean', |
|
105 | + 'description' => esc_html__( |
|
106 | + 'Limit the result to the active countries.', |
|
107 | + 'event_espresso' |
|
108 | + ), |
|
109 | + ], |
|
110 | + ]; |
|
111 | 111 | |
112 | - $newArgs = apply_filters( |
|
113 | - 'FHEE__EventEspresso_core_domain_services_graphql_connections__country_args', |
|
114 | - $newArgs, |
|
115 | - $args |
|
116 | - ); |
|
117 | - return array_merge( |
|
118 | - $newArgs, |
|
119 | - $args |
|
120 | - ); |
|
121 | - } |
|
112 | + $newArgs = apply_filters( |
|
113 | + 'FHEE__EventEspresso_core_domain_services_graphql_connections__country_args', |
|
114 | + $newArgs, |
|
115 | + $args |
|
116 | + ); |
|
117 | + return array_merge( |
|
118 | + $newArgs, |
|
119 | + $args |
|
120 | + ); |
|
121 | + } |
|
122 | 122 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function __construct() |
24 | 24 | { |
25 | - $this->setName($this->namespace . 'StatesConnectionOrderbyInput'); |
|
25 | + $this->setName($this->namespace.'StatesConnectionOrderbyInput'); |
|
26 | 26 | $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
27 | 27 | parent::__construct(); |
28 | 28 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | return [ |
37 | 37 | new GraphQLField( |
38 | 38 | 'field', |
39 | - ['non_null' => $this->namespace . 'StatesConnectionOrderbyEnum'] |
|
39 | + ['non_null' => $this->namespace.'StatesConnectionOrderbyEnum'] |
|
40 | 40 | ), |
41 | 41 | new GraphQLField( |
42 | 42 | 'order', |
@@ -16,31 +16,31 @@ |
||
16 | 16 | */ |
17 | 17 | class StatesConnectionOrderbyInput extends InputBase |
18 | 18 | { |
19 | - /** |
|
20 | - * StatesConnectionOrderbyInput constructor. |
|
21 | - */ |
|
22 | - public function __construct() |
|
23 | - { |
|
24 | - $this->setName($this->namespace . 'StatesConnectionOrderbyInput'); |
|
25 | - $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
26 | - parent::__construct(); |
|
27 | - } |
|
19 | + /** |
|
20 | + * StatesConnectionOrderbyInput constructor. |
|
21 | + */ |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + $this->setName($this->namespace . 'StatesConnectionOrderbyInput'); |
|
25 | + $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
26 | + parent::__construct(); |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * @return GraphQLFieldInterface[] |
|
32 | - */ |
|
33 | - protected function getFields(): array |
|
34 | - { |
|
35 | - return [ |
|
36 | - new GraphQLField( |
|
37 | - 'field', |
|
38 | - ['non_null' => $this->namespace . 'StatesConnectionOrderbyEnum'] |
|
39 | - ), |
|
40 | - new GraphQLField( |
|
41 | - 'order', |
|
42 | - 'OrderEnum' |
|
43 | - ), |
|
44 | - ]; |
|
45 | - } |
|
30 | + /** |
|
31 | + * @return GraphQLFieldInterface[] |
|
32 | + */ |
|
33 | + protected function getFields(): array |
|
34 | + { |
|
35 | + return [ |
|
36 | + new GraphQLField( |
|
37 | + 'field', |
|
38 | + ['non_null' => $this->namespace . 'StatesConnectionOrderbyEnum'] |
|
39 | + ), |
|
40 | + new GraphQLField( |
|
41 | + 'order', |
|
42 | + 'OrderEnum' |
|
43 | + ), |
|
44 | + ]; |
|
45 | + } |
|
46 | 46 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function __construct() |
24 | 24 | { |
25 | - $this->setName($this->namespace . 'CountriesConnectionOrderbyInput'); |
|
25 | + $this->setName($this->namespace.'CountriesConnectionOrderbyInput'); |
|
26 | 26 | $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
27 | 27 | parent::__construct(); |
28 | 28 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | return [ |
37 | 37 | new GraphQLField( |
38 | 38 | 'field', |
39 | - ['non_null' => $this->namespace . 'CountriesConnectionOrderbyEnum'] |
|
39 | + ['non_null' => $this->namespace.'CountriesConnectionOrderbyEnum'] |
|
40 | 40 | ), |
41 | 41 | new GraphQLField( |
42 | 42 | 'order', |
@@ -16,31 +16,31 @@ |
||
16 | 16 | */ |
17 | 17 | class CountriesConnectionOrderbyInput extends InputBase |
18 | 18 | { |
19 | - /** |
|
20 | - * CountriesConnectionOrderbyInput constructor. |
|
21 | - */ |
|
22 | - public function __construct() |
|
23 | - { |
|
24 | - $this->setName($this->namespace . 'CountriesConnectionOrderbyInput'); |
|
25 | - $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
26 | - parent::__construct(); |
|
27 | - } |
|
19 | + /** |
|
20 | + * CountriesConnectionOrderbyInput constructor. |
|
21 | + */ |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + $this->setName($this->namespace . 'CountriesConnectionOrderbyInput'); |
|
25 | + $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
26 | + parent::__construct(); |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * @return GraphQLFieldInterface[] |
|
32 | - */ |
|
33 | - protected function getFields(): array |
|
34 | - { |
|
35 | - return [ |
|
36 | - new GraphQLField( |
|
37 | - 'field', |
|
38 | - ['non_null' => $this->namespace . 'CountriesConnectionOrderbyEnum'] |
|
39 | - ), |
|
40 | - new GraphQLField( |
|
41 | - 'order', |
|
42 | - 'OrderEnum' |
|
43 | - ), |
|
44 | - ]; |
|
45 | - } |
|
30 | + /** |
|
31 | + * @return GraphQLFieldInterface[] |
|
32 | + */ |
|
33 | + protected function getFields(): array |
|
34 | + { |
|
35 | + return [ |
|
36 | + new GraphQLField( |
|
37 | + 'field', |
|
38 | + ['non_null' => $this->namespace . 'CountriesConnectionOrderbyEnum'] |
|
39 | + ), |
|
40 | + new GraphQLField( |
|
41 | + 'order', |
|
42 | + 'OrderEnum' |
|
43 | + ), |
|
44 | + ]; |
|
45 | + } |
|
46 | 46 | } |
@@ -15,28 +15,28 @@ |
||
15 | 15 | */ |
16 | 16 | class CountryLoader extends AbstractLoader |
17 | 17 | { |
18 | - /** |
|
19 | - * @return EEM_Base|EEM_Country |
|
20 | - * @throws EE_Error |
|
21 | - * @throws InvalidArgumentException |
|
22 | - * @throws InvalidDataTypeException |
|
23 | - * @throws InvalidInterfaceException |
|
24 | - * @throws ReflectionException |
|
25 | - */ |
|
26 | - protected function getQuery(): EEM_Base |
|
27 | - { |
|
28 | - return EEM_Country::instance(); |
|
29 | - } |
|
18 | + /** |
|
19 | + * @return EEM_Base|EEM_Country |
|
20 | + * @throws EE_Error |
|
21 | + * @throws InvalidArgumentException |
|
22 | + * @throws InvalidDataTypeException |
|
23 | + * @throws InvalidInterfaceException |
|
24 | + * @throws ReflectionException |
|
25 | + */ |
|
26 | + protected function getQuery(): EEM_Base |
|
27 | + { |
|
28 | + return EEM_Country::instance(); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * @param array $keys |
|
34 | - * @return array |
|
35 | - */ |
|
36 | - protected function getWhereParams(array $keys): array |
|
37 | - { |
|
38 | - return [ |
|
39 | - 'CNT_ISO' => ['IN', $keys], |
|
40 | - ]; |
|
41 | - } |
|
32 | + /** |
|
33 | + * @param array $keys |
|
34 | + * @return array |
|
35 | + */ |
|
36 | + protected function getWhereParams(array $keys): array |
|
37 | + { |
|
38 | + return [ |
|
39 | + 'CNT_ISO' => ['IN', $keys], |
|
40 | + ]; |
|
41 | + } |
|
42 | 42 | } |
@@ -15,28 +15,28 @@ |
||
15 | 15 | */ |
16 | 16 | class StateLoader extends AbstractLoader |
17 | 17 | { |
18 | - /** |
|
19 | - * @return EEM_Base|EEM_State |
|
20 | - * @throws EE_Error |
|
21 | - * @throws InvalidArgumentException |
|
22 | - * @throws InvalidDataTypeException |
|
23 | - * @throws InvalidInterfaceException |
|
24 | - * @throws ReflectionException |
|
25 | - */ |
|
26 | - protected function getQuery(): EEM_Base |
|
27 | - { |
|
28 | - return EEM_State::instance(); |
|
29 | - } |
|
18 | + /** |
|
19 | + * @return EEM_Base|EEM_State |
|
20 | + * @throws EE_Error |
|
21 | + * @throws InvalidArgumentException |
|
22 | + * @throws InvalidDataTypeException |
|
23 | + * @throws InvalidInterfaceException |
|
24 | + * @throws ReflectionException |
|
25 | + */ |
|
26 | + protected function getQuery(): EEM_Base |
|
27 | + { |
|
28 | + return EEM_State::instance(); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * @param array $keys |
|
34 | - * @return array |
|
35 | - */ |
|
36 | - protected function getWhereParams(array $keys): array |
|
37 | - { |
|
38 | - return [ |
|
39 | - 'STA_ID' => ['IN', $keys], |
|
40 | - ]; |
|
41 | - } |
|
32 | + /** |
|
33 | + * @param array $keys |
|
34 | + * @return array |
|
35 | + */ |
|
36 | + protected function getWhereParams(array $keys): array |
|
37 | + { |
|
38 | + return [ |
|
39 | + 'STA_ID' => ['IN', $keys], |
|
40 | + ]; |
|
41 | + } |
|
42 | 42 | } |