Enable Winden with conditions

Marko Krstić
25 Jul 2022

In scenario where you have existing website and want to partially rebuild it and migrate to tailwind we are offering option to enable Winden only selected pages, post types, taxonomies or what ever you desire.

<?php
    /**
    * Call CDN in Particular page.
    */
    function dp_call_winden(){                
        if (is_page(['blog', 'about-us', 'contact-us']) || if_front_page() ) {
            add_action('wp_footer', 'dp_footer_cdn');
        }
    }
    function dp_footer_cdn(){
        $winden_instance = apply_filters('f!Wakaloka\\Winden::get_instance', null);
        $winden_instance->runtime->enqueue_cdn(); // print / echo the cdn
    }
    add_action('template_redirect', 'dp_call_winden');

    /**
    * Disable auto CDN load.
    */
    function dp_init()
    {
        if (!is_admin()) {
            add_filter('f!Wakaloka\\Winden\\Core\\Runtime::is_inside_builder', fn($is) => true, 5);
        }
    }
    add_action('init', 'dp_init', 5);

?>

Replace WP Condition on line 6 with your own condition.

The easier way is to use Scripts Organizer
to add this code snippet.

How to write conditions?

Use WordPress native conditions that are available on WP Codex conditional tags.

https://codex.wordpress.org/Conditional_Tags

Conditionally disable Oxygen Builder CSS

If you are using Oxygen and want de disable Oxygen CSS on those pages where Winden is enabled you can use another code snippet

Disable Oxygen Builder completely and use theme or builders such as Bricks

In case if you are migrating completely from Oxygen and want to use Gutenberg of Bricks you can use plugin Freesoul Deactivate Plugins – Plugin manager and cleanup to disable oxygen per page

Was this article helpful?

Tags

Categories

Never miss new post again

Subscribe and get list of new posts in your inbox

Click to Copy