PluginProbe ʕ •ᴥ•ʔ
reCaptcha by BestWebSoft / 1.21
reCaptcha by BestWebSoft v1.21
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 / google-captcha.php
google-captcha Last commit date
bws_menu 10 years ago css 10 years ago images 10 years ago js 10 years ago languages 10 years ago lib 10 years ago lib_v2 10 years ago google-captcha.php 10 years ago readme.txt 10 years ago screenshot-1.png 10 years ago screenshot-2.png 10 years ago screenshot-3.png 10 years ago screenshot-4.png 10 years ago screenshot-5.png 10 years ago screenshot-6.png 10 years ago screenshot-7.png 10 years ago screenshot-8.png 10 years ago
google-captcha.php
1067 lines
1 <?php
2 /*
3 Plugin Name: Google Captcha (reCAPTCHA) by BestWebSoft
4 Plugin URI: http://bestwebsoft.com/products/
5 Description: Plugin Google Captcha intended to prove that the visitor is a human being and not a spam robot.
6 Author: BestWebSoft
7 Text Domain: google-captcha
8 Domain Path: /languages
9 Version: 1.21
10 Author URI: http://bestwebsoft.com/
11 License: GPLv3 or later
12 */
13
14 /* © Copyright 2015 BestWebSoft ( http://support.bestwebsoft.com )
15
16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License, version 2, as
18 published by the Free Software Foundation.
19
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30 /* Add menu page */
31 if ( ! function_exists( 'gglcptch_admin_menu' ) ) {
32 function gglcptch_admin_menu() {
33 bws_general_menu();
34 $gglcptch_settings = add_submenu_page( 'bws_plugins', __( 'Google Captcha Settings', 'google-captcha' ), 'Google Captcha', 'manage_options', 'google-captcha.php', 'gglcptch_settings_page' );
35 add_action( 'load-' . $gglcptch_settings, 'gglcptch_add_tabs' );
36 }
37 }
38
39 if ( ! function_exists( 'gglcptch_plugins_loaded' ) ) {
40 function gglcptch_plugins_loaded() {
41 /* Internationalization, first(!) */
42 load_plugin_textdomain( 'google-captcha', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
43 }
44 }
45
46 /* Get option from the php.ini */
47 if ( ! function_exists( 'gglcptch_get_allow_url_fopen' ) ) {
48 function gglcptch_get_allow_url_fopen() {
49 return ( ini_get( 'allow_url_fopen' ) != 1 ) ? false : true;
50 }
51 }
52
53 if ( ! function_exists( 'gglcptch_init' ) ) {
54 function gglcptch_init() {
55 global $gglcptch_options, $gglcptch_plugin_info;
56
57 require_once( dirname( __FILE__ ) . '/bws_menu/bws_include.php' );
58 bws_include_init( plugin_basename( __FILE__ ) );
59
60 if ( empty( $gglcptch_plugin_info ) ) {
61 if ( ! function_exists( 'get_plugin_data' ) )
62 require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
63 $gglcptch_plugin_info = get_plugin_data( __FILE__ );
64 }
65
66 /* Function check if plugin is compatible with current WP version */
67 bws_wp_min_version_check( plugin_basename( __FILE__ ), $gglcptch_plugin_info, '3.8', '3.1' );
68
69 /* Get options from the database */
70 $gglcptch_options = get_option( 'gglcptch_options' );
71
72 if ( ! $gglcptch_options ) {
73 register_gglcptch_settings();
74 $gglcptch_options = get_option( 'gglcptch_options' );
75 }
76
77 /* Add hooks */
78
79 if ( '1' == $gglcptch_options['login_form'] || '1' == $gglcptch_options['reset_pwd_form'] || '1' == $gglcptch_options['registration_form'] ) {
80 add_action( 'login_enqueue_scripts', 'gglcptch_add_site_script_styles' );
81
82 if ( '1' == $gglcptch_options['login_form'] ) {
83 add_action( 'login_form', 'gglcptch_login_display' );
84 add_action( 'authenticate', 'gglcptch_login_check', 21, 1 );
85 }
86
87 if ( '1' == $gglcptch_options['comments_form'] ) {
88 add_action( 'comment_form_after_fields', 'gglcptch_commentform_display' );
89 add_action( 'comment_form_logged_in_after', 'gglcptch_commentform_display' );
90 add_action( 'pre_comment_on_post', 'gglcptch_commentform_check' );
91 }
92
93 if ( '1' == $gglcptch_options['reset_pwd_form'] ) {
94 add_action( 'lostpassword_form', 'gglcptch_login_display' );
95 add_action( 'lostpassword_post', 'gglcptch_lostpassword_check' );
96 }
97
98 if ( '1' == $gglcptch_options['registration_form'] ) {
99 if ( ! is_multisite() ) {
100 add_action( 'register_form', 'gglcptch_login_display' );
101 add_action( 'register_post', 'gglcptch_lostpassword_check' );
102 } else {
103 add_action( 'signup_extra_fields', 'gglcptch_signup_display' );
104 add_filter( 'wpmu_validate_user_signup', 'gglcptch_signup_check', 10, 3 );
105 }
106 }
107 }
108
109 if ( '1' == $gglcptch_options['contact_form'] ) {
110 add_filter( 'cntctfrm_display_captcha', 'gglcptch_cf_display' );
111 add_filter( 'cntctfrmpr_display_captcha', 'gglcptch_cf_display' );
112 }
113 }
114 }
115
116 if ( ! function_exists( 'gglcptch_admin_init' ) ) {
117 function gglcptch_admin_init() {
118 global $bws_plugin_info, $gglcptch_plugin_info, $bws_shortcode_list;
119
120 if ( ! isset( $bws_plugin_info ) || empty( $bws_plugin_info ) )
121 $bws_plugin_info = array( 'id' => '109', 'version' => $gglcptch_plugin_info["Version"] );
122
123 /* Call register settings function */
124 if ( isset( $_GET['page'] ) && "google-captcha.php" == $_GET['page'] )
125 register_gglcptch_settings();
126
127 /* add google captcha to global $bws_shortcode_list */
128 $bws_shortcode_list['gglcptch'] = array( 'name' => 'Google Captcha (reCAPTCHA)', 'js_function' => 'gglcptch_shortcode_init' );
129 }
130 }
131
132 /* Add google captcha styles */
133 if ( ! function_exists( 'gglcptch_add_admin_script_styles' ) ) {
134 function gglcptch_add_admin_script_styles() {
135 if ( isset( $_REQUEST['page'] ) && 'google-captcha.php' == $_REQUEST['page'] ) {
136 wp_enqueue_style( 'gglcptch_stylesheet', plugins_url( 'css/style.css', __FILE__ ) );
137 wp_enqueue_script( 'gglcptch_admin_script', plugins_url( 'js/admin_script.js', __FILE__ ), array( 'jquery' ) );
138 }
139 }
140 }
141
142 /* Add google captcha scripts */
143 if ( ! function_exists( 'gglcptch_add_site_script_styles' ) ) {
144 function gglcptch_add_site_script_styles() {
145 global $gglcptch_plugin_info, $gglcptch_options;
146
147 if ( isset( $gglcptch_options['recaptcha_version'] ) && 'v2' == $gglcptch_options['recaptcha_version'] ) {
148 $gglcptch_api = "https://www.google.com/recaptcha/api.js?render=explicit&hl=en";
149 } else {
150 $gglcptch_api = "//www.google.com/recaptcha/api/js/recaptcha_ajax.js";
151 }
152
153 wp_enqueue_script( 'gglcptch_api', $gglcptch_api, false, $gglcptch_plugin_info["Version"] );
154 wp_enqueue_script( 'gglcptch_script', plugins_url( 'js/script.js', __FILE__ ), array( 'jquery' ), $gglcptch_plugin_info["Version"] );
155
156 $gglcptch_for_version = ( $gglcptch_options['recaptcha_version'] == 'v2' ) ? '_v2' : '';
157
158 wp_localize_script( 'gglcptch_script', 'gglcptch', array(
159 'options' => array(
160 'version' => $gglcptch_options['recaptcha_version'],
161 'sitekey' => $gglcptch_options['public_key'],
162 'theme' => $gglcptch_options[ 'theme' . $gglcptch_for_version ],
163 ),
164 'vars' => array(
165 'ajaxurl' => admin_url( 'admin-ajax.php' ),
166 'error_msg' => __( 'Error: You have entered an incorrect reCAPTCHA value.', 'google-captcha' ),
167 'nonce' => wp_create_nonce( 'gglcptch_recaptcha_nonce' )
168 )
169 ) );
170
171 wp_enqueue_style( 'gglcptch', plugins_url( 'css/gglcptch.css', __FILE__ ), false, $gglcptch_plugin_info["Version"] );
172
173 }
174 }
175 /* Google catpcha settings */
176 if ( ! function_exists( 'register_gglcptch_settings' ) ) {
177 function register_gglcptch_settings() {
178 global $gglcptch_options, $bws_plugin_info, $gglcptch_plugin_info, $gglcptch_default_options;
179
180 $gglcptch_default_options = array(
181 'public_key' => '',
182 'private_key' => '',
183 'login_form' => '1',
184 'registration_form' => '1',
185 'reset_pwd_form' => '1',
186 'comments_form' => '1',
187 'contact_form' => '0',
188 'theme' => 'red',
189 'theme_v2' => 'light',
190 'recaptcha_version' => ( gglcptch_get_allow_url_fopen() ) ? 'v2' : 'v1',
191 'plugin_option_version' => $gglcptch_plugin_info["Version"],
192 'first_install' => strtotime( "now" ),
193 'display_settings_notice' => 1
194 );
195
196 if ( function_exists( 'get_editable_roles' ) ) {
197 foreach ( get_editable_roles() as $role => $fields ) {
198 $gglcptch_default_options[ $role ] = '0';
199 }
200 }
201
202 /* Install the option defaults */
203 if ( ! get_option( 'gglcptch_options' ) )
204 add_option( 'gglcptch_options', $gglcptch_default_options );
205 /* Get options from the database */
206 $gglcptch_options = get_option( 'gglcptch_options' );
207
208 /* Array merge incase this version has added new options */
209 if ( ! isset( $gglcptch_options['plugin_option_version'] ) || $gglcptch_options['plugin_option_version'] != $gglcptch_plugin_info["Version"] ) {
210 $gglcptch_default_options['display_settings_notice'] = 0;
211 $gglcptch_options = array_merge( $gglcptch_default_options, $gglcptch_options );
212 $gglcptch_options['plugin_option_version'] = $gglcptch_plugin_info["Version"];
213 /* show pro features */
214 $gglcptch_options['hide_premium_options'] = array();
215 update_option( 'gglcptch_options', $gglcptch_options );
216 }
217 }
218 }
219
220 if ( ! function_exists( 'gglcptch_plugin_status' ) ) {
221 function gglcptch_plugin_status( $plugins, $all_plugins, $is_network ) {
222 $result = array(
223 'status' => '',
224 'plugin' => '',
225 'plugin_info' => array(),
226 );
227 foreach ( (array)$plugins as $plugin ) {
228 if ( array_key_exists( $plugin, $all_plugins ) ) {
229 if (
230 ( $is_network && is_plugin_active_for_network( $plugin ) ) ||
231 ( ! $is_network && is_plugin_active( $plugin ) )
232 ) {
233 $result['status'] = 'actived';
234 $result['plugin'] = $plugin;
235 $result['plugin_info'] = $all_plugins[$plugin];
236 break;
237 } else {
238 $result['status'] = 'deactivated';
239 $result['plugin'] = $plugin;
240 $result['plugin_info'] = $all_plugins[$plugin];
241 }
242
243 }
244 }
245 if ( empty( $result['status'] ) )
246 $result['status'] = 'not_installed';
247 return $result;
248 }
249 }
250
251 /* Display settings page */
252 if ( ! function_exists( 'gglcptch_settings_page' ) ) {
253 function gglcptch_settings_page() {
254 global $gglcptch_options, $gglcptch_plugin_info, $wp_version, $gglcptch_default_options;
255
256 $plugin_basename = plugin_basename( __FILE__ );
257 $message = $error = '';
258
259 $all_plugins = get_plugins();
260 $is_network = is_multisite() && is_network_admin();
261 $is_main_site = is_main_site( get_current_blog_id() );
262 $admin_url = $is_network ? network_admin_url( '/' ) : admin_url( '/' );
263 $bws_contact_form = gglcptch_plugin_status( array( 'contact-form-plugin/contact_form.php', 'contact-form-pro/contact_form_pro.php' ), $all_plugins, $is_network );
264
265 if ( ! isset( $_GET['action'] ) ) {
266
267 $all_plugins = get_plugins();
268
269 $gglcptch_sizes_v2 = array(
270 'normal' => __( 'Normal', 'google-captcha' ),
271 'compact' => __( 'Compact', 'google-captcha' )
272 );
273
274 /* Private and public keys */
275 $gglcptch_keys = array(
276 'public' => array(
277 'display_name' => __( 'Site key', 'google-captcha' ),
278 'form_name' => 'gglcptch_public_key',
279 'error_msg' => '',
280 ),
281 'private' => array(
282 'display_name' => __( 'Secret Key', 'google-captcha' ),
283 'form_name' => 'gglcptch_private_key',
284 'error_msg' => '',
285 ),
286 );
287
288 /* Checked forms */
289 $gglcptch_forms = array(
290 array( 'login_form', __( 'Login form', 'google-captcha' ) ),
291 array( 'registration_form', __( 'Registration form', 'google-captcha' ) ),
292 array( 'reset_pwd_form', __( 'Reset password form', 'google-captcha' ) ),
293 array( 'comments_form', __( 'Comments form', 'google-captcha' ) ),
294 );
295
296 /* Google captcha themes */
297 $gglcptch_themes = array(
298 array( 'red', 'Red' ),
299 array( 'white', 'White' ),
300 array( 'blackglass', 'Blackglass' ),
301 array( 'clean', 'Clean' ),
302 );
303
304 /* Save data for settings page */
305 if ( isset( $_POST['gglcptch_form_submit'] ) && check_admin_referer( $plugin_basename, 'gglcptch_nonce_name' ) ) {
306 if ( isset( $_POST['bws_hide_premium_options'] ) ) {
307 $hide_result = bws_hide_premium_options( $gglcptch_options );
308 $gglcptch_options = $hide_result['options'];
309 }
310
311 if ( ! $_POST['gglcptch_public_key'] || '' == $_POST['gglcptch_public_key'] ) {
312 $gglcptch_keys['public']['error_msg'] = __( 'Enter site key', 'google-captcha' );
313 $error = __( "WARNING: The captcha will not display while you don't fill key fields.", 'google-captcha' );
314 } else
315 $gglcptch_keys['public']['error_msg'] = '';
316
317 if ( ! $_POST['gglcptch_private_key'] || '' == $_POST['gglcptch_private_key'] ) {
318 $gglcptch_keys['private']['error_msg'] = __( 'Enter secret key', 'google-captcha' );
319 $error = __( "WARNING: The captcha will not display while you don't fill key fields.", 'google-captcha' );
320 } else
321 $gglcptch_keys['private']['error_msg'] = '';
322
323 $gglcptch_options['public_key'] = trim( stripslashes( esc_html( $_POST['gglcptch_public_key'] ) ) );
324 $gglcptch_options['private_key'] = trim( stripslashes( esc_html( $_POST['gglcptch_private_key'] ) ) );
325 $gglcptch_options['login_form'] = isset( $_POST['gglcptch_login_form'] ) ? 1 : 0;
326 $gglcptch_options['registration_form'] = isset( $_POST['gglcptch_registration_form'] ) ? 1 : 0;
327 $gglcptch_options['reset_pwd_form'] = isset( $_POST['gglcptch_reset_pwd_form'] ) ? 1 : 0;
328 $gglcptch_options['comments_form'] = isset( $_POST['gglcptch_comments_form'] ) ? 1 : 0;
329 $gglcptch_options['contact_form'] = isset( $_POST['gglcptch_contact_form'] ) ? 1 : 0;
330 $gglcptch_options['recaptcha_version'] = $_POST['gglcptch_recaptcha_version'];
331 $gglcptch_options['theme'] = $_POST['gglcptch_theme'];
332 $gglcptch_options['theme_v2'] = $_POST['gglcptch_theme_v2'];
333
334 if ( function_exists( 'get_editable_roles' ) ) {
335 foreach ( get_editable_roles() as $role => $fields ) {
336 $gglcptch_options[ $role ] = isset( $_POST[ 'gglcptch_' . $role ] ) ? 1 : 0;
337 }
338 }
339
340 update_option( 'gglcptch_options', $gglcptch_options );
341 $message = __( 'Settings saved', 'google-captcha' );
342 }
343
344 if ( isset( $_REQUEST['bws_restore_confirm'] ) && check_admin_referer( $plugin_basename, 'bws_settings_nonce_name' ) ) {
345 $gglcptch_options = $gglcptch_default_options;
346 update_option( 'gglcptch_options', $gglcptch_options );
347 $message = __( 'All plugin settings were restored.', 'google-captcha' );
348 }
349 }
350
351 $bws_hide_premium_options_check = bws_hide_premium_options_check( $gglcptch_options );
352
353 /* GO PRO */
354 if ( isset( $_GET['action'] ) && 'go_pro' == $_GET['action'] ) {
355 $go_pro_result = bws_go_pro_tab_check( $plugin_basename, 'gglcptch_options' );
356 if ( ! empty( $go_pro_result['error'] ) )
357 $error = $go_pro_result['error'];
358 elseif ( ! empty( $go_pro_result['message'] ) )
359 $message = $go_pro_result['message'];
360 } ?>
361 <div class="wrap">
362 <h1 style="line-height: normal;"><?php _e( 'Google Captcha Settings', 'google-captcha' ); ?></h1>
363 <h2 class="nav-tab-wrapper">
364 <a class="nav-tab<?php if ( ! isset( $_GET['action'] ) ) echo ' nav-tab-active'; ?>" href="admin.php?page=google-captcha.php"><?php _e( 'Settings', 'google-captcha' ); ?></a>
365 <a class="nav-tab<?php if ( isset( $_GET['action'] ) && 'go_pro' == $_GET['action'] ) echo ' nav-tab-active'; ?> bws_go_pro_tab" href="admin.php?page=google-captcha.php&amp;action=go_pro"><?php _e( 'Go PRO', 'google-captcha' ); ?></a>
366 </h2>
367 <?php if ( ! isset( $_GET['action'] ) && ! isset( $_REQUEST['bws_restore_default'] ) ) {
368 if ( ! gglcptch_get_allow_url_fopen() && $gglcptch_options['recaptcha_version'] == 'v2' ) {
369 printf( '<div class="error"><p><strong>%s</strong></p></div>',
370 __( 'Google Captcha version 2 will not work correctly, since the option "allow_url_fopen" is disabled. Please contact your hosting support service.', 'google-captcha' )
371 );
372 }
373 if ( $gglcptch_options['recaptcha_version'] == 'v1' ) {
374 printf( '<div id="gglcptch_v1_notice" class="updated"><p><strong>%s</strong></p></div>',
375 __( "Only one reCAPTCHA can be displayed on the page, it's related to reCAPTCHA version 1 features.", 'google-captcha' )
376 );
377 }
378 }
379 bws_show_settings_notice(); ?>
380 <div class="updated fade" <?php if ( "" == $message ) echo 'style="display:none"'; ?>><p><strong><?php echo $message; ?></strong></p></div>
381 <div class="error" <?php if ( "" == $error ) echo 'style="display:none"'; ?>><p><strong><?php echo $error; ?></strong></p></div>
382 <?php if ( ! empty( $hide_result['message'] ) ) { ?>
383 <div class="updated fade"><p><strong><?php echo $hide_result['message']; ?></strong></p></div>
384 <?php }
385 if ( ! isset( $_GET['action'] ) ) {
386 if ( isset( $_REQUEST['bws_restore_default'] ) && check_admin_referer( $plugin_basename, 'bws_settings_nonce_name' ) ) {
387 bws_form_restore_default_confirm( $plugin_basename );
388 } else { ?>
389 <div style="margin: 20px 0;">
390 <?php printf( __( "If you would like to add a Google Captcha (reCAPTCHA) to your page or post, please use %s button", 'google-captcha' ),
391 '<span class="bws_code"><img style="vertical-align: sub;" src="' . plugins_url( 'bws_menu/images/shortcode-icon.png', __FILE__ ) . '" alt=""/></span>'
392 ); ?>
393 <div class="bws_help_box bws_help_box_right dashicons dashicons-editor-help" style="vertical-align: middle;">
394 <div class="bws_hidden_help_text" style="min-width: 260px;">
395 <?php printf(
396 __( "You can add the Google Captcha (reCAPTCHA) to your page or post by clicking on %s button in the content edit block using the Visual mode. If the button isn't displayed or you would like to add the Google Captcha (reCAPTCHA) to your own form , please use the shortcode %s", 'google-captcha' ),
397 '<code><img style="vertical-align: sub;" src="' . plugins_url( 'bws_menu/images/shortcode-icon.png', __FILE__ ) . '" alt="" /></code>',
398 sprintf( '<span class="bws_code">[bws_google_captcha]</span><br/>' )
399 ); ?>
400 </div>
401 </div>
402 </div>
403 <form class="bws_form" method="post" action="admin.php?page=google-captcha.php">
404 <h3><?php _e( 'Authentication', 'google-captcha' ); ?></h3>
405 <p><?php printf( __( 'Before you are able to do something, you must to register %shere%s', 'google-captcha' ), '<a target="_blank" href="https://www.google.com/recaptcha/admin#list">','</a>.' ); ?></p>
406 <p><?php _e( 'Enter site key and secret key, that you get after registration.', 'google-captcha' ); ?></p>
407 <table id="gglcptch-keys" class="form-table">
408 <?php foreach ( $gglcptch_keys as $key => $fields ) { ?>
409 <tr valign="top">
410 <th scope="row"><?php echo $fields['display_name']; ?></th>
411 <td>
412 <input type="text" name="<?php echo $fields['form_name']; ?>" value="<?php echo $gglcptch_options[ $key . '_key' ] ?>" maxlength="200" />
413 <label class="gglcptch_error_msg"><?php echo $fields['error_msg']; ?></label>
414 </td>
415 </tr>
416 <?php } ?>
417 </table>
418 <h3><?php _e( 'Options', 'google-captcha' ); ?></h3>
419 <table class="form-table">
420 <tr valign="top">
421 <th scope="row"><?php _e( 'Enable reCAPTCHA for', 'google-captcha' ); ?></th>
422 <td>
423 <fieldset>
424 <p>
425 <i><?php _e( 'WordPress default', 'google-captcha' ); ?></i>
426 </p>
427 <?php foreach ( $gglcptch_forms as $form ) {
428 $gglcptch_form_type = $form[0];
429 $gglcptch_form_name = $form[1];
430 $gglcptch_form_attr = ( '1' == $gglcptch_options[ $gglcptch_form_type ] ) ? 'checked="checked"' : '';
431 $gglcptch_form_notice = '';
432
433 if ( ( $gglcptch_form_type == 'registration_form' || $gglcptch_form_type == 'reset_pwd_form' ) && ! $is_main_site ) {
434 $gglcptch_form_notice .= sprintf( '<span class="bws_info">%s</span>', __( 'This option is available only for network or for main blog', 'google-captcha' ) );
435 $gglcptch_form_attr = 'disabled="disabled" readonly="readonly"';
436 } ?>
437 <label><input type="checkbox" name="<?php echo 'gglcptch_' . $gglcptch_form_type; ?>" value="<?php echo $gglcptch_form_type; ?>" <?php echo $gglcptch_form_attr; ?> /> <?php echo $gglcptch_form_name; ?></label>
438 <div class="bws_help_box dashicons dashicons-editor-help" style="vertical-align: middle;"><div class="bws_hidden_help_text"><img src="<?php echo plugins_url( 'google-captcha/images') . '/' . $gglcptch_form_type; ?>.jpg" title="<?php echo $gglcptch_form_name; ?>" alt="<?php echo $gglcptch_form_name; ?>"></div></div> <?php echo $gglcptch_form_notice; ?><br />
439 <?php } ?>
440 <br />
441 <p>
442 <i><?php _e( 'Plugins', 'google-captcha' ); ?></i>
443 </p>
444 <?php /* Check Contact Form by BestWebSoft */
445 $gglcptch_plugin = $bws_contact_form;
446 $gglcptch_plugin_name = 'Contact Form by BestWebSoft';
447 $gglcptch_attrs = $gglcptch_plugin_notice = '';
448 if ( 'deactivated' == $gglcptch_plugin['status'] ) {
449 $gglcptch_attrs = 'disabled="disabled"';
450 $gglcptch_plugin_notice = sprintf( __( 'You should %s to use this functionality', 'google-captcha' ),
451 sprintf( '<a href="%splugins.php">%s%s %s</a>', $admin_url, __( 'activate', 'google-captcha' ), ( is_network_admin() ? ' ' . __( 'for network', 'google-captcha' ) : '' ), $gglcptch_plugin_name )
452 );
453 } elseif ( 'not_installed' == $gglcptch_plugin['status'] ) {
454 $gglcptch_attrs = 'disabled="disabled"';
455 $gglcptch_plugin_notice = sprintf( __( 'You should %s to use this functionality', 'google-captcha' ),
456 sprintf( '<a href="http://bestwebsoft.com/products/contact-form/?k=d70b58e1739ab4857d675fed2213cedc&pn=75&v=%s&wp_v=%s">%s %s</a>', $gglcptch_plugin_info["Version"], $wp_version, __( 'download', 'google-captcha' ), $gglcptch_plugin_name )
457 );
458 }
459 if ( '1' == $gglcptch_options['contact_form'] && $gglcptch_attrs == '' ) {
460 $gglcptch_attrs .= ' checked="checked"';
461 } ?>
462 <label><input type="checkbox" <?php echo $gglcptch_attrs; ?> name="gglcptch_contact_form" value="contact_form" /> <?php echo $gglcptch_plugin_name; ?></label>
463 <div class="bws_help_box dashicons dashicons-editor-help" style="vertical-align: middle;"><div class="bws_hidden_help_text"><img src="<?php echo plugins_url( 'google-captcha/images'); ?>/contact_form.jpg" title="<?php echo $gglcptch_plugin_name; ?>" alt="<?php echo $gglcptch_plugin_name; ?>"></div></div>
464 <span class="bws_info"><?php echo $gglcptch_plugin_notice; ?></span><br />
465 <?php if ( ! $bws_hide_premium_options_check ) { ?>
466 <div class="bws_pro_version_bloc">
467 <div class="bws_pro_version_table_bloc">
468 <button type="submit" name="bws_hide_premium_options" class="notice-dismiss bws_hide_premium_options" title="<?php _e( 'Close', 'google-captcha' ); ?>"></button>
469 <div class="bws_table_bg"></div>
470 <div class="bws_pro_version">
471 <label><input disabled="disabled" type="checkbox" disabled="disabled" name="gglcptch_sbscrbr" value="1"> Subscriber by BestWebSoft</label><br>
472 <label><input disabled="disabled" type="checkbox" disabled="disabled" name="gglcptch_cf7" value="1"> Contact Form 7</label><br>
473 <label><input disabled="disabled" type="checkbox" disabled="disabled" name="gglcptch_buddypress_register" value="1"> BuddyPress Registration form</label><br>
474 <label><input disabled="disabled" type="checkbox" disabled="disabled" name="gglcptch_buddypress_comments" value="1"> BuddyPress Comments form</label><br>
475 <label><input disabled="disabled" type="checkbox" disabled="disabled" name="gglcptch_buddypress_group" value="1"> BuddyPress "Create a Group" form</label>
476 </div>
477 </div>
478 <div class="bws_pro_version_tooltip">
479 <div class="bws_info">
480 <?php _e( 'Unlock premium options by upgrading to Pro version', 'google-captcha' ); ?>
481 </div>
482 <a class="bws_button" href="http://bestwebsoft.com/products/google-captcha/?k=b850d949ccc1239cab0da315c3c822ab&pn=109&v=<?php echo $gglcptch_plugin_info["Version"]; ?>&wp_v=<?php echo $wp_version; ?>" target="_blank" title="Google Captcha Pro (reCAPTCHA)">
483 <?php _e( 'Learn More', 'google-captcha' ); ?>
484 </a>
485 <div class="clear"></div>
486 </div>
487 </div><br>
488 <?php } ?>
489 <span class="bws_info"><?php printf( __( 'If you would like to add Google Captcha (reCAPTCHA) to a custom form see %s', 'google-captcha' ), sprintf( '<a href="http://bestwebsoft.com/products/google-captcha/faq/" target="_blank">%s</a>', __( 'FAQ', 'google-captcha' ) ) ); ?></span>
490 </fieldset>
491 </td>
492 </tr>
493 <tr valign="top">
494 <th scope="row"><?php _e( 'Hide reCAPTCHA in Comments form for', 'google-captcha' ); ?></th>
495 <td>
496 <fieldset>
497 <?php if ( function_exists( 'get_editable_roles' ) ) {
498 foreach ( get_editable_roles() as $role => $fields) : ?>
499 <label><input type="checkbox" name="<?php echo 'gglcptch_' . $role; ?>" value=<?php echo $role; if ( isset( $gglcptch_options[ $role ] ) && '1' == $gglcptch_options[ $role ] ) echo ' checked'; ?>> <?php echo $fields['name']; ?></label><br/>
500 <?php endforeach;
501 } ?>
502 </fieldset>
503 </td>
504 </tr>
505 <tr valign="top">
506 <th scope="row"><?php _e( 'reCAPTCHA version', 'google-captcha' ); ?></th>
507 <td>
508 <fieldset>
509 <label><input type="radio" name="gglcptch_recaptcha_version" value="v1"<?php if ( 'v1' == $gglcptch_options['recaptcha_version'] ) echo ' checked="checked"'; ?>> <?php _e( 'version', 'google-captcha' ); ?> 1</label>
510 <div class="bws_help_box dashicons dashicons-editor-help" style="vertical-align: middle;"><div class="bws_hidden_help_text"><img src="<?php echo plugins_url( 'google-captcha/images'); ?>/recaptcha_v1.png" title="reCAPTCHA <?php _e( 'version', 'google-captcha' ); ?> 1" alt="reCAPTCHA <?php _e( 'version', 'google-captcha' ); ?> 1"></div></div><br/>
511 <label><input type="radio" name="gglcptch_recaptcha_version" value="v2"<?php if ( 'v2' == $gglcptch_options['recaptcha_version'] ) echo ' checked="checked"'; ?>> <?php _e( 'version', 'google-captcha' ); ?> 2</label>
512 <div class="bws_help_box dashicons dashicons-editor-help" style="vertical-align: middle;"><div class="bws_hidden_help_text"><img src="<?php echo plugins_url( 'google-captcha/images'); ?>/recaptcha_v2.png" title="reCAPTCHA <?php _e( 'version', 'google-captcha' ); ?> 2" alt="reCAPTCHA <?php _e( 'version', 'google-captcha' ); ?> 2"></div></div>
513 </fieldset>
514 </td>
515 </tr>
516 <tr class="gglcptch_theme_v1" valign="top">
517 <th scope="row">
518 <?php _e( 'reCAPTCHA theme', 'google-captcha' ); ?>
519 <br/><span class="bws_info">(<?php _e( 'for version', 'google-captcha' ); ?> 1)</span>
520 </th>
521 <td>
522 <select name="gglcptch_theme">
523 <?php foreach ( $gglcptch_themes as $theme ) : ?>
524 <option value=<?php echo $theme[0]; if ( $theme[0] == $gglcptch_options['theme'] ) echo ' selected'; ?>> <?php echo $theme[1]; ?></option>
525 <?php endforeach; ?>
526 </select>
527 </td>
528 </tr>
529 <tr class="gglcptch_theme_v2" valign="top">
530 <th scope="row">
531 <?php _e( 'reCAPTCHA theme', 'google-captcha' ); ?>
532 <br/><span class="bws_info">(<?php _e( 'for version', 'google-captcha' ); ?> 2)</span>
533 </th>
534 <td>
535 <select name="gglcptch_theme_v2">
536 <option value="light" <?php if ( 'light' == $gglcptch_options['theme_v2'] ) echo ' selected'; ?>>light</option>
537 <option value="dark" <?php if ( 'dark' == $gglcptch_options['theme_v2'] ) echo ' selected'; ?>>dark</option>
538 </select>
539 </td>
540 </tr>
541 </table>
542 <?php if ( ! $bws_hide_premium_options_check ) { ?>
543 <div class="bws_pro_version_bloc">
544 <div class="bws_pro_version_table_bloc">
545 <button type="submit" name="bws_hide_premium_options" class="notice-dismiss bws_hide_premium_options" title="<?php _e( 'Close', 'google-captcha' ); ?>"></button>
546 <div class="bws_table_bg"></div>
547 <table class="form-table bws_pro_version">
548 <tr valign="top">
549 <th scope="row"><?php _e( 'reCAPTCHA language', 'google-captcha' ); ?></th>
550 <td>
551 <select disabled="disabled" name="gglcptch_language">
552 <option value="en" selected="selected">English (US)</option>
553 </select>
554 <div style="margin: 5px 0 0;">
555 <input disabled="disabled" id="gglcptch_use_multilanguage_locale" type="checkbox" name="gglcptch_use_multilanguage_locale" value="1" />
556 <label for="gglcptch_use_multilanguage_locale"><?php _e( 'Use the current site language', 'google-captcha' ); ?></label>&nbsp;<span class="bws_info">(<?php _e( 'Using', 'google-captcha' ); ?> Multilanguage by BestWebSoft)</span>
557 </div>
558 </td>
559 </tr>
560 <tr valign="top">
561 <th scope="row">
562 <?php _e( 'reCAPTCHA size', 'google-captcha' ); ?>
563 <br/><span class="bws_info">(<?php _e( 'for version', 'google-captcha' ); ?> 2)</span>
564 </th>
565 <td><fieldset>
566 <?php foreach ( $gglcptch_sizes_v2 as $value => $name ) {
567 printf(
568 '<div class="gglcptch_size_v2"><label><input disabled="disabled" type="radio" name="gglcptch_size_v2" value="%s"%s> %s</label></div>',
569 $value,
570 $name == 'Normal' ? ' checked="checked"' : '',
571 $name
572 );
573 } ?>
574 </fieldset>
575 </td>
576 </tr>
577 </table>
578 </div>
579 <div class="bws_pro_version_tooltip">
580 <div class="bws_info">
581 <?php _e( 'Unlock premium options by upgrading to Pro version', 'google-captcha' ); ?>
582 </div>
583 <a class="bws_button" href="http://bestwebsoft.com/products/google-captcha/?k=b850d949ccc1239cab0da315c3c822ab&pn=109&v=<?php echo $gglcptch_plugin_info["Version"]; ?>&wp_v=<?php echo $wp_version; ?>" target="_blank" title="Google Captcha Pro (reCAPTCHA)">
584 <?php _e( 'Learn More', 'google-captcha' ); ?>
585 </a>
586 <div class="clear"></div>
587 </div>
588 </div>
589 <?php } ?>
590 <p class="submit">
591 <input id="bws-submit-button" type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'google-captcha' ); ?>" name="gglcptch_save_changes" />
592 <input type="hidden" name="gglcptch_form_submit" value="submit" />
593 <?php wp_nonce_field( $plugin_basename, 'gglcptch_nonce_name' ); ?>
594 </p>
595 </form>
596 <?php bws_form_restore_default_settings( $plugin_basename );
597 }
598 } elseif ( 'go_pro' == $_GET['action'] ) {
599 bws_go_pro_tab_show( $bws_hide_premium_options_check, $gglcptch_plugin_info, $plugin_basename, 'google-captcha.php', 'google-captcha-pro.php', 'google-captcha-pro/google-captcha-pro.php', 'google-captcha', 'b850d949ccc1239cab0da315c3c822ab', '109', isset( $go_pro_result['pro_plugin_is_activated'] ) );
600 }
601 bws_plugin_reviews_block( $gglcptch_plugin_info['Name'], 'google-captcha' ); ?>
602 </div>
603 <?php }
604 }
605
606 /* Checking current user role */
607 if ( ! function_exists( 'gglcptch_check_role' ) ) {
608 function gglcptch_check_role() {
609 global $current_user, $gglcptch_options;
610 if ( ! is_user_logged_in() )
611 return false;
612 if ( ! empty( $current_user->roles[0] ) ) {
613 $role = $current_user->roles[0];
614 if ( '1' == $gglcptch_options[ $role ] )
615 return true;
616 else
617 return false;
618 } else
619 return false;
620 }
621 }
622
623 /* Display google captcha via shortcode */
624 if ( ! function_exists( 'gglcptch_display' ) ) {
625 function gglcptch_display( $content = false ) {
626 global $gglcptch_options, $gglcptch_count;
627
628 if ( gglcptch_check_role() ){
629 return;
630 }
631
632 if ( ! $gglcptch_count ) {
633 $gglcptch_count = 1;
634 }
635
636 if ( ! gglcptch_get_allow_url_fopen() && isset( $gglcptch_options['recaptcha_version'] ) && $gglcptch_options['recaptcha_version'] == 'v2' ) {
637 $content .= '<div class="gglcptch allow_url_fopen_off"></div>';
638 $gglcptch_count++;
639 return $content;
640 }
641
642 $publickey = $gglcptch_options['public_key'];
643 $privatekey = $gglcptch_options['private_key'];
644
645 $content .= '<div class="gglcptch gglcptch_' . $gglcptch_options['recaptcha_version'] . '">';
646 if ( ! $privatekey || ! $publickey ) {
647 if ( current_user_can( 'manage_options' ) ) {
648 $content .= sprintf(
649 '<strong>%s <a target="_blank" href="https://www.google.com/recaptcha/admin#list">%s</a> %s <a target="_blank" href="%s">%s</a>.</strong>',
650 __( 'To use Google Captcha you must get the keys from', 'google-captcha' ),
651 __ ( 'here', 'google-captcha' ),
652 __ ( 'and enter them on the', 'google-captcha' ),
653 admin_url( '/admin.php?page=google-captcha.php' ),
654 __( 'plugin setting page', 'google-captcha' )
655 );
656 }
657 $content .= '</div>';
658 $gglcptch_count++;
659 return $content;
660 }
661 if ( isset( $gglcptch_options['recaptcha_version'] ) && 'v2' == $gglcptch_options['recaptcha_version'] ) {
662 $content .= '<div id="gglcptch_recaptcha_' . $gglcptch_count . '" class="gglcptch_recaptcha"></div>
663 <noscript>
664 <div style="width: 302px;">
665 <div style="width: 302px; height: 422px; position: relative;">
666 <div style="width: 302px; height: 422px; position: absolute;">
667 <iframe src="https://www.google.com/recaptcha/api/fallback?k=' . $publickey . '" frameborder="0" scrolling="no" style="width: 302px; height:422px; border-style: none;"></iframe>
668 </div>
669 </div>
670 <div style="border-style: none; bottom: 12px; left: 25px; margin: 0px; padding: 0px; right: 25px; background: #f9f9f9; border: 1px solid #c1c1c1; border-radius: 3px; height: 60px; width: 300px;">
671 <textarea id="g-recaptcha-response" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px !important; height: 40px !important; border: 1px solid #c1c1c1 !important; margin: 10px 25px !important; padding: 0px !important; resize: none !important;"></textarea>
672 </div>
673 </div>
674 </noscript>';
675 } else {
676 require_once( 'lib/recaptchalib.php' );
677 $content .= '<div id="gglcptch_recaptcha_' . $gglcptch_count . '" class="gglcptch_recaptcha"></div>';
678 $content .= gglcptch_recaptcha_get_html( $publickey, null, is_ssl() );
679 }
680 $content .= '</div>';
681 $gglcptch_count++;
682 return $content;
683 }
684 }
685
686 /* Check google captcha */
687 if ( ! function_exists( 'gglcptch_check' ) ) {
688 function gglcptch_check() {
689 global $gglcptch_options;
690
691 if ( ! gglcptch_get_allow_url_fopen() && isset( $gglcptch_options['recaptcha_version'] ) && $gglcptch_options['recaptcha_version'] == 'v2' ) {
692 return array(
693 'response' => false,
694 'reason' => 'ERROR_ALLOW_URL_FOPEN'
695 );
696 }
697
698 $publickey = $gglcptch_options['public_key'];
699 $privatekey = $gglcptch_options['private_key'];
700
701 if ( ! $privatekey || ! $publickey ) {
702 return array(
703 'response' => false,
704 'reason' => 'ERROR_NO_KEYS'
705 );
706 }
707
708 $gglcptch_remote_addr = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP );
709
710 if ( isset( $gglcptch_options['recaptcha_version'] ) && 'v2' == $gglcptch_options['recaptcha_version'] ) {
711
712 $gglcptch_g_recaptcha_response = '';
713
714 if ( ! isset( $_POST["g-recaptcha-response"] ) ) {
715 return array(
716 'response' => false,
717 'reason' => 'RECAPTCHA_NO_RESPONSE'
718 );
719 } elseif ( empty( $_POST["g-recaptcha-response"] ) ) {
720 return array(
721 'response' => false,
722 'reason' => 'RECAPTCHA_EMPTY_RESPONSE'
723 );
724 } else {
725 $gglcptch_g_recaptcha_response = stripslashes( esc_html( $_POST["g-recaptcha-response"] ) );
726 }
727
728 require_once( 'lib_v2/recaptchalib.php' );
729 $reCaptcha = new gglcptch_ReCaptcha( $privatekey );
730 $resp = $reCaptcha->verifyResponse( $gglcptch_remote_addr, $gglcptch_g_recaptcha_response );
731
732 if ( $resp != null && $resp->success ) {
733 return array(
734 'response' => true,
735 'reason' => ''
736 );
737 } else {
738 return array(
739 'response' => false,
740 'reason' => 'VERIFICATION_FAILED'
741 );
742 }
743 } else {
744 $gglcptch_recaptcha_challenge_field = $gglcptch_recaptcha_response_field = '';
745
746 if ( ! isset( $_POST['recaptcha_challenge_field'] ) && ! isset( $_POST['recaptcha_response_field'] ) ) {
747 return array(
748 'response' => false,
749 'reason' => 'RECAPTCHA_NO_RESPONSE'
750 );
751 } elseif ( ! empty( $_POST['recaptcha_challenge_field'] ) && empty( $_POST['recaptcha_response_field'] ) ) {
752 return array(
753 'response' => false,
754 'reason' => 'RECAPTCHA_EMPTY_RESPONSE'
755 );
756 } else {
757 $gglcptch_recaptcha_challenge_field = stripslashes( esc_html( $_POST['recaptcha_challenge_field'] ) );
758 $gglcptch_recaptcha_response_field = stripslashes( esc_html( $_POST['recaptcha_response_field'] ) );
759 }
760
761 require_once( 'lib/recaptchalib.php' );
762 $resp = gglcptch_recaptcha_check_answer( $privatekey, $gglcptch_remote_addr, $gglcptch_recaptcha_challenge_field, $gglcptch_recaptcha_response_field );
763 if ( ! $resp->is_valid ) {
764 return array(
765 'response' => false,
766 'reason' => 'VERIFICATION_FAILED'
767 );
768 } else {
769 return array(
770 'response' => true,
771 'reason' => ''
772 );
773 }
774 }
775 }
776 }
777
778 /* Add google captcha to the login form */
779 if ( ! function_exists( 'gglcptch_login_display' ) ) {
780 function gglcptch_login_display() {
781 global $gglcptch_options;
782 if ( isset( $gglcptch_options['recaptcha_version'] ) && 'v2' == $gglcptch_options['recaptcha_version'] ) {
783 $from_width = 302;
784 } else {
785 $from_width = 320;
786 if ( 'clean' == $gglcptch_options['theme'] )
787 $from_width = 450;
788 } ?>
789 <style type="text/css" media="screen">
790 #loginform,
791 #lostpasswordform,
792 #registerform {
793 width: <?php echo $from_width; ?>px !important;
794 }
795 #login_error,
796 .message {
797 width: <?php echo $from_width + 20; ?>px !important;
798 }
799 #loginform .gglcptch,
800 #lostpasswordform .gglcptch,
801 #registerform .gglcptch {
802 margin-bottom: 10px;
803 }
804 </style>
805 <?php echo gglcptch_display();
806 return true;
807 }
808 }
809
810 /* Check google captcha in login form */
811 if ( ! function_exists( 'gglcptch_login_check' ) ) {
812 function gglcptch_login_check( $user ) {
813
814
815 $gglcptch_check = gglcptch_check();
816
817 if ( ! $gglcptch_check['response'] ) {
818 if ( $gglcptch_check['reason'] == 'ERROR_ALLOW_URL_FOPEN' || $gglcptch_check['reason'] == 'ERROR_NO_KEYS' ) {
819 return $user;
820 }
821
822 $error_message = sprintf( '<strong>%s</strong>: %s', __( 'Error', 'google-captcha' ), __( 'You have entered an incorrect reCAPTCHA value.', 'google-captcha' ) );
823
824 if ( $gglcptch_check['reason'] == 'VERIFICATION_FAILED' ) {
825 wp_clear_auth_cookie();
826 return new WP_Error( 'gglcptch_error', $error_message );
827 }
828
829 if ( isset( $_REQUEST['log'] ) && isset( $_REQUEST['pwd'] ) ) {
830 return new WP_Error( 'gglcptch_error', $error_message );
831 } else {
832 return $user;
833 }
834 } else {
835 return $user;
836 }
837 }
838 }
839
840 /* Check google captcha in lostpassword form */
841 if ( ! function_exists( 'gglcptch_lostpassword_check' ) ) {
842 function gglcptch_lostpassword_check() {
843
844 $gglcptch_check = gglcptch_check();
845
846 if ( ! $gglcptch_check['response'] ) {
847 if ( $gglcptch_check['reason'] == 'ERROR_ALLOW_URL_FOPEN' || $gglcptch_check['reason'] == 'ERROR_NO_KEYS' ) {
848 return;
849 }
850
851 $error_message = sprintf( '%s: %s', __( 'Error', 'google-captcha' ), __( 'You have entered an incorrect reCAPTCHA value. Click the BACK button on your browser, and try again.', 'google-captcha' ) );
852 wp_die( $error_message );
853 } else {
854 return;
855 }
856 }
857 }
858
859 /* Add google captcha to the multisite login form */
860 if ( ! function_exists( 'gglcptch_signup_display' ) ) {
861 function gglcptch_signup_display( $errors ) {
862 if ( $error_message = $errors->get_error_message( 'gglcptch_error' ) ) {
863 printf( '<p class="error gglcptch_error">%s</p>', $error_message );
864 }
865 echo gglcptch_display();
866 }
867 }
868
869 /* Check google captcha in multisite login form */
870 if ( ! function_exists( 'gglcptch_signup_check' ) ) {
871 function gglcptch_signup_check( $result ) {
872
873 $gglcptch_check = gglcptch_check();
874
875 if ( ! $gglcptch_check['response'] ) {
876 if ( $gglcptch_check['reason'] == 'ERROR_ALLOW_URL_FOPEN' || $gglcptch_check['reason'] == 'ERROR_NO_KEYS' ) {
877 return $result;
878 }
879
880 $errors = $result['errors'];
881 $error_message = __( 'You have entered an incorrect reCAPTCHA value.', 'google-captcha' );
882 $errors->add( 'gglcptch_error', $error_message );
883 return $result;
884
885 } else {
886 return $result;
887 }
888 }
889 }
890
891 /* Add google captcha to the comment form */
892 if ( ! function_exists( 'gglcptch_commentform_display' ) ) {
893 function gglcptch_commentform_display() {
894 if ( gglcptch_check_role() )
895 return;
896 echo gglcptch_display();
897 return true;
898 }
899 }
900
901 /* Check JS enabled for comment form */
902 if ( ! function_exists( 'gglcptch_commentform_check' ) ) {
903 function gglcptch_commentform_check() {
904 if ( isset( $_POST['gglcptch_test_enable_js_field'] ) ) {
905 if ( wp_verify_nonce( $_POST['gglcptch_test_enable_js_field'], 'gglcptch_recaptcha_nonce' ) )
906 return;
907 else {
908 if ( gglcptch_check_role() )
909 return;
910 gglcptch_lostpassword_check();
911 }
912 } else {
913 if ( gglcptch_check_role() )
914 return;
915 gglcptch_lostpassword_check();
916 }
917 }
918 }
919
920 /* display google captcha in Contact form */
921 if ( ! function_exists( 'gglcptch_cf_display' ) ) {
922 function gglcptch_cf_display( $error_message, $content = "" ) {
923 return $content . gglcptch_display();
924 }
925 }
926
927 /* Check Google Captcha in shortcode and contact form */
928 if ( ! function_exists( 'gglcptch_captcha_check' ) ) {
929 function gglcptch_captcha_check() {
930 $gglcptch_check = gglcptch_check();
931 if ( ! $gglcptch_check['response'] ) {
932 echo "error";
933 } else {
934 echo "success";
935 }
936 die();
937 }
938 }
939
940 if ( ! function_exists( 'gglcptch_action_links' ) ) {
941 function gglcptch_action_links( $links, $file ) {
942 if ( ! is_network_admin() ) {
943 static $this_plugin;
944 if ( ! $this_plugin )
945 $this_plugin = plugin_basename(__FILE__);
946
947 if ( $file == $this_plugin ) {
948 $settings_link = '<a href="admin.php?page=google-captcha.php">' . __( 'Settings', 'google-captcha' ) . '</a>';
949 array_unshift( $links, $settings_link );
950 }
951 }
952 return $links;
953 }
954 }
955
956 if ( ! function_exists( 'gglcptch_shortcode_button_content' ) ) {
957 function gglcptch_shortcode_button_content( $content ) {
958 global $wp_version; ?>
959 <div id="gglcptch" style="display:none;">
960 <input class="bws_default_shortcode" type="hidden" name="default" value="[bws_google_captcha]" />
961 </div>
962 <script type="text/javascript">
963 function gglcptch_shortcode_init() {
964 (function($) {
965 var current_object = '<?php echo ( $wp_version < 3.9 ) ? "#TB_ajaxContent" : ".mce-reset" ?>';
966 $( current_object + ' #bws_shortcode_display' ).bind( 'display_shortcode', function() {
967 var shortcode = '[bws_google_captcha]';
968 $( this ).text( shortcode );
969 });
970 })(jQuery);
971 }
972 </script>
973 <?php }
974 }
975
976 if ( ! function_exists( 'gglcptch_links' ) ) {
977 function gglcptch_links( $links, $file ) {
978 $base = plugin_basename( __FILE__ );
979 if ( $file == $base ) {
980 if ( ! is_network_admin() )
981 $links[] = '<a href="admin.php?page=google-captcha.php">' . __( 'Settings', 'google-captcha' ) . '</a>';
982 $links[] = '<a href="http://wordpress.org/plugins/google-captcha/faq/" target="_blank">' . __( 'FAQ', 'google-captcha' ) . '</a>';
983 $links[] = '<a href="http://support.bestwebsoft.com">' . __( 'Support', 'google-captcha' ) . '</a>';
984 }
985 return $links;
986 }
987 }
988
989 if ( ! function_exists ( 'gglcptch_plugin_banner' ) ) {
990 function gglcptch_plugin_banner() {
991 global $hook_suffix, $gglcptch_plugin_info, $gglcptch_options;
992 if ( 'plugins.php' == $hook_suffix ) {
993 if ( empty( $gglcptch_options['public_key'] ) || empty( $gglcptch_options['private_key'] ) ) { ?>
994 <div class="error">
995 <p>
996 <?php printf(
997 '<strong>%s <a target="_blank" href="https://www.google.com/recaptcha/admin#list">%s</a> %s <a target="_blank" href="%s">%s</a>.</strong>',
998 __( 'To use Google Captcha you must get the keys from', 'google-captcha' ),
999 __ ( 'here', 'google-captcha' ),
1000 __ ( 'and enter them on the', 'google-captcha' ),
1001 admin_url( '/admin.php?page=google-captcha.php' ),
1002 __( 'plugin setting page', 'google-captcha' )
1003 ); ?>
1004 </p>
1005 </div>
1006 <?php }
1007 if ( isset( $gglcptch_options['first_install'] ) && strtotime( '-1 week' ) > $gglcptch_options['first_install'] )
1008 bws_plugin_banner( $gglcptch_plugin_info, 'gglcptch', 'google-captcha', '676d9558f9786ab41d7de35335cf5c4d', '109', '//ps.w.org/google-captcha/assets/icon-128x128.png' );
1009
1010 bws_plugin_banner_to_settings( $gglcptch_plugin_info, 'gglcptch_options', 'google-captcha', 'admin.php?page=google-captcha.php' );
1011 }
1012 }
1013 }
1014
1015 /* add help tab */
1016 if ( ! function_exists( 'gglcptch_add_tabs' ) ) {
1017 function gglcptch_add_tabs() {
1018 $screen = get_current_screen();
1019 $args = array(
1020 'id' => 'gglcptch',
1021 'section' => '200538719'
1022 );
1023 bws_help_tab( $screen, $args );
1024 }
1025 }
1026
1027 if ( ! function_exists( 'gglcptch_delete_options' ) ) {
1028 function gglcptch_delete_options() {
1029 global $wpdb;
1030 if ( function_exists( 'is_multisite' ) && is_multisite() ) {
1031 $old_blog = $wpdb->blogid;
1032 /* Get all blog ids */
1033 $blogids = $wpdb->get_col( "SELECT `blog_id` FROM $wpdb->blogs" );
1034 foreach ( $blogids as $blog_id ) {
1035 switch_to_blog( $blog_id );
1036 delete_option( 'gglcptch_options' );
1037 }
1038 switch_to_blog( $old_blog );
1039 } else {
1040 delete_option( 'gglcptch_options' );
1041 }
1042 }
1043 }
1044
1045 add_action( 'admin_menu', 'gglcptch_admin_menu' );
1046
1047 add_action( 'init', 'gglcptch_init' );
1048 add_action( 'admin_init', 'gglcptch_admin_init' );
1049
1050 add_action( 'plugins_loaded', 'gglcptch_plugins_loaded' );
1051
1052 add_action( 'admin_enqueue_scripts', 'gglcptch_add_admin_script_styles' );
1053 add_action( 'wp_enqueue_scripts', 'gglcptch_add_site_script_styles' );
1054
1055 /* custom filter for bws button in tinyMCE */
1056 add_filter( 'bws_shortcode_button_content', 'gglcptch_shortcode_button_content' );
1057 add_shortcode( 'bws_google_captcha', 'gglcptch_display' );
1058
1059 add_filter( 'plugin_action_links', 'gglcptch_action_links', 10, 2 );
1060 add_filter( 'plugin_row_meta', 'gglcptch_links', 10, 2 );
1061
1062 add_action( 'admin_notices', 'gglcptch_plugin_banner' );
1063
1064 add_action( 'wp_ajax_gglcptch_captcha_check', 'gglcptch_captcha_check' );
1065 add_action( 'wp_ajax_nopriv_gglcptch_captcha_check', 'gglcptch_captcha_check' );
1066
1067 register_uninstall_hook( __FILE__, 'gglcptch_delete_options' );