#56: Header Insert Plugin for WPMU
Wordpress MU again … :p
I wrote a plugin, I call it : Header Insert Plugin, which can insert a HTML code into the head section. Using this plugin, Site Admin can insert a specific HTML into the head admin, and users can supply their own value.
For example, Site Admin enter this code :
<style>.myimage { url(%image_url%); }</style>
and the user enter this as ‘image_url’ parameter in the Header Insert Options :
http://myserver.com/username/files/2008/10/test.jpg
then, the plugin will display :
<style>.myimage { url(http://myserver.com/username/files/2008/10/test.jpg); }</style>
in the user’s client.
What is this for ?
- as a Site Admin we can overwrite a theme css parameter with our own code, customized by our users.
- put some additional HTML code in the head section displayed by all users,
- etc … independent from theme that users select.
Save this as a PHP file (right click, Save As … and don’t forget to rename the file, I put it here as a JPG ones), and put it in your mu-plugins for automatic execution, or in the plugins if you want to activate it manually.
After that, you will get an additional option in the [Site Admin][Options] menu (to input your main code), and additional menu in the [Design][Header Insert] for users to input their own text.
Hope it is usefull,

i enabled your plugin and it working using site admin-> options, it inserts the header too all blogs, but when a user goes to design-> header insert it says “No Parameters needed.” how do i allow my users to insert their one code in the header?
Comment by Marco Ferreira — 24 October 2008 @ 10:08 pm
ok, i fixed my last issue, i declared and now i have the field to set up, when i insert in the html field a google webmaster for validation of the blog
(example:
the blog gets a different code:
its adding some in the html code, i tried to understand in the plugin code where this conversion is made and adapt it but all attempts failed, can you tell me what i have to change in the plugin so it doesn’t add the slashes () to the final code?
btw this plugin is great :)
Comment by Marco Ferreira — 25 October 2008 @ 12:30 am
Change line 84: from $value to stripslashes($value) and line 99 from $arr_hip_options[$field] to htmlspecialchars($arr_hip_options[$field])
Or just re-download it from the same url.
Comment by rizapn — 25 October 2008 @ 6:22 am
i tested and now its working perfectly, thanks a lot
Comment by Marco Ferreira — 25 October 2008 @ 6:07 pm
Hi,
I loaded the HTML as directed above…but no header displays. I am not a expert when it comes to code. Any help will be appreciated. Thanks!
Comment by Keith — 24 December 2008 @ 3:41 am
You must copy all files (php) mentioned in this article to the right location to make the plug-in active first. Then, you can put the HTML code as mentioned …
Comment by Riza Purwo Nugroho — 25 December 2008 @ 5:32 pm
Hi Riza,
The plugins are activated. I placed them in the plugins folder and activated it manually.
I placed the “.myimage { url(%image_url%); }” code in the Site Admin-Options page as directed. I then included the location of the image on my server in the Design-Header Insert line. All those fields are present.
After I saved each step and refreshed my site…the old header remained.
Any ideas? Does this plugin work on all themes? I will try others. Thanks!
Comment by Keith — 26 December 2008 @ 9:27 pm
@Keith: do you include the <style> also? So, the complete HTML code for yours should be : <style>.myimage {url(%image_url%);} </style> …
Comment by rizapn — 27 December 2008 @ 9:35 am
Good Morning,
That’s exactly as I have it. My blogs are at a subdomain, blogs.mysite.org. When I include the location in the Design-Header Insert line, should I format it”http://blogs.mysite.org/images/image.jpg” or should I list it as “http://mysite.org/blogs/images/image.jpg”?
I have done it both ways with no results.
I have also uploaded the image in both the root of blogs.mysite.org as well as the image file within the theme.
Any other help will be appreciated. Thank you!
Comment by Keith — 29 December 2008 @ 9:25 pm
I have that code as you displayed it. Any other ideas? Thank you!
Comment by Keith — 29 December 2008 @ 10:13 pm
I’ve installed this and it’s exactly what I wanted! I needed a plugin to allow my users to tweak their CSS and this is perfect.
Thanks :)
Comment by Leo — 6 January 2009 @ 7:59 am
is there anyway for me NOT to include the header on the main site?
Comment by David Johnson — 11 January 2009 @ 2:31 am
HIii
ok, i fixed my last issue, i declared and now i have the field to set up, when i insert in the html field a google webmaster for validation of the blog
(example:
the blog gets a different code:
its adding some in the html code, i tried to understand in the plugin code where this conversion is made and adapt it but all attempts failed, can you tell me what i have to change in the plugin so it doesn’t add the slashes () to the final code?
btw this plugin is great :)
Ioffersearch.com Blogs - Just another Ioffersearch.com weblog
Comment by ioffersearch001 — 5 March 2009 @ 11:21 pm
@David : you can add a wordpress function (is_home I think) to check weather it is executed from the main or not.
@Ioffersearch : use a php function stripslashes to delete that slashes.
Comment by rizapn — 6 March 2009 @ 9:26 am
I’m having an issue with this plugin. Whenever I input a value into the text box generated on the Header Insert page, the values are not saved. I am using MU version 2.7.1.
Comment by Dan — 13 July 2009 @ 12:07 am