From 24f28c5c25d3f86c78654d1cf1162904acccaa62 Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Sat, 22 Aug 2015 17:33:11 +0100 Subject: [PATCH] combined a/i patch * set the correct recaptcha key where you have an empty one * adding a define for the global public and private recaptcha keys. - Fix all blogs that have an empty recaptcha key. - require configuration for wp-recaptcha (to define the global keys) * patch to stop recaptcha from dumbly use http:// schema when we are on https --- .../plugins/wp-recaptcha-bp/recaptcha.php | 23 +++++++++++++------ .../plugins/wp-recaptcha-bp/wp-plugin.php | 8 +++++-- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/wp-content/plugins/wp-recaptcha-bp/recaptcha.php b/wp-content/plugins/wp-recaptcha-bp/recaptcha.php index 73461902f..a9ea1d6c7 100644 --- a/wp-content/plugins/wp-recaptcha-bp/recaptcha.php +++ b/wp-content/plugins/wp-recaptcha-bp/recaptcha.php @@ -11,6 +11,7 @@ * @link http://www.google.com/recaptcha */ +require_once('config.php'); require_once('wp-plugin.php'); if (class_exists('ReCAPTCHAPlugin')) @@ -110,13 +111,19 @@ class ReCAPTCHAPlugin extends WPPlugin // set the default options function register_default_options() { - if ($this->options) + if ($this->options) { + if ($this->keys_missing()) { + $this->options['site_key'] = GLOBAL_RECAPTCHA_KEY; + $this->options['secret'] = GLOBAL_RECAPTCHA_PRIVATE_KEY; + WPPlugin::add_options($this->options_name, $this->options); + } return; + } $option_defaults = array(); $old_options = WPPlugin::retrieve_options("recaptcha"); if ($old_options) { - $option_defaults['site_key'] = $old_options['pubkey']; - $option_defaults['secret'] = $old_options['privkey']; + $option_defaults['site_key'] = $old_options['pubkey'] ? $old_options['pubkey'] : GLOBAL_RECAPTCHA_KEY; + $option_defaults['secret'] = $old_options['privkey'] ? $old_options['privkey'] : GLOBAL_RECAPTCHA_PRIVATE_KEY; // styling $option_defaults['recaptcha_language'] = $old_options['re_lang']; @@ -126,14 +133,14 @@ class ReCAPTCHAPlugin extends WPPlugin } else { $old_options = WPPlugin::retrieve_options($this->options_name); if ($old_options) { - $option_defaults['site_key'] = $old_options['public_key']; - $option_defaults['secret'] = $old_options['private_key']; + $option_defaults['site_key'] = $old_options['public_key'] ? $old_options['pubkey'] : GLOBAL_RECAPTCHA_KEY; + $option_defaults['secret'] = $old_options['private_key'] ? $old_options['privkey'] : GLOBAL_RECAPTCHA_PRIVATE_KEY; $option_defaults['comments_theme'] = 'standard'; $option_defaults['recaptcha_language'] = $old_options['recaptcha_language']; $option_defaults['no_response_error'] = $old_options['no_response_error']; } else { - $option_defaults['site_key'] = ''; - $option_defaults['secret'] = ''; + $option_defaults['site_key'] = GLOBAL_RECAPTCHA_KEY; + $option_defaults['secret'] = GLOBAL_RECAPTCHA_PRIVATE_KEY; $option_defaults['comments_theme'] = 'standard'; $option_defaults['recaptcha_language'] = 'en'; $option_defaults['no_response_error'] = @@ -171,9 +178,11 @@ class ReCAPTCHAPlugin extends WPPlugin } function missing_keys_notice() { + /* if ($this->keys_missing()) { $this->create_error_notice('reCAPTCHA API Keys are missing.'); } + */ } function validate_dropdown($array, $key, $value) { diff --git a/wp-content/plugins/wp-recaptcha-bp/wp-plugin.php b/wp-content/plugins/wp-recaptcha-bp/wp-plugin.php index ef05111ee..4fc2dcfae 100644 --- a/wp-content/plugins/wp-recaptcha-bp/wp-plugin.php +++ b/wp-content/plugins/wp-recaptcha-bp/wp-plugin.php @@ -59,9 +59,13 @@ if (!class_exists('WPPlugin')) { static function plugins_url() { if (WPPlugin::determine_environment() == Environment::WordPressMU) - return site_url() . '/wp-content/mu-plugins'; + $url = site_url() . '/wp-content/mu-plugins'; else - return site_url() . '/wp-content/plugins'; + $url = site_url() . '/wp-content/plugins'; + if ($_SERVER['https'] = 'on') { + $url = str_replace('http://', 'https://', $url); + } + return $url; } static function path_to_plugin_directory() { -- GitLab