following a tutorial at http://josephscott.org/archives/2010/03/database-powered-css-in-wordpress-themes/ i'm attempting to use wordpress' parse_request function to include some php-driven CSS... mostly style options occur my theme's options panel. i know that my code looks a bit not the same as the author's, however i attempted it his way already. i'm able to add the
function kia_wp_head() {
wp_enqueue_style('dynamic', get_bloginfo('stylesheet_directory') . '/admin/ . '?my-custom-content=css');
}
add_action('wp_print_styles', 'kia_wp_head');
//this shows up properly enqueued but when i click on it in source it just brings up a directory listing for the admin folder
function my_custom_wp_request( $wp ) {
if( isset($_GET['my-custom-content']) && $_GET['my-custom-content'] == 'css' ) {
# get theme options
header( 'Content-Type: text/css' ); ?>
body {
background-color: <?php echo 'red'; ?>
}
<?php
exit;
}
}
add_action( 'parse_request', 'my_custom_wp_request' );
consider the backdrop never turns red-colored, I'm either not applying this correctly or even the tutorial is missing a vital step. i have also attempted another approach to putting the dynamic css in the own custom-css.php file, that is my ultimate goale, however i only agreed to be trying to ascertain if i possibly could communicate with the parse request function correctly:
function my_custom_wp_request( $wp ) {
if (
isset($_GET['my-custom-content'])
&& $_GET['my-custom-content'] == 'css'
) {
# get theme options
header( 'Content-Type: text/css' );
require dirname( __FILE__ ) . '/custom-css.php';
exit;
}
}
add_action( 'parse_request', 'my_custom_wp_request' );
here i am unsure what dirname( FILE ) means exactly, however i also have attempted utilizing a hardcoded path which did not work either.
so how do you get parse_request to determine my php-driven stylesheet?
/* EDIT FOR SOLUTION */
essentially this does not work w/ wordpress_enqueue_style
wordpress_enqueue_style('dynamic', get_bloginfo('stylesheet_directory') . '/admin/ . '?my-custom-content=css')
but Works as referred to at josephscott.org by placing the design and style tag into the mind
. '/admin?my-custom-content=css">i discovered it doesn’t work w/ wordpress_enqueue_script. it will act as designed in the tutorial by by hand adding the script tag towards the header.