class-evf-settings-email.php
6 years ago
class-evf-settings-general.php
6 years ago
class-evf-settings-integrations.php
6 years ago
class-evf-settings-page.php
7 years ago
class-evf-settings-recaptcha.php
6 years ago
class-evf-settings-validation.php
6 years ago
class-evf-settings-recaptcha.php
150 lines
| 1 | <?php |
| 2 | /** |
| 3 | * EverestForms reCAPTCHA Settings |
| 4 | * |
| 5 | * @package EverestForms\Admin |
| 6 | * @version 1.0.0 |
| 7 | */ |
| 8 | |
| 9 | defined( 'ABSPATH' ) || exit; |
| 10 | |
| 11 | if ( class_exists( 'EVF_Settings_reCAPTCHA', false ) ) { |
| 12 | return new EVF_Settings_reCAPTCHA(); |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * EVF_Settings_reCAPTCHA. |
| 17 | */ |
| 18 | class EVF_Settings_reCAPTCHA extends EVF_Settings_Page { |
| 19 | |
| 20 | /** |
| 21 | * Constructor. |
| 22 | */ |
| 23 | public function __construct() { |
| 24 | $this->id = 'recaptcha'; |
| 25 | $this->label = esc_html__( 'reCAPTCHA', 'everest-forms' ); |
| 26 | |
| 27 | parent::__construct(); |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Get settings array. |
| 32 | * |
| 33 | * @return array |
| 34 | */ |
| 35 | public function get_settings() { |
| 36 | $recaptcha_type = get_option( 'everest_forms_recaptcha_type', 'v2' ); |
| 37 | $invisible = get_option( 'everest_forms_recaptcha_v2_invisible', 'no' ); |
| 38 | $settings = apply_filters( |
| 39 | 'everest_forms_recaptcha_settings', |
| 40 | array( |
| 41 | array( |
| 42 | 'title' => esc_html__( 'Google reCAPTCHA Integration', 'everest-forms' ), |
| 43 | 'type' => 'title', |
| 44 | /* translators: %1$s - Google reCAPTCHA docs url */ |
| 45 | 'desc' => sprintf( __( '<p>Google\'s reCAPTCHA is a free service that protects your website from spam and abuse while letting valid users pass through with ease.</p><p>reCAPTCHA uses an advanced risk analysis engine and adaptive challenges to keep automated software from engaging in abusive activities on your site.</p><p>Sites already using v2 reCAPTCHA will need to create new site keys before switching to the Invisible reCAPTCHA or v3 reCAPTCHA.</p><p><a href="%1$s" target="_blank">Read our documentation</a> for step-by-step instructions.</p>', 'everest-forms' ), 'https://docs.wpeverest.com/docs/everest-forms/tutorials/how-to-integrate-google-recaptcha/' ), |
| 46 | 'id' => 'integration_options', |
| 47 | ), |
| 48 | array( |
| 49 | 'title' => esc_html__( 'reCAPTCHA type', 'everest-forms' ), |
| 50 | 'desc' => esc_html__( 'Choose the type of reCAPTCHA for this site key.', 'everest-forms' ), |
| 51 | 'id' => 'everest_forms_recaptcha_type', |
| 52 | 'default' => 'v2', |
| 53 | 'type' => 'radio', |
| 54 | 'options' => array( |
| 55 | 'v2' => esc_html__( 'reCAPTCHA v2', 'everest-forms' ), |
| 56 | 'v3' => esc_html__( 'reCAPTCHA v3', 'everest-forms' ), |
| 57 | ), |
| 58 | 'class' => 'everest-forms-recaptcha-type', |
| 59 | 'desc_tip' => true, |
| 60 | ), |
| 61 | array( |
| 62 | 'title' => esc_html__( 'Site Key', 'everest-forms' ), |
| 63 | 'type' => 'text', |
| 64 | /* translators: %1$s - Google reCAPTCHA docs url */ |
| 65 | 'desc' => sprintf( esc_html__( 'Please enter your site key for your reCAPTCHA v2. <a href="%1$s" target="_blank">Learn More</a>', 'everest-forms' ), esc_url( 'https://docs.wpeverest.com/docs/everest-forms/tutorials/how-to-integrate-google-recaptcha/' ) ), |
| 66 | 'id' => 'everest_forms_recaptcha_v2_site_key', |
| 67 | 'is_visible' => 'v2' === $recaptcha_type && 'no' === $invisible, |
| 68 | 'default' => '', |
| 69 | 'desc_tip' => true, |
| 70 | ), |
| 71 | array( |
| 72 | 'title' => esc_html__( 'Secret Key', 'everest-forms' ), |
| 73 | 'type' => 'text', |
| 74 | /* translators: %1$s - Google reCAPTCHA docs url */ |
| 75 | 'desc' => sprintf( esc_html__( 'Please enter your secret key for your reCAPTCHA v2. <a href="%1$s" target="_blank">Learn More</a>', 'everest-forms' ), esc_url( 'https://docs.wpeverest.com/docs/everest-forms/tutorials/how-to-integrate-google-recaptcha/' ) ), |
| 76 | 'id' => 'everest_forms_recaptcha_v2_secret_key', |
| 77 | 'is_visible' => 'v2' === $recaptcha_type && 'no' === $invisible, |
| 78 | 'default' => '', |
| 79 | 'desc_tip' => true, |
| 80 | ), |
| 81 | array( |
| 82 | 'title' => esc_html__( 'Site Key', 'everest-forms' ), |
| 83 | 'type' => 'text', |
| 84 | /* translators: %1$s - Google reCAPTCHA docs url */ |
| 85 | 'desc' => sprintf( esc_html__( 'Please enter your site key for your reCAPTCHA v2. <a href="%1$s" target="_blank">Learn More</a>', 'everest-forms' ), esc_url( 'https://docs.wpeverest.com/docs/everest-forms/tutorials/how-to-integrate-google-recaptcha/' ) ), |
| 86 | 'id' => 'everest_forms_recaptcha_v2_invisible_site_key', |
| 87 | 'is_visible' => 'v2' === $recaptcha_type && 'yes' === $invisible, |
| 88 | 'default' => '', |
| 89 | 'desc_tip' => true, |
| 90 | ), |
| 91 | array( |
| 92 | 'title' => esc_html__( 'Secret Key', 'everest-forms' ), |
| 93 | 'type' => 'text', |
| 94 | /* translators: %1$s - Google reCAPTCHA docs url */ |
| 95 | 'desc' => sprintf( esc_html__( 'Please enter your secret key for your reCAPTCHA v2. <a href="%1$s" target="_blank">Learn More</a>', 'everest-forms' ), esc_url( 'https://docs.wpeverest.com/docs/everest-forms/tutorials/how-to-integrate-google-recaptcha/' ) ), |
| 96 | 'id' => 'everest_forms_recaptcha_v2_invisible_secret_key', |
| 97 | 'is_visible' => 'yes' === $invisible && 'v2' === $recaptcha_type, |
| 98 | 'default' => '', |
| 99 | 'desc_tip' => true, |
| 100 | ), |
| 101 | array( |
| 102 | 'title' => esc_html__( 'Invisible reCAPTCHA', 'everest-forms' ), |
| 103 | 'type' => 'checkbox', |
| 104 | 'desc' => esc_html__( 'Enable Invisible reCAPTCHA.', 'everest-forms' ), |
| 105 | 'id' => 'everest_forms_recaptcha_v2_invisible', |
| 106 | 'is_visible' => 'v2' === $recaptcha_type, |
| 107 | 'default' => 'no', |
| 108 | ), |
| 109 | array( |
| 110 | 'title' => esc_html__( 'Site Key', 'everest-forms' ), |
| 111 | 'type' => 'text', |
| 112 | /* translators: %1$s - Google reCAPTCHA docs url */ |
| 113 | 'desc' => sprintf( esc_html__( 'Please enter your site key for your reCAPTCHA v3. <a href="%1$s" target="_blank">Learn More</a>', 'everest-forms' ), esc_url( 'https://docs.wpeverest.com/docs/everest-forms/tutorials/how-to-integrate-google-recaptcha/' ) ), |
| 114 | 'id' => 'everest_forms_recaptcha_v3_site_key', |
| 115 | 'is_visible' => 'v3' === $recaptcha_type, |
| 116 | 'default' => '', |
| 117 | 'desc_tip' => true, |
| 118 | ), |
| 119 | array( |
| 120 | 'title' => esc_html__( 'Secret Key', 'everest-forms' ), |
| 121 | 'type' => 'text', |
| 122 | /* translators: %1$s - Google reCAPTCHA docs url */ |
| 123 | 'desc' => sprintf( esc_html__( 'Please enter your secret key for your reCAPTCHA v2. <a href="%1$s" target="_blank">Learn More</a>', 'everest-forms' ), esc_url( 'https://docs.wpeverest.com/docs/everest-forms/tutorials/how-to-integrate-google-recaptcha/' ) ), |
| 124 | 'id' => 'everest_forms_recaptcha_v3_secret_key', |
| 125 | 'is_visible' => 'v3' === $recaptcha_type, |
| 126 | 'default' => '', |
| 127 | 'desc_tip' => true, |
| 128 | ), |
| 129 | array( |
| 130 | 'type' => 'sectionend', |
| 131 | 'id' => 'integration_options', |
| 132 | ), |
| 133 | ) |
| 134 | ); |
| 135 | |
| 136 | return apply_filters( 'everest_forms_get_settings_' . $this->id, $settings ); |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Save settings. |
| 141 | */ |
| 142 | public function save() { |
| 143 | $settings = $this->get_settings(); |
| 144 | |
| 145 | EVF_Admin_Settings::save_fields( $settings ); |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | return new EVF_Settings_reCAPTCHA(); |
| 150 |