HeadSpace Plugin

Apr 14, 2005 | Tags: , , , | Written by John
Version 3.6.2 of this plugin exists for WordPress 2+ only. You may want to use that unless you are running WordPress 1.5

download

Download: headspace.zip
Version: 1.4
Updated: September 18, 2007
Size: 2 KB

Support This Plugin!

While this software is being provided free to use, it takes considerable time to develop and support. If you do find it particularly useful or want to request a feature then consider donating money as an incentive for me to carry on developing it.

Thanks!

I have other plugins too!

Style-sheets are great and have completely transformed the web. WordPress is great too, and also happens to make extensive use of style-sheets, as do the many plugins and hacks that are available for it. This leads to a small problem: any plugin that requires style-sheet definitions must have them added to the main WordPress style-sheet. This is not a good thing for several reasons:

  • It's bad design to have a plugin modifying the main theme
  • If you change theme, you need to make the changes all over again (if you can remember what they were)
  • If you delete the theme then you have a lot of styles you don't need any more.

I initially created a basic style-sheet plugin to solve the problem, but this soon evolved into a general purpose head manager - head referring to a special section of an HTML document that provides the meta-data to describe style-sheets, keywords, and an assortment of other goodies.

Reasons for using the plugin

At its most basic, the plugin allows you to add any HTML head elements to:

  • Individual posts
  • Posts written by a specific users
  • Posts belonging to certain categories

Why would you want to do any of that? Well, there are many reasons. The most simple is that you might want posts from different categories to appear with different styles, or maybe a post written by the administrator is in one style while posts from normal users get another.

Installation

The plugin should support the One-click format of the WP-Plugin-Mgr plugin. If installing manually then:

  1. Copy headspace.php to your wp-content/plugins directory
  2. Activate plugin

You can find full details of installing a plugin on the plugin installation page.

Requirements:

There must be a call to wp_head () somewhere in your theme's header.php code. This is included in the default and classic themes provided with WordPress, and is likely to also occur in most themes you download. If the plugin does not work then check this first.

Using the plugin

Once the plugin is activated it is configured on a post-by-post basis by adding any of the following custom field data:

head_title Inserts an HTML title. Note that you are allowed one title per page, and your current theme probably provides it already.
head_keywords Add meta keywords, to be picked up by search engines. Keywords are separated with commas:

example,eggs,cheese

head_description Add a meta description, sometimes used by search engines.
head_style Add a style-sheet. The format of this is:
  • import type url - where type is an import type (screen, TV, projector etc)
  • link url
head_meta Add any generic meta data. The format of this is:

name="something" content="content" equiv="httpequiv"

head_raw Add raw data. This data will simply be inserted into the head - use at your own peril!

Wildcards

The plugin makes use of special 'wildcards'. These are tags that are replaced with dynamic data taken from the current post:

  • %%nickname%% - insert the nickname of the author
  • %%useremail%% - insert the email of the author
  • %%userid%% - insert the user ID of the author
  • %%categoryNid%% - insert the Nth category ID of the post (start at 1)
  • %%categoryNdesc%% - insert the Nth category description of the post (start at 1)
  • %%categoryNname%% - insert the Nth category name of the post (start at 1)
  • %%title%% - insert the title of the post
  • %%date%% - insert the date the post was created
  • %%modifed%% - insert the date the post was modified
  • %%excerpt%% - insert the post excerpt
  • %%id%% - insert the post's database ID
  • %%gid%% - insert the relative URL to the post

Any number of wildcards can exist within a single keyword.

Examples

Add an extra style-sheet

head_style = link /wp-content/styles/example/extrastyle.css

Add a style-sheet that changes depending on who authored the post

head_style = link /wp-content/styles/users/%%nickname%%/extrastyle.css

Add keywords to the post

head_keywords = eggs,sandwiches,%%title%%

Add a description to the post

head_description = %%excerpt%%

Adding custom data

To add custom data to posts, and so get the plugin to work, you need to:

  1. Enable 'Advanced Editing'
    • Either press the 'Advanced Editing' button on the post
    • Or enable Advanced Editing by default in the Options / Writing section of the administration screen
  2. Add a new custom field with a keyword being one of the above, and the value being your chosen value

