Skip to content

Instantly share code, notes, and snippets.

@Bowriverstudio
Created October 22, 2018 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Bowriverstudio/ad559aab2fda28bc9e47ce3a66b1e2a4 to your computer and use it in GitHub Desktop.
Save Bowriverstudio/ad559aab2fda28bc9e47ce3a66b1e2a4 to your computer and use it in GitHub Desktop.
Remove scripts and styles from bookly on pages not using the shortcode
/**
* Removes the scripts regestered for the plugin bookly except on the page bookly shortcode is rendered on.
*
* @author bowriverstudio.com
* @see bowriverstudio.com/2018/10/15/adding-plugin-bookly-to-site/
* @see https://www.booking-wp-plugin.com/
* @todo You will have to modify the code "PAGE_SLUG" to your page ie: book-free-consolation
* @version 15.1 (Based on bookly's version)
*/
function brs_deregister_bookly_scripts(){
if (!is_page('PAGE_SLUG')):
wp_deregister_script( 'bookly-spin' );
wp_deregister_script( 'bookly-ladda' );
wp_deregister_script( 'bookly-hammer' );
wp_deregister_script( 'bookly-jq-hammer' );
wp_deregister_script( 'bookly-picker' );
wp_deregister_script( 'bookly-picker-date ' );
wp_deregister_script( 'bookly-intlTelInput' );
wp_deregister_script( 'bookly' );
wp_deregister_script( 'bookly-customer-profile' );
endif;
}
add_action( 'wp_print_scripts', 'brs_deregister_bookly_scripts', 7 );
/**
* Removes the styles regestered for the plugin bookly except on the page bookly shortcode is rendered on.
*
* @author bowriverstudio.com
* @see bowriverstudio.com/2018/10/15/adding-plugin-bookly-to-site/
* @see https://www.booking-wp-plugin.com/
* @todo You will have to modify the code "PAGE_SLUG" to your page ie: book-free-consolation
* @version 15.1 (Based on bookly's version)
*/
function brs_deregister_bookly_styles(){
if (!is_page('PAGE_SLUG')):
wp_deregister_style( ' bookly-intlTelInput' );
wp_deregister_style( ' bookly-ladda-min' );
wp_deregister_style( ' bookly-picker' );
wp_deregister_style( ' bookly-picker-date' );
wp_deregister_style( ' bookly-main' );
wp_deregister_style( ' bookly-customer-profile' );
endif;
}
add_action( 'wp_print_styles', 'brs_deregister_bookly_styles', 7 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment