0
我想取我的WordPress插件,然後讓所有的gettext函數的參數PHP的正則表達式:從碼提取物起paramerts文件
例
die(_e('Error')) ;
die('<b>'._e('Error').'</b>') ;
_e('Error')
功能爲WordPress gettext的,我用
_e,__
以及如何繞過si milar功能
use_e,get_email,select__
我創建的正則表達式此功能,但它不是非常有用
$list_words = array();
function po_fetch_code($dir , $preg = "/_\(('|\")(.*?)('|\")\)/"){
if(is_dir($dir)){
$list = scandir($dir) ;
foreach($list as $l){
if($l == '.' || $l == '..'){
// Do Nothing
}else{
po_fetch_code($dir.'/'.$l , $preg) ;
}
}
}else{
$ext = strrchr($dir , '.') ;
//if($ext == '.php' || $ext == '.html' || $ext == 'html'){
//$cont = file_get_contents($dir) ;
$list = file($dir) ;
global $list_words ;
foreach($list as $key => $l){
preg_match_all($preg , $l , $matches);
if(!empty($matches[2])){
foreach($matches[2] as $k=>$m){
//$m = str_replace(array("\'",'\\' , '"' , "'",'\''), '' ,$m) ;
//$m = str_replace('\'s', 's' ,$m) ;
if(!isset($list_words[$m])){
$list_words[$m]['msgid'] = array($m) ;
$list_words[$m]['msgstr'] = array($m) ;
$list_words[$m]['reference'] = array() ;
}
$list_words[$m]['reference'][] = $dir.':'.$key ;
}
}
}
// }
}
}
$dir = 'themes/mytheme/' ;
po_fetch_code($dir , "/__\(('|\")(.*?)('|\")\)/") ;
po_fetch_code($dir , "/_e\(('|\")(.*?)('|\")\)/") ;
是否有任何的方式來提高我的功能?? 謝謝
你是說你想用'_e('? – chris85
是的,還有其他的gettext函數__ – Safy
搜索你的代碼庫嗎?你有沒有訪問命令行/ shell接口? – chris85