Simple Google reCAPTCHA - Version 1.3

Version Description

  • Added "Settings" button to WordPress plugins page
  • reCAPTCHA is required only after filled in settings
  • Text domain were changed from simple-google-recaptcha to sgr - need to set up keys again
Download this release

Release Info

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

Code changes from version 1.2 to 1.3

languages/sgr-cs_CZ.mo ADDED
Binary file
languages/{simple-google-recaptcha-cs_CZ.po → sgr-cs_CZ.po} RENAMED
@@ -2,8 +2,8 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Simple Google reCAPTCHA\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: Thu Jul 28 2016 03:31:39 GMT+0200\n"
6
- "PO-Revision-Date: Tue Aug 02 2016 19:23:37 GMT+0200\n"
7
  "Last-Translator: Minor <blog@novami.cz>\n"
8
  "Language-Team: \n"
9
  "Language: Czech\n"
@@ -24,20 +24,12 @@ msgstr ""
24
  "X-Loco-Target-Locale: cs_CZ"
25
 
26
  #. Description of the plugin
27
- msgid "Simply protect your WordPress from spam, thanks to Google reCAPTCHA!"
28
- msgstr "Jednoduše ochraňte svůj WordPress před spamem, díky Google reCAPTCHA!"
29
-
30
- #: ../simple-google-recaptcha.php:85
31
- msgid "<p><strong>ERROR</strong>: Google reCAPTCHA verification failed.</p>"
32
- msgstr "<p><strong>CHYBA</strong>: Selhalo ověření Google reCAPTCHA.</p>"
33
-
34
- #: ../simple-google-recaptcha.php:89
35
  msgid ""
36
- "<p><strong>ERROR</strong>: Google reCAPTCHA verification failed. Do you have "
37
- "JavaScript enabled?</p>"
38
  msgstr ""
39
- "<p><strong>CHYBA</strong>: Selhalo ověření Google reCAPTCHA. Máte povolený "
40
- "JavaScript?</p>"
41
 
42
  #. Name of the plugin
43
  msgid "Simple Google reCAPTCHA"
@@ -51,32 +43,44 @@ msgstr "Michal Nov&aacute;k"
51
  msgid "https://www.novami.cz"
52
  msgstr "https://www.novami.cz"
53
 
54
- #: ../simple-google-recaptcha.php:18
 
 
 
 
55
  msgid "reCAPTCHA Options"
56
  msgstr "Nastavení reCAPTCHA"
57
 
58
- #: ../simple-google-recaptcha.php:29
59
- msgid "Keys"
60
- msgstr "Klíče"
61
 
62
- #: ../simple-google-recaptcha.php:31
63
  msgid "Site Key"
64
  msgstr "Klíč stránky"
65
 
66
- #: ../simple-google-recaptcha.php:32
67
  msgid "Secret Key"
68
  msgstr "Tajný klíč"
69
 
70
- #: ../simple-google-recaptcha.php:39
71
  msgid ""
72
  "<p>You have to <a href=\"https://www.google.com/recaptcha/admin\" "
73
- "rel=\"external\">register your domain</a> first and get required keys from "
74
- "Google.</p>"
75
  msgstr ""
76
  "<p>Nejprve musíte <a href=\"https://www.google.com/recaptcha/admin\" "
77
- "rel=\"external\">zaregistrovat svou doménu</a> a získat tak potřebné klíče od "
78
- "Googlu.</p>"
79
 
80
- #: ../simple-google-recaptcha.php:40
81
- msgid "<p>Enter your keys below:</p>"
82
- msgstr "<p>Níže vložte získané klíče:</p>"
 
 
 
 
 
 
 
 
2
  msgstr ""
3
  "Project-Id-Version: Simple Google reCAPTCHA\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: Thu Aug 04 2016 19:45:38 GMT+0200\n"
6
+ "PO-Revision-Date: Thu Aug 04 2016 21:13:37 GMT+0200\n"
7
  "Last-Translator: Minor <blog@novami.cz>\n"
8
  "Language-Team: \n"
