$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>tinymce - Load WordPress Editor .css on Front End|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

tinymce - Load WordPress Editor .css on Front End

matteradmin9PV0评论

This issues seems to have cropped up for me after a recent WordPress udpate (I'm on 4.9.9) as I haven't had issues before.

I load wp_editor on the front end using the following code:

     $argswp = array(
    'textarea_rows' => 10,
    'teeny' => false,
    'quicktags' => false,
    'wpautop' => true,
    'media_buttons' => false,
    'tinymce' => array(
        'theme_advanced_buttons1' => 'custom1',
      ),
);
wp_editor( 'Write your content here...', 'postContent', $argswp ); ?> 

I am now having issues that when a regular non-admin user logs in and sees this editor, some buttons don't show and others don't work. For example, selecting insert/edit link causes the page to scroll down but nothing happens, the "pop-up" box that usually appears doesn't work.

After going through all the network requests (once as admin and once as regular user) I can see that regular users are not getting the following .css file:

/wp-includes/css/editor.min.css?ver=4.9.9

So I tried two things, I first tried to register and enqueue it in my php functions file and then I tried to add it directly to the html of the page as an external stylesheet link. This is the result for both:

The button is now working but they don't seem to be loading correctly now. Help is appreciated!

This issues seems to have cropped up for me after a recent WordPress udpate (I'm on 4.9.9) as I haven't had issues before.

I load wp_editor on the front end using the following code:

     $argswp = array(
    'textarea_rows' => 10,
    'teeny' => false,
    'quicktags' => false,
    'wpautop' => true,
    'media_buttons' => false,
    'tinymce' => array(
        'theme_advanced_buttons1' => 'custom1',
      ),
);
wp_editor( 'Write your content here...', 'postContent', $argswp ); ?> 

I am now having issues that when a regular non-admin user logs in and sees this editor, some buttons don't show and others don't work. For example, selecting insert/edit link causes the page to scroll down but nothing happens, the "pop-up" box that usually appears doesn't work.

After going through all the network requests (once as admin and once as regular user) I can see that regular users are not getting the following .css file:

/wp-includes/css/editor.min.css?ver=4.9.9

So I tried two things, I first tried to register and enqueue it in my php functions file and then I tried to add it directly to the html of the page as an external stylesheet link. This is the result for both:

The button is now working but they don't seem to be loading correctly now. Help is appreciated!

Share Improve this question asked Feb 26, 2019 at 8:33 GenesisBitsGenesisBits 1477 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Fixed it! Although I still don't know why I have to now enqueue the specific stylesheet when I didn't before. If anyone knows why I'd definitely appreciate it.

But for now, my answer:

I had previously added in this code which was a bad idea. For some reason I didn't those specific icons were being used:

// remove dashicons as they don't need to be loaded on the front-end and are using 1400ms in render blocking
function wpdocs_dequeue_dashicon() {
    if (current_user_can( 'edit_published_posts' )) {
        return;
    }
    wp_deregister_style('dashicons');
}
add_action( 'wp_enqueue_scripts', 'wpdocs_dequeue_dashicon' ); 

Removing that fixed the icon issue.

And then I had to register and enqueue the style:

wp_register_style( 'tinymce_stylesheet', 'https://example/wp-includes/css/editor.min.css?ver=4.9.9' );

//Editor Stylesheet for Deck Submit
function editor_send_deck() {
    // only enqueue on specific page slug
    if ( is_page( 'front-end' ) ) {
        wp_enqueue_style( 'tinymce_stylesheet' );
    }
}
add_action( 'wp_enqueue_scripts', 'editor_send_deck' );
Post a comment

comment list (0)

  1. No comments so far