WordPress.org

Make WordPress Core

Opened 4 weeks ago

#44172 new defect (bug)

TinyMCE style_formats broken for `a` tags

Reported by: Horttcore Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.9.6
Component: Editor Keywords:
Focuses: Cc:

Description

It seems that the link inserter breaks the TinyMCE style formats. P-tag is working, the link-tag not.

<?php
// Custom styles
add_filter( 'mce_buttons_2', function( $buttons ){
    array_unshift( $buttons, 'styleselect' );
    return $buttons;
} );
add_filter( 'tiny_mce_before_init', function($init_array){
    $style_formats = [
        // These are the custom styles
        [
            'title' => 'Button',
            'inline' => 'a',
            'classes' => 'btn',
        ],
        [
            'title' => 'P',
            'block' => 'p',
            'classes' => 'largerp',
        ],
    ];
    // Insert the array, JSON ENCODED, into 'style_formats'
    $init_array['style_formats'] = json_encode( $style_formats );
    return $init_array;
} );

Change History (0)

Note: See TracTickets for help on using tickets.