bkraul wrote:
My question is: Is it OK to directly reference plugin_file.php? For example:
PluginName/files/mystyle.css
Code: Select all
.myclass {
background-image: url("plugin_file.php?file=PluginName/mybackground.png");
}
I'd say that it's ok, it gets the work done.
One example of that is in the jQueryUI plugin.
bkraul wrote:
Or is the only way to have to create a php file with a text/css header in order to call the actual function:
PluginName/pages/mystyle_css.php
Code: Select all
<?php header("Content-type: text/css", true); ?>
.myclass {
background-image: url("<?php echo plugin_file('mybackground.png') ?>");
}
With that approach, you are linking to a plugin page as if it was the actual css file:
Code: Select all
<link rel="stylesheet" type="text/css" href="http://.../plugin_page.php?page=xxxxxx" />
plugin file(...) is not valid there, because it returns a full filesystem path (which is local to the server). Eg: "/var/www/html/mantis/plugins/basename/files/xxxx.png"
you could creat a function "plugin_url" which creates a proper static url path: "plugins/basename/files/xxxx.png" (with, or without the
http://domain part)
Actually, that "plugin_url" probably should be part of the plugin API, as linking to satic content, through static path, makes sense.
Maybe plugin_file serves as an abstraction layer, independent of plugin paths, etc, but a static url, for inmediately used content, has its benefits too.