Skip Navigation

[Resolved] WordPress 5.3 & Frontend Editor

This thread is resolved. Here is a description of the problem and solution.

Problem: After updating WordPress I'm not able to see any of my custom styles applied in a WYSIWYG field editor in one of my edit post Forms.

Solution: Add the following custom code to enqueue the stylesheet:

function plugin_mce_css( $mce_css ) {
  if ( ! empty( $mce_css ) )
    $mce_css .= ',';
 
  $mce_css .= get_stylesheet_directory_uri() . '/editor-style.css';
 
  return $mce_css;
}
add_filter( 'mce_css', 'plugin_mce_css' );

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

This support ticket is created 5 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 4 replies, has 2 voices.

Last updated by mikeH-3 5 years, 2 months ago.

Assisted by: Christian Cox.

Author
Posts
#1382395

I just upgraded to wordpress 5.3 and now the classic wysiwyg editor in the frontend (I am using it to edit pages on the frontend) does not load in any styles from my style.css or editor-style.css file I have. So all the text in the editor is unstyled. This always worked until I upgraded. I deactivated every other plugin in my site and it still did not work. I am just using my bare bones theme I made, that always worked. Can you replicate this?

#1382405

Hi, can you tell me more about the classic wysiwyg editor in the front-end? Are you talking about the editor in a Toolset Form that edits a post content, or a custom field WYSIWYG? Or is there another front-end editor you are referring to? It would be helpful if you can show me a full-screen screenshot of the editor so I can see what you're describing.

Also, can you tell me what version of WordPress you were using before the update? Was it < 5?

Thank you!

#1382565

This is the WYSIWYG field I added and put it into a CRED FORM in the frontend.

I was using 5.2.4 or whatever the last one was before 5.3.

The wysiwyg get editor works fine in the backend but not in the front, with styles.

#1382585

I'm testing locally in 5.2.4, and trying to enqueue styles for the editors with this code:

add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
  $parent_style = 'twentynineteen-style';
  wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
  wp_enqueue_style( 'child-style',
    get_stylesheet_directory_uri() . '/style.css',
    array( $parent_style ),
    wp_get_theme()->get('Version')
  );
  wp_enqueue_style( 'tssupp-wysiwyg-field-style',
    get_stylesheet_directory_uri() . '/editor-style.css',
    array( $parent_style ),
    wp_get_theme()->get('Version')
  );
}
function my_theme_add_editor_styles() {
  add_editor_style( 'editor-style.css' );
}
add_action( 'admin_init', 'my_theme_add_editor_styles' );

Works fine in the backend, but neither style.css nor editor-style.css are applied in the tiny MCE editors on the front-end. In my experience, style.css and editor-style.css are not applied to the tiny MCE editor on the front-end of the site unless you do something like this:

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

  $mce_css .= get_stylesheet_directory_uri() . '/editor-style.css';

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

...but there may be multiple ways to do this I'm not aware of. If you have another experience I'll be glad to make a clone of your site, downgrade to 5.2.4, and see if I can replicate the issue. Let me know how you would like to proceed.

#1382627

Yes I replaced my code with that code and it now works again. Thanks much!