Last active
February 11, 2019 18:48
-
-
Save bappi-d-great/208d06bc3139f2076074 to your computer and use it in GitHub Desktop.
How to write dynamic css in a php file in wordpress
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
<!-- functions.php --> | |
<?php | |
add_action( 'wp_enqueue_scripts', 'theme_custom_style_script', 11 ); | |
function theme_custom_style_script() { | |
wp_enqueue_style( 'dynamic-css', admin_url('admin-ajax.php').'?action=dynamic_css', '', VERSION); | |
} | |
add_action('wp_ajax_dynamic_css', 'dynamic_css'); | |
add_action('wp_ajax_nopriv_dynamic_css', 'dynamic_css'); | |
function dynamic_css() { | |
require( get_template_directory().'/assets/css/custom.css.php' ); | |
exit; | |
} | |
?> | |
<!-- custm.css.php file --> | |
<?php | |
header( "Content-type: text/css; charset: UTF-8" ); | |
global $lts; | |
?> | |
body{ | |
color: <?php echo $lts['base-color'] ?>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
no va