tab_activity.php
4 months ago
tab_captcha.php
3 months ago
tab_design.php
4 months ago
tab_firewall.php
4 months ago
tab_geoip.php
4 months ago
tab_login_form.php
4 months ago
tab_temp_access.php
4 months ago
tab_captcha.php
276 lines
| 1 | <?php |
| 2 | /** |
| 3 | * WP Captcha |
| 4 | * https://getwpcaptcha.com/ |
| 5 | * (c) WebFactory Ltd, 2022 - 2026, www.webfactoryltd.com |
| 6 | */ |
| 7 | |
| 8 | class WPCaptcha_Tab_Captcha extends WPCaptcha |
| 9 | { |
| 10 | static function display() |
| 11 | { |
| 12 | $tabs[] = array('id' => 'tab_captcha', 'class' => 'tab-content', 'label' => __('Captcha', 'advanced-google-recaptcha'), 'callback' => array(__CLASS__, 'tab_captcha')); |
| 13 | $tabs[] = array('id' => 'tab_captcha_location', 'class' => 'tab-content', 'label' => __('Where To Show', 'advanced-google-recaptcha'), 'callback' => array(__CLASS__, 'tab_captcha_location')); |
| 14 | |
| 15 | echo '<div id="tabs_log" class="ui-tabs wpcaptcha-tabs-2nd-level">'; |
| 16 | echo '<ul>'; |
| 17 | foreach ($tabs as $tab) { |
| 18 | echo '<li><a href="#' . esc_attr($tab['id']) . '">' . esc_html($tab['label']) . '</a></li>'; |
| 19 | } |
| 20 | echo '</ul>'; |
| 21 | |
| 22 | foreach ($tabs as $tab) { |
| 23 | if (is_callable($tab['callback'])) { |
| 24 | echo '<div style="display: none;" id="' . esc_attr($tab['id']) . '" class="' . esc_attr($tab['class']) . '">'; |
| 25 | call_user_func($tab['callback']); |
| 26 | echo '</div>'; |
| 27 | } |
| 28 | } // foreach |
| 29 | |
| 30 | echo '</div>'; // second level of tabs |
| 31 | } // display |
| 32 | |
| 33 | static function tab_captcha() |
| 34 | { |
| 35 | $options = WPCaptcha_Setup::get_options(); |
| 36 | |
| 37 | echo '<div class="tab-content">'; |
| 38 | |
| 39 | echo '<table class="form-table"><tbody>'; |
| 40 | |
| 41 | $captcha = array(); |
| 42 | $captcha[] = array('val' => 'disabled', 'label' => 'Disabled'); |
| 43 | $captcha[] = array('val' => 'builtin', 'label' => 'Built-in Math Captcha'); |
| 44 | $captcha[] = array('val' => 'icons', 'label' => 'Built-in Icon Captcha', 'class' => 'pro-option'); |
| 45 | $captcha[] = array('val' => 'recaptchav2', 'label' => 'Google reCAPTCHA v2'); |
| 46 | $captcha[] = array('val' => 'recaptchav3', 'label' => 'Google reCAPTCHA v3'); |
| 47 | $captcha[] = array('val' => 'hcaptcha', 'label' => 'hCaptcha', 'class' => 'pro-option'); |
| 48 | $captcha[] = array('val' => 'cloudflare', 'label' => 'Cloudflare Turnstile', 'class' => 'pro-option'); |
| 49 | |
| 50 | echo '<tr valign="top"> |
| 51 | <th scope="row"><label for="captcha">Captcha</label></th> |
| 52 | <td><select id="captcha" name="' . esc_attr(WPCAPTCHA_OPTIONS_KEY) . '[captcha]">'; |
| 53 | WPCaptcha_Utility::create_select_options($captcha, $options['captcha']); |
| 54 | echo '</select>'; |
| 55 | echo '<br /><span>Captcha or "are you human" verification ensures bots can\'t attack your login page and provides additional protection with minimal impact to users.</span>'; |
| 56 | echo '</td></tr>'; |
| 57 | |
| 58 | echo '<tr class="captcha_challenge_text" style="display:none;" valign="top"> |
| 59 | <th scope="row"><label for="captcha_challenge_text">Captcha Challenge Text</label></th> |
| 60 | <td><input type="text" class="regular-text" id="captcha_challenge_text" name="' . esc_attr(WPCAPTCHA_OPTIONS_KEY) . '[captcha_challenge_text]" value="' . (!empty($options['captcha_challenge_text']) ? esc_html($options['captcha_challenge_text']) : 'Are you human? Please solve:') . '" />'; |
| 61 | echo '</td></tr>'; |
| 62 | |
| 63 | echo '<tr class="captcha_keys_wrapper" style="display:none;" valign="top"> |
| 64 | <th scope="row"><label for="captcha_site_key">Captcha Site Key</label></th> |
| 65 | <td><input type="text" class="regular-text" id="captcha_site_key" name="' . esc_attr(WPCAPTCHA_OPTIONS_KEY) . '[captcha_site_key]" value="' . esc_html($options['captcha_site_key']) . '" data-old="' . esc_html($options['captcha_site_key']) . '" />'; |
| 66 | echo '</td></tr>'; |
| 67 | |
| 68 | echo '<tr class="captcha_keys_wrapper" style="display:none;" valign="top"> |
| 69 | <th scope="row"><label for="captcha_secret_key">Captcha Secret Key</label></th> |
| 70 | <td><input type="text" class="regular-text" id="captcha_secret_key" name="' . esc_attr(WPCAPTCHA_OPTIONS_KEY) . '[captcha_secret_key]" value="' . esc_html($options['captcha_secret_key']) . '" data-old="' . esc_html($options['captcha_secret_key']) . '" />'; |
| 71 | echo '</td></tr>'; |
| 72 | |
| 73 | echo '<tr class="captcha_score_wrapper" style="display:none;" valign="top"> |
| 74 | <th scope="row"><label for="captcha_secret_key">Captcha Score</label><a title="This feature is available in the PRO version. Click for details." href="#" data-feature="recaptchav3_score" class="open-upsell pro-label">PRO</a></th> |
| 75 | <td><select id="captcha_score" name="' . esc_attr(WPCAPTCHA_OPTIONS_KEY) . '[captcha_score]" class="pro-option"> |
| 76 | <option value="0.0" class="pro-option">0.0</option> |
| 77 | <option value="0.1" class="pro-option">0.1</option> |
| 78 | <option value="0.2" class="pro-option">0.2</option> |
| 79 | <option value="0.3" class="pro-option">0.3</option> |
| 80 | <option value="0.4" class="pro-option">0.4</option> |
| 81 | <option value="0.5" selected>0.5</option> |
| 82 | <option value="0.6" class="pro-option">0.6</option> |
| 83 | <option value="0.7" class="pro-option">0.7</option> |
| 84 | <option value="0.8" class="pro-option">0.8</option> |
| 85 | <option value="0.9" class="pro-option">0.9</option> |
| 86 | <option value="1.0" class="pro-option">1.0</option> |
| 87 | </select>'; |
| 88 | echo '<br /><span>reCAPTCHA v3 returns a score (1.0 is very likely a good interaction, 0.0 is very likely a bot)</span>'; |
| 89 | |
| 90 | echo '</td></tr>'; |
| 91 | |
| 92 | echo '<tr class="captcha_verify_wrapper" style="display:none;" valign="top"> |
| 93 | <th scope="row"></th> |
| 94 | <td><button id="verify-captcha" class="button button-primary button-large button-yellow">Verify Captcha <i class="wpcaptcha-icon wpcaptcha-make-group"></i></button>'; |
| 95 | echo '<input type="hidden" class="regular-text" id="captcha_verified" name="' . esc_attr(WPCAPTCHA_OPTIONS_KEY) . '[captcha_verified]" value="1" />'; |
| 96 | echo '<br /><span>Click the Verify Captcha button to verify that the captcha is valid and working otherwise captcha settings will not be saved</span>'; |
| 97 | echo '</td></tr>'; |
| 98 | |
| 99 | echo '<tr><td></td><td>'; |
| 100 | WPCaptcha_admin::footer_save_button(); |
| 101 | echo '</td></tr>'; |
| 102 | |
| 103 | echo '<tr><td colspan="2">'; |
| 104 | echo '<div class="captcha-box-wrapper ' . ($options['captcha'] == 'disabled'?'captcha-selected':'') . '" data-captcha="disabled">'; |
| 105 | echo '<img src="' . esc_url(WPCAPTCHA_PLUGIN_URL) . '/images/captcha_disabled.png" />'; |
| 106 | echo '<div class="captcha-box-desc">'; |
| 107 | echo '<h3>Captcha Disabled</h3>'; |
| 108 | echo '<ul>'; |
| 109 | echo '<li>No Additional Security</li>'; |
| 110 | echo '</ul>'; |
| 111 | echo '</div>'; |
| 112 | echo '</div>'; |
| 113 | |
| 114 | echo '<div class="captcha-box-wrapper ' . ($options['captcha'] == 'builtin'?'captcha-selected':'') . '" data-captcha="builtin">'; |
| 115 | echo '<img src="' . esc_url(WPCAPTCHA_PLUGIN_URL) . '/images/captcha_builtin.png" />'; |
| 116 | echo '<div class="captcha-box-desc">'; |
| 117 | echo '<h3>Built-in Math Captcha</h3>'; |
| 118 | echo '<ul>'; |
| 119 | echo '<li>Low Security</li>'; |
| 120 | echo '<li>No API keys</li>'; |
| 121 | echo '<li>No 3rd party services</li>'; |
| 122 | echo '<li>GDPR Compatible</li>'; |
| 123 | echo '</ul>'; |
| 124 | echo '</div>'; |
| 125 | echo '</div>'; |
| 126 | |
| 127 | echo '<div class="captcha-box-wrapper ' . ($options['captcha'] == 'icons'?'captcha-selected':'') . '" data-captcha="icons">'; |
| 128 | echo '<a title="This feature is available in the PRO version. Click for details." href="#" data-feature="recaptchav2" class="open-upsell pro-label">PRO</a>'; |
| 129 | echo '<img src="' . esc_url(WPCAPTCHA_PLUGIN_URL) . '/images/captcha_icons.png" />'; |
| 130 | echo '<div class="captcha-box-desc">'; |
| 131 | echo '<h3>Built-in Icon Captcha</h3>'; |
| 132 | echo '<ul>'; |
| 133 | echo '<li>Low Security</li>'; |
| 134 | echo '<li>No API keys</li>'; |
| 135 | echo '<li>No 3rd party services</li>'; |
| 136 | echo '<li>GDPR Compatible</li>'; |
| 137 | echo '</ul>'; |
| 138 | echo '</div>'; |
| 139 | echo '</div>'; |
| 140 | |
| 141 | echo '<div class="captcha-box-wrapper ' . ($options['captcha'] == 'recaptchav2'?'captcha-selected':'') . '" data-captcha="recaptchav2">'; |
| 142 | echo '<img src="' . esc_url(WPCAPTCHA_PLUGIN_URL) . '/images/captcha_recaptcha_v2.png" />'; |
| 143 | echo '<div class="captcha-box-desc">'; |
| 144 | echo '<h3>Google reCaptcha v2</h3>'; |
| 145 | echo '<ul>'; |
| 146 | echo '<li>High Security</li>'; |
| 147 | echo '<li>Requires <a href="https://www.google.com/recaptcha/about/" target="_blank">API Keys</a></li>'; |
| 148 | echo '<li>Powered by Google</li>'; |
| 149 | echo '<li>Not GDPR Compatible</li>'; |
| 150 | echo '</ul>'; |
| 151 | echo '</div>'; |
| 152 | echo '</div>'; |
| 153 | |
| 154 | echo '<div class="captcha-box-wrapper ' . ($options['captcha'] == 'recaptchav3'?'captcha-selected':'') . '" data-captcha="recaptchav3">'; |
| 155 | echo '<img src="' . esc_url(WPCAPTCHA_PLUGIN_URL) . '/images/captcha_recaptcha_v3.png" />'; |
| 156 | echo '<div class="captcha-box-desc">'; |
| 157 | echo '<h3>Google reCaptcha v3</h3>'; |
| 158 | echo '<ul>'; |
| 159 | echo '<li>High Security</li>'; |
| 160 | echo '<li>Requires <a href="https://www.google.com/recaptcha/about/" target="_blank">API Keys</a></li>'; |
| 161 | echo '<li>Powered by Google</li>'; |
| 162 | echo '<li>Not GDPR Compatible</li>'; |
| 163 | echo '</ul>'; |
| 164 | echo '</div>'; |
| 165 | echo '</div>'; |
| 166 | |
| 167 | echo '<div class="captcha-box-wrapper ' . ($options['captcha'] == 'hcaptcha'?'captcha-selected':'') . '" data-captcha="hcaptcha">'; |
| 168 | echo '<a title="This feature is available in the PRO version. Click for details." href="#" data-feature="recaptchav2" class="open-upsell pro-label">PRO</a>'; |
| 169 | echo '<img src="' . esc_url(WPCAPTCHA_PLUGIN_URL) . '/images/captcha_hcaptcha.png" />'; |
| 170 | echo '<div class="captcha-box-desc">'; |
| 171 | echo '<h3>hCaptcha</h3>'; |
| 172 | echo '<ul>'; |
| 173 | echo '<li>High Security</li>'; |
| 174 | echo '<li>Requires <a href="https://www.hcaptcha.com/signup-interstitial" target="_blank">API Keys</a></li>'; |
| 175 | echo '<li>GDPR Compatible</li>'; |
| 176 | echo '<li>Best Choice</li>'; |
| 177 | echo '</ul>'; |
| 178 | echo '</div>'; |
| 179 | echo '</div>'; |
| 180 | |
| 181 | echo '<div class="captcha-box-wrapper ' . ($options['captcha'] == 'cloudflare'?'captcha-selected':'') . '" data-captcha="cloudflare">'; |
| 182 | echo '<a title="This feature is available in the PRO version. Click for details." href="#" data-feature="recaptchav2" class="open-upsell pro-label">PRO</a>'; |
| 183 | echo '<img src="' . esc_url(WPCAPTCHA_PLUGIN_URL) . '/images/captcha_cloudflare.png" />'; |
| 184 | echo '<div class="captcha-box-desc">'; |
| 185 | echo '<h3>Cloudflare Turnstile</h3>'; |
| 186 | echo '<ul>'; |
| 187 | echo '<li>High Security</li>'; |
| 188 | echo '<li>Requires <a href="https://dash.cloudflare.com/sign-up?to=/:account/turnstile" target="_blank">API Keys</a></li>'; |
| 189 | echo '<li>Not explicitly GDPR Compatible</li>'; |
| 190 | echo '<li>Powered by Cloudflare</li>'; |
| 191 | echo '</ul>'; |
| 192 | echo '</div>'; |
| 193 | echo '</div>'; |
| 194 | |
| 195 | |
| 196 | echo '</td></tr>'; |
| 197 | |
| 198 | echo '</tbody></table>'; |
| 199 | |
| 200 | echo '</div>'; |
| 201 | } // tab_captcha |
| 202 | |
| 203 | static function tab_captcha_location() |
| 204 | { |
| 205 | $options = WPCaptcha_Setup::get_options(); |
| 206 | |
| 207 | echo '<div class="tab-content">'; |
| 208 | |
| 209 | echo '<table class="form-table"><tbody>'; |
| 210 | |
| 211 | echo '<tr valign="top"> |
| 212 | <th scope="row"><label for="captcha_show_login">Login Form</label></th> |
| 213 | <td>'; |
| 214 | WPCaptcha_Utility::create_toggle_switch('captcha_show_login', array('saved_value' => $options['captcha_show_login'], 'option_key' => esc_attr(WPCAPTCHA_OPTIONS_KEY) . '[captcha_show_login]')); |
| 215 | echo '<br /><span>Applies to default login, WooCommerce, and Easy Digital Downloads login pages</span>'; |
| 216 | echo '</td></tr>'; |
| 217 | |
| 218 | echo '<tr valign="top"> |
| 219 | <th scope="row"><label for="captcha_show_wp_registration">Registration Form</label></th> |
| 220 | <td>'; |
| 221 | WPCaptcha_Utility::create_toggle_switch('captcha_show_wp_registration', array('saved_value' => $options['captcha_show_wp_registration'], 'option_key' => esc_attr(WPCAPTCHA_OPTIONS_KEY) . '[captcha_show_wp_registration]')); |
| 222 | echo '<br /><span>Show captcha on WordPress user registration form</span>'; |
| 223 | echo '</td></tr>'; |
| 224 | |
| 225 | echo '<tr valign="top"> |
| 226 | <th scope="row"><label for="captcha_show_wp_lost_password">Lost Password Form</label></th> |
| 227 | <td>'; |
| 228 | WPCaptcha_Utility::create_toggle_switch('captcha_show_wp_lost_password', array('saved_value' => $options['captcha_show_wp_lost_password'], 'option_key' => esc_attr(WPCAPTCHA_OPTIONS_KEY) . '[captcha_show_wp_lost_password]')); |
| 229 | echo '<br /><span>Show captcha on WordPress lost password form</span>'; |
| 230 | echo '</td></tr>'; |
| 231 | |
| 232 | echo '<tr valign="top"> |
| 233 | <th scope="row"><label for="captcha_show_wp_comment">Comment Form</label></th> |
| 234 | <td>'; |
| 235 | WPCaptcha_Utility::create_toggle_switch('captcha_show_wp_comment', array('saved_value' => $options['captcha_show_wp_comment'], 'option_key' => esc_attr(WPCAPTCHA_OPTIONS_KEY) . '[captcha_show_wp_comment]')); |
| 236 | echo '<br /><span>Show captcha on WordPress comments form</span>'; |
| 237 | echo '</td></tr>'; |
| 238 | |
| 239 | echo '<tr valign="top"> |
| 240 | <th scope="row"><label for="captcha_show_woo_registration">WooCommerce Registration Form</label></th> |
| 241 | <td>'; |
| 242 | WPCaptcha_Utility::create_toggle_switch('captcha_show_woo_registration', array('saved_value' => $options['captcha_show_woo_registration'], 'option_key' => esc_attr(WPCAPTCHA_OPTIONS_KEY) . '[captcha_show_woo_registration]')); |
| 243 | echo '<br /><span>Show captcha on WooCommerce registration form</span>'; |
| 244 | echo '</td></tr>'; |
| 245 | |
| 246 | echo '<tr valign="top"> |
| 247 | <th scope="row"><label for="captcha_show_woo_checkout">WooCommerce Checkout Form</label></th> |
| 248 | <td>'; |
| 249 | WPCaptcha_Utility::create_toggle_switch('captcha_show_woo_checkout', array('saved_value' => $options['captcha_show_woo_checkout'], 'option_key' => esc_attr(WPCAPTCHA_OPTIONS_KEY) . '[captcha_show_woo_checkout]')); |
| 250 | echo '<br /><span>Show captcha on WooCommerce checkout form</span>'; |
| 251 | echo '</td></tr>'; |
| 252 | |
| 253 | echo '<tr valign="top"> |
| 254 | <th scope="row"><label for="captcha_show_edd_registration">Easy Digital Downloads Registration Form</label></th> |
| 255 | <td>'; |
| 256 | WPCaptcha_Utility::create_toggle_switch('captcha_show_edd_registration', array('saved_value' => $options['captcha_show_edd_registration'], 'option_key' => esc_attr(WPCAPTCHA_OPTIONS_KEY) . '[captcha_show_edd_registration]')); |
| 257 | echo '<br /><span>Show captcha on Easy Digital Downloads registration form</span>'; |
| 258 | echo '</td></tr>'; |
| 259 | |
| 260 | echo '<tr valign="top"> |
| 261 | <th scope="row"><label for="captcha_show_bp_registration">BuddyPress Registration Form</label></th> |
| 262 | <td>'; |
| 263 | WPCaptcha_Utility::create_toggle_switch('captcha_show_bp_registration', array('saved_value' => $options['captcha_show_bp_registration'], 'option_key' => esc_attr(WPCAPTCHA_OPTIONS_KEY) . '[captcha_show_bp_registration]')); |
| 264 | echo '<br /><span>Show captcha on BuddyPress registration form</span>'; |
| 265 | echo '</td></tr>'; |
| 266 | |
| 267 | echo '<tr><td></td><td>'; |
| 268 | WPCaptcha_admin::footer_save_button(); |
| 269 | echo '</td></tr>'; |
| 270 | |
| 271 | echo '</tbody></table>'; |
| 272 | |
| 273 | echo '</div>'; |
| 274 | } // tab_captcha_location |
| 275 | } // class WPCaptcha_Tab_Captcha |
| 276 |