checkbox-field.php
7 years ago
date-field.php
7 years ago
file-field.php
1 week ago
full-line-checkbox-field.php
5 years ago
multiselect-field.php
7 years ago
password-field.php
7 years ago
radio-field.php
7 years ago
recaptcha-field.php
7 years ago
recaptcha-v3-field.php
2 years ago
select-field.php
4 years ago
term-checklist-field.php
6 years ago
term-multiselect-field.php
6 years ago
term-select-field.php
2 years ago
text-field.php
7 years ago
textarea-field.php
7 years ago
uploaded-file-html.php
7 years ago
wp-editor-field.php
6 years ago
recaptcha-v3-field.php
45 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Shows the `recaptcha` form field on job listing forms. |
| 4 | * |
| 5 | * This template can be overridden by copying it to yourtheme/job_manager/form-fields/recaptcha-v3-field.php. |
| 6 | * |
| 7 | * @see https://wpjobmanager.com/document/template-overrides/ |
| 8 | * @author Automattic |
| 9 | * @package wp-job-manager |
| 10 | * @category Template |
| 11 | * @version 2.3.0 |
| 12 | */ |
| 13 | |
| 14 | if ( ! defined( 'ABSPATH' ) ) { |
| 15 | exit; // Exit if accessed directly. |
| 16 | } |
| 17 | $site_key = get_option( 'job_manager_recaptcha_site_key' ); |
| 18 | |
| 19 | if ( doing_action( 'submit_resume_form_resume_fields_end' ) ) { |
| 20 | $form = 'submit_resume'; |
| 21 | } elseif ( doing_action( 'job_application_form_fields_end' ) ) { |
| 22 | $form = 'job-manager-application-form'; |
| 23 | } else { |
| 24 | $form = 'submit_job'; |
| 25 | } |
| 26 | ?> |
| 27 | <script> |
| 28 | let form = document.getElementById( 'submit-job-form' ) || |
| 29 | document.getElementById( 'submit-resume-form' ) || |
| 30 | document.querySelector( '.job-manager-application-form' ); |
| 31 | |
| 32 | function jm_job_submit_click(e) { |
| 33 | e.preventDefault(); |
| 34 | grecaptcha.ready(function() { |
| 35 | grecaptcha.execute( decodeURIComponent( '<?php echo rawurlencode( (string) $site_key ) ?>' ), { action: 'submit' } ).then( function( token ) { |
| 36 | document.getElementById( 'g-recaptcha-response' ).value = token; |
| 37 | form.submit(); |
| 38 | }); |
| 39 | }); |
| 40 | } |
| 41 | </script> |
| 42 | |
| 43 | <input type="hidden" name="g-recaptcha-response" id="g-recaptcha-response"> |
| 44 | <input type="hidden" name="<?php echo esc_attr( $form ) ?>" value="true"> |
| 45 |