31
Aug
05

Footer plugin requirements, notes

A few days ago, Joseph and I were talking about bolting statcounter onto our blogs. He’s the one that pointed out statcounter to me, and all he needed to do was add the statcounter script to his theme’s footer.php file. This would probably work for any single-theme site, but I’m still running multiple themes on my blog. I need to do one of the following if I want to use statcounter:

  1. Drop all but one theme. There are several good reasons for this, most important of which is maintenance. This would allow me to add the statcounter script to the remaining theme’s footer.php and I’d be done.
  2. Add statcounter to all my themes. This probably wouldn’t be too bad, except for maintenance–whenever a new version of one of my themes came out, I’d have to manually reapply my changes.
  3. Write a plugin to insert the statcounter script in the footer of every page. This would be the most work up front, but it would give me a good excuse to learn how to write plugins for WordPress.

I found some useful resources for plugin authoring. The WordPress codex has a section on writing plugins. Owen’s tutorial is a great introduction–just read it and start hacking! :) Carthik’s Plunge into Plugins article has lots of good advice, but isn’t a tutorial–check it out after/while you get started with Owen’s page. More good info is available on the Codex page Writing a Plugin.

I’ve started working on this plugin, and I’ve already been bitten by the “extra blank line” problem. (Admin interface was reporting “Cannot modify header information - headers already sent by…” error. Note to self–scroll to the bottom of each PHP file, and make sure the PHP close tag is right at the bottom of the file.) I have the code to insert arbitrary text into the footer, but I still need to add the Options menu which would allow J. Random User to edit the text to be inserted. (Right now, the text is hard-coded in the “plugin”, which I have installed and activated on this blog. Check the bottom left corner of any blog page for the statcounter.)

I don’t see any reason for this plugin to be statcounter-specific. It would be more useful to provide some sort of generic footer plugin which would allow HTML or javascript to be inserted in the footer. We’ll see how it goes. If I’m happy with it by the end of the night or later this week, I will go ahead and release it.


6 Responses to “Footer plugin requirements, notes”


  1. 1 jim Aug 31st, 2005 at 14:15 UTC

    Bitcloud asked me to post my plugin “as-is”. Glad to help, but just remember–this is my first attempt at writing a plugin. Back up your blog before installing!

    1. The plugin source is here. Download or copy-and-paste this file into your wp-content/plugins directory.
    2. Replace the MY_FOOTER_TEXT definition with the text you want to appear in your blog’s footer.
    3. Activate the plugin using the WordPress admin interface.
  2. 2 jim Oct 8th, 2005 at 13:55 UTC

    I’ve posted some more information about Statcounter. I put a link to this post in that article, so I should have gotten a pingback here, but didn’t for some reason. Nothing awaiting moderation, either. Strange…

  3. 3 Michelle Feb 14th, 2006 at 07:57 UTC

    Awesome Plugin, thankyou makes changing themes so much easier. Would it be possible to also be able to use this for php in the footer as well? If so how would I do that.

  4. 4 jim Mar 6th, 2006 at 16:33 UTC

    I think you should be able to embed PHP. The only problem would be quoting, since the footer text is single-quoted already. If the PHP you want in the footer is simple (i.e. can be embedded in a quoted string), just go for it. If the PHP isn’t simple, write it as a function and then insert a call to the function in the quoted string.

  1. 1 SonicChicken weblog » Blog Archive » Displaying (vs executing) PHP code on web pages Pingback on Aug 31st, 2005 at 21:45 UTC
  2. 2 SonicChicken weblog » Blog Archive » New website for my wife’s business Pingback on Oct 7th, 2005 at 04:50 UTC

Leave a Reply




August 2005
M T W T F S S
« Jul   Sep »
1234567
891011121314
15161718192021
22232425262728
293031  

Tags

abramoff accessibility acetylene activism aerial photo afrofunk aim4tree air america airport express alite alito amtrak andante andy anti failure any browser apache apple applescript arden arcade arden park ariana arnold ashland astronomy attic attika audio avid reader backup baen bart bathroom bbq bee beef begonia bgg bike bike hikers bike journal bikejournal biketalk bill oreilly bittorrent blacklist blog bloggercode blogroll blueberry boardgamegeek boardgames bonjour book bookcrossing boot failure bootcamp borderline chaos bugmenot bush business card cabinetry caira caitlin california candamir caroline carpet cat cateye cdrom celebration cellular phone century cheese chicken chico chimney chinese chipotle chocolate christmas chumby city bikes civilization cjd claire club club fed co op coconut coffee comfort food community computer concord congress conquest conservation consumer reports copyright costco crazybikerchick crepe crock pot cruftbox css csus curl currency custard cvntrak dagoba daniel goetz darwinports datarescue date format death delicious monster democracy now Democrat demolition dessert dickens diff disaster discrimination discworld dishwasher diskwarrior dixie belle dock doors downing street memo drm dryer drywall dump ed burke eff eggs eject election electric car electric truck electrical electricity elvgren email energy efficiency eric meyer esr etext euthanasia facebook family faq faux news feed feedreader fence finder firefox first4internet first amendment fishmeal flash flickr flooring foreign exchange foundation fox and goose framing freebsd freedback fyq garage garden geek geotag geourl gnutar go gonuls google google earth google maps gpl gracenote graywater greek green group concat gtd gunthers gutters gwbush gymnastics hacking halloween handspring hardwood harry potter headmeta high speed photograph high tech inv hoax hobbies hobby hodgins holiday holly home power magazine horcrux houseblogs how to html humor hvac ilovejackdaniels impeach inspection insulation intel internet ipod ipodder iq iraq isight itunes ivins iwantsandy java city javascript joint chiefs joseph jott journalized blue judges cup kctc khs kimkerry kitchen kyocera la salles la times labor landscape laundry law leatherbys legal lego leopard lhc liberal library linkedin ljurban lodi logic logo lungren maaloufs mac macbook mailinator malware map marin markdown mason media media clip media reform meetup metric mexican microsoft mike comfort military milonic mindstorms mlk model railroading modoc hall monterey morning sedition motorcycle movie moving munchkin murray mushroom music mynetflix mysql naked lounge nerd score netflix network new urbanism new year New Yorker nofollow nutella oatmeal obama obcz occidental occupation omni openssl oracle organic osx owp paint pair palast palm panasonic parallels party patch peak adventures peak oil pear pedestrian village perl petaluma php ping pingback pingomatic pingomation pingqueue pirate pl sql planet bike plasma playroom entertainment plugin plugin:preview theme plugin:text control plugin:ultimate tag warrior plumbing podcast podsite politics portupgrade potato powerbook printer programming project gutenberg pryde punk puzzle qiana quilt quilt shop quiz quote r5 records racism radio railroad recent comments recipe redalt remodel resaurant resolution restaurant restore review richmond rio americano robotics roger niello ron montana roof rootkit rss sacbee sacog sacramento sacramento spotlight magazine salad san francisco sandwich santa cruz scam scandal school days scplugin security session report shakespeare shuffle sigma siriradha sitemap snl snopes social social network software soma somafab sonicchicken sonicchicken blog sony spam spam karma spellcheck spinach spirit spoiler etiquette spring hill cheese sql sqlserver stairs standards statcounter stephen king stop loss stucco stunt subversion sudoku superbowl superhero supreme court sushi svn sysadmin tacoma tags plugin takara technology telephone television template terms and conditions textcontrol thai kitchen thanksgiving theater theme theme:borderline chaos theme:elvgren theme:elvgren wordpress google code theme:fluid blue theme:fullwidth theme:head theme:journalized theme:journalized blue theme:psycho theme:redoable theme:sharepoint like theme:simple green theme:spirit theme:steam theme:wuhan theme:yadda theme switcher thomas tigris euphrates tile tinfoil hat toc tofu tower theater training transit transit oriented development tribute u haul uneasy rhetoric university village van zant veterans day video vie viking hobby vote smart w3c wall warboss washer washington post weather web web developer web server wikipedia windows wishlist woodworking wordpress workplace wpblacklist wpgatekeeper wsj yaaarr yard