Skip to content

Instantly share code, notes, and snippets.

@grappler
Created July 11, 2014 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grappler/3cbf38d40fd4a7aaac8f to your computer and use it in GitHub Desktop.
Save grappler/3cbf38d40fd4a7aaac8f to your computer and use it in GitHub Desktop.
<?php
/**
* Add minified and RTL Stlysheets with automatic theme version
* Load styles for specific stylesheets
*/
function theme_name_css() {
$template_directory_uri = get_template_directory_uri();
$rtl = ( is_rtl() ) ? '-rtl' : '';
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
$theme_name = wp_get_theme( 'theme-name' );
// Depending on the settings RTL or minified version will be loaded
wp_enqueue_style( 'theme-name-style', $template_directory_uri . '/css/style' . $rtl . $suffix . '.css', false, $theme_name['Version'] );
if ( is_child_theme() ) {
$theme = wp_get_theme();
wp_enqueue_style( 'theme-name-child-style', get_stylesheet_uri(), false, $theme['Version'] );
}
$page_id = get_queried_object_id();
$post_type = get_post_type( $page_id ):
if ( ! empty( $post_type ) ) {
wp_enqueue_style( 'theme-name-' . $post_type , $template_directory_uri . '/css/style' . $post_type . $rtl . $suffix . '.css', false, $theme_name['Version'] );
}
}
add_action( 'wp_enqueue_scripts', 'responsive_css' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment