これをやったが、適応って文字とか他にも使われている文字も変更になるので、
翻訳を変更するので対応。
親クラスを指定できれば良いのだが、。
//管理画面の商品画像部分の文字変更
//変更内容
// 大文字と小文字を区別する場合は「str_replace」を使用する
function po_file_text_change_hook_script( $translated ) {
//$translated = str_ireplace('投稿一覧', '作成済み記事一覧', $translated);//大文字小文字区別なし
$translated = str_replace('ファイル', '選択中', $translated);//大文字小文字区別
return $translated;
}
//定義 admin.php(プラグイン拡張ぺーじ)のみ定義する
if( is_admin() ){
global $pagenow;
$request_uri = $_SERVER['REQUEST_URI'];
if( $pagenow == 'admin.php' ){
// 管理画面内にある文言のみ置換するため
if( strpos($request_uri,'page=usces_itemedit') !== false ){
add_filter('gettext', 'po_file_text_change_hook_script');
add_filter('gettext_with_context', 'po_file_text_change_hook_script');
add_filter('ngettext', 'po_file_text_change_hook_script');
add_filter('ngettext_with_context', 'po_file_text_change_hook_script');
}
}
}
参考
// 管理画面内にある文言のみ置換するための条件分岐を追加する
if ( is_admin() ) {
add_filter('gettext', 'po_file_text_change_hook_script');
add_filter('gettext_with_context', 'po_file_text_change_hook_script');
add_filter('ngettext', 'po_file_text_change_hook_script');
add_filter('ngettext_with_context', 'po_file_text_change_hook_script');
}
// 大文字と小文字を区別する場合は「str_replace」を使用する
function po_file_text_change_hook_script( $translated ) {
$translated = str_ireplace('投稿一覧', '作成済み記事一覧', $translated);
$translated = str_replace('MenuTest', 'メニューテスト', $translated);
$translated = str_ireplace('メニューを閉じる', 'アイコンのみ表示', $translated);
return $translated;
}
https://lunaris-code.com/web/1253/
https://tech.ayataka.blog/?p=325
if( is_admin() ){
global $pagenow;
$request_uri = $_SERVER['REQUEST_URI'];
//カテゴリ・タグ編集ページ
if( $pagenow == 'edit-tags.php' ){
//カテゴリーの処理
if( strpos($request_uri,'taxonomy=category') !== false ){
}
//タグの処理
if( strpos($request_uri,'taxonomy=post_tag') !== false ){
}
}
}