Skip to content

Commit

Permalink
Merge pull request #2 from diggy/patch-1
Browse files Browse the repository at this point in the history
Use WP_LANG_DIR const, wp_mkdir_p()
  • Loading branch information
aurovrata authored Nov 10, 2016
2 parents 21fd93b + 4f109ca commit 533cd9b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions admin/class-cf7-polylang-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,13 +387,13 @@ public function get_cf7_translations(){
foreach($languages as $locale){
if(isset($cf7_locales[$locale])){
$zipFile = $locale.'.zip';
$zipPath = ABSPATH . 'wp-content/languages/plugins/';// Local Zip File Path
$zipPath = WP_LANG_DIR . '/plugins/';// Local Zip File Path
//get the file stream, not using cURL as may not support https
file_put_contents($zipFile, fopen($cf7_locales[$locale], 'r'));

/* Open the Zip file */
$zip = new ZipArchive;
$extractPath = ABSPATH . 'wp-content/languages/plugins/';
$extractPath = WP_LANG_DIR . '/plugins/';
if($zip->open($zipFile) != "true"){
debug_msg( "CF7 POLYLANG: Error, unable to open the Zip File ". $zipFile);
}
Expand All @@ -403,8 +403,8 @@ public function get_cf7_translations(){
//delete zip file
unlink($zipFile);
//copy the .mo file to the CF7 language folder
if(! copy( ABSPATH . 'wp-content/languages/plugins/contact-form-7-'.$locale.'.mo',
ABSPATH . 'wp-content/languages/plugins/contact-form-7/contact-form-7-'.$locale.'.mo') ){
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);
Expand All @@ -424,10 +424,10 @@ public function get_cf7_translations(){
* @return array an array of locales
*/
protected function scan_local_locales(){
if(!is_dir(ABSPATH . 'wp-content/languages/plugins/contact-form-7/')){
mkdir(ABSPATH . 'wp-content/languages/plugins/contact-form-7/');
if(!is_dir(WP_LANG_DIR . '/plugins/contact-form-7/')){
wp_mkdir_p(WP_LANG_DIR . '/plugins/contact-form-7/');
}
$translations = scandir(ABSPATH . 'wp-content/languages/plugins/contact-form-7/');
$translations = scandir(WP_LANG_DIR . '/plugins/contact-form-7/');
$local_locales = array();
foreach($translations as $translation_file){
$parts = pathinfo($translation_file);
Expand Down

0 comments on commit 533cd9b

Please sign in to comment.