• ABrotto

    (@amauri-brotto)


    Hello there,

    The exclusions by “add_filter(‘wpmeteor_exclude’…” does not work when the scripts are loaded by “add_action( ‘wp_enqueue_scripts’,…” as snippet bellow.

    Should the exclusions (by add_ filter or even by ‘setting>exclusions tab’) work for the scenario bellow?

    FUNCTIONS PHP

    add_action( 'wp_enqueue_scripts', 'my_js_functions' );
    function my_js_functions() {
    	wp_enqueue_script( 'custom-script01', get_stylesheet_directory_uri() . '/js/functiona.js');
    	wp_enqueue_script( 'custom-script01', get_stylesheet_directory_uri() . '/js/functionb.js');
    	wp_enqueue_script( 'custom-script01', get_stylesheet_directory_uri() . '/js/functionc.js');
    }
    
    add_filter('wpmeteor_exclude', function ($exclude, $content) {
        if (preg_match('/functionb\.js/', $content)) {
            return true;
        }
        return $exclude;
    }, null, 2);

    tks

The topic ‘Script exclusion with ‘wp_enqueue_scripts’’ is closed to new replies.