WPML
ステータス
未解決
報告対象
Advanced Custom Fields Multilingual 2.1.3
関連するプラグイン/テーマ
Advanced Custom Fields (ACF)
トピックタグ
Compatibility

問題の概要

ラジオボタンの選択肢を持つAdvanced Custom Fields (ACF)ギャラリーブロックを含むページを翻訳する際、これらのラジオボタンの選択肢が高度な翻訳エディタ(ATE)に予期せず表示されます。

回避策

続行する前に、サイトの完全なバックアップを取得していることを確認してください。


  • テーマのfunctions.phpファイルを開きます。

  • 次のコードを追加します。
    // WPML Workaround for compsupp-7404
    add_filter( 'wpml_found_strings_in_block', function( array $strings, WP_Block_Parser_Block $block ) {
    
    	$isInBlacklistedStrings = function( string $fieldName ) {
    		
    		// Add the fields to ignore here
    		$fieldsToIgnore = [];
    		$fieldsToIgnore[] = 'gallery_section_type';
    		$fieldsToIgnore[] = 'gallery_section_variant';
    
    		if ( in_array($fieldName, $fieldsToIgnore) ) {
    			return true;
    		}
    
    		return false;
        };
    
    	if ( $block->blockName == 'acf/gallery' ) {
    		foreach( $block->attrs['data'] as $fieldName => $string ) {
    			if ( $isInBlacklistedStrings( $fieldName ) ) {
    				unset( $block->attrs['data'][ $fieldName ] );
    			}
    		}
    	}
    
        return $strings;
    }, 9, 2 ); // Lower priority than 10.

すべての既知の問題 →