Simple Google reCAPTCHA - Version 1.4

Version Description

  • Encoding was converted from Windows to Unix
  • Little text corrections, English isn't my strong page, sorry :-)
Download this release

Release Info

Developer Minor
Plugin Icon 128x128 Simple Google reCAPTCHA
Version 1.4
Comparing to
See all releases

Code changes from version 1.3 to 1.4

Files changed (2) hide show
  1. readme.txt +11 -27
  2. simple-google-recaptcha.php +108 -108
readme.txt CHANGED
@@ -1,60 +1,44 @@
1
  === Simple Google reCAPTCHA ===
2
-
3
  Contributors: Minor
4
  Tags: recaptcha, spam, block, captcha, bots, brute-force, protect
5
- Requires at least: 4.3.0
6
  Tested up to: 4.5.3
7
- Stable tag: 1.3
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
11
  Simply protect your WordPress against spam and brute-force attacks, thanks to Google reCAPTCHA!
12
 
13
-
14
  == Description ==
15
 
16
  Simple Google reCAPTCHA will protect your WordPress! No more spam and brute-force attacks against user accounts.
17
 
18
- What is protected with Google reCAPTCHA?
19
-
20
- 1. Comments
21
-
22
- 2. New password form
23
-
24
- 3. Registration form
25
-
26
- 4. Login form
27
-
28
 
29
  == Installation ==
30
-
31
  1. Upload the plugin files to the "/wp-content/plugins/simple-google-recaptcha" directory, or install the plugin through the WordPress plugins screen directly.
32
-
33
  2. Activate the plugin through the "Plugins" screen in WordPress.
34
-
35
  3. Use the Settings => reCAPTCHA screen to configure the plugin.
36
 
37
-
38
  == Frequently Asked Questions ==
39
-
40
  = Why to install this plugin? =
41
- Just pure protection no bullshit on the background.
42
-
43
 
44
  == Screenshots ==
45
-
46
  1. Google reCAPTCHA - Add new comment form
47
-
48
  2. Google reCAPTCHA - New password form
49
-
50
  3. Google reCAPTCHA - Registration form
51
-
52
  4. Google reCAPTCHA - Login form
53
-
54
  5. Settings
55
 
56
-
57
  == Changelog ==
 
 
 
58
 
59
  = 1.3 =
60
  * Added "Settings" button to WordPress plugins page
1
  === Simple Google reCAPTCHA ===
 
2
  Contributors: Minor
3
  Tags: recaptcha, spam, block, captcha, bots, brute-force, protect
4
+ Requires at least: 4.2.0
5
  Tested up to: 4.5.3
6
+ Stable tag: 1.4
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
10
  Simply protect your WordPress against spam and brute-force attacks, thanks to Google reCAPTCHA!
11
 
 
12
  == Description ==
13
 
14
  Simple Google reCAPTCHA will protect your WordPress! No more spam and brute-force attacks against user accounts.
15
 
16
+ = What is protected with Google reCAPTCHA? =
17
+ * Comments
18
+ * New password form
19
+ * Registration form
20
+ * Login form
 
 
 
 
 
21
 
22
  == Installation ==
 
23
  1. Upload the plugin files to the "/wp-content/plugins/simple-google-recaptcha" directory, or install the plugin through the WordPress plugins screen directly.
 
24
  2. Activate the plugin through the "Plugins" screen in WordPress.
 
25
  3. Use the Settings => reCAPTCHA screen to configure the plugin.
26
 
 
27
  == Frequently Asked Questions ==
 
28
  = Why to install this plugin? =
29
+ Just pure protection - no bullshits like ads and any other unnecessary changes in the WordPress core.
 
30
 
31
  == Screenshots ==
 
32
  1. Google reCAPTCHA - Add new comment form
 
33
  2. Google reCAPTCHA - New password form
 
34
  3. Google reCAPTCHA - Registration form
 
35
  4. Google reCAPTCHA - Login form
 
36
  5. Settings
37
 
 
38
  == Changelog ==
39
+ = 1.4 =
40
+ * Encoding was converted from Windows to Unix
41
+ * Little text corrections, English isn't my strong page, sorry :-)
42
 
43
  = 1.3 =
44
  * Added "Settings" button to WordPress plugins page
simple-google-recaptcha.php CHANGED
@@ -1,109 +1,109 @@
1
- <?php
2
- /*
3
- * Plugin Name: Simple Google reCAPTCHA
4
- * Description: Simply protect your WordPress against spam and brute-force attacks, thanks to Google reCAPTCHA!
5
- * Version: 1.3
6
- * Author: Michal Nov&aacute;k
7
- * Author URI: https://www.novami.cz
8
- * License: GPL3
9
- * Text Domain: sgr
10
- */
11
-
12
- function sgr_add_plugin_action_links($links) {
13
- return array_merge(array("settings" => "<a href=\"options-general.php?page=sgr-options\">".__("Settings", "sgr")."</a>"), $links);
14
- }
15
- add_filter("plugin_action_links_".plugin_basename(__FILE__), "sgr_add_plugin_action_links");
16
-
17
- function sgr_options_page() {
18
- echo "<div class=\"wrap\">
19
- <h1>".__("reCAPTCHA Options", "sgr")."</h1>
20
- <form method=\"post\" action=\"options.php\">";
21
- settings_fields("header_section");
22
- do_settings_sections("sgr-options");
23
- submit_button();
24
- echo "</form>
25
- </div>";
26
- }
27
-
28
- function sgr_menu() {
29
- add_submenu_page("options-general.php", "reCAPTCHA", "reCAPTCHA", "manage_options", "sgr-options", "sgr_options_page");
30
- }
31
- add_action("admin_menu", "sgr_menu");
32
-
33
- function display_sgr_options() {
34
- add_settings_section("header_section", __("What first?", "sgr"), "display_sgr_content", "sgr-options");
35
- add_settings_field("sgr_site_key", __("Site Key", "sgr"), "display_sgr_site_key_element", "sgr-options", "header_section");
36
- add_settings_field("sgr_secret_key", __("Secret Key", "sgr"), "display_sgr_secret_key_element", "sgr-options", "header_section");
37
-
38
- register_setting("header_section", "sgr_site_key");
39
- register_setting("header_section", "sgr_secret_key");
40
- }
41
-
42
- function display_sgr_content() {
43
- echo __("<p>You have to <a href=\"https://www.google.com/recaptcha/admin\" rel=\"external\">register your domain</a> first, get required keys from Google and save them bellow.</p>", "sgr");
44
- }
45
-
46
- function display_sgr_site_key_element() {
47
- echo "<input type=\"text\" name=\"sgr_site_key\" class=\"regular-text\" id=\"sgr_site_key\" value=\"".get_option("sgr_site_key")."\" />";
48
- }
49
-
50
- function display_sgr_secret_key_element() {
51
- echo "<input type=\"text\" name=\"sgr_secret_key\" class=\"regular-text\" id=\"sgr_secret_key\" value=\"".get_option("sgr_secret_key")."\" />";
52
- }
53
- add_action("admin_init", "display_sgr_options");
54
-
55
- function frontend_sgr_script() {
56
- wp_register_script("recaptcha", "https://www.google.com/recaptcha/api.js");
57
- wp_enqueue_script("recaptcha");
58
- $plugin_url = plugin_dir_url(__FILE__);
59
- wp_enqueue_style("style", $plugin_url."style.css");
60
- }
61
- add_action("wp_enqueue_scripts", "frontend_sgr_script");
62
- add_action("login_enqueue_scripts", "frontend_sgr_script");
63
-
64
- function load_language_sgr() {
65
- load_plugin_textdomain("sgr", false, dirname(plugin_basename(__FILE__)) . "/languages/");
66
- }
67
- add_action("plugins_loaded", "load_language_sgr");
68
-
69
- function display_sgr() {
70
- echo "<div class=\"g-recaptcha\" data-sitekey=\"".get_option("sgr_site_key")."\"></div>";
71
- }
72
-
73
- function verify_sgr($input) {
74
- if (isset($_POST["g-recaptcha-response"])) {
75
- $recaptcha_response = sanitize_text_field($_POST["g-recaptcha-response"]);
76
- $recaptcha_secret = get_option("sgr_secret_key");
77
- $response = wp_remote_get("https://www.google.com/recaptcha/api/siteverify?secret=".$recaptcha_secret."&response=".$recaptcha_response);
78
- $response = json_decode($response["body"], true);
79
- if (true == $response["success"]) {
80
- return $input;
81
- } else {
82
- wp_die(__("<p><strong>ERROR</strong>: Google reCAPTCHA verification failed.</p>", "sgr")."</p>\n\n<p><a href=".wp_get_referer().">&laquo; Zpět</a>");
83
- return null;
84
- }
85
- } else {
86
- wp_die(__("<p><strong>ERROR</strong>: Google reCAPTCHA verification failed. Do you have JavaScript enabled?</p>", "sgr")."</p>\n\n<p><a href=".wp_get_referer().">&laquo; Zpět</a>");
87
- return null;
88
- }
89
- }
90
-
91
- if (get_option("sgr_site_key") != "" && get_option("sgr_secret_key") != "") {
92
- add_action("comment_form_logged_in_after", "display_sgr");
93
- add_action("comment_form_after_fields", "display_sgr");
94
- add_action("login_form", "display_sgr" );
95
- add_action("register_form", "display_sgr");
96
- add_action("lostpassword_form", "display_sgr");
97
-
98
- do_action("preprocess_comment", $commentdata);
99
- add_action("preprocess_comment", "verify_sgr");
100
-
101
- do_action("wp_authenticate_user", $user);
102
- add_action("wp_authenticate_user", "verify_sgr");
103
-
104
- do_action("registration_errors", $errors);
105
- add_action("registration_errors", "verify_sgr");
106
-
107
- do_action("lostpassword_post", $errors);
108
- add_action("lostpassword_post", "verify_sgr");
109
  }
1
+ <?php
2
+ /*
3
+ * Plugin Name: Simple Google reCAPTCHA
4
+ * Description: Simply protect your WordPress against spam and brute-force attacks, thanks to Google reCAPTCHA!
5
+ * Version: 1.4
6
+ * Author: Michal Nov&aacute;k
7
+ * Author URI: https://www.novami.cz
8
+ * License: GPL3
9
+ * Text Domain: sgr
10
+ */
11
+
12
+ function sgr_add_plugin_action_links($links) {
13
+ return array_merge(array("settings" => "<a href=\"options-general.php?page=sgr-options\">".__("Settings", "sgr")."</a>"), $links);
14
+ }
15
+ add_filter("plugin_action_links_".plugin_basename(__FILE__), "sgr_add_plugin_action_links");
16
+
17
+ function sgr_options_page() {
18
+ echo "<div class=\"wrap\">
19
+ <h1>".__("reCAPTCHA Options", "sgr")."</h1>
20
+ <form method=\"post\" action=\"options.php\">";
21
+ settings_fields("header_section");
22
+ do_settings_sections("sgr-options");
23
+ submit_button();
24
+ echo "</form>
25
+ </div>";
26
+ }
27
+
28
+ function sgr_menu() {
29
+ add_submenu_page("options-general.php", "reCAPTCHA", "reCAPTCHA", "manage_options", "sgr-options", "sgr_options_page");
30
+ }
31
+ add_action("admin_menu", "sgr_menu");
32
+
33
+ function display_sgr_options() {
34
+ add_settings_section("header_section", __("What first?", "sgr"), "display_sgr_content", "sgr-options");
35
+ add_settings_field("sgr_site_key", __("Site Key", "sgr"), "display_sgr_site_key_element", "sgr-options", "header_section");
36
+ add_settings_field("sgr_secret_key", __("Secret Key", "sgr"), "display_sgr_secret_key_element", "sgr-options", "header_section");
37
+
38
+ register_setting("header_section", "sgr_site_key");
39
+ register_setting("header_section", "sgr_secret_key");
40
+ }
41
+
42
+ function display_sgr_content() {
43
+ echo __("<p>You have to <a href=\"https://www.google.com/recaptcha/admin\" rel=\"external\">register your domain</a> first, get required keys from Google and save them bellow.</p>", "sgr");
44
+ }
45
+
46
+ function display_sgr_site_key_element() {
47
+ echo "<input type=\"text\" name=\"sgr_site_key\" class=\"regular-text\" id=\"sgr_site_key\" value=\"".get_option("sgr_site_key")."\" />";
48
+ }
49
+
50
+ function display_sgr_secret_key_element() {
51
+ echo "<input type=\"text\" name=\"sgr_secret_key\" class=\"regular-text\" id=\"sgr_secret_key\" value=\"".get_option("sgr_secret_key")."\" />";
52
+ }
53
+ add_action("admin_init", "display_sgr_options");
54
+
55
+ function frontend_sgr_script() {
56
+ wp_register_script("recaptcha", "https://www.google.com/recaptcha/api.js");
57
+ wp_enqueue_script("recaptcha");
58
+ $plugin_url = plugin_dir_url(__FILE__);
59
+ wp_enqueue_style("style", $plugin_url."style.css");
60
+ }
61
+ add_action("wp_enqueue_scripts", "frontend_sgr_script");
62
+ add_action("login_enqueue_scripts", "frontend_sgr_script");
63
+
64
+ function load_language_sgr() {
65
+ load_plugin_textdomain("sgr", false, dirname(plugin_basename(__FILE__)) . "/languages/");
66
+ }
67
+ add_action("plugins_loaded", "load_language_sgr");
68
+
69
+ function display_sgr() {
70
+ echo "<div class=\"g-recaptcha\" data-sitekey=\"".get_option("sgr_site_key")."\"></div>";
71
+ }
72
+
73
+ function verify_sgr($input) {
74
+ if (isset($_POST["g-recaptcha-response"])) {
75
+ $recaptcha_response = sanitize_text_field($_POST["g-recaptcha-response"]);
76
+ $recaptcha_secret = get_option("sgr_secret_key");
77
+ $response = wp_remote_get("https://www.google.com/recaptcha/api/siteverify?secret=".$recaptcha_secret."&response=".$recaptcha_response);
78
+ $response = json_decode($response["body"], true);
79
+ if (true == $response["success"]) {
80
+ return $input;
81
+ } else {
82
+ wp_die(__("<p><strong>ERROR</strong>: Google reCAPTCHA verification failed.</p>", "sgr")."</p>\n\n<p><a href=".wp_get_referer().">&laquo; Zpět</a>");
83
+ return null;
84
+ }
85
+ } else {
86
+ wp_die(__("<p><strong>ERROR</strong>: Google reCAPTCHA verification failed. Do you have JavaScript enabled?</p>", "sgr")."</p>\n\n<p><a href=".wp_get_referer().">&laquo; Zpět</a>");
87
+ return null;
88
+ }
89
+ }
90
+
91
+ if (get_option("sgr_site_key") != "" && get_option("sgr_secret_key") != "") {
92
+ add_action("comment_form_logged_in_after", "display_sgr");
93
+ add_action("comment_form_after_fields", "display_sgr");
94
+ add_action("login_form", "display_sgr" );
95
+ add_action("register_form", "display_sgr");
96
+ add_action("lostpassword_form", "display_sgr");
97
+
98
+ do_action("preprocess_comment", $commentdata);
99
+ add_action("preprocess_comment", "verify_sgr");
100
+
101
+ do_action("wp_authenticate_user", $user);
102
+ add_action("wp_authenticate_user", "verify_sgr");
103
+
104
+ do_action("registration_errors", $errors);
105
+ add_action("registration_errors", "verify_sgr");
106
+
107
+ do_action("lostpassword_post", $errors);
108
+ add_action("lostpassword_post", "verify_sgr");
109
  }