| @@ -27,8 +27,9 @@ | ||
| 27 | 27 | public function verify( array $request ) { |
| 28 | 28 | $action = ( new Verify_Token_Action() ) |
| 29 | 29 | ->set_secret( $this->options['secret'] ?? '' ) |
| 30 | 30 | ->set_token( $request[ self::FIELD ] ?? '' ) |
| 31 | + ->set_site_key( $this->get_captcha_args()['sitekey'] ) | |
| 31 | 32 | ->set_action( jet_fb_live()->form_id ); |
| 32 | 33 | |
| 33 | 34 | try { |
| 34 | 35 | $action->send_request(); |
| @@ -44,14 +45,9 @@ | ||
| 44 | 45 | /** |
| 45 | 46 | * @return string |
| 46 | 47 | */ |
| 47 | 48 | public function render(): string { |
| 48 | - $captcha_args = apply_filters( | |
| 49 | - 'jet-form-builder/h-captcha/options', | |
| 50 | - array( | |
| 51 | - 'sitekey' => $this->options['key'] ?? '', | |
| 52 | - ) | |
| 53 | - ); | |
| 49 | + $captcha_args = $this->get_captcha_args(); | |
| 54 | 50 | |
| 55 | 51 | if ( empty( $captcha_args['sitekey'] ) ) { |
| 56 | 52 | return ''; |
| 57 | 53 | } |
| @@ -72,8 +68,26 @@ | ||
| 72 | 68 | </div>', |
| 73 | 69 | self::FIELD_CLASS, |
| 74 | 70 | self::FIELD |
| 75 | 71 | ); |
| 72 | + } | |
| 73 | + | |
| 74 | + private function get_captcha_args(): array { | |
| 75 | + $captcha_args = apply_filters( | |
| 76 | + 'jet-form-builder/h-captcha/options', | |
| 77 | + array( | |
| 78 | + 'sitekey' => $this->options['key'] ?? '', | |
| 79 | + ) | |
| 80 | + ); | |
| 81 | + | |
| 82 | + if ( ! is_array( $captcha_args ) ) { | |
| 83 | + $captcha_args = array(); | |
| 84 | + } | |
| 85 | + | |
| 86 | + $site_key = $captcha_args['sitekey'] ?? ''; | |
| 87 | + $captcha_args['sitekey'] = is_scalar( $site_key ) ? sanitize_text_field( (string) $site_key ) : ''; | |
| 88 | + | |
| 89 | + return $captcha_args; | |
| 76 | 90 | } |
| 77 | 91 | |
| 78 | 92 | public function on_save_options( array $post_request ): array { |
| 79 | 93 | // phpcs:disable WordPress.Security.NonceVerification.Missing |