@@ -20,198 +20,198 @@ |
||
20 | 20 | */ |
21 | 21 | class EE_Registration_Custom_Questions_Form extends EE_Form_Section_Proper |
22 | 22 | { |
23 | - /** |
|
24 | - * |
|
25 | - * @var EE_Registration |
|
26 | - */ |
|
27 | - protected $_registration = null; |
|
23 | + /** |
|
24 | + * |
|
25 | + * @var EE_Registration |
|
26 | + */ |
|
27 | + protected $_registration = null; |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * |
|
32 | - * @param EE_Registration $reg |
|
33 | - * @param array $options |
|
34 | - * @throws EE_Error |
|
35 | - * @throws ReflectionException |
|
36 | - */ |
|
37 | - public function __construct(EE_Registration $reg, $options = array()) |
|
38 | - { |
|
39 | - $this->_registration = $reg; |
|
40 | - if (! isset($options['layout_strategy'])) { |
|
41 | - $options['layout_strategy'] = new EE_Admin_Two_Column_Layout(); |
|
42 | - } |
|
43 | - if (! isset($options['html_id'])) { |
|
44 | - $options['html_id'] = 'reg-admin-attendee-questions-frm'; |
|
45 | - } |
|
46 | - $this->build_form_from_registration(); |
|
47 | - parent::__construct($options); |
|
48 | - } |
|
30 | + /** |
|
31 | + * |
|
32 | + * @param EE_Registration $reg |
|
33 | + * @param array $options |
|
34 | + * @throws EE_Error |
|
35 | + * @throws ReflectionException |
|
36 | + */ |
|
37 | + public function __construct(EE_Registration $reg, $options = array()) |
|
38 | + { |
|
39 | + $this->_registration = $reg; |
|
40 | + if (! isset($options['layout_strategy'])) { |
|
41 | + $options['layout_strategy'] = new EE_Admin_Two_Column_Layout(); |
|
42 | + } |
|
43 | + if (! isset($options['html_id'])) { |
|
44 | + $options['html_id'] = 'reg-admin-attendee-questions-frm'; |
|
45 | + } |
|
46 | + $this->build_form_from_registration(); |
|
47 | + parent::__construct($options); |
|
48 | + } |
|
49 | 49 | |
50 | 50 | |
51 | - /** |
|
52 | - * Gets the registration object this form is about |
|
53 | - * @return EE_Registration |
|
54 | - */ |
|
55 | - public function get_registration() |
|
56 | - { |
|
57 | - return $this->_registration; |
|
58 | - } |
|
51 | + /** |
|
52 | + * Gets the registration object this form is about |
|
53 | + * @return EE_Registration |
|
54 | + */ |
|
55 | + public function get_registration() |
|
56 | + { |
|
57 | + return $this->_registration; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @since 4.10.0.p |
|
62 | - * @throws EE_Error |
|
63 | - * @throws InvalidArgumentException |
|
64 | - * @throws ReflectionException |
|
65 | - * @throws InvalidDataTypeException |
|
66 | - * @throws InvalidInterfaceException |
|
67 | - */ |
|
68 | - public function build_form_from_registration() |
|
69 | - { |
|
70 | - $reg = $this->get_registration(); |
|
71 | - if (! $reg instanceof EE_Registration) { |
|
72 | - throw new EE_Error(esc_html__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso')); |
|
73 | - } |
|
74 | - // we want to get all their question groups |
|
75 | - $question_groups = EEM_Question_Group::instance()->get_all( |
|
76 | - [ |
|
77 | - [ |
|
78 | - 'Event_Question_Group.EVT_ID' => $reg->event_ID(), |
|
79 | - 'OR' => [ |
|
80 | - 'Question.QST_system*blank' => '', |
|
81 | - 'Question.QST_system*null' => ['IS_NULL'] |
|
82 | - ], |
|
83 | - 'Event_Question_Group.' |
|
84 | - . EEM_Event_Question_Group::instance()->fieldNameForContext( |
|
85 | - $reg->is_primary_registrant() |
|
86 | - ) => true |
|
87 | - ], |
|
88 | - 'order_by' => ['QSG_order' => 'ASC'] |
|
89 | - ] |
|
90 | - ); |
|
91 | - // get each question groups questions |
|
92 | - foreach ($question_groups as $question_group) { |
|
93 | - if ($question_group instanceof EE_Question_Group) { |
|
94 | - $this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group( |
|
95 | - $question_group, |
|
96 | - $reg |
|
97 | - ); |
|
98 | - } |
|
99 | - } |
|
100 | - } |
|
60 | + /** |
|
61 | + * @since 4.10.0.p |
|
62 | + * @throws EE_Error |
|
63 | + * @throws InvalidArgumentException |
|
64 | + * @throws ReflectionException |
|
65 | + * @throws InvalidDataTypeException |
|
66 | + * @throws InvalidInterfaceException |
|
67 | + */ |
|
68 | + public function build_form_from_registration() |
|
69 | + { |
|
70 | + $reg = $this->get_registration(); |
|
71 | + if (! $reg instanceof EE_Registration) { |
|
72 | + throw new EE_Error(esc_html__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso')); |
|
73 | + } |
|
74 | + // we want to get all their question groups |
|
75 | + $question_groups = EEM_Question_Group::instance()->get_all( |
|
76 | + [ |
|
77 | + [ |
|
78 | + 'Event_Question_Group.EVT_ID' => $reg->event_ID(), |
|
79 | + 'OR' => [ |
|
80 | + 'Question.QST_system*blank' => '', |
|
81 | + 'Question.QST_system*null' => ['IS_NULL'] |
|
82 | + ], |
|
83 | + 'Event_Question_Group.' |
|
84 | + . EEM_Event_Question_Group::instance()->fieldNameForContext( |
|
85 | + $reg->is_primary_registrant() |
|
86 | + ) => true |
|
87 | + ], |
|
88 | + 'order_by' => ['QSG_order' => 'ASC'] |
|
89 | + ] |
|
90 | + ); |
|
91 | + // get each question groups questions |
|
92 | + foreach ($question_groups as $question_group) { |
|
93 | + if ($question_group instanceof EE_Question_Group) { |
|
94 | + $this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group( |
|
95 | + $question_group, |
|
96 | + $reg |
|
97 | + ); |
|
98 | + } |
|
99 | + } |
|
100 | + } |
|
101 | 101 | |
102 | 102 | |
103 | - /** |
|
104 | - * |
|
105 | - * @param EE_Question_Group $question_group |
|
106 | - * @param EE_Registration $registration |
|
107 | - * @return EE_Form_Section_Proper |
|
108 | - * @throws EE_Error |
|
109 | - * @throws ReflectionException |
|
110 | - */ |
|
111 | - public function build_subform_from_question_group($question_group, $registration) |
|
112 | - { |
|
113 | - if ( |
|
114 | - ! $question_group instanceof EE_Question_Group || |
|
115 | - ! $registration instanceof EE_Registration |
|
116 | - ) { |
|
117 | - throw new EE_Error(esc_html__('A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso')); |
|
118 | - } |
|
119 | - $parts_of_subsection = array( |
|
120 | - 'title' => new EE_Form_Section_HTML( |
|
121 | - EEH_HTML::h5( |
|
122 | - $question_group->name(), |
|
123 | - $question_group->identifier(), |
|
124 | - 'espresso-question-group-title-h5 section-title' |
|
125 | - ) |
|
126 | - ) |
|
127 | - ); |
|
128 | - $questions = $question_group->questions( |
|
129 | - array( |
|
130 | - array( |
|
131 | - 'OR' => array( |
|
132 | - 'QST_system*blank' => '', |
|
133 | - 'QST_system*null' => array( 'IS_NULL' ) |
|
134 | - ) |
|
135 | - ) |
|
136 | - ) |
|
137 | - ); |
|
138 | - foreach ($questions as $question) { |
|
139 | - $parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration); |
|
140 | - } |
|
141 | - if ( |
|
142 | - EE_Registry::instance()->CAP->current_user_can( |
|
143 | - 'ee_edit_registration', |
|
144 | - 'edit-reg-questions-mbox', |
|
145 | - $this->_registration->ID() |
|
146 | - ) |
|
147 | - ) { |
|
148 | - $parts_of_subsection['edit_link'] = new EE_Form_Section_HTML( |
|
149 | - EEH_HTML::table( |
|
150 | - EEH_HTML::tr( |
|
151 | - '<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="' . esc_attr__('click to edit question', 'event_espresso') . '"> |
|
103 | + /** |
|
104 | + * |
|
105 | + * @param EE_Question_Group $question_group |
|
106 | + * @param EE_Registration $registration |
|
107 | + * @return EE_Form_Section_Proper |
|
108 | + * @throws EE_Error |
|
109 | + * @throws ReflectionException |
|
110 | + */ |
|
111 | + public function build_subform_from_question_group($question_group, $registration) |
|
112 | + { |
|
113 | + if ( |
|
114 | + ! $question_group instanceof EE_Question_Group || |
|
115 | + ! $registration instanceof EE_Registration |
|
116 | + ) { |
|
117 | + throw new EE_Error(esc_html__('A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso')); |
|
118 | + } |
|
119 | + $parts_of_subsection = array( |
|
120 | + 'title' => new EE_Form_Section_HTML( |
|
121 | + EEH_HTML::h5( |
|
122 | + $question_group->name(), |
|
123 | + $question_group->identifier(), |
|
124 | + 'espresso-question-group-title-h5 section-title' |
|
125 | + ) |
|
126 | + ) |
|
127 | + ); |
|
128 | + $questions = $question_group->questions( |
|
129 | + array( |
|
130 | + array( |
|
131 | + 'OR' => array( |
|
132 | + 'QST_system*blank' => '', |
|
133 | + 'QST_system*null' => array( 'IS_NULL' ) |
|
134 | + ) |
|
135 | + ) |
|
136 | + ) |
|
137 | + ); |
|
138 | + foreach ($questions as $question) { |
|
139 | + $parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration); |
|
140 | + } |
|
141 | + if ( |
|
142 | + EE_Registry::instance()->CAP->current_user_can( |
|
143 | + 'ee_edit_registration', |
|
144 | + 'edit-reg-questions-mbox', |
|
145 | + $this->_registration->ID() |
|
146 | + ) |
|
147 | + ) { |
|
148 | + $parts_of_subsection['edit_link'] = new EE_Form_Section_HTML( |
|
149 | + EEH_HTML::table( |
|
150 | + EEH_HTML::tr( |
|
151 | + '<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="' . esc_attr__('click to edit question', 'event_espresso') . '"> |
|
152 | 152 | <span class="reg-admin-edit-question-group-spn">' . esc_html__('edit the above question group', 'event_espresso') . '</span> |
153 | 153 | <div class="dashicons dashicons-edit"></div> |
154 | 154 | </a></td>' |
155 | - ) . |
|
156 | - EEH_HTML::no_row() |
|
157 | - ) |
|
158 | - ); |
|
159 | - } |
|
160 | - return new EE_Form_Section_Proper( |
|
161 | - array( |
|
162 | - 'subsections' => $parts_of_subsection, |
|
163 | - 'html_class' => 'question-group-questions', |
|
164 | - ) |
|
165 | - ); |
|
166 | - } |
|
155 | + ) . |
|
156 | + EEH_HTML::no_row() |
|
157 | + ) |
|
158 | + ); |
|
159 | + } |
|
160 | + return new EE_Form_Section_Proper( |
|
161 | + array( |
|
162 | + 'subsections' => $parts_of_subsection, |
|
163 | + 'html_class' => 'question-group-questions', |
|
164 | + ) |
|
165 | + ); |
|
166 | + } |
|
167 | 167 | |
168 | 168 | |
169 | - /** |
|
170 | - * Overrides parent so if inputs were disabled, we leave those with their defaults |
|
171 | - * from the answers in the DB |
|
172 | - * |
|
173 | - * @param array $req_data like $_POST |
|
174 | - * @return void |
|
175 | - * @throws EE_Error |
|
176 | - */ |
|
177 | - protected function _normalize($req_data) |
|
178 | - { |
|
179 | - $this->_received_submission = true; |
|
180 | - $this->_validation_errors = array(); |
|
181 | - foreach ($this->get_validatable_subsections() as $subsection) { |
|
182 | - if ($subsection->form_data_present_in($req_data)) { |
|
183 | - try { |
|
184 | - $subsection->_normalize($req_data); |
|
185 | - } catch (EE_Validation_Error $e) { |
|
186 | - $subsection->add_validation_error($e); |
|
187 | - } |
|
188 | - } |
|
189 | - } |
|
190 | - } |
|
169 | + /** |
|
170 | + * Overrides parent so if inputs were disabled, we leave those with their defaults |
|
171 | + * from the answers in the DB |
|
172 | + * |
|
173 | + * @param array $req_data like $_POST |
|
174 | + * @return void |
|
175 | + * @throws EE_Error |
|
176 | + */ |
|
177 | + protected function _normalize($req_data) |
|
178 | + { |
|
179 | + $this->_received_submission = true; |
|
180 | + $this->_validation_errors = array(); |
|
181 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
182 | + if ($subsection->form_data_present_in($req_data)) { |
|
183 | + try { |
|
184 | + $subsection->_normalize($req_data); |
|
185 | + } catch (EE_Validation_Error $e) { |
|
186 | + $subsection->add_validation_error($e); |
|
187 | + } |
|
188 | + } |
|
189 | + } |
|
190 | + } |
|
191 | 191 | |
192 | 192 | |
193 | - /** |
|
194 | - * Performs validation on this form section and its subsections. For each subsection, |
|
195 | - * calls _validate_{subsection_name} on THIS form (if the function exists) and passes it the subsection, then calls |
|
196 | - * _validate on that subsection. If you need to perform validation on the form as a whole (considering multiple) |
|
197 | - * you would be best to override this _validate method, calling parent::_validate() first. |
|
198 | - * |
|
199 | - * @throws EE_Error |
|
200 | - */ |
|
201 | - protected function _validate() |
|
202 | - { |
|
203 | - /** @var RequestInterface $request */ |
|
204 | - $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
205 | - $form_data = $request->requestParams(); |
|
206 | - foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
207 | - if ($subsection->form_data_present_in($form_data)) { |
|
208 | - if (method_exists($this, '_validate_' . $subsection_name)) { |
|
209 | - call_user_func_array(array($this,'_validate_' . $subsection_name), array($subsection)); |
|
210 | - } |
|
211 | - $subsection->_validate(); |
|
212 | - } elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
213 | - $subsection->_received_submission = true; |
|
214 | - } |
|
215 | - } |
|
216 | - } |
|
193 | + /** |
|
194 | + * Performs validation on this form section and its subsections. For each subsection, |
|
195 | + * calls _validate_{subsection_name} on THIS form (if the function exists) and passes it the subsection, then calls |
|
196 | + * _validate on that subsection. If you need to perform validation on the form as a whole (considering multiple) |
|
197 | + * you would be best to override this _validate method, calling parent::_validate() first. |
|
198 | + * |
|
199 | + * @throws EE_Error |
|
200 | + */ |
|
201 | + protected function _validate() |
|
202 | + { |
|
203 | + /** @var RequestInterface $request */ |
|
204 | + $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
205 | + $form_data = $request->requestParams(); |
|
206 | + foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
207 | + if ($subsection->form_data_present_in($form_data)) { |
|
208 | + if (method_exists($this, '_validate_' . $subsection_name)) { |
|
209 | + call_user_func_array(array($this,'_validate_' . $subsection_name), array($subsection)); |
|
210 | + } |
|
211 | + $subsection->_validate(); |
|
212 | + } elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
213 | + $subsection->_received_submission = true; |
|
214 | + } |
|
215 | + } |
|
216 | + } |
|
217 | 217 | } |
@@ -37,10 +37,10 @@ discard block |
||
37 | 37 | public function __construct(EE_Registration $reg, $options = array()) |
38 | 38 | { |
39 | 39 | $this->_registration = $reg; |
40 | - if (! isset($options['layout_strategy'])) { |
|
40 | + if ( ! isset($options['layout_strategy'])) { |
|
41 | 41 | $options['layout_strategy'] = new EE_Admin_Two_Column_Layout(); |
42 | 42 | } |
43 | - if (! isset($options['html_id'])) { |
|
43 | + if ( ! isset($options['html_id'])) { |
|
44 | 44 | $options['html_id'] = 'reg-admin-attendee-questions-frm'; |
45 | 45 | } |
46 | 46 | $this->build_form_from_registration(); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | public function build_form_from_registration() |
69 | 69 | { |
70 | 70 | $reg = $this->get_registration(); |
71 | - if (! $reg instanceof EE_Registration) { |
|
71 | + if ( ! $reg instanceof EE_Registration) { |
|
72 | 72 | throw new EE_Error(esc_html__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso')); |
73 | 73 | } |
74 | 74 | // we want to get all their question groups |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | // get each question groups questions |
92 | 92 | foreach ($question_groups as $question_group) { |
93 | 93 | if ($question_group instanceof EE_Question_Group) { |
94 | - $this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group( |
|
94 | + $this->_subsections[$question_group->ID()] = $this->build_subform_from_question_group( |
|
95 | 95 | $question_group, |
96 | 96 | $reg |
97 | 97 | ); |
@@ -130,13 +130,13 @@ discard block |
||
130 | 130 | array( |
131 | 131 | 'OR' => array( |
132 | 132 | 'QST_system*blank' => '', |
133 | - 'QST_system*null' => array( 'IS_NULL' ) |
|
133 | + 'QST_system*null' => array('IS_NULL') |
|
134 | 134 | ) |
135 | 135 | ) |
136 | 136 | ) |
137 | 137 | ); |
138 | 138 | foreach ($questions as $question) { |
139 | - $parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration); |
|
139 | + $parts_of_subsection[$question->ID()] = $question->generate_form_input($registration); |
|
140 | 140 | } |
141 | 141 | if ( |
142 | 142 | EE_Registry::instance()->CAP->current_user_can( |
@@ -148,11 +148,11 @@ discard block |
||
148 | 148 | $parts_of_subsection['edit_link'] = new EE_Form_Section_HTML( |
149 | 149 | EEH_HTML::table( |
150 | 150 | EEH_HTML::tr( |
151 | - '<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="' . esc_attr__('click to edit question', 'event_espresso') . '"> |
|
152 | - <span class="reg-admin-edit-question-group-spn">' . esc_html__('edit the above question group', 'event_espresso') . '</span> |
|
151 | + '<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="'.esc_attr__('click to edit question', 'event_espresso').'"> |
|
152 | + <span class="reg-admin-edit-question-group-spn">' . esc_html__('edit the above question group', 'event_espresso').'</span> |
|
153 | 153 | <div class="dashicons dashicons-edit"></div> |
154 | 154 | </a></td>' |
155 | - ) . |
|
155 | + ). |
|
156 | 156 | EEH_HTML::no_row() |
157 | 157 | ) |
158 | 158 | ); |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | $form_data = $request->requestParams(); |
206 | 206 | foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
207 | 207 | if ($subsection->form_data_present_in($form_data)) { |
208 | - if (method_exists($this, '_validate_' . $subsection_name)) { |
|
209 | - call_user_func_array(array($this,'_validate_' . $subsection_name), array($subsection)); |
|
208 | + if (method_exists($this, '_validate_'.$subsection_name)) { |
|
209 | + call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection)); |
|
210 | 210 | } |
211 | 211 | $subsection->_validate(); |
212 | 212 | } elseif ($subsection instanceof EE_Form_Section_Proper) { |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function __construct($pm_instance = null) |
31 | 31 | { |
32 | - require_once($this->file_folder() . 'EEG_Paypal_Standard.gateway.php'); |
|
32 | + require_once($this->file_folder().'EEG_Paypal_Standard.gateway.php'); |
|
33 | 33 | $this->_gateway = new EEG_Paypal_Standard(); |
34 | 34 | $this->_pretty_name = esc_html__("PayPal Standard", 'event_espresso'); |
35 | 35 | $this->_default_description = sprintf( |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | '</strong>' |
42 | 42 | ); |
43 | 43 | parent::__construct($pm_instance); |
44 | - $this->_default_button_url = $this->file_url() . 'lib/paypal-logo.png'; |
|
44 | + $this->_default_button_url = $this->file_url().'lib/paypal-logo.png'; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function generate_new_settings_form() |
67 | 67 | { |
68 | - require_once($this->file_folder() . 'EE_Paypal_Standard_Form.form.php'); |
|
68 | + require_once($this->file_folder().'EE_Paypal_Standard_Form.form.php'); |
|
69 | 69 | $form = new EE_Paypal_Standard_Form($this); |
70 | 70 | $form->get_input('PMD_debug_mode')->set_html_label_text( |
71 | 71 | sprintf(esc_html__("Use PayPal Sandbox %s", 'event_espresso'), $this->get_help_tab_link()) |
@@ -15,106 +15,106 @@ |
||
15 | 15 | */ |
16 | 16 | class EE_PMT_Paypal_Standard extends EE_PMT_Base |
17 | 17 | { |
18 | - const shipping_info_none = 1; |
|
18 | + const shipping_info_none = 1; |
|
19 | 19 | |
20 | - const shipping_info_optional = 0; |
|
20 | + const shipping_info_optional = 0; |
|
21 | 21 | |
22 | - const shipping_info_required = 2; |
|
22 | + const shipping_info_required = 2; |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * @param EE_Payment_Method|null $pm_instance |
|
27 | - * @throws ReflectionException |
|
28 | - * @throws EE_Error |
|
29 | - */ |
|
30 | - public function __construct($pm_instance = null) |
|
31 | - { |
|
32 | - require_once($this->file_folder() . 'EEG_Paypal_Standard.gateway.php'); |
|
33 | - $this->_gateway = new EEG_Paypal_Standard(); |
|
34 | - $this->_pretty_name = esc_html__("PayPal Standard", 'event_espresso'); |
|
35 | - $this->_default_description = sprintf( |
|
36 | - esc_html__( |
|
37 | - 'Upon submitting this form, you will be forwarded to PayPal to make your payment. %1$sMake sure you return to this site in order to properly finalize your registration.%2$s', |
|
38 | - 'event_espresso' |
|
39 | - ), |
|
40 | - '<strong>', |
|
41 | - '</strong>' |
|
42 | - ); |
|
43 | - parent::__construct($pm_instance); |
|
44 | - $this->_default_button_url = $this->file_url() . 'lib/paypal-logo.png'; |
|
45 | - } |
|
25 | + /** |
|
26 | + * @param EE_Payment_Method|null $pm_instance |
|
27 | + * @throws ReflectionException |
|
28 | + * @throws EE_Error |
|
29 | + */ |
|
30 | + public function __construct($pm_instance = null) |
|
31 | + { |
|
32 | + require_once($this->file_folder() . 'EEG_Paypal_Standard.gateway.php'); |
|
33 | + $this->_gateway = new EEG_Paypal_Standard(); |
|
34 | + $this->_pretty_name = esc_html__("PayPal Standard", 'event_espresso'); |
|
35 | + $this->_default_description = sprintf( |
|
36 | + esc_html__( |
|
37 | + 'Upon submitting this form, you will be forwarded to PayPal to make your payment. %1$sMake sure you return to this site in order to properly finalize your registration.%2$s', |
|
38 | + 'event_espresso' |
|
39 | + ), |
|
40 | + '<strong>', |
|
41 | + '</strong>' |
|
42 | + ); |
|
43 | + parent::__construct($pm_instance); |
|
44 | + $this->_default_button_url = $this->file_url() . 'lib/paypal-logo.png'; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * Creates the billing form for this payment method type |
|
50 | - * @param EE_Transaction|null $transaction |
|
51 | - * @return EE_Billing_Info_Form|null |
|
52 | - */ |
|
53 | - public function generate_new_billing_form(EE_Transaction $transaction = null) |
|
54 | - { |
|
55 | - return null; |
|
56 | - } |
|
48 | + /** |
|
49 | + * Creates the billing form for this payment method type |
|
50 | + * @param EE_Transaction|null $transaction |
|
51 | + * @return EE_Billing_Info_Form|null |
|
52 | + */ |
|
53 | + public function generate_new_billing_form(EE_Transaction $transaction = null) |
|
54 | + { |
|
55 | + return null; |
|
56 | + } |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * Gets the form for all the settings related to this payment method type |
|
61 | - * |
|
62 | - * @return EE_Payment_Method_Form |
|
63 | - * @throws EE_Error |
|
64 | - * @throws ReflectionException |
|
65 | - */ |
|
66 | - public function generate_new_settings_form() |
|
67 | - { |
|
68 | - require_once($this->file_folder() . 'EE_Paypal_Standard_Form.form.php'); |
|
69 | - $form = new EE_Paypal_Standard_Form($this); |
|
70 | - $form->get_input('PMD_debug_mode')->set_html_label_text( |
|
71 | - sprintf(esc_html__("Use PayPal Sandbox %s", 'event_espresso'), $this->get_help_tab_link()) |
|
72 | - ); |
|
73 | - $form->get_input('shipping_details')->set_html_label_text( |
|
74 | - sprintf(esc_html__("Shipping Address Options %s", "event_espresso"), $this->get_help_tab_link()) |
|
75 | - ); |
|
76 | - return $form; |
|
77 | - } |
|
59 | + /** |
|
60 | + * Gets the form for all the settings related to this payment method type |
|
61 | + * |
|
62 | + * @return EE_Payment_Method_Form |
|
63 | + * @throws EE_Error |
|
64 | + * @throws ReflectionException |
|
65 | + */ |
|
66 | + public function generate_new_settings_form() |
|
67 | + { |
|
68 | + require_once($this->file_folder() . 'EE_Paypal_Standard_Form.form.php'); |
|
69 | + $form = new EE_Paypal_Standard_Form($this); |
|
70 | + $form->get_input('PMD_debug_mode')->set_html_label_text( |
|
71 | + sprintf(esc_html__("Use PayPal Sandbox %s", 'event_espresso'), $this->get_help_tab_link()) |
|
72 | + ); |
|
73 | + $form->get_input('shipping_details')->set_html_label_text( |
|
74 | + sprintf(esc_html__("Shipping Address Options %s", "event_espresso"), $this->get_help_tab_link()) |
|
75 | + ); |
|
76 | + return $form; |
|
77 | + } |
|
78 | 78 | |
79 | 79 | |
80 | - /** |
|
81 | - * Adds the help tab |
|
82 | - * |
|
83 | - * @return array |
|
84 | - * @see EE_PMT_Base::help_tabs_config() |
|
85 | - */ |
|
86 | - public function help_tabs_config() |
|
87 | - { |
|
88 | - return [ |
|
89 | - $this->get_help_tab_name() => [ |
|
90 | - 'title' => esc_html__("PayPal Standard Settings", 'event_espresso'), |
|
91 | - 'filename' => 'payment_methods_overview_paypalstandard', |
|
92 | - ], |
|
93 | - ]; |
|
94 | - } |
|
80 | + /** |
|
81 | + * Adds the help tab |
|
82 | + * |
|
83 | + * @return array |
|
84 | + * @see EE_PMT_Base::help_tabs_config() |
|
85 | + */ |
|
86 | + public function help_tabs_config() |
|
87 | + { |
|
88 | + return [ |
|
89 | + $this->get_help_tab_name() => [ |
|
90 | + 'title' => esc_html__("PayPal Standard Settings", 'event_espresso'), |
|
91 | + 'filename' => 'payment_methods_overview_paypalstandard', |
|
92 | + ], |
|
93 | + ]; |
|
94 | + } |
|
95 | 95 | |
96 | 96 | |
97 | - /** |
|
98 | - * Logic to be accomplished when the payment attempt is complete. |
|
99 | - * Most payment methods don't need to do anything at this point; but some, like Mijireh, do. |
|
100 | - * (Mijireh was an offsite gateway which doesn't send an IPN. So when the user returns to EE from |
|
101 | - * Mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status |
|
102 | - * of the payment). Fed a transaction because it's always assumed to be the last payment that |
|
103 | - * |
|
104 | - * @param EE_Transaction $transaction |
|
105 | - * @return EE_Payment |
|
106 | - * @throws EE_Error |
|
107 | - * @throws ReflectionException |
|
108 | - */ |
|
109 | - public function finalize_payment_for(EE_Transaction $transaction): ?EE_Payment |
|
110 | - { |
|
111 | - /** @var RequestInterface $request */ |
|
112 | - $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
113 | - // PayPal standard actually sends the IPN info along with the user when they return to our site |
|
114 | - // so in case the IPN is arriving later, let's try to process an IPN! |
|
115 | - if ($request->getServerParam('REQUEST_METHOD') === 'POST') { |
|
116 | - return $this->handle_ipn($request->postParams(), $transaction); |
|
117 | - } |
|
118 | - return parent::finalize_payment_for($transaction); |
|
119 | - } |
|
97 | + /** |
|
98 | + * Logic to be accomplished when the payment attempt is complete. |
|
99 | + * Most payment methods don't need to do anything at this point; but some, like Mijireh, do. |
|
100 | + * (Mijireh was an offsite gateway which doesn't send an IPN. So when the user returns to EE from |
|
101 | + * Mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status |
|
102 | + * of the payment). Fed a transaction because it's always assumed to be the last payment that |
|
103 | + * |
|
104 | + * @param EE_Transaction $transaction |
|
105 | + * @return EE_Payment |
|
106 | + * @throws EE_Error |
|
107 | + * @throws ReflectionException |
|
108 | + */ |
|
109 | + public function finalize_payment_for(EE_Transaction $transaction): ?EE_Payment |
|
110 | + { |
|
111 | + /** @var RequestInterface $request */ |
|
112 | + $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
113 | + // PayPal standard actually sends the IPN info along with the user when they return to our site |
|
114 | + // so in case the IPN is arriving later, let's try to process an IPN! |
|
115 | + if ($request->getServerParam('REQUEST_METHOD') === 'POST') { |
|
116 | + return $this->handle_ipn($request->postParams(), $transaction); |
|
117 | + } |
|
118 | + return parent::finalize_payment_for($transaction); |
|
119 | + } |
|
120 | 120 | } |
@@ -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 | } |