Support

Account

Home Forums Backend Issues (wp-admin) Avoiding admin editors tags strip

Solved

Avoiding admin editors tags strip

  • For stopping removing <p> tags inside WordPress TinyMCE (classic) editor (during switch Visual and Text editor’s tabs),

    I add to ${THEME_FOLDER}/functions.php:

    remove_filter( ‘the_content’, ‘wpautop’ );
    remove_filter( ‘the_excerpt’, ‘wpautop’ );
    remove_filter( ‘term_decription’, ‘wpautop’ );

    function config_tinymce( $config ) {
    $config[‘wpautop’] = false;
    return $config;
    }
    add_filter( ‘tiny_mce_before_init’, ‘config_tinymce’, 10 );

    But this doesn’t work for ACF’s fields editors.

    Help, please? Thanks!

  • For stopping removing <p> tags inside WordPress TinyMCE (classic) editor (during switch Visual and Text editor’s tabs),

    I add to ${THEME_FOLDER}/functions.php:

    remove_filter( ‘the_content’, ‘wpautop’ );
    remove_filter( ‘the_excerpt’, ‘wpautop’ );
    remove_filter( ‘term_decription’, ‘wpautop’ );

    function config_tinymce( $config ) {
    $config[‘wpautop’] = false;
    return $config;
    }
    add_filter( ‘tiny_mce_before_init’, ‘config_tinymce’, 10 );

    But this doesn’t work for ACF’s fields editors.

    Help, please? Thanks!

    ———————

    Spoiler:

    function acf_wysiwyg_remove_wpautop() {
    remove_filter( ‘acf_the_content’, ‘wpautop’ );
    }
    add_action( ‘acf/init’, ‘acf_wysiwyg_remove_wpautop’);

    with

    remove_filter( ‘acf_the_content’, ‘wpautop’ );

    don’t work.

    I think, we need something like (analogue of)

    function config_tinymce( $config ) {
    $config[‘wpautop’] = false;
    return $config;
    }
    add_filter( ‘tiny_mce_before_init’, ‘config_tinymce’, 10 );

  • Can anybody help? Support doesn’t reply, too.

  • Hi @kuraga

    Thanks for the email,
    Elliot here – ACF dev​​​.

    The PHP filters “the_content”, “the_excerpt” and “term_decription” are run during the output of these values in the theme front-end. They are PHP filters, which won’t affect the WYSIWG field.

    The WYSIWYG field uses a similar, but unique filter, named “acf_the_content”. Using this filter will allow you to customize the WYSIWYG output in your theme.

    The “tiny_mce_before_init” filter is used to cusotmize the tinymce settings. These will affect how the editor saves the value into the DB. In theory, ACF should inherit these settings, but to be extra sure, please checkout the ACF JS filter: https://www.advancedcustomfields.com/resources/javascript-api/#filters-wysiwyg_tinymce_settings

    Hope this helps.

    Cheers
    Elliot

  • Eliot,

    thanks about acf_the_content!

    About TinyMCE: fixed after I’ve added as admin script:

    acf.add_filter(‘wysiwyg_tinymce_settings’, function( mceInit, id, field ){
    // is true before
    mceInit[‘wpautop’] = false;

    return mceInit;
    });

    Thanks!

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Avoiding admin editors tags strip’ is closed to new replies.