9
  "Language: Czech\n"
24
  "X-Loco-Target-Locale: cs_CZ"
25
 
26
  #. Description of the plugin
 
 
 
 
 
 
 
 
27
  msgid ""
28
+ "Simply protect your WordPress against spam and brute-force attacks, thanks "
29
+ "to Google reCAPTCHA!"
30
  msgstr ""
31
+ "Jednoduše ochraňte svůj WordPress před spamem a brute-force útoky, díky "
32
+ "Google reCAPTCHA!"
33
 
34
  #. Name of the plugin
35
  msgid "Simple Google reCAPTCHA"
43
  msgid "https://www.novami.cz"
44
  msgstr "https://www.novami.cz"
45
 
46
+ #: ../simple-google-recaptcha.php:13
47
+ msgid "Settings"
48
+ msgstr "Nastavení"
49
+
50
+ #: ../simple-google-recaptcha.php:23
51
  msgid "reCAPTCHA Options"
52
  msgstr "Nastavení reCAPTCHA"
53
 
54
+ #: ../simple-google-recaptcha.php:34
55
+ msgid "What first?"
56
+ msgstr "Co nejdříve?"
57
 
58
+ #: ../simple-google-recaptcha.php:35
59
  msgid "Site Key"
60
  msgstr "Klíč stránky"
61
 
62
+ #: ../simple-google-recaptcha.php:36
63
  msgid "Secret Key"
64
  msgstr "Tajný klíč"
65
 
66
+ #: ../simple-google-recaptcha.php:43
67
  msgid ""
68
  "<p>You have to <a href=\"https://www.google.com/recaptcha/admin\" "
69
+ "rel=\"external\">register your domain</a> first, get required keys from Google "
70
+ "and save them bellow.</p>"
71
  msgstr ""
72
  "<p>Nejprve musíte <a href=\"https://www.google.com/recaptcha/admin\" "
73
+ "rel=\"external\">zaregistrovat svou doménu</a>, získat potřebné klíče od "
74
+ "Googlu a nastavit je níže.</p>"
75
 
76
+ #: ../simple-google-recaptcha.php:82
77
+ msgid "<p><strong>ERROR</strong>: Google reCAPTCHA verification failed.</p>"
78
+ msgstr "<p><strong>CHYBA</strong>: Selhalo ověření Google reCAPTCHA.</p>"
79
+
80
+ #: ../simple-google-recaptcha.php:86
81
+ msgid ""
82
+ "<p><strong>ERROR</strong>: Google reCAPTCHA verification failed. Do you have "
83
+ "JavaScript enabled?</p>"
84
+ msgstr ""
85
+ "<p><strong>CHYBA</strong>: Selhalo ověření Google reCAPTCHA. Máte povolený "
86
+ "JavaScript?</p>"
languages/{simple-google-recaptcha.pot → sgr.pot} RENAMED
@@ -4,8 +4,8 @@ msgid ""
4
  msgstr ""
5
  "Project-Id-Version: Simple Google reCAPTCHA\n"
6
  "Report-Msgid-Bugs-To: \n"
7
- "POT-Creation-Date: Thu Jul 28 2016 03:31:39 GMT+0200\n"
8
- "POT-Revision-Date: Tue Aug 02 2016 19:22:00 GMT+0200\n"
9
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
10
  "Last-Translator: \n"
11
  "Language-Team: \n"
@@ -29,7 +29,9 @@ msgid "Simple Google reCAPTCHA"
29
  msgstr ""
30
 
31
  #. Description of the plugin
32
- msgid "Simply protect your WordPress from spam, thanks to Google reCAPTCHA!"
 
 
33
  msgstr ""
34
 
35
  #. Author of the plugin
@@ -40,38 +42,38 @@ msgstr ""
40
  msgid "https://www.novami.cz"
41
  msgstr ""
42
 
43
- #: ../simple-google-recaptcha.php:18
 
 
 
 
44
  msgid "reCAPTCHA Options"
45
  msgstr ""
46
 
47
- #: ../simple-google-recaptcha.php:29
48
- msgid "Keys"
49
  msgstr ""
50
 
51
- #: ../simple-google-recaptcha.php:31
52
  msgid "Site Key"
53
  msgstr ""
54
 
55
- #: ../simple-google-recaptcha.php:32
56
  msgid "Secret Key"
57
  msgstr ""
58
 
59
- #: ../simple-google-recaptcha.php:39
60
  msgid ""
61
  "<p>You have to <a href=\"https://www.google.com/recaptcha/admin\" "
62
- "rel=\"external\">register your domain</a> first and get required keys from "
63
- "Google.</p>"
64
- msgstr ""
65
-
66
- #: ../simple-google-recaptcha.php:40
67
- msgid "<p>Enter your keys below:</p>"
68
  msgstr ""
69
 
70
- #: ../simple-google-recaptcha.php:85
71
  msgid "<p><strong>ERROR</strong>: Google reCAPTCHA verification failed.</p>"
72
  msgstr ""
73
 
74
- #: ../simple-google-recaptcha.php:89
75
  msgid ""
76
  "<p><strong>ERROR</strong>: Google reCAPTCHA verification failed. Do you have "
77
  "JavaScript enabled?</p>"
4
  msgstr ""
5
  "Project-Id-Version: Simple Google reCAPTCHA\n"
6
  "Report-Msgid-Bugs-To: \n"
7
+ "POT-Creation-Date: Thu Aug 04 2016 19:45:38 GMT+0200\n"
8
+ "POT-Revision-Date: Thu Aug 04 2016 21:12:49 GMT+0200\n"
9
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
10
  "Last-Translator: \n"
11
  "Language-Team: \n"
29
  msgstr ""
30
 
31
  #. Description of the plugin
32
+ msgid ""
33
+ "Simply protect your WordPress against spam and brute-force attacks, thanks "
34
+ "to Google reCAPTCHA!"
35
  msgstr ""
36
 
37
  #. Author of the plugin
42
  msgid "https://www.novami.cz"
43
  msgstr ""
44
 
45
+ #: ../simple-google-recaptcha.php:13
46
+ msgid "Settings"
47
+ msgstr ""
48
+
49
+ #: ../simple-google-recaptcha.php:23
50
  msgid "reCAPTCHA Options"
51
  msgstr ""
52
 
53
+ #: ../simple-google-recaptcha.php:34
54
+ msgid "What first?"
55
  msgstr ""
56
 
57
+ #: ../simple-google-recaptcha.php:35
58
  msgid "Site Key"
59
  msgstr ""
60
 
61
+ #: ../simple-google-recaptcha.php:36
62
  msgid "Secret Key"
63
  msgstr ""
64
 
65
+ #: ../simple-google-recaptcha.php:43
66
  msgid ""
67
  "<p>You have to <a href=\"https://www.google.com/recaptcha/admin\" "
68
+ "rel=\"external\">register your domain</a> first, get required keys from Google "
69
+ "and save them bellow.</p>"
 
 
 
 
70
  msgstr ""
71
 
72
+ #: ../simple-google-recaptcha.php:82
73
  msgid "<p><strong>ERROR</strong>: Google reCAPTCHA verification failed.</p>"
74
  msgstr ""
75
 
76
+ #: ../simple-google-recaptcha.php:86
77
  msgid ""
78
  "<p><strong>ERROR</strong>: Google reCAPTCHA verification failed. Do you have "
79
  "JavaScript enabled?</p>"
languages/simple-google-recaptcha-cs_CZ.mo DELETED
Binary file
readme.txt CHANGED
@@ -1,25 +1,28 @@
1
  === Simple Google reCAPTCHA ===
2
 
3
  Contributors: Minor
4
- Tags: recaptcha, spam protect, block spam, google captcha
5
  Requires at least: 4.3.0
6
  Tested up to: 4.5.3
7
- Stable tag: 1.2
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
11
- Simply protect your WordPress from spam, thanks to Google reCAPTCHA!
12
 
13
 
14
  == Description ==
15
 
16
- Are you bored from removing spam comments and users from your WordPress? Simple Google reCAPTCHA will protect your WordPress and save your time! It's the best solution today.
17
 
18
  What is protected with Google reCAPTCHA?
19
 
20
  1. Comments
 
21
  2. New password form
 
22
  3. Registration form
 
23
  4. Login form
24
 
25
 
@@ -27,29 +30,37 @@ What is protected with Google reCAPTCHA?
27
 
28
  1. Upload the plugin files to the "/wp-content/plugins/simple-google-recaptcha" directory, or install the plugin through the WordPress plugins screen directly.
29
 
30
- 2. Activate the plugin through the "Plugins" screen in WordPress
31
 
32
- 3. Use the Settings => reCAPTCHA screen to configure the plugin
33
 
34
 
35
  == Frequently Asked Questions ==
36
 
37
- = No questions yet =
38
-
39
- No answers yet.
40
 
41
 
42
  == Screenshots ==
43
 
44
  1. Google reCAPTCHA - Add new comment form
 
45
  2. Google reCAPTCHA - New password form
 
46
  3. Google reCAPTCHA - Registration form
 
47
  4. Google reCAPTCHA - Login form
 
48
  5. Settings
49
 
50
 
51
  == Changelog ==
52
 
 
 
 
 
 
53
  = 1.2 =
54
  * Cleaning plugin folder - smaller
55
 
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
 
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
61
+ * reCAPTCHA is required only after filled in settings
62
+ * Text domain were changed from simple-google-recaptcha to sgr - need to set up keys again
63
+
64
  = 1.2 =
65
  * Cleaning plugin folder - smaller
66
 
