Last active
December 18, 2015 16:49
-
-
Save justincarroll/5814115 to your computer and use it in GitHub Desktop.
This is an ongoing list of my most-used WordPress snippets for functions.php files. Take the meat, spit out the bones! The eating references in these descriptions are mounting.
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 | |
/* Updates jQuery manually */ | |
function update_jquery() { | |
if (!is_admin()) { | |
wp_deregister_script("jquery"); | |
wp_register_script("jquery", "http://code.jquery.com/jquery.js", false, "11.11.1"); | |
wp_enqueue_script("jquery"); | |
} | |
} | |
add_action("init", "update_jquery"); | |
/* Adds custom scripts to the page */ | |
function my_scripts() { | |
if ( !is_admin() ) { | |
global $wp_styles; | |
wp_enqueue_style("bootstrap", "http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"); | |
wp_enqueue_style("font-awesome", "http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css"); | |
wp_enqueue_style("style", get_template_directory_uri() . "/style.css"); | |
wp_enqueue_script("bootstrap", "http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js", array("jquery")); | |
wp_enqueue_script("html5shiv", "https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"); | |
$wp_styles->add_data("html5shiv", "conditional", "lt IE 9"); | |
wp_enqueue_script("respond", "https://oss.maxcdn.com/respond/1.4.2/respond.min.js"); | |
$wp_styles->add_data("respond", "conditional", "lt IE 9"); | |
wp_enqueue_script("script", get_template_directory_uri() ."/js/default.js", array("jquery")); | |
} | |
} | |
add_action("wp_enqueue_scripts", "my_scripts"); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );
2 pointers: