Navigation überspringen

Open

Reported for: Advanced Custom Fields Multilingual 2.1.3

Topic Tags: Compatibility

Overview of the issue

When translating pages that include an Advanced Custom Fields (ACF) Gallery block with radio button selections, these radio choices are unexpectedly appearing in the Advanced Translation Editor (ATE).

Workaround

Please, make sure of having a full site backup of your site before proceeding.

  • Open your theme’s functions.php file.
  • Add the following code:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    // 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.

Hinterlassen Sie eine Antwort

Bitte bleiben Sie beim Thema und respektieren Sie andere. Wenn Sie Hilfe bei Problemen benötigen, die nicht mit diesem Beitrag zusammenhängen, nutzen Sie unser Support-Forum, um einen Chat zu starten oder ein Ticket zu erstellen.

Sie können diese Tags verwenden:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>