Valid Google Publisher Link and More

Posted By: Ian on Dec 20, 2012 in Google
Last modified on January 29th, 2015 at 9:31 pm,

Hey,
You wanted to link your google+ page to your website – You have! (If not go here)
Now you want it to validate! – It fails!
Well here is a sneaky little snippet to make that link appear on everything but the validator.

if(substr($_SERVER['HTTP_USER_AGENT'], 0, 13) != 'W3C_Validator'){
  echo '<link href="https://plus.google.com/YOUR_SITE_ID/" rel="publisher" />'; 
}

Basically unless the User Agent string starts “W3C_Validator” it will include your google+ link.
Now you can be a valid google publisher
OK!
But why does it not validate?
Well this is because rel="publisher" is not currently a valid rel (relationship) value but it is proposed to be added.


We don’t need to stop there with this piece of code as if you think about it there are a lot of uses for it!
Lets say you want to use conditional comments for firefox, safari or any other browser out there well now you can.

Some people might think this is cheating and i suppose in some senses it is but the google+ link is only useful to google so why should you be penalised for that why you wait for it to become valid.

AnonymousIan.J.Gough

Did this help you? Please Let me know by commenting below even if it’s just to say “Thanks”

leave a comment

About This Site

Dreams are built from lines of code well it's true!
If you can dream it you can usually code it.

I have learned so much from other people on the Internet and this site is for me to give back some of what i have learned and hope people can now learn from me.
Have fun and surf safely,
Ian.J.Gough

protected by copyscape duplicate content check

Categories


Powered by Banner Bar 125