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

  1. christian_gnoth
    Posted 5 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)

      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
    Posted 5 years ago #

    I found a solution:

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

    global $plugin_url;
    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