TinyMCE Advanced
Error PHP 5.4 (10 posts)

  1. gatocristiano
    Posted 1 year ago #

    I am receiving this error, maybe my hosting updated PHP to 5.4 recently...

    Warning: Illegal string offset 'menubar' in /home4/carlosco/public_html/bajardepeso/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 383


  2. Andrew Ozz
    WordPress Dev
    Plugin Author

    Posted 1 year ago #

    This error suggests that something is using the 'tiny_mce_before_init' filter improperly. It passes an array, but the error is about it being a string.

    If you can debug further, could you add a var_dump( $init ); on the first line in Tinymce_Advanced::mce_options().

  3. Hi Andrew,
    I also had some trouble with this in my plugin.
    I think it may have been related to PHP 5.4 as well.

    I ended up adding an if/else check to first see if the array elements were empty or not.

    $myMenubar = 'link unlink';
    if( empty($init['menubar']) || $init['menubar'] === '') {
        $init['menubar'] = $myMenubar;
    } else {
        $init['menubar'] = $init['menubar'].' '.$myMenubar;

    I'm not saying this will work in every case, but I'm 99.98% sure it's working for me.

    It can get a little tricky when working with arrays (you have to know what's going "in", to know how to add your customizations).

  4. Andrew Ozz
    WordPress Dev
    Plugin Author

    Posted 1 year ago #

    @Josh yeah, that makes sense when you're appending some settings. You need to check whether the array element is already set.

    However in my case it just sets or overrides the previous value:

    function mce_options( $init ) {
      if ( ... ) {
        $init['menubar'] = true;
      return $init;

    As far as I see the only way that would throw the above warning is if $init is a string. However that should never happen as it uses the 'tiny_mce_before_init' filter that always passes an array...

    I can probably add:

    if( ! is_array( $init ) ) {
      $init = array();

    But that will silence the underlying problem which is the improper use of the 'tiny_mce_before_init' filter.

  5. I just tested this in my dev site:
    1. WP trunk
    2. PHP 5.5.9
    3. All WP-debug set to true
    4. No other plugins
    5. Default 2014 theme

    I could not get any error notice. However, I did note when I added the menubar option; while it did display correctly; I was unable to un-check the option and remove the menubar.

    Basically, once I enabled the option, the menubar stayed there until I deactivated the plugin.

    Your code is like super-freaking optimized (that's a good thing); still one or two pay-grades above mine ;)

    But I don't think the #init['menubar'] will accept a parameter of true? I think it either has to be false (disabled) or a string of the layout you would like to use; for example "tools table format view insert edit".

    Taken from here:

    Could the parameter of true be what's causing the erratic behavior where the menubar can't removed?

  6. Andrew Ozz
    WordPress Dev
    Plugin Author

    Posted 1 year ago #

    @Josh it's a bit more complicated. The menubar setting is used in three places: https://github.com/tinymce/tinymce/blob/master/js/tinymce/themes/modern/theme.js#L279 https://github.com/tinymce/tinymce/blob/master/js/tinymce/themes/modern/theme.js#L427 and https://github.com/tinymce/tinymce/blob/master/js/tinymce/themes/modern/theme.js#L503.

    The first gets the actual menu items if it is a string, the other two just check if it is not false. So setting it to true would use the default menu items and enable it.

    I was unable to un-check the option and remove the menubar.

    Hmm, that's weird. It is a simple checkbox. If you get the time can you add var_dump( $_POST ); at the top and see what's being submitted when saving the settings. It should be in that array when checked and not in the array when unchecked.

  7. You're right :) That makes sense. Thank you for the explanation Andrew. I really appreciate you taking the time to put those links together to show me.

    Of course I'll check the var_dump. Be back shortly.

  8. You're good, Andrew. It must have been something in my cache. I'm going to make a 'cache-buster' for development purposes in TiynMCE :)

    To clarify (since I took the thread off topic slightly)... I cannot seem to replicate any error notices using PHP 5.5.9 on localhost.

    If the OP would like to provide steps to replicate receiving the warning, I'll be happy to dig further.

    Thank you for all your help. It's working fine.

  9. badboymark
    Posted 9 months ago #

    Andrew, I've had the same issue with the tinymce-advanced plugin because my hosting service has done the same thing with the PHP setting.
    My PHP setting is 5.4 here and I get the same error from it. If there is a way to correct this in the WP dashboard in the editing error, how I do this? The plugin is currently deactivated because of this issue. Could you or someone please tell me how to fix this issue? Because the hosting provider PHP setting in the server is PHP 5.4 and that is what is causing the issue as previously mentioned above and in the previous post to this thread. Please respond soon. P.S If you did fix this problem, how did you do it as I would like to know? Please fill me in tell me if there is anything I need to do from my end.

  10. badboymark
    Posted 9 months ago #

    Josh, Thank You as well also.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • TinyMCE Advanced
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.