0

I'm building a plugin that loads iframes to display some content. I have specific scripts & styles for that content and would thus like to ignore the active theme when loading those templates; both to save loading time & to avoid CSS conflicts.

I know it is possible to dequeue all scripts & styles using the wp_enqueue_scripts and wp_enqueue_scripts hooks.

Thing is, as my plugin do also queue some scripts and styles, it would be cleaner to find a way to disable the current theme uphill rather than to quibble to unload some files and not others.

SO: is it possible to ignore / unload the current theme on certain pages / templates ?

Thanks

1 Answer 1

0

here is no specialized hook for this. However the hook switch_theme should work for you.

/**
 * Switches current theme to new template and stylesheet names.
 *
 * @since unknown
 * @uses do_action() Calls 'switch_theme' action on updated theme display name.
 *
 * @param string $template Template name
 * @param string $stylesheet Stylesheet name.
 */
function switch_theme($template, $stylesheet) {
    update_option('template', $template);
    update_option('stylesheet', $stylesheet);
    delete_option('current_theme');
    $theme = get_current_theme();
    do_action('switch_theme', $theme);
}

So you should write custom function that deactivate the theme via hook and activate back, if your done with your task.

add_action('switch_theme', function($theme){
    if ( 'Your_Theme_Name' == $theme )
    {
        // do something.
    }

    // do others.

    return;
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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