I am searching for a hack to insert code in all sidebars of my site.
Any one knows any metod without change theme by theme?
I am searching for a hack to insert code in all sidebars of my site.
Any one knows any metod without change theme by theme?
Widgets?
Yes, but how can i put a widget in all blogs and the user dont know that the widget is put?
I don't even think there's any hooks within the sidebar that one could use. The only thing I can think of right off is putting the code into the meta function but you can get around that by not displaying the meta widget.
Hmmm... It's too early for this. :)
I can think of lots of ideas but they all mean going through the themes one by one.
Does it have to be within the sidebar? What are you trying to add in anyway? I'm guessing Adsense or something simular.
drmike, i want to add to the sidebar Adsense, but i have done a script to show it only if you come from Google (for not put adsense to the readers of the blog).
Any idea for put this in all blogs?
I think drmike is right - there are no hooks that allow you to force a function or a piece of code in the sidebar. The only thing I can think of is to go through the themes each by each. Sorry :)
Ok, thanks to all! :)
Actually yes. (edit: That's yes by the way to having an idea. I still not away of an idea for the sidebar)
Take a look at the admin-bar plugin from over at wpmudev.org It adds in a bar along the top if your user is logged in. You could probably work something out of that. if not, put the code you're trying to add in into a txt file and send it to me as an attachment at theapparatus at gmail dot com and I can probably look at it this weekend.
Hope this helps,
-drmike
I can put the code here, there is no problem ;)
This is the code that i want to put in the sidebar:
function vienedegoogle()
{
if(empty($_SERVER['HTTP_REFERER']))
return false;
$referer = urldecode($_SERVER['HTTP_REFERER']);
if (preg_match('|^http://(www)?\.?google.*|i',$referer))
{
return true;
}else{
return false;
}
}
if(vienedegoogle()){
---MY ADSENSE CODE HERE---
}
drmike any idea? :S
If widgets are coded into every sidebar, and who isn't doing that anyway, then put your adsense code into the widgets.php.
about line 135
function dynamic_sidebar($name = 1) {
global $registered_sidebars, $registered_widgets;
echo 'My Adsense Goes Here';