function csp_po_ajax_handle_generate_mo_file(){ csp_po_check_security(); load_plugin_textdomain(CSP_PO_TEXTDOMAIN, PLUGINDIR.'/codestyling-localization','codestyling-localization'); require_once('includes/class-translationfile.php'); $pofile = (string)$_POST['pofile']; $textdomain = (string)$_POST['textdomain']; $f = new CspTranslationFile(); if (!$f->read_pofile($pofile)) { header('Status: 404 Not Found'); header('HTTP/1.1 404 Not Found'); echo sprintf(__("You do not have the permission to read the file '%s'.", CSP_PO_TEXTDOMAIN), $pofile); exit(); } //lets detected, what we are about to be writing: $mo = substr($pofile,0,-2).'mo'; $wp_dir = str_replace("\\","/",WP_LANG_DIR); $pl_dir = str_replace("\\","/",WP_PLUGIN_DIR); $plm_dir = str_replace("\\","/",WPMU_PLUGIN_DIR); $parts = pathinfo($mo); //dirname|basename|extension if (preg_match("|^".$wp_dir."|", $mo)) { //we are WordPress itself if (!empty($textdomain)) { $mo = $parts['dirname'].'/'.$textdomain.'-'.$parts['basename']; } }elseif(preg_match("|^".$pl_dir."|", $mo)|| preg_match("|^".$plm_dir."|", $mo)) { //we are a normal or wpmu plugin if (strpos($parts['basename'], $textdomain) === false) { preg_match("/([a-z][a-z]_[A-Z][A-Z]\.mo)$/", $parts['basename'], $h); if (!empty($textdomain)) { $mo = $parts['dirname'].'/'.$textdomain.'-'.$h[1]; }else { $mo = $parts['dirname'].'/'.$h[1]; } } }else{ //we are a theme plugin, could be tested but skipped for now. } if (!$f->write_mofile($mo,$textdomain)) { header('Status: 404 Not Found'); header('HTTP/1.1 404 Not Found'); echo sprintf(__("You do not have the permission to write the file '%s'.", CSP_PO_TEXTDOMAIN), $mo); exit(); } header('Content-Type: application/json'); ?> { filetime: '<?php echo date (__('m/d/Y H:i:s',CSP_PO_TEXTDOMAIN), filemtime($mo)); ?>' } <?php exit(); }