Created
July 11, 2014 18:49
-
-
Save grappler/3cbf38d40fd4a7aaac8f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* 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