What I mean by Dynamic Editor Style is adding CSS style based on user setting/option. For example you have a font option via the customizer where user can select font to use or maybe link color option like my previous tutorial about color option in customizer. What is Editor Style? For you who don’t know, Editor Style is a theme feature in WordPress where we can style the “Visual Editor” so it will look similar with the front-end. As you can see, it uses a CSS file in a theme. So, we can’t change the content of that stylesheet file dynamically. But with a little Ajax, we can do that. Another way to add Editor Style WordPress have filter. I explained about it long time ago in this tutorial: Add Editor Style from Plugin. But instead of linking to a real CSS file, we use “fake” CSS file via Ajax Callback Function. /* Add Editor Style */ add_filter( 'mce_css', 'my_dynamic_link_color_mce_css' ); /**  * Add Link Color Option in Editor Style (MCE CSS)  * @since 1.1.0  */ function my_dynamic_link_color_mce_css( $mce_css ){     $mce_css .= ', ' . add_query_arg( array( 'action' => 'my_color_mce_css', '_nonce' => wp_create_nonce( 'my-color-mce-nonce', __FILE__ ) ), admin_url( 'admin-ajax.php'
Share This