1

I'm developing a plugin that has its own templates to render the page. This includes header, content, footer, etc.

Therefore I have to dequeue every other style added by either theme or plugins, in order to keep the page clean. Right now I'm using this piece of code:

add_action( 'wp_enqueue_scripts', 'remove_all_styles', 1000 );
function remove_all_styles() {
    global $wp_styles;
    $wp_styles->queue = array();
}

It almost does what I want. This dequeues every CSS file, except the theme's rtl.css. I'm using the default Twenty Seventeen theme.

How can I achieve this?

1

RTL stylesheet is not loaded with wp_enqueue_style() so it wouldn't appear in global $wp_styles variable. Wordpress loads it with get_locale_stylesheet() function. You can remove loading locale scripts completely:

function abort_loading_rtl_stylesheet() {
    remove_action( 'wp_head', 'locale_stylesheet' );
}
add_action( 'init', 'abort_loading_rtl_stylesheet' );

or filter its output to load your custom rtl stylesheet:

function override_default_rtl_styles(){
    return 'path/to/custom/rtl.css';
}

add_filter( 'locale_stylesheet_uri', 'override_default_rtl_styles', 1000 );

I hope that's what you're looking for, cheers!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.