PluginProbe ʕ •ᴥ•ʔ
reCaptcha by BestWebSoft / 1.67
reCaptcha by BestWebSoft v1.67
1.79 1.80 1.82 1.83 1.84 1.85 1.86 1.87 trunk 1.01 1.02 1.03 1.04 1.05 1.06 1.07 1.08 1.09 1.10 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.18 1.19 1.20 1.21 1.22 1.23 1.24 1.25 1.26 1.27 1.28 1.29 1.30 1.31 1.32 1.33 1.34 1.35 1.36 1.37 1.38 1.39 1.40 1.41 1.42 1.43 1.44 1.45 1.46 1.47 1.48 1.49 1.50 1.51 1.52 1.53 1.54 1.55 1.56 1.57 1.58 1.59 1.60 1.61 1.62 1.63 1.64 1.65 1.66 1.67 1.68 1.70 1.71 1.72 1.73 1.74 1.75 1.78
google-captcha / includes / class-gglcptch-settings-tabs.php
google-captcha / includes Last commit date
allowlist.php 4 years ago class-gglcptch-settings-tabs.php 4 years ago forms.php 4 years ago pro_banners.php 4 years ago
class-gglcptch-settings-tabs.php
420 lines
1 <?php
2 /**
3 * Displays the content on the plugin settings page
4 */
5 if ( ! class_exists( 'Gglcptch_Settings_Tabs' ) ) {
6 class Gglcptch_Settings_Tabs extends Bws_Settings_Tabs {
7 private $keys, $versions, $forms, $sections;
8
9 /**
10 * Constructor.
11 *
12 * @access public
13 *
14 * @see Bws_Settings_Tabs::__construct() for more information on default arguments.
15 *
16 * @param string $plugin_basename
17 */
18 public function __construct( $plugin_basename ) {
19 global $gglcptch_options, $gglcptch_plugin_info;
20
21 $tabs = array(
22 'settings' => array( 'label' => __( 'Settings', 'google-captcha' ) ),
23 'misc' => array( 'label' => __( 'Misc', 'google-captcha' ) ),
24 'custom_code' => array( 'label' => __( 'Custom Code', 'google-captcha' ) ),
25 /*pls */
26 'license' => array( 'label' => __( 'License Key', 'google-captcha' ) )
27 /* pls*/
28 );
29
30 parent::__construct( array(
31 'plugin_basename' => $plugin_basename,
32 'plugins_info' => $gglcptch_plugin_info,
33 'prefix' => 'gglcptch',
34 'default_options' => gglcptch_get_default_options(),
35 'options' => $gglcptch_options,
36 'tabs' => $tabs,
37 'doc_link' => 'https://bestwebsoft.com/documentation/recaptcha/recaptcha-user-guide/',
38 'doc_video_link' => 'https://www.youtube.com/watch?v=ZFv6txtic0Y/',
39 /*pls */
40 'wp_slug' => 'google-captcha',
41 'link_key' => 'b850d949ccc1239cab0da315c3c822ab',
42 'link_pn' => '109'
43 /* pls*/
44 ) );
45
46 $this->all_plugins = get_plugins();
47
48 /* Private and public keys */
49 $this->keys = array(
50 'public' => array(
51 'display_name' => __( 'Site Key', 'google-captcha' ),
52 'form_name' => 'gglcptch_public_key',
53 'error_msg' => '',
54 ),
55 'private' => array(
56 'display_name' => __( 'Secret Key', 'google-captcha' ),
57 'form_name' => 'gglcptch_private_key',
58 'error_msg' => '',
59 ),
60 );
61
62 $this->versions = array(
63 'v2' => sprintf( '%s 2', __( 'Version', 'google-captcha' ) ),
64 'v3' => sprintf( '%s 3', __( 'Version', 'google-captcha' ) ),
65 'invisible' => __( 'Invisible', 'google-captcha' )
66 );
67
68 /* Supported forms */
69 $this->forms = gglcptch_get_forms();
70 $this->sections = gglcptch_get_sections();
71
72 add_action( get_parent_class( $this ) . '_display_custom_messages', array( $this, 'display_custom_messages' ) );
73 add_action( get_parent_class( $this ) . '_additional_misc_options', array( $this, 'additional_misc_options' ) );
74 add_action( get_parent_class( $this ) . '_display_metabox', array( $this, 'display_metabox' ) );
75 add_action( get_parent_class( $this ) .'_information_postbox_bottom', array( $this, 'information_postbox_bottom' ) );
76 }
77
78 /**
79 * Save plugin options to the database
80 * @access public
81 * @param void
82 * @return array The action results
83 */
84 public function save_options() {
85
86 $message = $notice = $error = '';
87
88 /* Save data for settings page */
89 if ( empty( $_POST['gglcptch_public_key'] ) ) {
90 $this->keys['public']['error_msg'] = __( 'Enter site key', 'google-captcha' );
91 $error = __( "WARNING: The captcha will not be displayed until you fill key fields.", 'google-captcha' );
92 } else {
93 $this->keys['public']['error_msg'] = '';
94 }
95
96 if ( empty( $_POST['gglcptch_private_key'] ) ) {
97 $this->keys['private']['error_msg'] = __( 'Enter secret key', 'google-captcha' );
98 $error = __( "WARNING: The captcha will not be displayed until you fill key fields.", 'google-captcha' );
99 } else {
100 $this->keys['private']['error_msg'] = '';
101 }
102
103 if ( $_POST['gglcptch_public_key'] != $this->options['public_key'] || $_POST['gglcptch_private_key'] != $this->options['private_key'] ) {
104 $this->options['keys_verified'] = false;
105 }
106
107 if ( $_POST['gglcptch_recaptcha_version'] != $this->options['recaptcha_version'] ) {
108 $this->options['keys_verified'] = false;
109 $this->options['need_keys_verified_check'] = true;
110 }
111
112 $this->options['allowlist_message'] = stripslashes( sanitize_text_field( $_POST['gglcptch_allowlist_message'] ) );
113 $this->options['public_key'] = stripslashes( sanitize_text_field( $_POST['gglcptch_public_key'] ) );
114 $this->options['private_key'] = stripslashes( sanitize_text_field( $_POST['gglcptch_private_key'] ) );
115 $this->options['recaptcha_version'] = in_array( $_POST['gglcptch_recaptcha_version'], array( 'v2', 'invisible', 'v3' ) ) ? $_POST['gglcptch_recaptcha_version'] : $this->options['recaptcha_version'];
116 $this->options['theme_v2'] = in_array( $_POST['gglcptch_theme_v2'], array( 'light', 'dark' ) ) ? $_POST['gglcptch_theme_v2'] : $this->options['theme_v2'];
117 $this->options['score_v3'] = isset( $_POST['gglcptch_score_v3'] ) ? (float)$_POST['gglcptch_score_v3'] : 0.5;
118 $this->options['disable_submit'] = isset( $_POST['gglcptch_disable_submit'] ) ? 1 : 0;
119 $this->options['hide_badge'] = isset( $_POST['gglcptch_hide_badge'] ) ? 1 : 0;
120 $this->options['disable_submit_button'] = isset( $_POST['gglcptch_disable_submit_button'] ) ? 1 : 0;
121 $this->options['use_globally'] = intval( $_POST['gglcptch_use_globally'] );
122
123 foreach ( $this->forms as $form_slug => $form_data ) {
124 $this->options[ $form_slug ] = isset( $_POST["gglcptch_{$form_slug}"] ) ? 1 : 0;
125 }
126
127 if ( function_exists( 'get_editable_roles' ) ) {
128 foreach ( get_editable_roles() as $role => $fields ) {
129 $this->options[ $role ] = isset( $_POST[ 'gglcptch_' . $role ] ) ? 1 : 0;
130 }
131 }
132
133 $this->options = apply_filters( 'gglcptch_before_save_options', $this->options );
134 update_option( 'gglcptch_options', $this->options );
135 $message = __( "Settings saved.", 'google-captcha' );
136
137 return compact( 'message', 'notice', 'error' );
138 }
139
140 /**
141 * Displays 'settings' menu-tab
142 * @access public
143 * @param void
144 * @return void
145 */
146 public function tab_settings() { ?>
147 <h3 class="bws_tab_label"><?php _e( 'reCaptcha Settings', 'google-captcha' ); ?></h3>
148 <?php $this->help_phrase(); ?>
149 <hr>
150 <div class="bws_tab_sub_label"><?php _e( 'General', 'google-captcha' ); ?></div>
151 <table class="form-table">
152 <tr valign="top">
153 <th scope="row"><?php _e( 'reCaptcha Version', 'google-captcha' ); ?></th>
154 <td>
155 <fieldset>
156 <?php foreach ( $this->versions as $version => $version_name ) { ?>
157 <label>
158 <input type="radio" name="gglcptch_recaptcha_version" value="<?php echo $version; ?>" <?php checked( $version, $this->options['recaptcha_version'] ); ?>> <?php echo $version_name; ?>
159 </label>
160 <br/>
161 <?php } ?>
162 </fieldset>
163 </td>
164 </tr>
165 </table>
166 <table class="form-table gglcptch_settings_form">
167 <div class="bws_info gglcptch_settings_form"><?php printf( __( 'Register your domain name with Google reCaptcha service and add the keys to the fields below. %s Get the API Keys. %s' , 'google-captcha' ),
168 '<a target="_blank" href="https://www.google.com/recaptcha/admin#list">',
169 '</a>' ) ?>
170 </div>
171 <div class="bws_info gglcptch_settings_form"><?php printf( __( 'If you do not want to create API keys use %s Captcha by BestWebSoft %s plugin.', 'google-captcha' ),
172 '<a target="_blank" href="https://bestwebsoft.com/products/wordpress/plugins/captcha/?k=dcf21edcd5cc9374f5e15c8055e40797">',
173 '</a>' ); ?>
174 </div>
175 <?php foreach ( $this->keys as $key => $fields ) { ?>
176 <tr>
177 <th><?php echo $fields['display_name']; ?></th>
178 <td>
179 <input class="regular-text" type="text" name="<?php echo $fields['form_name']; ?>" value="<?php echo $this->options[ $key . '_key' ] ?>" maxlength="200" />
180 <label class="gglcptch_error_msg error"><?php echo $fields['error_msg']; ?></label>
181 <span class="dashicons dashicons-yes gglcptch_verified <?php if ( ! isset( $this->options['keys_verified'] ) || true !== $this->options['keys_verified'] ) echo 'hidden'; ?>"></span>
182 </td>
183 </tr>
184 <?php } if ( ! empty( $this->options['public_key'] ) && ! empty( $this->options['private_key'] ) ) { ?>
185 <tr class="hide-if-no-js">
186 <th></th>
187 <td>
188 <div id="gglcptch-test-keys">
189 <a class="button button-secondary" href="<?php echo add_query_arg( array( '_wpnonce' => wp_create_nonce( 'gglcptch-test-keys' ), 'action' => 'gglcptch-test-keys', 'is_network' => $this->is_network_options ? '1' : '0' ), admin_url( 'admin-ajax.php' ) ); ?>"><?php _e( 'Test reCaptcha' , 'google-captcha' ); ?></a>
190 </div>
191 </td>
192 </tr>
193 <?php } ?>
194 <tr valign="top">
195 <th scope="row"><?php _e( 'Enable reCaptcha for', 'google-captcha' ); ?></th>
196 <td>
197 <!--[if !IE]> -->
198 <div class="gglcptch-settings-accordion">
199 <!-- <![endif]-->
200 <?php foreach ( $this->sections as $section_slug => $section ) {
201
202 if ( empty( $section['name'] ) || empty( $section['forms'] ) || ! is_array( $section['forms'] ) ) {
203 continue;
204 }
205
206 $section_notice = ! empty( $section['section_notice'] ) ? $section['section_notice'] : ''; ?>
207 <p class="gglcptch_section_header">
208 <i><?php echo $section['name']; ?></i>
209 <?php if ( ! empty( $section_notice ) ) { ?>
210 &nbsp;<span class="bws_info"><?php echo $section_notice; ?></span>
211 <?php } ?><br />
212 </p>
213 <fieldset class="gglcptch_section_forms">
214 <?php foreach ( $section['forms'] as $form_slug ) {
215 $form_notice = $this->forms[ $form_slug ]['form_notice'];
216 $form_atts = '';
217 if ( '' != $form_notice || '' != $section_notice ) {
218 $form_atts .= disabled( 1, 1, false );
219 }
220 $form_atts .= checked( ! empty( $this->options[ $form_slug ] ), true, false ); ?>
221 <label>
222 <input type="checkbox"<?php echo $form_atts; ?> name="gglcptch_<?php echo $form_slug; ?>" value="1" /> <?php echo $this->forms[ $form_slug ]['form_name']; ?>
223 </label>
224 <?php if ( '' != $form_notice ) { ?>
225 &nbsp;<span class="bws_info"><?php echo $form_notice; ?></span>
226 <?php } ?>
227 <br />
228 <?php } ?>
229 <hr />
230 </fieldset>
231 <?php } ?>
232 <!--[if !IE]> -->
233 </div> <!-- .gglcptch-settings-accordion -->
234 <!-- <![endif]-->
235 </td>
236 </tr>
237 </table>
238 <!-- pls -->
239 <?php if ( ! $this->hide_pro_tabs ) { ?>
240 <div class="bws_pro_version_bloc">
241 <div class="bws_pro_version_table_bloc">
242 <button type="submit" name="bws_hide_premium_options" class="notice-dismiss bws_hide_premium_options" title="<?php _e( 'Close', 'google-captcha' ); ?>"></button>
243 <div class="bws_table_bg"></div>
244 <?php gglcptch_supported_plugins_banner(); ?>
245 </div>
246 <?php $this->bws_pro_block_links(); ?>
247 </div>
248 <?php } ?>
249 <!-- end pls -->
250 <table class="form-table">
251 <tr valign="top">
252 <th scope="row">
253 <?php _e( 'reCaptcha Domain', 'google-captcha' ); ?>
254 </th>
255 <td>
256 <select <?php echo $this->change_permission_attr; ?> name="gglcptch_use_globally">
257 <option value="0" <?php selected( $this->options['use_globally'], 0 ); ?>>google.com</option>
258 <option value="1" <?php selected( $this->options['use_globally'], 1 ); ?>>recaptcha.net</option>
259 </select>
260 <div class="bws_info">
261 <?php _e( 'If Google is not accessible or blocked in your country select other one.', 'google-captcha' ); ?>
262 </div>
263 </td>
264 </tr>
265 </table>
266 <!-- pls -->
267 <?php if ( ! $this->hide_pro_tabs ) { ?>
268 <div class="bws_pro_version_bloc">
269 <div class="bws_pro_version_table_bloc">
270 <button type="submit" name="bws_hide_premium_options" class="notice-dismiss bws_hide_premium_options" title="<?php _e( 'Close', 'google-captcha' ); ?>"></button>
271 <div class="bws_table_bg"></div>
272 <?php gglcptch_additional_settings_banner_general(); ?>
273 </div>
274 <?php $this->bws_pro_block_links(); ?>
275 </div>
276 <?php } ?>
277 <!-- end pls -->
278
279 <div class="bws_tab_sub_label"><?php _e( 'Appearance', 'google-captcha' ); ?></div>
280 <table class="form-table">
281 <tr class="gglcptch_theme_v2" valign="top">
282 <th scope="row">
283 <?php _e( 'Theme', 'google-captcha' ); ?>
284 </th>
285 <td>
286 <select name="gglcptch_theme_v2">
287 <option value="light" <?php selected( 'light', $this->options['theme_v2'] ); ?>><?php _e( 'Light', 'google-captcha' ); ?></option>
288 <option value="dark" <?php selected( 'dark', $this->options['theme_v2'] ); ?>><?php _e( 'Dark', 'google-captcha' ); ?></option>
289 </select>
290 </td>
291 </tr>
292 </table>
293 <!-- pls -->
294 <?php if ( ! $this->hide_pro_tabs ) { ?>
295 <div class="bws_pro_version_bloc">
296 <div class="bws_pro_version_table_bloc">
297 <button type="submit" name="bws_hide_premium_options" class="notice-dismiss bws_hide_premium_options" title="<?php _e( 'Close', 'google-captcha' ); ?>"></button>
298 <div class="bws_table_bg"></div>
299 <?php gglcptch_additional_settings_banner_appearance(); ?>
300 </div>
301 <?php $this->bws_pro_block_links(); ?>
302 </div>
303 <?php } ?>
304 <!-- end pls -->
305 <table class="form-table">
306 <tr class="gglcptch_badge_v3" valign="top">
307 <th scope="row">
308 <?php _e( 'Hide reCaptcha Badge', 'google-captcha' ); ?>
309 </th>
310 <td>
311 <input<?php echo $this->change_permission_attr; ?> id="gglcptch_hide_badge" type="checkbox" <?php checked( ! empty( $this->options['hide_badge'] ) ); ?> name="gglcptch_hide_badge" value="1" />&nbsp;
312 <span class="bws_info">
313 <?php _e( 'Enable to hide reCaptcha Badge for Version 3 and Invisible reCaptcha.', 'google-captcha' ); ?>
314 </span>
315 </td>
316 </tr>
317 </table>
318
319 <div class="bws_tab_sub_label"><?php _e( 'Additional Protective Measures', 'google-captcha' ); ?></div>
320 <table class="form-table">
321 <tr class="gglcptch_score_v3" valign="top">
322 <th scope="row">
323 <?php _e( 'Score', 'google-captcha' ); ?>
324 </th>
325 <td>
326 <input name="gglcptch_score_v3" id="gglcptch_score_v3" type="range" list="gglcptch_score_v3_rangeList" min="0" max="1.0" step="0.1" value="<?php echo $this->options['score_v3']; ?>">
327 <output id="gglcptch_score_out_v3" for="gglcptch_score_v3"></output>
328 <span class="bws_info" style="display: block;"><?php printf( __( 'Set the minimum verification score from %s to %s (default is %s).', 'google-captcha' ), 0, 1, 0.5 ); ?></span>
329 </td>
330 </tr>
331 <tr valign="top">
332 <th scope="row"><?php _e( 'Hide reCaptcha for', 'google-captcha' ); ?></th>
333 <td>
334 <fieldset>
335 <?php if ( function_exists( 'get_editable_roles' ) ) {
336 foreach ( get_editable_roles() as $role => $fields ) {
337 printf(
338 '<label><input type="checkbox" name="%1$s" value="%2$s" %3$s> %4$s</label><br/>',
339 'gglcptch_' . $role,
340 $role,
341 checked( ! empty( $this->options[ $role ] ), true, false ),
342 translate_user_role( $fields['name'] )
343 );
344 }
345 } ?>
346 </fieldset>
347 </td>
348 </tr>
349 <tr valign="top">
350 <th scope="row"><?php _e( 'Allow List Notification', 'google-captcha' ); ?></th>
351 <td>
352 <textarea name="gglcptch_allowlist_message"><?php echo $this->options['allowlist_message']; ?></textarea>
353 <div class="bws_info"><?php _e( 'This message will be displayed instead of the reCaptcha.', 'google-captcha' ); ?></div>
354 </td>
355 </tr>
356 <tr valign="top">
357 <th scope="row"><?php _e( 'Advanced Protection', 'google-captcha' ); ?></th>
358 <td>
359 <input<?php echo $this->change_permission_attr; ?> id="gglcptch_disable_submit" type="checkbox" <?php checked( ! empty( $this->options["disable_submit"] ) ); ?> name="gglcptch_disable_submit" value="1" />
360 <span class="bws_info">
361 <?php _e( 'Enable to keep submit button disabled until reCaptcha is loaded (do not use this option if you see "Failed to load Google reCaptcha" message).', 'google-captcha' ); ?>
362 </span>
363 </td>
364 </tr>
365 <tr class="gglcptch_submit_v2" valign="top">
366 <th scope="row">
367 <?php _e( 'Disabled Submit Button', 'google-captcha' ); ?>
368 </th>
369 <td>
370 <input<?php echo $this->change_permission_attr; ?> id="gglcptch_disable_submit_button" type="checkbox" <?php checked( ! empty( $this->options['disable_submit_button'] ) ); ?> name="gglcptch_disable_submit_button" value="1" />
371 <span class="bws_info">
372 <?php _e( 'Enable to keep submit button disabled until user passes the reCaptcha test (for Version 2).', 'google-captcha' ); ?>
373 </span>
374 </td>
375 </tr>
376 </table>
377 <?php }
378
379 /**
380 * Display custom error\message\notice
381 * @access public
382 * @return void
383 */
384 public function display_custom_messages() {
385 if ( ! empty( $this->options['need_keys_verified_check'] ) ) { ?>
386 <div class="updated inline bws-notice"><p><strong><?php _e( 'reCaptcha version was changed. Please submit "Test reCaptcha" and regenerate Site and Secret keys if necessary.', 'google-captcha' ); ?></strong></p></div>
387 <?php }
388 }
389
390 public function additional_misc_options() {
391 do_action( 'gglcptch_settings_page_misc_action', $this->options );
392 }
393
394 public function information_postbox_bottom() { ?>
395 <div class="misc-pub-section">
396 <?php printf( __( 'ReCaptcha plugin is fully compliant with GDPR. %s Learn more %s' , 'google-captcha' ),
397 '<a target="_blank" href="https://support.bestwebsoft.com/hc/en-us/articles/4406398670097">',
398 '</a>' ); ?>
399 </div>
400 <?php }
401
402 /**
403 * Display custom metabox
404 * @access public
405 * @param void
406 * @return array The action results
407 */
408 public function display_metabox() { ?>
409 <div class="postbox">
410 <h3 class="hndle">
411 <?php _e( 'reCaptcha Shortcode', 'google-captcha' ); ?>
412 </h3>
413 <div class="inside">
414 <?php _e( "Add reCaptcha to your posts or pages using the following shortcode:", 'google-captcha' ); ?>
415 <?php bws_shortcode_output( '[bws_google_captcha]' ); ?>
416 </div>
417 </div>
418 <?php }
419 }
420 }