Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

With WordPress 3.9 coming soon it's bringing along TinyMCE 4.0. I'm running my plugins and functions through some testing and found that one of my functions seems broken / not working with the new tinyMCE

function myformatTinyMCE( $in )
{
    $in['theme_advanced_buttons1'] = 'bold';
    $in['theme_advanced_buttons2'] = 'formatselect';
    $in['wordpress_adv_hidden'] = false;
    return $in; 
}
add_filter( 'tiny_mce_before_init', 'myformatTinyMCE' );

The above function used to limit the buttons in the tinyMCE to specific buttons, I've simplified it a bit to make it easier for testing. If I print out $in it shows the correct values in the correct spots, but when I actually load up a page it just defaults to the normal buttons.

I've also tried to use the example in the TinyMCE Codex which also didn't seem to have any effect.

I'm using the WordPress Beta Tester Plugin and I do have TinyMCE Advanced installed but disabled.

With the new TinyMCE how can I continue using / customizing, and are there any 'Gotchas' that have changed from the previous TinyMCE Version?

EDIT

Looks like $in['wordpress_adv_hidden'] = false; is not longer being used - No idea how to unhide the Kitchen Sink.

share|improve this question

2 Answers 2

up vote 5 down vote accepted
+200

The strings was new, not more for your requirements.

This is the new content of the hook.

array (
  'selector' => '#content',
  'resize' => 'vertical',
  'menubar' => false,
  'wpautop' => true,
  'indent' => false,
  'toolbar1' => 'template,|,bold,italic,strikethrough,bullist,numlist,blockquote,hr,alignleft,aligncenter,alignright,link,unlink,wp_more,spellchecker,wp_fullscreen,wp_adv',
  'toolbar2' => 'formatselect,underline,alignjustify,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help',
  'toolbar3' => '',
  'toolbar4' => '',
  'tabfocus_elements' => 'insert-media-button,save-post',
  'body_class' => 'content post-type-post post-status-draft post-format-standard',
)

Also change the strings inside the array in your source to:

function myformatTinyMCE( $in ) {

    $in['toolbar1'] = 'bold';
    $in['toolbar2'] = 'formatselect';

    return $in; 
}
add_filter( 'tiny_mce_before_init', 'myformatTinyMCE' );

But see also this test plugin Gist 9758082 and this thread for WP 3.9 and the new TinyMCE 4.0 to understand the topic.

Forcing Toolbar2

To show always the toolbar 2, without use the button wp_adv add the follow source to a plugin.

add_action( 'plugins_loaded', 'fb_force_show_toolbar2' );
function fb_force_show_toolbar2() {
    set_user_setting( 'hidetb', 1 );
}

BUT, now the hint for the value wordpress_adv_hidden. In the next WordPress version, after 3.9 will restore the old hook wordpress_adv_hidden to toggle the toolbar, see ticket 27963. Then is possible to to use the follow source. $in['wordpress_adv_hidden'] = FALSE;

add_filter( 'tiny_mce_before_init', 'myformatTinyMCE' );
function myformatTinyMCE( $in ) {

    $in['wordpress_adv_hidden'] = FALSE;

    return $in; 
}
share|improve this answer
    
So there's no unhiding the "kitchen sink" (toolbar2)? –  Howdy_McGee Apr 17 at 15:09
    
What is the Kitchen sink? –  bueltge Apr 18 at 18:24
    
Toolbar2, wp_adv - show toolbar1 and toolbar 2 by default. You used to be able to do this by $in['wordpress_adv_hidden'] = false; which no longer works. –  Howdy_McGee Apr 18 at 18:26
    
Ah, ok. Now I have add the source to my answer to forcing the toolbar2. –  bueltge Apr 19 at 8:22
1  
@Howdy_McGee I just read in Make WordPress Core that the kitchen sink parameter should be coming back in 3.9.1 very soon. –  helgatheviking Apr 24 at 7:53

One change is that:

theme_advanced_buttons1 is going to be changed to:

toolbar1 which allows you to update the buttons so my new function will look something like:

function myformatTinyMCE( $in ) {
    $in['toolbar1'] = 'bold';
    $in['toolbar2'] = 'formatselect';
    return $in; 
}
add_filter( 'tiny_mce_before_init', 'myformatTinyMCE' );

Also it looks like formatselect is not really favored as much in this iteration. Should probably be converting over to styleselect as it allows more options and customizations (such as nested styles) and also goes with a more minimalist design.

Another gotcha is alignment options have been changed from justify to align like so: alignleft, aligncenter, alignright, alignjustify.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.