simple-google-recaptcha.php CHANGED
@@ -1,104 +1,109 @@
1
- <?php
2
- /*
3
- * Plugin Name: Simple Google reCAPTCHA
4
- * Description: Simply protect your WordPress from spam, thanks to Google reCAPTCHA!
5
- * Version: 1.2
6
- * Author: Michal Nov&aacute;k
7
- * Author URI: https://www.novami.cz
8
- * License: GPL3
9
- * Text Domain: simple-google-recaptcha
10
- */
11
-
12
- function simple_google_recaptcha_menu() {
13
- add_submenu_page("options-general.php", "reCAPTCHA", "reCAPTCHA", "manage_options", "simple-google-recaptcha-options", "simple_google_recaptcha_options_page");
14
- }
15
-
16
- function simple_google_recaptcha_options_page() {
17
- echo "<div class=\"wrap\">
18
- <h1>".__("reCAPTCHA Options", "simple-google-recaptcha")."</h1>
19
- <form method=\"post\" action=\"options.php\">";
20
- settings_fields("header_section");
21
- do_settings_sections("simple-google-recaptcha-options");
22
- submit_button();
23
- echo "</form>
24
- </div>";
25
- }
26
- add_action("admin_menu", "simple_google_recaptcha_menu");
27
-
28
- function display_simple_google_recaptcha_options() {
29
- add_settings_section("header_section", __("Keys", "simple-google-recaptcha"), "display_simple_google_recaptcha_content", "simple-google-recaptcha-options");
30
-
31
- add_settings_field("simple_google_recaptcha_site_key", __("Site Key", "simple-google-recaptcha"), "display_simple_google_recaptcha_site_key_element", "simple-google-recaptcha-options", "header_section");
32
- add_settings_field("simple_google_recaptcha_secret_key", __("Secret Key", "simple-google-recaptcha"), "display_simple_google_recaptcha_secret_key_element", "simple-google-recaptcha-options", "header_section");
33
-
34
- register_setting("header_section", "simple_google_recaptcha_site_key");
35
- register_setting("header_section", "simple_google_recaptcha_secret_key");
36
- }
37
-
38
- function display_simple_google_recaptcha_content() {
39
- echo __("<p>You have to <a href=\"https://www.google.com/recaptcha/admin\" rel=\"external\">register your domain</a> first and get required keys from Google.</p>", "simple-google-recaptcha");
40
- echo __("<p>Enter your keys below:</p>", "simple-google-recaptcha");
41
- }
42
-
43
- function display_simple_google_recaptcha_site_key_element() {
44
- echo "<input type=\"text\" name=\"simple_google_recaptcha_site_key\" class=\"regular-text\" id=\"simple_google_recaptcha_site_key\" value=\"".get_option("simple_google_recaptcha_site_key")."\" />";
45
- }
46
-
47
- function display_simple_google_recaptcha_secret_key_element() {
48
- echo "<input type=\"text\" name=\"simple_google_recaptcha_secret_key\" class=\"regular-text\" id=\"simple_google_recaptcha_secret_key\" value=\"".get_option("simple_google_recaptcha_secret_key")."\" />";
49
- }
50
- add_action("admin_init", "display_simple_google_recaptcha_options");
51
-
52
- function frontend_simple_google_recaptcha_script() {
53
- wp_register_script("recaptcha", "https://www.google.com/recaptcha/api.js");
54
- wp_enqueue_script("recaptcha");
55
- $plugin_url = plugin_dir_url(__FILE__);
56
- wp_enqueue_style("style", $plugin_url ."style.css");
57
- }
58
- add_action("wp_enqueue_scripts", "frontend_simple_google_recaptcha_script");
59
- add_action("login_enqueue_scripts", "frontend_simple_google_recaptcha_script");
60
-
61
- function load_language_simple_google_recaptcha() {
62
- load_plugin_textdomain("simple-google-recaptcha", false, dirname(plugin_basename(__FILE__)) . "/languages/");
63
- }
64
- add_action("plugins_loaded", "load_language_simple_google_recaptcha");
65
-
66
- function display_simple_google_recaptcha() {
67
- echo "<div class=\"g-recaptcha\" data-sitekey=\"".get_option("simple_google_recaptcha_site_key")."\"></div>";
68
- }
69
-
70
- add_action("comment_form_logged_in_after", "display_simple_google_recaptcha");
71
- add_action("comment_form_after_fields", "display_simple_google_recaptcha");
72
- add_action("login_form", "display_simple_google_recaptcha" );
73
- add_action("register_form", "display_simple_google_recaptcha");
74
- add_action("lostpassword_form", "display_simple_google_recaptcha");
75
-
76
- function verify_simple_google_recaptcha($input) {
77
- if (isset($_POST["g-recaptcha-response"])) {
78
- $recaptcha_response = sanitize_text_field($_POST["g-recaptcha-response"]);
79
- $recaptcha_secret = get_option("simple_google_recaptcha_secret_key");
80
- $response = wp_remote_get("https://www.google.com/recaptcha/api/siteverify?secret=".$recaptcha_secret."&response=".$recaptcha_response);
81
- $response = json_decode($response["body"], true);
82
- if (true == $response["success"]) {
83
- return $input;
84
- } else {
85
- wp_die(__("<p><strong>ERROR</strong>: Google reCAPTCHA verification failed.</p>", "simple-google-recaptcha")."</p>\n\n<p><a href=".wp_get_referer().">&laquo; Zpět</a>");
86
- return null;
87
- }
88
- } else {
89
- wp_die(__("<p><strong>ERROR</strong>: Google reCAPTCHA verification failed. Do you have JavaScript enabled?</p>", "simple-google-recaptcha")."</p>\n\n<p><a href=".wp_get_referer().">&laquo; Zpět</a>");
90
- return null;
91
- }
92
- }
93
-
94
- do_action("preprocess_comment", $commentdata);
95
- add_action("preprocess_comment", "verify_simple_google_recaptcha");
96
-
97
- do_action("wp_authenticate_user", $user);
98
- add_action("wp_authenticate_user", "verify_simple_google_recaptcha");
99
-
100
- do_action("registration_errors", $errors);
101
- add_action("registration_errors", "verify_simple_google_recaptcha");
102
-
103
- do_action("lostpassword_post", $errors);
104
- add_action("lostpassword_post", "verify_simple_google_recaptcha");
 
 
 
 
 
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
+ }