Hi Themeco,
Using a child theme, and have enqueued scripts excluding admin, using !is_admin
https://codex.wordpress.org/Function_Reference/is_admin
This works correctly and the scripts are included only the theme frontend, not on Wordpress admin.
However the scripts are still getting enqueued on all of the Pro builders (Header, Footer, Content, Global Block)
I’m using custom javascript to modify the scroll behaviour, this work correctly on the frontend theme. However, I do not want these javascript enqueued on any or Pro Builders as the modified scroll behaviour stops the builders from working. !is_admin works prefectly, however I cannot exclude the enqueue or dequeue load the scripts on the Pro Builders.
I tried using the url to exclude following https://kinsta.com/blog/disable-wordpress-plugins-loading/ using
Enqueue
function my_scripts() {
$request_uri = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
$is_pro = strpos( $request_uri, '/pro/' );
if ( ! is_admin() ) {
if ( $is_pro === false) {
wp_enqueue_script('my_bundle_js', get_stylesheet_directory_uri() . '/dist/js/my-bundle.js', null, X_VERSION, true);
}
}
}
add_action('wp_enqueue_scripts', 'my_scripts');
Dequeue
function my_dequeue_scripts_pro() {
$request_uri = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
$is_pro = strpos( $request_uri, '/pro/' );
if ( $is_pro !== false ) {
wp_dequeue_script( 'my_bundle_js' );
wp_deregister_script( 'my_bundle_js' );
}
}
add_action( 'wp_print_scripts', 'my_dequeue_scripts_pro', 100 );
However, because the Pro Content builder loads the page in a iframe this url method to exclude enqueue or dequeue scripts does not work.
What is the Pro equivalent of !is_admin or how can I exclude enqueue or dequeue scripts from all of the Pro Builders?