admin管理员组

文章数量:1193316

I want to add custom settings to the editor, for which I am using the tiny_mce_before_init filter, as following:

function custom_tinymce_settings( $settings ) {
    
    $settings['link_class_list'] = "[
            {title: 'None', value: ''},
            {title: 'Dog', value: 'dog'},
            {title: 'Cat', value: 'cat'}
        ]";

    return $settings;

}

add_filter( 'tiny_mce_before_init', 'theme\act\custom_tinymce_settings' );

The added setting comes right from the Tiny docs for v4, see link_class_list.

But it's not adding the classes to the link dialog.

Any idea on what I am doing wrong?

I want to add custom settings to the editor, for which I am using the tiny_mce_before_init filter, as following:

function custom_tinymce_settings( $settings ) {
    
    $settings['link_class_list'] = "[
            {title: 'None', value: ''},
            {title: 'Dog', value: 'dog'},
            {title: 'Cat', value: 'cat'}
        ]";

    return $settings;

}

add_filter( 'tiny_mce_before_init', 'theme\act\custom_tinymce_settings' );

The added setting comes right from the Tiny docs for v4, see link_class_list.

But it's not adding the classes to the link dialog.

Any idea on what I am doing wrong?

Share Improve this question edited Aug 1, 2022 at 16:34 Tom J Nowell 60.8k7 gold badges77 silver badges147 bronze badges asked Aug 1, 2022 at 14:27 Álvaro FranzÁlvaro Franz 1,0901 gold badge9 silver badges31 bronze badges 1
  • 1 The WordPress editor does not use the TinyMCE link dialog. It has its own. – Jacob Peattie Commented Aug 1, 2022 at 14:48
Add a comment  | 

1 Answer 1

Reset to default 0

As Jacob mentioned in the comment, WordPress adds a custom plugin to TinyMCE which uses a native window with extra features, like loading content from WordPress.

The documentation I referenced is for the TinyMCE official link plugin.

You can still use it, all you have to do is replace the wplink plugin with the link plugin in the TinyMCE settings.

本文标签: tinymceAdd custom value for linkclasslist for the classic editor