WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] css file as php - how to get wp environment variables (2 posts)

  1. christian_gnoth
    Member
    Posted 3 years ago #

    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?

  2. christian_gnoth
    Member
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic