Make WordPress Core

Opened 7 years ago

Closed 5 years ago

#44172 closed defect (bug) (worksforme)

TinyMCE style_formats broken for `a` tags

Reported by: horttcore's profile Horttcore Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.9.6
Component: TinyMCE Keywords: reporter-feedback
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 (3)

#1 @pento
5 years ago

  • Component changed from Editor to TinyMCE

#2 @azaozz
5 years ago

Some more details would be helpful.

Trying to reproduce, TinyMCE inserts an <a> tag with no href when using "Button" from the Formats drop-down. That seems to be the expected behaviour.

#3 @desrosj
5 years ago

  • Keywords reporter-feedback added
  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

I am also seeing the behavior that @azaozz describes above. I am going to close this out due to lack of reporter feedback. @Horttcore if you are still able to reproduce, please reopen with more details.

Note: See TracTickets for help on using tickets.