From e6c306bcb1b89d0c1585dca38418355758e67284 Mon Sep 17 00:00:00 2001 From: aurovrata Date: Thu, 24 Sep 2020 21:12:08 +0530 Subject: [PATCH] v2.3.3 --- README.txt | 5 +-- admin/class-cf7-polylang-admin.php | 50 ++++++++++++++++-------------- cf7-polylang.php | 4 +-- 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/README.txt b/README.txt index 6ad2797..d905ea1 100755 --- a/README.txt +++ b/README.txt @@ -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 @@ -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 = diff --git a/admin/class-cf7-polylang-admin.php b/admin/class-cf7-polylang-admin.php index 539bd73..29a59b9 100755 --- a/admin/class-cf7-polylang-admin.php +++ b/admin/class-cf7-polylang-admin.php @@ -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'; @@ -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 @@ -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 @@ -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']; @@ -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"); } } } diff --git a/cf7-polylang.php b/cf7-polylang.php index 21c89ed..f576220 100755 --- a/cf7-polylang.php +++ b/cf7-polylang.php @@ -16,7 +16,7 @@ * Plugin Name: Contact Form 7 Polylang extension * Plugin URI: http://wordpress.syllogic.in * Description: This plugin extends Contact Form 7 plugin to manage multiple language forms using the PolyLang 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+ @@ -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