Matija Mrkaic
Matija Mrkaic

Reputation: 1933

TinyMCE hook breaks Wordpress media preview in editor

I am extending WP editor with custom button. Problem happens when I use this hook:

add_filter( 'mce_css', 'mytheme_icon_picker' );

This is used to enqueue custom scripts and styles. Even the empty function leads to media player not being displayed/styled in editor. This leads me to believe that hooking to mce_css, breaks WP enqueueing media-player assets.

Does anyone know what hook to use, to correctly include custom files without breaking default behavior?

Upvotes: 0

Views: 144

Answers (1)

Nathan Dawson
Nathan Dawson

Reputation: 19308

The code you're using is a filter. It must return a value.

http://codex.wordpress.org/Plugin_API/Filter_Reference/mce_css

Your function should append the CSS URL to the existing list of CSS files.

function wpse_icon_picker( $mce_css ) {
    if ( ! empty( $mce_css ) ) {
        $mce_css .= ',';
    }

    $mce_css .= 'enter URL to CSS here';

    return $mce_css;
}
add_filter( 'mce_css', 'wpse_icon_picker' );

Upvotes: 1

Related Questions