せっかく作ったので
デスクトップにtest.phpってファイル名で置いてたら、消して後悔しそうだったのでここに書いておこうと思う。
id属性”_wp_unfiltered_html_comment”の先頭のアンダーバーを除去するプラグイン。(ただし、手動)
<?php
$initdir = "/wordpress/";
$ext = ".php";
$find = "_wp_unfiltered_html_comment";
$replace = "wp_unfiltered_html_comment";
$filelist = get_filelist($initdir, $ext);
foreach($filelist as $key => $filename) {
// ファイルを読み込む
$fcontents = @file_get_contents($filename);
// 検索
$pos = strpos($fcontents, "_wp_unfiltered_html_comment");
if($pos !== FALSE) {
// 文字列が存在した場合
// 置換
$fout = fopen($filename, "w");
fwrite($fout, str_replace($find, $replace, $fcontents));
fclose($fout);
echo "replace : " . $filename . "\n";
}
}
// $initdir以下の$extファイルのリストを取得する
function get_filelist($startDir, $ext) {
$dir = $startDir;
$dirs = array();
$filename = array();
$next = 0;
foreach(glob($dir."*".$ext) as $_filename) {
$filename[] = $_filename;
}
while(true) {
$_dirs = glob($dir."*", GLOB_ONLYDIR | GLOB_MARK);
if(count($_dirs)) {
foreach ($_dirs as $key => $_dir) {
foreach(glob($_dir."*".$ext) as $_filename) {
$filename[] = $_filename;
}
$dirs[] = $_dir;
}
} else {
break;
}
$dir = $dirs[$next++];
}
return $filename;
}
?>











205StudioTR
コメント/トラックバック
トラックバック用URL
この記事へのコメント/トラックバックRSS
この記事へのコメント/トラックバックはありません。
コメントする