views:

23

answers:

2

Hi,

I am trying to write a simple plugin to wordpress but i have a problem. this is the plugin:


function replace_css_php($text){
   return str_replace(".css",".php",$text);
}

add_filter('bloginfo', 'replace_css_php', 1, 1);
add_filter('bloginfo_url', 'replace_css_php', 1, 2);

the problems is that other plugins (not my plugins), added text to the header after me. it means that only some of the text going through replace_css_php and not all of it.

(the function replace_css_php is just a simple example, not in real life)

any idea?

Thanks

A: 

You would want to change the execution order (priority) of your filter:

add_filter ( 'hook_name', 'your_filter', [priority], [accepted_args] );

The default is 10, and you're setting the priority of both to 1, so they're being over-ridden by everything else on the page with a lower priority. Set the priority value to something much higher and it should work.

hollsk
Changed that upto 20000 and it did not work.thanks
fatnjazzy
A: 

Looks to me like you're trying to filter the stylesheet URL?

In which case, use the more appropriate filter stylesheet_uri;

function replace_css_php($uri)
{
    return str_replace('.css', '.php', $uri);
}
add_filter('stylesheet_uri', 'replace_css_php');
TheDeadMedic
Thanks, Even worst. now nothing changed.
fatnjazzy
No offence @fatnjazzy, but you're really not helping - 'it doesn't work' won't get us anywhere. Please explain a little more what you're trying to achieve, and what results or errors you're getting with the current suggestions.
TheDeadMedic