Created
November 3, 2016 18:35
-
-
Save mathetos/532b45c10ebf3dd24bd86b2756ed90cd to your computer and use it in GitHub Desktop.
Dequeue Maps Builder JS except certain pages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Dequeue GMB script for certain pages | |
* | |
* Hooked to the wp_print_scripts action, with a late priority (100), | |
* so that it is after the script was enqueued. | |
*/ | |
function gmb_dequeue_script() { | |
global $post; | |
wp_deregister_script( 'google-maps-builder-gmaps' ); | |
wp_dequeue_script( 'google-maps-builder-gmaps' ); | |
$posts = array(754, 586); | |
if ( in_array($form_id, $posts) ) { | |
wp_register_script( 'google-maps-builder-gmaps' ); | |
wp_enqueue_script( 'google-maps-builder-gmaps' ); | |
} | |
} | |
add_action( 'wp_print_scripts', 'gmb_dequeue_script', 100 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tried using this but "$form_id" isn't referenced anywhere and throws an error. It then also didn't like the way the "wp_register_script() was being used saying missing 2nd argument.