murtaugh/HTML5-Reset

Dynamically-generated site name instead of www-sitename-com

Closed this issue · 2 comments

Hey all, here's a solution I added to make the little

<head id="www-sitename-com" in header.php a dynamic thing based on the user-entered site title, not just a static thing that would need be to be replaced.

First, I created a hook in functions.php:

function html5reset_head_id() {
    do_action('html5reset_head_id');
}

function head_id_slug() {
 $headidslug = get_bloginfo('name');
 $headidslug = ereg_replace("[^A-Za-z]", "", $headidslug);
 $headidslug = strtolower($headidslug);
 echo $headidslug; 
}          
add_action('html5reset_head_id','head_id_slug');  

This removes all non-letter characters, even numbers, and then makes the string all lowercase.

Then, I just replaced

<head id="www-sitename-com" data-template-set="html5-reset-wordpress-theme" profile="http://gmpg.org/xfn/11">

with

<head id="www-<?php html5reset_head_id(); ?>-com" data-template-set="html5-reset-wordpress-theme" profile="http://gmpg.org/xfn/11">

So for the site I have with the title Hey It's George, www-heyitsgeorge-com is returned :)

Let me know if you guys have problems with this, if not maybe it can be added to the Reset.

Shouldn't it be the site's URL ( get_bloginfo('siteurl'); ) instead, since it starts with 'www' & ends with 'com'? The title is not always the same as the URL. Semantically speaking?

Yeah true. But this has no actual function in the development of a website, it's purely for viewing purposes if you have a bunch of sites open.