@@ -12,75 +12,75 @@ |
||
| 12 | 12 | { |
| 13 | 13 | |
| 14 | 14 | |
| 15 | - protected $_naming_method; |
|
| 15 | + protected $_naming_method; |
|
| 16 | 16 | |
| 17 | 17 | |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * |
|
| 21 | - * @param EE_Base_Class[] $answer_options |
|
| 22 | - * @param array $input_settings { |
|
| 23 | - * @var EE_Base_Class[] or array $default |
|
| 24 | - * @var string $naming_method function name on the class which will be used for getting the displayed-name. |
|
| 25 | - * example: if the class were an EE_Event, this could be slug(), description(), name() (default) |
|
| 26 | - * } |
|
| 27 | - */ |
|
| 28 | - public function __construct($answer_options = array(), $input_settings = array()) |
|
| 29 | - { |
|
| 30 | - if (isset($input_settings['naming_method'])) { |
|
| 31 | - $this->set_option_naming_method($input_settings['naming_method']); |
|
| 32 | - } |
|
| 33 | - parent::__construct($answer_options, $input_settings); |
|
| 34 | - } |
|
| 19 | + /** |
|
| 20 | + * |
|
| 21 | + * @param EE_Base_Class[] $answer_options |
|
| 22 | + * @param array $input_settings { |
|
| 23 | + * @var EE_Base_Class[] or array $default |
|
| 24 | + * @var string $naming_method function name on the class which will be used for getting the displayed-name. |
|
| 25 | + * example: if the class were an EE_Event, this could be slug(), description(), name() (default) |
|
| 26 | + * } |
|
| 27 | + */ |
|
| 28 | + public function __construct($answer_options = array(), $input_settings = array()) |
|
| 29 | + { |
|
| 30 | + if (isset($input_settings['naming_method'])) { |
|
| 31 | + $this->set_option_naming_method($input_settings['naming_method']); |
|
| 32 | + } |
|
| 33 | + parent::__construct($answer_options, $input_settings); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Sets the method name which will be called when outputting the options list |
|
| 38 | - * @param string $method |
|
| 39 | - */ |
|
| 40 | - public function set_option_naming_method($method) |
|
| 41 | - { |
|
| 42 | - $this->_naming_method = $method; |
|
| 43 | - } |
|
| 36 | + /** |
|
| 37 | + * Sets the method name which will be called when outputting the options list |
|
| 38 | + * @param string $method |
|
| 39 | + */ |
|
| 40 | + public function set_option_naming_method($method) |
|
| 41 | + { |
|
| 42 | + $this->_naming_method = $method; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * You CAN pass an array of model objects instead of simple values for teh options |
|
| 49 | - * @param EE_Base_Class[] $answer_options |
|
| 50 | - * @return null|void |
|
| 51 | - */ |
|
| 52 | - public function set_select_options($answer_options = array()) |
|
| 53 | - { |
|
| 54 | - // convert the model objects to select from into normal select options |
|
| 55 | - $select_options = array(); |
|
| 56 | - foreach ($answer_options as $model_obj) { |
|
| 57 | - if ($this->_naming_method) { |
|
| 58 | - $display_value = call_user_func(array( $model_obj, $this->_naming_method )); |
|
| 59 | - } else { |
|
| 60 | - $display_value = $model_obj->name(); |
|
| 61 | - } |
|
| 62 | - $select_options[ $model_obj->ID() ] = $display_value; |
|
| 63 | - } |
|
| 64 | - parent::set_select_options($select_options); |
|
| 65 | - } |
|
| 47 | + /** |
|
| 48 | + * You CAN pass an array of model objects instead of simple values for teh options |
|
| 49 | + * @param EE_Base_Class[] $answer_options |
|
| 50 | + * @return null|void |
|
| 51 | + */ |
|
| 52 | + public function set_select_options($answer_options = array()) |
|
| 53 | + { |
|
| 54 | + // convert the model objects to select from into normal select options |
|
| 55 | + $select_options = array(); |
|
| 56 | + foreach ($answer_options as $model_obj) { |
|
| 57 | + if ($this->_naming_method) { |
|
| 58 | + $display_value = call_user_func(array( $model_obj, $this->_naming_method )); |
|
| 59 | + } else { |
|
| 60 | + $display_value = $model_obj->name(); |
|
| 61 | + } |
|
| 62 | + $select_options[ $model_obj->ID() ] = $display_value; |
|
| 63 | + } |
|
| 64 | + parent::set_select_options($select_options); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | 67 | |
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * if they passed in an array of model objects for the default, convert it |
|
| 71 | - * into the format EE_Select_Multiple expects |
|
| 72 | - * @param EE_Base_Class[]|array $values |
|
| 73 | - */ |
|
| 74 | - public function set_default($values) |
|
| 75 | - { |
|
| 76 | - $defaults_as_simple_ids = array(); |
|
| 77 | - foreach ($values as $key => $value) { |
|
| 78 | - if ($value instanceof EE_Base_Class) { |
|
| 79 | - $defaults_as_simple_ids[] = $value->ID(); |
|
| 80 | - } else { |
|
| 81 | - $defaults_as_simple_ids[] = $value; |
|
| 82 | - } |
|
| 83 | - } |
|
| 84 | - parent::set_default($defaults_as_simple_ids); |
|
| 85 | - } |
|
| 69 | + /** |
|
| 70 | + * if they passed in an array of model objects for the default, convert it |
|
| 71 | + * into the format EE_Select_Multiple expects |
|
| 72 | + * @param EE_Base_Class[]|array $values |
|
| 73 | + */ |
|
| 74 | + public function set_default($values) |
|
| 75 | + { |
|
| 76 | + $defaults_as_simple_ids = array(); |
|
| 77 | + foreach ($values as $key => $value) { |
|
| 78 | + if ($value instanceof EE_Base_Class) { |
|
| 79 | + $defaults_as_simple_ids[] = $value->ID(); |
|
| 80 | + } else { |
|
| 81 | + $defaults_as_simple_ids[] = $value; |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | + parent::set_default($defaults_as_simple_ids); |
|
| 85 | + } |
|
| 86 | 86 | } |
@@ -55,11 +55,11 @@ |
||
| 55 | 55 | $select_options = array(); |
| 56 | 56 | foreach ($answer_options as $model_obj) { |
| 57 | 57 | if ($this->_naming_method) { |
| 58 | - $display_value = call_user_func(array( $model_obj, $this->_naming_method )); |
|
| 58 | + $display_value = call_user_func(array($model_obj, $this->_naming_method)); |
|
| 59 | 59 | } else { |
| 60 | 60 | $display_value = $model_obj->name(); |
| 61 | 61 | } |
| 62 | - $select_options[ $model_obj->ID() ] = $display_value; |
|
| 62 | + $select_options[$model_obj->ID()] = $display_value; |
|
| 63 | 63 | } |
| 64 | 64 | parent::set_select_options($select_options); |
| 65 | 65 | } |
@@ -136,17 +136,17 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | private function addIframeAssets(array $localized_vars) |
| 138 | 138 | { |
| 139 | - if (! $this->useCaptcha()) { |
|
| 139 | + if ( ! $this->useCaptcha()) { |
|
| 140 | 140 | return; |
| 141 | 141 | } |
| 142 | 142 | add_filter( |
| 143 | 143 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
| 144 | - function (array $iframe_assets) { |
|
| 145 | - $iframe_assets[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA ] = |
|
| 144 | + function(array $iframe_assets) { |
|
| 145 | + $iframe_assets[EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA] = |
|
| 146 | 146 | EED_Recaptcha_Invisible::assetsUrl() |
| 147 | 147 | . 'espresso_invisible_recaptcha.js?ver=' |
| 148 | 148 | . EVENT_ESPRESSO_VERSION; |
| 149 | - $iframe_assets[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA ] = |
|
| 149 | + $iframe_assets[EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA] = |
|
| 150 | 150 | add_query_arg( |
| 151 | 151 | array( |
| 152 | 152 | 'onload' => 'espressoLoadRecaptcha', |
@@ -160,15 +160,15 @@ discard block |
||
| 160 | 160 | ); |
| 161 | 161 | add_filter( |
| 162 | 162 | 'FHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__js_attributes', |
| 163 | - function (array $iframe_asset_attributes) { |
|
| 164 | - $iframe_asset_attributes[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA ] |
|
| 163 | + function(array $iframe_asset_attributes) { |
|
| 164 | + $iframe_asset_attributes[EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA] |
|
| 165 | 165 | = ' async="async" defer="defer"'; |
| 166 | 166 | return $iframe_asset_attributes; |
| 167 | 167 | } |
| 168 | 168 | ); |
| 169 | 169 | add_action( |
| 170 | 170 | 'AHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__complete', |
| 171 | - function (EventEspresso\modules\ticket_selector\TicketSelectorIframe $ticket_selector_iframe) use ($localized_vars) { |
|
| 171 | + function(EventEspresso\modules\ticket_selector\TicketSelectorIframe $ticket_selector_iframe) use ($localized_vars) { |
|
| 172 | 172 | $ticket_selector_iframe->addLocalizedVars($localized_vars, 'eeRecaptcha'); |
| 173 | 173 | } |
| 174 | 174 | ); |
@@ -180,13 +180,13 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | private function registerScripts() |
| 182 | 182 | { |
| 183 | - if (! $this->useCaptcha()) { |
|
| 183 | + if ( ! $this->useCaptcha()) { |
|
| 184 | 184 | return; |
| 185 | 185 | } |
| 186 | 186 | add_filter('script_loader_tag', array($this, 'addScriptAttributes'), 10, 2); |
| 187 | 187 | wp_register_script( |
| 188 | 188 | EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA, |
| 189 | - EED_Recaptcha_Invisible::assetsUrl() . 'espresso_invisible_recaptcha.js', |
|
| 189 | + EED_Recaptcha_Invisible::assetsUrl().'espresso_invisible_recaptcha.js', |
|
| 190 | 190 | array('espresso_core'), |
| 191 | 191 | EVENT_ESPRESSO_VERSION, |
| 192 | 192 | true |
@@ -15,222 +15,222 @@ |
||
| 15 | 15 | class EE_Invisible_Recaptcha_Input extends EE_Form_Input_Base |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - const SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA = 'google_invisible_recaptcha'; |
|
| 19 | - |
|
| 20 | - const SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA = 'espresso_invisible_recaptcha'; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * @var EE_Registration_Config $config |
|
| 24 | - */ |
|
| 25 | - private $config; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * @var string $recaptcha_id |
|
| 29 | - */ |
|
| 30 | - private $recaptcha_id; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * @var string $submit_button_id |
|
| 34 | - */ |
|
| 35 | - private $submit_button_id; |
|
| 36 | - |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @param array $input_settings |
|
| 40 | - * @param EE_Registration_Config $registration_config |
|
| 41 | - * @throws InvalidArgumentException |
|
| 42 | - * @throws InvalidDataTypeException |
|
| 43 | - * @throws InvalidInterfaceException |
|
| 44 | - * @throws DomainException |
|
| 45 | - */ |
|
| 46 | - public function __construct(array $input_settings = array(), EE_Registration_Config $registration_config = null) |
|
| 47 | - { |
|
| 48 | - $this->_set_display_strategy(new EE_Invisible_Recaptcha_Display_Strategy()); |
|
| 49 | - parent::__construct($input_settings); |
|
| 50 | - $registration_config = $registration_config instanceof EE_Registration_Config |
|
| 51 | - ? $registration_config |
|
| 52 | - : EE_Registry::instance()->CFG->registration; |
|
| 53 | - $this->config = $registration_config; |
|
| 54 | - $this->recaptcha_id = isset($input_settings['recaptcha_id']) |
|
| 55 | - ? $input_settings['recaptcha_id'] |
|
| 56 | - : substr(spl_object_hash($this), 8, 8); |
|
| 57 | - $this->submit_button_id = isset($input_settings['submit_button_id']) |
|
| 58 | - ? $input_settings['submit_button_id'] |
|
| 59 | - : ''; |
|
| 60 | - if ( |
|
| 61 | - isset($input_settings['localized_vars']) |
|
| 62 | - && filter_var($input_settings['iframe'], FILTER_VALIDATE_BOOLEAN) |
|
| 63 | - ) { |
|
| 64 | - $this->addIframeAssets($input_settings['localized_vars']); |
|
| 65 | - } else { |
|
| 66 | - $this->registerScripts(); |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * @return bool |
|
| 73 | - */ |
|
| 74 | - public function useCaptcha() |
|
| 75 | - { |
|
| 76 | - return $this->config->use_captcha && $this->config->recaptcha_theme === 'invisible'; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * @return string |
|
| 82 | - */ |
|
| 83 | - public function badge() |
|
| 84 | - { |
|
| 85 | - return $this->config->recaptcha_badge; |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * @return string |
|
| 91 | - */ |
|
| 92 | - public function language() |
|
| 93 | - { |
|
| 94 | - return $this->config->recaptcha_language; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * @return string |
|
| 100 | - */ |
|
| 101 | - public function siteKey() |
|
| 102 | - { |
|
| 103 | - return $this->config->recaptcha_publickey; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * @return string |
|
| 109 | - */ |
|
| 110 | - public function secretKey() |
|
| 111 | - { |
|
| 112 | - return $this->config->recaptcha_privatekey; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * @return string |
|
| 118 | - */ |
|
| 119 | - public function recaptchaId() |
|
| 120 | - { |
|
| 121 | - return $this->recaptcha_id; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * @return string |
|
| 127 | - */ |
|
| 128 | - public function submitButtonId() |
|
| 129 | - { |
|
| 130 | - return $this->submit_button_id; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * @param array $localized_vars |
|
| 136 | - * @throws DomainException |
|
| 137 | - */ |
|
| 138 | - private function addIframeAssets(array $localized_vars) |
|
| 139 | - { |
|
| 140 | - if (! $this->useCaptcha()) { |
|
| 141 | - return; |
|
| 142 | - } |
|
| 143 | - add_filter( |
|
| 144 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
| 145 | - function (array $iframe_assets) { |
|
| 146 | - $iframe_assets[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA ] = |
|
| 147 | - EED_Recaptcha_Invisible::assetsUrl() |
|
| 148 | - . 'espresso_invisible_recaptcha.js?ver=' |
|
| 149 | - . EVENT_ESPRESSO_VERSION; |
|
| 150 | - $iframe_assets[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA ] = |
|
| 151 | - add_query_arg( |
|
| 152 | - array( |
|
| 153 | - 'onload' => 'espressoLoadRecaptcha', |
|
| 154 | - 'render' => 'explicit', |
|
| 155 | - 'hl' => $this->language(), |
|
| 156 | - ), |
|
| 157 | - 'https://www.google.com/recaptcha/api.js?' |
|
| 158 | - ); |
|
| 159 | - return $iframe_assets; |
|
| 160 | - } |
|
| 161 | - ); |
|
| 162 | - add_filter( |
|
| 163 | - 'FHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__js_attributes', |
|
| 164 | - function (array $iframe_asset_attributes) { |
|
| 165 | - $iframe_asset_attributes[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA ] |
|
| 166 | - = ' async="async" defer="defer"'; |
|
| 167 | - return $iframe_asset_attributes; |
|
| 168 | - } |
|
| 169 | - ); |
|
| 170 | - add_action( |
|
| 171 | - 'AHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__complete', |
|
| 172 | - function (EventEspresso\modules\ticket_selector\TicketSelectorIframe $ticket_selector_iframe) use ($localized_vars) { |
|
| 173 | - $ticket_selector_iframe->addLocalizedVars($localized_vars, 'eeRecaptcha'); |
|
| 174 | - } |
|
| 175 | - ); |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - |
|
| 179 | - /** |
|
| 180 | - * @return void |
|
| 181 | - */ |
|
| 182 | - private function registerScripts() |
|
| 183 | - { |
|
| 184 | - if (! $this->useCaptcha()) { |
|
| 185 | - return; |
|
| 186 | - } |
|
| 187 | - add_filter('script_loader_tag', array($this, 'addScriptAttributes'), 10, 2); |
|
| 188 | - wp_register_script( |
|
| 189 | - EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA, |
|
| 190 | - EED_Recaptcha_Invisible::assetsUrl() . 'espresso_invisible_recaptcha.js', |
|
| 191 | - array('espresso_core'), |
|
| 192 | - EVENT_ESPRESSO_VERSION, |
|
| 193 | - true |
|
| 194 | - ); |
|
| 195 | - wp_register_script( |
|
| 196 | - EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA, |
|
| 197 | - add_query_arg( |
|
| 198 | - array( |
|
| 199 | - 'onload' => 'espressoLoadRecaptcha', |
|
| 200 | - 'render' => 'explicit', |
|
| 201 | - 'hl' => $this->language(), |
|
| 202 | - ), |
|
| 203 | - 'https://www.google.com/recaptcha/api.js?' |
|
| 204 | - ), |
|
| 205 | - array(EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA), |
|
| 206 | - false, |
|
| 207 | - true |
|
| 208 | - ); |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * @param string $tag |
|
| 214 | - * @param string $handle |
|
| 215 | - * @return string |
|
| 216 | - */ |
|
| 217 | - public function addScriptAttributes($tag, $handle) |
|
| 218 | - { |
|
| 219 | - if ($handle === EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA) { |
|
| 220 | - $tag = str_replace('></script>', ' async="async" defer="defer"></script>', $tag); |
|
| 221 | - } |
|
| 222 | - return $tag; |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - |
|
| 226 | - /** |
|
| 227 | - * Gets the HTML for displaying the label for this form input |
|
| 228 | - * according to the form section's layout strategy |
|
| 229 | - * |
|
| 230 | - * @return string |
|
| 231 | - */ |
|
| 232 | - public function get_html_for_label() |
|
| 233 | - { |
|
| 234 | - return ''; |
|
| 235 | - } |
|
| 18 | + const SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA = 'google_invisible_recaptcha'; |
|
| 19 | + |
|
| 20 | + const SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA = 'espresso_invisible_recaptcha'; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * @var EE_Registration_Config $config |
|
| 24 | + */ |
|
| 25 | + private $config; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * @var string $recaptcha_id |
|
| 29 | + */ |
|
| 30 | + private $recaptcha_id; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * @var string $submit_button_id |
|
| 34 | + */ |
|
| 35 | + private $submit_button_id; |
|
| 36 | + |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @param array $input_settings |
|
| 40 | + * @param EE_Registration_Config $registration_config |
|
| 41 | + * @throws InvalidArgumentException |
|
| 42 | + * @throws InvalidDataTypeException |
|
| 43 | + * @throws InvalidInterfaceException |
|
| 44 | + * @throws DomainException |
|
| 45 | + */ |
|
| 46 | + public function __construct(array $input_settings = array(), EE_Registration_Config $registration_config = null) |
|
| 47 | + { |
|
| 48 | + $this->_set_display_strategy(new EE_Invisible_Recaptcha_Display_Strategy()); |
|
| 49 | + parent::__construct($input_settings); |
|
| 50 | + $registration_config = $registration_config instanceof EE_Registration_Config |
|
| 51 | + ? $registration_config |
|
| 52 | + : EE_Registry::instance()->CFG->registration; |
|
| 53 | + $this->config = $registration_config; |
|
| 54 | + $this->recaptcha_id = isset($input_settings['recaptcha_id']) |
|
| 55 | + ? $input_settings['recaptcha_id'] |
|
| 56 | + : substr(spl_object_hash($this), 8, 8); |
|
| 57 | + $this->submit_button_id = isset($input_settings['submit_button_id']) |
|
| 58 | + ? $input_settings['submit_button_id'] |
|
| 59 | + : ''; |
|
| 60 | + if ( |
|
| 61 | + isset($input_settings['localized_vars']) |
|
| 62 | + && filter_var($input_settings['iframe'], FILTER_VALIDATE_BOOLEAN) |
|
| 63 | + ) { |
|
| 64 | + $this->addIframeAssets($input_settings['localized_vars']); |
|
| 65 | + } else { |
|
| 66 | + $this->registerScripts(); |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @return bool |
|
| 73 | + */ |
|
| 74 | + public function useCaptcha() |
|
| 75 | + { |
|
| 76 | + return $this->config->use_captcha && $this->config->recaptcha_theme === 'invisible'; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * @return string |
|
| 82 | + */ |
|
| 83 | + public function badge() |
|
| 84 | + { |
|
| 85 | + return $this->config->recaptcha_badge; |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * @return string |
|
| 91 | + */ |
|
| 92 | + public function language() |
|
| 93 | + { |
|
| 94 | + return $this->config->recaptcha_language; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * @return string |
|
| 100 | + */ |
|
| 101 | + public function siteKey() |
|
| 102 | + { |
|
| 103 | + return $this->config->recaptcha_publickey; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * @return string |
|
| 109 | + */ |
|
| 110 | + public function secretKey() |
|
| 111 | + { |
|
| 112 | + return $this->config->recaptcha_privatekey; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * @return string |
|
| 118 | + */ |
|
| 119 | + public function recaptchaId() |
|
| 120 | + { |
|
| 121 | + return $this->recaptcha_id; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * @return string |
|
| 127 | + */ |
|
| 128 | + public function submitButtonId() |
|
| 129 | + { |
|
| 130 | + return $this->submit_button_id; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * @param array $localized_vars |
|
| 136 | + * @throws DomainException |
|
| 137 | + */ |
|
| 138 | + private function addIframeAssets(array $localized_vars) |
|
| 139 | + { |
|
| 140 | + if (! $this->useCaptcha()) { |
|
| 141 | + return; |
|
| 142 | + } |
|
| 143 | + add_filter( |
|
| 144 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
| 145 | + function (array $iframe_assets) { |
|
| 146 | + $iframe_assets[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA ] = |
|
| 147 | + EED_Recaptcha_Invisible::assetsUrl() |
|
| 148 | + . 'espresso_invisible_recaptcha.js?ver=' |
|
| 149 | + . EVENT_ESPRESSO_VERSION; |
|
| 150 | + $iframe_assets[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA ] = |
|
| 151 | + add_query_arg( |
|
| 152 | + array( |
|
| 153 | + 'onload' => 'espressoLoadRecaptcha', |
|
| 154 | + 'render' => 'explicit', |
|
| 155 | + 'hl' => $this->language(), |
|
| 156 | + ), |
|
| 157 | + 'https://www.google.com/recaptcha/api.js?' |
|
| 158 | + ); |
|
| 159 | + return $iframe_assets; |
|
| 160 | + } |
|
| 161 | + ); |
|
| 162 | + add_filter( |
|
| 163 | + 'FHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__js_attributes', |
|
| 164 | + function (array $iframe_asset_attributes) { |
|
| 165 | + $iframe_asset_attributes[ EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA ] |
|
| 166 | + = ' async="async" defer="defer"'; |
|
| 167 | + return $iframe_asset_attributes; |
|
| 168 | + } |
|
| 169 | + ); |
|
| 170 | + add_action( |
|
| 171 | + 'AHEE__EventEspresso_modules_ticket_selector_TicketSelectorIframe__construct__complete', |
|
| 172 | + function (EventEspresso\modules\ticket_selector\TicketSelectorIframe $ticket_selector_iframe) use ($localized_vars) { |
|
| 173 | + $ticket_selector_iframe->addLocalizedVars($localized_vars, 'eeRecaptcha'); |
|
| 174 | + } |
|
| 175 | + ); |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + |
|
| 179 | + /** |
|
| 180 | + * @return void |
|
| 181 | + */ |
|
| 182 | + private function registerScripts() |
|
| 183 | + { |
|
| 184 | + if (! $this->useCaptcha()) { |
|
| 185 | + return; |
|
| 186 | + } |
|
| 187 | + add_filter('script_loader_tag', array($this, 'addScriptAttributes'), 10, 2); |
|
| 188 | + wp_register_script( |
|
| 189 | + EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA, |
|
| 190 | + EED_Recaptcha_Invisible::assetsUrl() . 'espresso_invisible_recaptcha.js', |
|
| 191 | + array('espresso_core'), |
|
| 192 | + EVENT_ESPRESSO_VERSION, |
|
| 193 | + true |
|
| 194 | + ); |
|
| 195 | + wp_register_script( |
|
| 196 | + EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA, |
|
| 197 | + add_query_arg( |
|
| 198 | + array( |
|
| 199 | + 'onload' => 'espressoLoadRecaptcha', |
|
| 200 | + 'render' => 'explicit', |
|
| 201 | + 'hl' => $this->language(), |
|
| 202 | + ), |
|
| 203 | + 'https://www.google.com/recaptcha/api.js?' |
|
| 204 | + ), |
|
| 205 | + array(EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_ESPRESSO_INVISIBLE_RECAPTCHA), |
|
| 206 | + false, |
|
| 207 | + true |
|
| 208 | + ); |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + |
|
| 212 | + /** |
|
| 213 | + * @param string $tag |
|
| 214 | + * @param string $handle |
|
| 215 | + * @return string |
|
| 216 | + */ |
|
| 217 | + public function addScriptAttributes($tag, $handle) |
|
| 218 | + { |
|
| 219 | + if ($handle === EE_Invisible_Recaptcha_Input::SCRIPT_HANDLE_GOOGLE_INVISIBLE_RECAPTCHA) { |
|
| 220 | + $tag = str_replace('></script>', ' async="async" defer="defer"></script>', $tag); |
|
| 221 | + } |
|
| 222 | + return $tag; |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * Gets the HTML for displaying the label for this form input |
|
| 228 | + * according to the form section's layout strategy |
|
| 229 | + * |
|
| 230 | + * @return string |
|
| 231 | + */ |
|
| 232 | + public function get_html_for_label() |
|
| 233 | + { |
|
| 234 | + return ''; |
|
| 235 | + } |
|
| 236 | 236 | } |
@@ -9,15 +9,15 @@ |
||
| 9 | 9 | class EE_Select_Multiple_Input extends EE_Form_Input_With_Options_Base |
| 10 | 10 | { |
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * @param array | EE_Question_Option[] $answer_options |
|
| 14 | - * @param array $input_settings |
|
| 15 | - */ |
|
| 16 | - public function __construct($answer_options, $input_settings = array()) |
|
| 17 | - { |
|
| 18 | - $this->_set_display_strategy(new EE_Select_Multiple_Display_Strategy()); |
|
| 19 | - $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array( new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null) ))); |
|
| 20 | - $this->_multiple_selections = true; |
|
| 21 | - parent::__construct($answer_options, $input_settings); |
|
| 22 | - } |
|
| 12 | + /** |
|
| 13 | + * @param array | EE_Question_Option[] $answer_options |
|
| 14 | + * @param array $input_settings |
|
| 15 | + */ |
|
| 16 | + public function __construct($answer_options, $input_settings = array()) |
|
| 17 | + { |
|
| 18 | + $this->_set_display_strategy(new EE_Select_Multiple_Display_Strategy()); |
|
| 19 | + $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array( new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null) ))); |
|
| 20 | + $this->_multiple_selections = true; |
|
| 21 | + parent::__construct($answer_options, $input_settings); |
|
| 22 | + } |
|
| 23 | 23 | } |
@@ -16,7 +16,7 @@ |
||
| 16 | 16 | public function __construct($answer_options, $input_settings = array()) |
| 17 | 17 | { |
| 18 | 18 | $this->_set_display_strategy(new EE_Select_Multiple_Display_Strategy()); |
| 19 | - $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array( new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null) ))); |
|
| 19 | + $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array(new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : null)))); |
|
| 20 | 20 | $this->_multiple_selections = true; |
| 21 | 21 | parent::__construct($answer_options, $input_settings); |
| 22 | 22 | } |
@@ -12,17 +12,17 @@ |
||
| 12 | 12 | class EE_Year_Input extends EE_Select_Input |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - public function __construct($input_settings = array(), $four_digit_year = true, $years_behind = 100, $years_ahead = 0) |
|
| 16 | - { |
|
| 17 | - if ($four_digit_year) { |
|
| 18 | - $current_year_int = intval(date('Y')); |
|
| 19 | - } else { |
|
| 20 | - $current_year_int = intval(date('y')); |
|
| 21 | - } |
|
| 22 | - $answer_options = array(); |
|
| 23 | - for ($start = $current_year_int - $years_behind; $start <= ($current_year_int + $years_ahead); $start++) { |
|
| 24 | - $answer_options[ $start ] = $start; |
|
| 25 | - } |
|
| 26 | - parent::__construct($answer_options, $input_settings); |
|
| 27 | - } |
|
| 15 | + public function __construct($input_settings = array(), $four_digit_year = true, $years_behind = 100, $years_ahead = 0) |
|
| 16 | + { |
|
| 17 | + if ($four_digit_year) { |
|
| 18 | + $current_year_int = intval(date('Y')); |
|
| 19 | + } else { |
|
| 20 | + $current_year_int = intval(date('y')); |
|
| 21 | + } |
|
| 22 | + $answer_options = array(); |
|
| 23 | + for ($start = $current_year_int - $years_behind; $start <= ($current_year_int + $years_ahead); $start++) { |
|
| 24 | + $answer_options[ $start ] = $start; |
|
| 25 | + } |
|
| 26 | + parent::__construct($answer_options, $input_settings); |
|
| 27 | + } |
|
| 28 | 28 | } |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | } |
| 22 | 22 | $answer_options = array(); |
| 23 | 23 | for ($start = $current_year_int - $years_behind; $start <= ($current_year_int + $years_ahead); $start++) { |
| 24 | - $answer_options[ $start ] = $start; |
|
| 24 | + $answer_options[$start] = $start; |
|
| 25 | 25 | } |
| 26 | 26 | parent::__construct($answer_options, $input_settings); |
| 27 | 27 | } |
@@ -10,14 +10,14 @@ |
||
| 10 | 10 | { |
| 11 | 11 | |
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * @param array $input_settings |
|
| 15 | - */ |
|
| 16 | - public function __construct($input_settings = array()) |
|
| 17 | - { |
|
| 18 | - $this->_set_display_strategy(new EE_Text_Input_Display_Strategy('password')); |
|
| 19 | - $this->_set_normalization_strategy(new EE_Text_Normalization()); |
|
| 20 | - parent::__construct($input_settings); |
|
| 21 | - $this->set_html_class($this->html_class() . 'password'); |
|
| 22 | - } |
|
| 13 | + /** |
|
| 14 | + * @param array $input_settings |
|
| 15 | + */ |
|
| 16 | + public function __construct($input_settings = array()) |
|
| 17 | + { |
|
| 18 | + $this->_set_display_strategy(new EE_Text_Input_Display_Strategy('password')); |
|
| 19 | + $this->_set_normalization_strategy(new EE_Text_Normalization()); |
|
| 20 | + parent::__construct($input_settings); |
|
| 21 | + $this->set_html_class($this->html_class() . 'password'); |
|
| 22 | + } |
|
| 23 | 23 | } |
@@ -18,6 +18,6 @@ |
||
| 18 | 18 | $this->_set_display_strategy(new EE_Text_Input_Display_Strategy('password')); |
| 19 | 19 | $this->_set_normalization_strategy(new EE_Text_Normalization()); |
| 20 | 20 | parent::__construct($input_settings); |
| 21 | - $this->set_html_class($this->html_class() . 'password'); |
|
| 21 | + $this->set_html_class($this->html_class().'password'); |
|
| 22 | 22 | } |
| 23 | 23 | } |
@@ -12,21 +12,21 @@ |
||
| 12 | 12 | class EE_Credit_Card_Month_Input extends EE_Month_Input |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @param bool $leading_zero |
|
| 17 | - * @param array $input_settings |
|
| 18 | - * @param bool $january_is_month_1 |
|
| 19 | - */ |
|
| 20 | - public function __construct( |
|
| 21 | - $leading_zero = false, |
|
| 22 | - $input_settings = array(), |
|
| 23 | - $january_is_month_1 = true |
|
| 24 | - ) { |
|
| 25 | - $this->set_sensitive_data_removal_strategy(new EE_All_Sensitive_Data_Removal()); |
|
| 26 | - parent::__construct( |
|
| 27 | - $leading_zero, |
|
| 28 | - $input_settings, |
|
| 29 | - $january_is_month_1 |
|
| 30 | - ); |
|
| 31 | - } |
|
| 15 | + /** |
|
| 16 | + * @param bool $leading_zero |
|
| 17 | + * @param array $input_settings |
|
| 18 | + * @param bool $january_is_month_1 |
|
| 19 | + */ |
|
| 20 | + public function __construct( |
|
| 21 | + $leading_zero = false, |
|
| 22 | + $input_settings = array(), |
|
| 23 | + $january_is_month_1 = true |
|
| 24 | + ) { |
|
| 25 | + $this->set_sensitive_data_removal_strategy(new EE_All_Sensitive_Data_Removal()); |
|
| 26 | + parent::__construct( |
|
| 27 | + $leading_zero, |
|
| 28 | + $input_settings, |
|
| 29 | + $january_is_month_1 |
|
| 30 | + ); |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -9,21 +9,21 @@ |
||
| 9 | 9 | class EE_Email_Input extends EE_Form_Input_Base |
| 10 | 10 | { |
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * @param array $input_settings |
|
| 14 | - */ |
|
| 15 | - public function __construct($input_settings = array()) |
|
| 16 | - { |
|
| 17 | - $this->_set_display_strategy(new EE_Text_Input_Display_Strategy('email')); |
|
| 18 | - $this->_set_normalization_strategy(new EE_Text_Normalization()); |
|
| 19 | - $this->_add_validation_strategy( |
|
| 20 | - new EE_Email_Validation_Strategy( |
|
| 21 | - isset($input_settings['validation_error_message']) |
|
| 22 | - ? $input_settings['validation_error_message'] |
|
| 23 | - : null |
|
| 24 | - ) |
|
| 25 | - ); |
|
| 26 | - parent::__construct($input_settings); |
|
| 27 | - $this->set_html_class($this->html_class() . ' email'); |
|
| 28 | - } |
|
| 12 | + /** |
|
| 13 | + * @param array $input_settings |
|
| 14 | + */ |
|
| 15 | + public function __construct($input_settings = array()) |
|
| 16 | + { |
|
| 17 | + $this->_set_display_strategy(new EE_Text_Input_Display_Strategy('email')); |
|
| 18 | + $this->_set_normalization_strategy(new EE_Text_Normalization()); |
|
| 19 | + $this->_add_validation_strategy( |
|
| 20 | + new EE_Email_Validation_Strategy( |
|
| 21 | + isset($input_settings['validation_error_message']) |
|
| 22 | + ? $input_settings['validation_error_message'] |
|
| 23 | + : null |
|
| 24 | + ) |
|
| 25 | + ); |
|
| 26 | + parent::__construct($input_settings); |
|
| 27 | + $this->set_html_class($this->html_class() . ' email'); |
|
| 28 | + } |
|
| 29 | 29 | } |
@@ -24,6 +24,6 @@ |
||
| 24 | 24 | ) |
| 25 | 25 | ); |
| 26 | 26 | parent::__construct($input_settings); |
| 27 | - $this->set_html_class($this->html_class() . ' email'); |
|
| 27 | + $this->set_html_class($this->html_class().' email'); |
|
| 28 | 28 | } |
| 29 | 29 | } |
@@ -13,20 +13,20 @@ |
||
| 13 | 13 | class EE_Select_Input extends EE_Form_Input_With_Options_Base |
| 14 | 14 | { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * @param array $answer_options |
|
| 18 | - * @param array $input_settings |
|
| 19 | - */ |
|
| 20 | - public function __construct($answer_options, $input_settings = array()) |
|
| 21 | - { |
|
| 22 | - $this->_set_display_strategy(new EE_Select_Display_Strategy($answer_options)); |
|
| 23 | - $this->_add_validation_strategy( |
|
| 24 | - new EE_Enum_Validation_Strategy( |
|
| 25 | - isset($input_settings['validation_error_message']) |
|
| 26 | - ? $input_settings['validation_error_message'] |
|
| 27 | - : null |
|
| 28 | - ) |
|
| 29 | - ); |
|
| 30 | - parent::__construct($answer_options, $input_settings); |
|
| 31 | - } |
|
| 16 | + /** |
|
| 17 | + * @param array $answer_options |
|
| 18 | + * @param array $input_settings |
|
| 19 | + */ |
|
| 20 | + public function __construct($answer_options, $input_settings = array()) |
|
| 21 | + { |
|
| 22 | + $this->_set_display_strategy(new EE_Select_Display_Strategy($answer_options)); |
|
| 23 | + $this->_add_validation_strategy( |
|
| 24 | + new EE_Enum_Validation_Strategy( |
|
| 25 | + isset($input_settings['validation_error_message']) |
|
| 26 | + ? $input_settings['validation_error_message'] |
|
| 27 | + : null |
|
| 28 | + ) |
|
| 29 | + ); |
|
| 30 | + parent::__construct($answer_options, $input_settings); |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -9,40 +9,40 @@ |
||
| 9 | 9 | abstract class EE_Form_Input_Strategy_Base |
| 10 | 10 | { |
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * Form Input to display |
|
| 14 | - * |
|
| 15 | - * @var EE_Form_Input_Base |
|
| 16 | - */ |
|
| 17 | - protected $_input; |
|
| 12 | + /** |
|
| 13 | + * Form Input to display |
|
| 14 | + * |
|
| 15 | + * @var EE_Form_Input_Base |
|
| 16 | + */ |
|
| 17 | + protected $_input; |
|
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | |
| 21 | - public function __construct() |
|
| 22 | - { |
|
| 23 | - } |
|
| 21 | + public function __construct() |
|
| 22 | + { |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * The form input on which this strategy is to perform |
|
| 29 | - * |
|
| 30 | - * @param EE_Form_Input_Base $form_input |
|
| 31 | - */ |
|
| 32 | - public function _construct_finalize(EE_Form_Input_Base $form_input) |
|
| 33 | - { |
|
| 34 | - $this->_input = $form_input; |
|
| 35 | - } |
|
| 27 | + /** |
|
| 28 | + * The form input on which this strategy is to perform |
|
| 29 | + * |
|
| 30 | + * @param EE_Form_Input_Base $form_input |
|
| 31 | + */ |
|
| 32 | + public function _construct_finalize(EE_Form_Input_Base $form_input) |
|
| 33 | + { |
|
| 34 | + $this->_input = $form_input; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Gets this strategy's input |
|
| 41 | - * |
|
| 42 | - * @return EE_Form_Input_Base |
|
| 43 | - */ |
|
| 44 | - public function get_input() |
|
| 45 | - { |
|
| 46 | - return $this->_input; |
|
| 47 | - } |
|
| 39 | + /** |
|
| 40 | + * Gets this strategy's input |
|
| 41 | + * |
|
| 42 | + * @return EE_Form_Input_Base |
|
| 43 | + */ |
|
| 44 | + public function get_input() |
|
| 45 | + { |
|
| 46 | + return $this->_input; |
|
| 47 | + } |
|
| 48 | 48 | } |