Created
March 7, 2017 22:27
-
-
Save anastis/205aa7531a61a50a304646bd5e26087e to your computer and use it in GitHub Desktop.
Inlining styles in WordPress without an actual CSS file
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 | |
add_action( 'some_hook', 'maxslider_enqueue_slider_css' ); | |
function maxslider_enqueue_slider_css() { | |
$css = ''; | |
// ... | |
if ( true === $something ) { | |
$css = 'body { background-color: ' . $color . '; }'; | |
} | |
// ... | |
wp_register_style( 'maxslider-footer', false ); | |
wp_enqueue_style( 'maxslider-footer' ); | |
wp_add_inline_style( 'maxslider-footer', $css ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment