#やりたいこと
日本語ドメインのURLを変換したい。
#今のソースコード
function convert_punycode($text){ $html_content = $text; $regex = "|<a href=\"(.*?)\".*?>(.*?)</a>|mis"; preg_match_all($regex,$html_content,$matches, PREG_SET_ORDER); foreach ($matches as $val) { $url = $val; } require_once('/home/DocumentRoot/wp-content/themes/mytheme/Net_IDNA/Net/IDNA2.php'); $idna = Net_IDNA2::getInstance(); $replace = array( $url => $idna->decode($url) ); $text = str_replace(array_keys($replace), $replace, $text); return $text; } add_filter('the_content', 'convert_punycode');
あなたの回答
tips
プレビュー