Hi,
I’m trying to find a way to enqueue ACSS generated CSS file to load into the editor.
Tried using this code snippet but not working
$c_url = get_site_url();
wp_enqueue_style(
“automatic-framework”,
$c_url . “/wp-content/uploads/automatic-css/automatic.css”
);
Any ideas how to make ACSS classes and variables available in the editor?
Thank you.
1 Like
Louis
2
Hello @beleancristian,
You’ll want to use the add_editor_style()
function with the after_setup_theme
action.
sunny
3
I’m not using the Cwicly theme so this might be different, and I can only hack together PHP at best, but you can try something like:
<?php
$acss_stylesheet = "/wp-content/uploads/automatic-css/automatic.css";
add_theme_support( 'editor-styles' );
add_editor_style( get_site_url() . $acss_stylesheet . '?v=' . filemtime( get_home_path() . $acss_stylesheet ) );
The filemtime() will help with busting the cache
Without it, you could simply do:
<?php
add_theme_support( 'editor-styles' );
add_editor_style( get_site_url() . '/wp-content/uploads/automatic-css/automatic.css');
3 Likes
Great stuff @sunny and @Louis. It worked, thank you!
2 Likes
Hi,
Worked using the 1st code provided! Appreciate the code supplier…
1 Like