Skip to content

Instantly share code, notes, and snippets.

@shrinkray
Created January 25, 2021 14:48
Show Gist options
  • Save shrinkray/4fdd4e544df90a1b4f7e6fed85d445f5 to your computer and use it in GitHub Desktop.
Save shrinkray/4fdd4e544df90a1b4f7e6fed85d445f5 to your computer and use it in GitHub Desktop.
Enqueue Child Theme CSS from Task Runner Webpack Bundler
/** Enqueue Child Theme JavaScript
* Function adds JS after other plugins
@created for a child theme named Mowtown Ecommerce
@parent is Shopical Pro from AF Themes
*/
function enqueue_after_wc() {
// vars
$jsFileURI = get_stylesheet_directory_uri() . '/dist/js/mowtown.js';
$ver = time();
wp_enqueue_script('mowtown_js', $jsFileURI, [], $ver, true);
}
add_action('wp_enqueue_scripts', 'enqueue_after_wc', 20);
/** Enqueue Parent and Child Theme Style CSS
*/
if ( !function_exists( 'mowtown_locale_css' ) ):
function mowtown_locale_css( $uri ): string
{
if ( empty( $uri ) && is_rtl() && file_exists( get_template_directory() . '/rtl.css' ) )
$uri = get_template_directory_uri() . '/rtl.css';
return $uri;
}
endif;
add_filter( 'locale_stylesheet_uri', 'mowtown_locale_css' );
// Apply Parent Theme's style.css
if ( !function_exists( 'mowtown_parent_css' ) ):
function mowtown_parent_css() {
wp_enqueue_style( 'mowtown_parent', trailingslashit( get_template_directory_uri() ) . 'style.css',
array( 'bootstrap','font-awesome','owl-carousel','owl-theme-default','sidr','jquery-countdown', 'shopical-woocommerce-style' ) );
}
endif;
add_action( 'wp_enqueue_scripts', 'mowtown_parent_css', 10 );
// Enqueue /dist/ path CSS from Laravel Mix
if ( !function_exists( 'mowtown_mix_css' ) ):
function mowtown_mix_css() {
$child_css_path = 'dist/css/mowtown.css';
wp_enqueue_style( 'mowtown_custom_styles', trailingslashit( get_stylesheet_directory_uri() ) .
$child_css_path, array( 'mowtown_parent','shopical-style' ) );
}
endif;
add_action( 'wp_enqueue_scripts', 'mowtown_mix_css', 10 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment