Skip to content

Commit

Permalink
v2.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
aurovrata committed Sep 24, 2020
1 parent 12ede49 commit e6c306b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 28 deletions.
5 changes: 3 additions & 2 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
Tags: polylang, contact form 7, multisite, contact form 7 extension, contact form 7 module, multilingual contact form 7, multilingual form, cf7 smart grid extension
Requires at least: 4.7
Requires PHP: 5.6
Tested up to: 5.2.0
Requires PHP: 5.6
Tested up to: 5.5.1
Stable tag: trunk
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -133,6 +132,8 @@ function my_cf7_mail_tag($output, $name, $html ) {
4. Ensure you enable translations for Contact Forms in your Polyland settings.

== Changelog ==
= 2.3.3 =
* fix ZipArchive class missing Fatal error for PHP 7.3 onwards.
= 2.3.2 =
* fix continue warning.
= 2.3.1 =
Expand Down
50 changes: 26 additions & 24 deletions admin/class-cf7-polylang-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public function admin_notices(){

foreach($notices[$pagenow] as $key=>$notice){
switch(true){
case strpos($key, 'page=') !== false && $_GET['page'] === str_replace('page=','',$key):
case strpos($key, 'post_type=') !== false && $_GET['post_type'] === str_replace('post_type=','',$key):
case strpos($key, 'page=') !== false && isset($_GET['page']) && $_GET['page'] === str_replace('page=','',$key):
case strpos($key, 'post_type=') !== false && isset($_GET['post_type']) && $_GET['post_type'] === str_replace('post_type=','',$key):
case $key==='any':
case $key==='polylang':
$dismiss = $notice['nonce'].'-forever';
Expand Down Expand Up @@ -292,9 +292,13 @@ public function set_edit_form_link($link, $post_ID, $context){
* @since 1.0.0
*/
public function get_cf7_translations(){
if(!class_exists('ZipArchive')){
debug_msg( 'CF7 POLYLANG: Error, no ZipArchive class found, install php zip module');
return false;
}
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
if(! $this->check_plugin_dependency()){
return;
return false;
};

//what locales are already installed
Expand All @@ -315,7 +319,7 @@ public function get_cf7_translations(){
$languages = array_diff($languages, $local_locales, array('en_US'));

if(empty($languages)){
return; //nothing to be loaded
return true; //nothing to be loaded
}

//get available locales for CF7
Expand All @@ -326,9 +330,9 @@ public function get_cf7_translations(){
'version' => WPCF7_VERSION ) );
if ( is_wp_error( $api ) ) {
//display error
debug_msg("CF7 POLYLANG: Error loading CF7 translations, ".$api->get_error_message());
debug_msg("CF7 POLYLANG: Error loading CF7 translations, {$api->get_error_message()}");
}else if( empty( $api['translations'] ) ){
debug_msg("CF7 POLYLANG: CF7 translations are empty, please try again");
debug_msg('CF7 POLYLANG: CF7 translations are empty, please try again');
}else{
foreach($api['translations'] as $translation){
$cf7_locales[$translation['language']] = $translation['package'];
Expand All @@ -343,28 +347,26 @@ public function get_cf7_translations(){
file_put_contents($zipFile, fopen($cf7_locales[$locale], 'r'));

/* Open the Zip file */
$zip = new ZipArchive;
$zip = new ZipArchive;

$extractPath = WP_LANG_DIR . '/plugins/';
if($zip->open($zipFile) != "true"){
debug_msg( "CF7 POLYLANG: Error, unable to open the Zip File ". $zipFile);
}
/* Extract Zip File */
$zip->extractTo($extractPath);
$zip->close();
//delete zip file
unlink($zipFile);
//copy the .mo file to the CF7 language folder
if(! copy( WP_LANG_DIR . '/plugins/contact-form-7-'.$locale.'.mo',
WP_LANG_DIR . '/plugins/contact-form-7/contact-form-7-'.$locale.'.mo') ){
debug_msg("CF7 POLYLANG: Unable to copy CF7 translation for locale ".$zipFile." to CF7 plugin folder.");
}else{
debug_msg("CF7 POLYLANG: Found and installed CF7 translation for locale ".$zipFile);
//register locale for cf7 domain
// load_textdomain( 'contact-form-7', WP_LANG_DIR . '/plugins/contact-form-7-'.$locale.'.mo' );
if( $zip->open($zipFile) != "true"){
debug_msg( "CF7 POLYLANG: Error, unable to open the Zip File $zipFile");
}else{
/* Extract Zip File */
$zip->extractTo($extractPath);
$zip->close();
//delete zip file
unlink($zipFile);
//copy the .mo file to the CF7 language folder
if(! copy( WP_LANG_DIR . '/plugins/contact-form-7-'.$locale.'.mo',
WP_LANG_DIR . '/plugins/contact-form-7/contact-form-7-'.$locale.'.mo') ){
debug_msg("CF7 POLYLANG: Unable to copy CF7 translation for locale $zipFile to CF7 plugin folder.");
}
}
}else{
//we need to report the missing translation
debug_msg("CF7 POLYLANG: Missing CF7 translation file for locale ".$locale);
debug_msg("CF7 POLYLANG: Missing CF7 translation file for locale $locale");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions cf7-polylang.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Plugin Name: Contact Form 7 Polylang extension
* Plugin URI: http://wordpress.syllogic.in
* Description: This plugin extends <a target="_blank" href="https://wordpress.org/plugins/contact-form-7/">Contact Form 7</a> plugin to manage multiple language forms using the <a target="_blank" href="https://wordpress.org/plugins/polylang/">PolyLang</a> plugin. It Requires both plugins to be active first.
* Version: 2.3.2
* Version: 2.3.3
* Author: Aurovrata V.
* Author URI: http://syllogic.in
* License: GPL-2.0+
Expand All @@ -30,7 +30,7 @@
die;
}
define( 'CF7_POLYLANG_PATH', plugin_dir_path( __FILE__ ) );
define( 'CF7_POLYLANG_VERSION', '2.3.2' );
define( 'CF7_POLYLANG_VERSION', '2.3.3' );
/**
* The code that runs during plugin activation.
* This action is documented in includes/class-cf7-polylang-activator.php
Expand Down

0 comments on commit e6c306b

Please sign in to comment.