-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
202 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
# cf7-pll-recaptcha | ||
A simple Wordpress plugin that changes the Contact Forms 7 recaptcha language to the current language of Polylang. | ||
# Contact Form 7 Polylang Recaptcha | ||
|
||
A simple Wordpress plugin that changes the Contact Form 7 recaptcha language to the current language of Polylang (the one chosen by the user). | ||
|
||
## Requirements | ||
|
||
This plugin requires [Contact Form 7](https://wordpress.org/plugins/contact-form-7/) and [Polylang](https://wordpress.org/plugins/polylang/) to be installed and active. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Nicomv\Cf7\Polylang\Recaptcha\I18n; | ||
|
||
/** | ||
* Define the internationalization functionality. | ||
* | ||
* Loads and defines the internationalization files for this plugin | ||
* so that it is ready for translation. | ||
* | ||
* @since 0.0.1 | ||
* @package Nicomv\Cf7\Polylang\Recaptcha | ||
* @subpackage Nicomv\Cf7\Polylang\Recaptcha\I18n | ||
* @author Your Name <[email protected]> | ||
*/ | ||
class I18n { | ||
/** | ||
* Load the plugin text domain for translation. | ||
* | ||
* @since 0.0.1 | ||
*/ | ||
public function loadTextDomain() { | ||
load_plugin_textdomain( | ||
'nmv-cf7-pll-recaptcha', | ||
false, | ||
dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace Nicomv\Cf7\Polylang\Recaptcha\Includes; | ||
|
||
/** | ||
* The main functionalaty of this plugin. | ||
*/ | ||
class Core | ||
{ | ||
/** | ||
* Retrieves the recaptcha api for the current polylang language. | ||
* @param string $src The script src. | ||
* @param string $handle The script handle, as defined in wp_register_script. | ||
* @return string A modified version of the api uri or the unmodified one | ||
* if the $handle doesn't match with the one defined by contact forms 7. | ||
*/ | ||
public function getScriptSrc($src, $handle) | ||
{ | ||
if ($handle !== 'google-recaptcha') { | ||
return $src; | ||
} | ||
return 'https://google.com/recaptcha/api.js?hl=' . strtolower(pll_current_language()); | ||
} | ||
|
||
public function run() | ||
{ | ||
$this->loadLang(); | ||
if (is_admin()) { | ||
add_action('admin_init', array($this, 'checkRequiredPlugins')); | ||
} else { | ||
$this->addFilters(); | ||
} | ||
} | ||
|
||
private function loadLang() | ||
{ | ||
require_once NMV_CF7_PLL_RECAPTCHA_PATH . 'i18n/I18n.php'; | ||
$i18n = new \Nicomv\Cf7\Polylang\Recaptcha\I18n\I18n; | ||
add_action('plugins_loaded', array($i18n, 'loadTextDomain')); | ||
} | ||
|
||
public function noPluginsNotice() | ||
{ | ||
include_once NMV_CF7_PLL_RECAPTCHA_PATH . 'includes/no-plugins.php'; | ||
} | ||
|
||
public function checkRequiredPlugins() | ||
{ | ||
if (!is_plugin_active('contact-form-7/wp-contact-form-7.php') || !is_plugin_active('polylang/polylang.php')) { | ||
add_action('admin_notices', array($this, 'noPluginsNotice')); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
public function addFilters() | ||
{ | ||
add_filter('script_loader_src', array($this, 'getScriptSrc'), 10, 2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div class="notice notice-error is-dismissible"> | ||
<p><?php _e('Los plugins necesarios no están habilitados. ', 'nmv-cf7-pll-recaptcha'); ?> | ||
<?=sprintf( | ||
__('Revise el siguiente enlace para saber qué plugins necesita: %s', 'nmv-cf7-pll-recaptcha'), | ||
'https://github.com/skaparate/cf7-pll-recaptcha' ); ?> | ||
</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: \n" | ||
"POT-Creation-Date: 2018-02-27 00:56-0300\n" | ||
"PO-Revision-Date: 2018-02-27 00:57-0300\n" | ||
"Last-Translator: \n" | ||
"Language-Team: [email protected] <[email protected]>\n" | ||
"Language: en_GB\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"X-Generator: Poedit 1.8.11\n" | ||
"X-Poedit-Basepath: ..\n" | ||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
"X-Poedit-SourceCharset: UTF-8\n" | ||
"X-Poedit-KeywordsList: __;_e\n" | ||
"X-Poedit-SearchPath-0: .\n" | ||
|
||
#: includes/no-plugins.php:2 | ||
msgid "Los plugins necesarios no están habilitados. " | ||
msgstr "The required plugins are disabled." | ||
|
||
#: includes/no-plugins.php:4 | ||
#, php-format | ||
msgid "Revise el siguiente enlace para saber qué plugins necesita: %s" | ||
msgstr "Check the following link to know which plugins are needed: %s" |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: \n" | ||
"POT-Creation-Date: 2018-02-27 00:56-0300\n" | ||
"PO-Revision-Date: 2018-02-27 00:57-0300\n" | ||
"Last-Translator: \n" | ||
"Language-Team: [email protected] <[email protected]>\n" | ||
"Language: en_GB\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"X-Generator: Poedit 1.8.11\n" | ||
"X-Poedit-Basepath: ..\n" | ||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
"X-Poedit-SourceCharset: UTF-8\n" | ||
"X-Poedit-KeywordsList: __;_e\n" | ||
"X-Poedit-SearchPath-0: .\n" | ||
|
||
#: includes/no-plugins.php:2 | ||
msgid "Los plugins necesarios no están habilitados. " | ||
msgstr "The required plugins are disabled." | ||
|
||
#: includes/no-plugins.php:4 | ||
#, php-format | ||
msgid "Revise el siguiente enlace para saber qué plugins necesita: %s" | ||
msgstr "Check the following link to know which plugins are needed: %s" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
namespace Nicomv\Cf7\Polylang\Recaptcha; | ||
|
||
/** | ||
* The plugin bootstrap file | ||
* | ||
* This file is read by WordPress to generate the plugin information in the plugin | ||
* admin area. This file also includes all of the dependencies used by the plugin, | ||
* registers the activation and deactivation functions, and defines a function | ||
* that starts the plugin. | ||
* | ||
* @link http://nicomv.com | ||
* @since 0.0.2 | ||
* @package Nicomv\Cf7\Polylang\Recaptcha | ||
* | ||
* @wordpress-plugin | ||
* Plugin Name: Contact Form 7 Polylang Recaptcha | ||
* Plugin URI: https://github.com/skaparate/cf7-pll-recaptcha/ | ||
* Description: A simple plugin that changes the recaptcha API URI language. | ||
* Version: 0.0.2 | ||
* Author: nicomv.com | ||
* Author URI: http://nicomv.com/ | ||
* License: GPL-2.0+ | ||
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt | ||
* Text Domain: nmv-cf7-pll-recaptcha | ||
* Domain Path: /languages | ||
*/ | ||
|
||
if (! defined('WPINC')) { | ||
die; | ||
} | ||
|
||
define('NMV_CF7_PLL_RECAPTCHA_PATH', plugin_dir_path(__FILE__)); | ||
|
||
function run() | ||
{ | ||
require_once NMV_CF7_PLL_RECAPTCHA_PATH.'includes/Core.php'; | ||
$core = new \Nicomv\Cf7\Polylang\Recaptcha\Includes\Core; | ||
$core->run(); | ||
return true; | ||
} | ||
run(); | ||
|