WordPress.org

Support

Support » Plugins and Hacks » Hacks » [Resolved] css file as php – how to get wp environment variables

[Resolved] css file as php – how to get wp environment variables

  • i have a plugin frontend (public) stylesheet with a background image definition which has to be set dynamic to the plugin directory folder:

    the stylesheet has the file ending .php (not .css)

    .bbnuke_tb_head_asc
    {
      background:        url(<?php echo WP_PLUGIN_URL . '/images/asc.gif'; ?>);
    }

    how i can get the wp enviroment variables like WP_PLUGIN_URL in a stylesheet php file?

Viewing 1 replies (of 1 total)
  • I found a solution:

    at the beginning of the file I added the following lines:

    global $plugin_url;
    
    require_once('../../../../wp-load.php');
    
    header('Content-type: text/css');

    then the variable $plugin_url from the plugin main php file is available.

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] css file as php – how to get wp environment variables’ is closed to new replies.
Skip to toolbar