The keywords should not be entered into the post itself.

Global meta data

A new feature is the ability to have a list of globally applied meta-data. That is, meta-data that is applied to every post regardless of whether it is defined in the post custom data. This would be useful to define site-wide styles and descriptions.

The global meta-data is a text file located at wp-content/plugins/headspace_global.txt. It is a simple list of keyword and value, one per line separated with a return. All keywords and data follow the same syntax and rules as described above:

head_title This post was updated at %%modified%%
head_description %%excerpt%%
head_style /wp-content/styles/%%nickname%%/style.css

See also

Post-plugin research shows that Dougal Campbell wrote the plugin HeadMeta, which does a similar job to this one. The moral of the story: research before writing!

Share This

Comments (page 4 of 6)

  1. John (author) :

    Feb 28, 2007 1:47 am

    Richard, there's a version for WordPress 2 at http://urbangiraffe.com/plugins/headspace2

  2. Stefan :

    Feb 13, 2007 5:28 pm

    Reeally nice plugin, thanks a lot!

    One thing, that doesnt work:
    %ĘtegoryNid%%

    I can put %Ętegory1id%% or %Ętegory2id%% or .. or ...
    But nothing happens :(
    Greetings from germany!

  3. author
    Richard :

    Jan 30, 2007 11:48 am

    Sorry, that should have read title tag but it was stripped.

    Also the file path looks like wp 2.05 but is really 2.1

  4. author
    Richard :

    Jan 30, 2007 11:43 am

    Any chance of getting this plugin to work with WP 2.1?

    It's the only plugin I've found that's simple to use and will create a tag.

    The errors are:

    Warning: implode() [function.implode]: Bad arguments. in C:\axampp\xampp\htdocs\projects\wordpress205\wp-content\plugins\headspace.php on line 368

    Warning: Invalid argument supplied for foreach() in C:\axampp\xampp\htdocs\projects\wordpress205\wp-content\plugins\headspace.php on line 412

    Warning: Invalid argument supplied for foreach() in C:\axampp\xampp\htdocs\projects\wordpress205\wp-content\plugins\headspace.php on line 418

    Many thanks,

    Richard

  5. Vw Tuning :

    Aug 5, 2006 12:26 pm

    Downloaded for my Plugin Collection :) Thanks, great Job!!!

  6. author
    Michiel :

    Jun 18, 2006 12:15 pm

    one line of php disappeared, after "here:" it said:

    (hope it works now)

  7. author
    Michiel :

    Jun 17, 2006 12:26 pm

    I am using your plugin for making a custom and meta description, it works perfect! Now I would like to use the same "head_title" for another plugin: Next-Previous Page plugin (http://wordpress.org/support/topic/43071). I want/need to put the it in this line of php where it says 'link', here:

    Is that possible?

    (I tried your inscript plugin, but without php knowledge I did not even manage to have it replace the HeadSpace plugin...)

  8. Patric :

    Mar 2, 2006 7:48 pm

    That plugin is great! I will definitely give it a try this weekend! Thanks! Patric

  9. John (author) :

    Feb 26, 2006 1:29 am

    Leon & Otilia: New version 1.4 will fix both problems!

  10. Otilia :

    Feb 22, 2006 12:08 pm

    Hi John,

    first of all, thanks for taking the time and trouble to fix all these plugins, they seem to be really valuable once put to work.
    I'm trying to set up my blog and badly need to use this plugin. I have installed it, made the call within the header and tried to create keywords.
    I keep on getting this message:

    Warning: Invalid argument supplied for foreach() in /home/.../public_html/marketing-journal/wp-content/plugins/headspace.php on line 96

    and I don't know what to do with it...
    The line 96 in headspace.php is this:

    foreach ($values AS $value).

    Any thoughts on what should I do and where?

    Thanks a million!

Leave a comment


XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Home | Software | Terms & Conditions | Sitemap | John Godley © 2008
Close
E-mail It