Skip to content

Instantly share code, notes, and snippets.

@dustinleer
Last active August 3, 2020 17:02
Show Gist options
  • Save dustinleer/f54f626100f3e2d1c3c518dadc4e2749 to your computer and use it in GitHub Desktop.
Save dustinleer/f54f626100f3e2d1c3c518dadc4e2749 to your computer and use it in GitHub Desktop.
<?php
/* == Queue up all css & js files ==================================================== */
function theme_scripts_styles() {
// JS
/** Removes WP stock jQuery
* https://developer.wordpress.org/reference/functions/wp_deregister_script/
*/
wp_deregister_script( 'jquery' );
/** Adds jQuery from a CDN, loads in the footer
* https://developers.google.com/speed/libraries
*/
wp_enqueue_script( 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js', array(), null, true );
/** Adds jQuery Cookie Scripts from CDN, loads in footer
* https://cdnjs.com/libraries/jquery-cookie
*/
wp_enqueue_script( 'js-cookies', '//cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js', array('jquery'), null, true );
/** Adds Slick Slider Scripts from CDN, loads in footer
* https://cdnjs.com/libraries/slick-carousel
*/
wp_enqueue_script( 'slick-js', '//cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.js', array('jquery'), null, true );
// CSS
/** Adds Slick Slider CSS from CDN
* https://cdnjs.com/libraries/slick-carousel
*/
wp_enqueue_style( 'slick-css', '//cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.css' );
wp_enqueue_style( 'slick-theme', '//cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick-theme.min.css' );
/** Removes dashicons in frontend to non-logged-in users
* https://developer.wordpress.org/reference/functions/is_user_logged_in/
* https://developer.wordpress.org/reference/functions/wp_deregister_style/
*/
if ( !is_user_logged_in() ) {
wp_deregister_style( 'dashicons' );
}
}
add_action( 'wp_enqueue_scripts', 'theme_scripts_styles' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment