Skip to content

Instantly share code, notes, and snippets.

@nladart
Forked from neverything/functions-snippet-1.php
Created March 21, 2013 18:10
Show Gist options
  • Save nladart/5215274 to your computer and use it in GitHub Desktop.
Save nladart/5215274 to your computer and use it in GitHub Desktop.
For Require + Foundation Child Theme
<?php
// Add the following line to your required_starter_themesetup in your child theme functions.php
remove_action( 'wp_enqueue_scripts', 'required_load_scripts' );
<?php
/**
* Custom function to load styles and scripts
*
* Handling the scripts and stylesheets all by yourself?
* See here on how to register and load theme in your
* child theme.
*
* @link http://themes.required.ch/?p=798
*/
function my_child_theme_load_scripts() {
// register required-foundation.min.js
wp_register_script(
'foundation-js', //handle
get_template_directory_uri() . '/javascripts/required-foundation.min.js', //source
array('jquery'), //dependencies
FOUNDATION_VERSION, //version
true //run in footer
);
//app.js – depending on foundation.js
wp_register_script(
'app-js',
get_template_directory_uri() . '/javascripts/app.js',
array( 'foundation-js' ),
FOUNDATION_VERSION,
true
);
// The stylesheets
wp_register_style(
'foundation-css', //handle
get_template_directory_uri() . '/stylesheets/foundation.min.css',
null, // no dependencies
FOUNDATION_VERSION //version
);
// Load scripts
wp_enqueue_script( 'app-js' );
// Load our Stylesheets
wp_enqueue_style( 'foundation-css' );
}
add_action( 'wp_enqueue_scripts', 'my_child_theme_load_scripts' );
<?php
/**
* Remove certain styles and scripts
*
* In case you only want to remove certain
* scripts and styles, this is how:
*
* @link http://themes.required.ch/?p=798
*/
function my_child_theme_remove_scripts() {
// Remove theme-js
wp_dequeue_script( 'theme-js' );
wp_deregister_script( 'theme-js' );
// Let's keep the app.js and required-foundation.min.js
wp_enqueue_script( 'app-js' );
// Remove theme css style.css calls,
// but keeps the app.css and foundation.min.css
// because we of the dependencies
wp_deregister_style( 'required-foundation-css' );
}
add_action( 'wp_enqueue_scripts', 'my_child_theme_remove_scripts', 11 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment