;

しんみゆ.com

群馬県高崎市在住の夫婦で日記というか、つぶやきブログしてます:しんみゆ.com

【仕事メモ】wordpress:contactform7で入力された半角カナを全角に

function.phpに下記を記載すると、contactform7で入力された半角カナを全角になるはず!というメモ。

function my_content_filter($content) {
$filter_table = array(
‘㈱’ => ‘(株)’, ‘㈲’ => ‘(有)’, ‘㈹’ => ‘(代)’, ‘℡’ => ‘TEL’, ‘№’ => ‘No.’,
‘①’ => ‘(1)’, ‘②’ => ‘(2)’, ‘③’ => ‘(3)’, ‘④’ => ‘(4)’, ‘⑤’ => ‘(5)’,
‘⑥’ => ‘(6)’, ‘⑦’ => ‘(7)’, ‘⑧’ => ‘(8)’, ‘⑨’ => ‘(9)’, ‘⑩’ => ‘(10)’,
‘Ⅰ’ => ‘I’, ‘Ⅱ’ => ‘II’, ‘Ⅲ’ => ‘III’, ‘Ⅳ’ => ‘IV’, ‘Ⅴ’ => ‘V’,
‘Ⅵ’ => ‘VI’, ‘Ⅶ’ => ‘VII’, ‘Ⅷ’ => ‘VIII’, ‘Ⅸ’ => ‘IX’, ‘Ⅹ’ => ‘X’,
‘㎜’ => ‘mm’, ‘㎝’ => ‘cm’, ‘㎞’ => ‘km’, ‘㎎’ => ‘mg’, ‘㎏’ => ‘kg’, ‘㏄’ => ‘cc’, ‘㎡’ => ‘m2’,
‘㍻’ => ‘平成’, ‘㍼’ => ‘昭和’, ‘㍽’ => ‘大正’, ‘㍾’ => ‘明治’,
);
$content = mb_convert_kana($content, "KV", ‘UTF-8’);
$content = str_replace(array_keys($filter_table), array_values($filter_table), $content);
return $content;
}
add_filter(‘wpcf7_mail_tag_replaced’, my_content_filter, 9);

%d人のブロガーが「いいね」をつけました。

ページトップ