WPML
Status
Offen
Gemeldet für
Advanced Custom Fields Multilingual 2.1.3
Zugehöriges Plugin/Theme
Advanced Custom Fields (ACF)
Themen-Tags
Compatibility

Übersicht über das Problem

Beim Übersetzen von Seiten, die einen Advanced Custom Fields (ACF) Galerie-Block mit Radiobutton-Auswahlen enthalten, erscheinen diese Radio-Optionen unerwartet im Erweiterten Übersetzungs-Editor (ATE).

Problemumgehung

Bitte stellen Sie sicher, dass Sie ein vollständiges Backup Ihrer Website erstellt haben, bevor Sie fortfahren.


  • Öffnen Sie die Datei functions.php Ihres Themes.

  • Fügen Sie den folgenden Code hinzu:
    // 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.

Alle bekannten Probleme →