問題の概要
WPMLでWP Configurator Proを使用すると、以下の問題が発生する可能性があります。コンフィギュレーターにリンクされた翻訳済みのWooCommerce商品において、コンフィギュレーターのタイトルが商品のタイトルを置き換え、コンフィギュレーターの説明が英語のままになり、PDFのテキストが翻訳できなくなります。
回避策
子テーマのfunctions.phpファイルに以下のコードを追加します。
PHP
add_filter( 'the_title', function ( $title, $id = 0 ) {
if ( ( is_admin() && ! wp_doing_ajax() ) || ! $id || 'product' !== get_post_type( $id ) ) {
return $title;
}
$post = get_post( $id );
return $post ? $post->post_title : $title;
}, 11, 2 );
add_filter( 'do_shortcode_tag', function ( $out, $tag, $attr ) {
if ( 'wpc_config_description' !== $tag || empty( $attr['id'] ) ) {
return $out;
}
$id = absint( $attr['id'] );
return wp_kses_post( apply_filters( 'wpc_single_product_description', get_post_meta( $id, '_wpc_description', true ), $id ) );
}, 10, 3 );WPML設定に移動し、カスタム XML 設定に以下を追加します。
XML
<wpml-config>
<admin-texts>
<key name="wpc_pdf_document_heading" />
<key name="wpc_pdf_download_btn_text" />
</admin-texts>
</wpml-config>その後、WPML文字列翻訳でテキストを翻訳します。