WordPress.org

Ready to get started?Download WordPress

Forums

Google Plus One (+1) Plugin (w3c validator neutral) (6 posts)

  1. konqi.de
    Member
    Posted 2 years ago #

    Hi!

    while using some google plus one plugins from the plugin browser i got a lot of validation warnings from w3c's validator. To make it short: I don't like warnings and i wanted my site to be 100% valid XHTML code. So i created a plugin of my own - but: I'm too lazy to go through all the plugin registration stuff - however maybe someone will find this useful. Here is the complete code of the plugin. Despite the bits that are required to be GPLv3 because of the wordpress licence i'm giving it to you as public domain. Use it well!

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Oh right, this it what it does:
    - Adds an empty <div> with the post id to each post.
    - Buffers the post ids
    - Places a javascript piece at the end that replaces the divs with the Google PlusOne code
    - Google does the rest for you

    Validators don't execute javascript, so it will only see an empty div-tag which is XHTML strict compatible.

    ... and if you like it... put some cheers in this thread so i can return here and be happy :-)

    konqi

  2. konqi.de
    Member
    Posted 2 years ago #

    Code pasted in pastebin as requested:
    http://pastebin.com/zn9mvByr

    Sorry...

    cheers

    konqi

  3. miz.chellie
    Member
    Posted 2 years ago #

    I am receiving validation errors too and am not a programmer. Can you walk me through what to do? Will this override any other plug-ins I have for google+.....I'm using WP Biographica and I have another plug-in that puts the icon at the end of my posts. Thanks.

  4. konqi
    Member
    Posted 2 years ago #

    1) Copy the code into a file called something like 'wp_googleplusone.php'.
    2) Upload the file into your plugins directory
    3) Enable plugin in wordpress

    It will not override any other plugins.

    You can see how the plugin works on my website.

  5. miz.chellie
    Member
    Posted 2 years ago #

    Hi. I did the above but there is not Google+ sign on my posts...I did pass validation which is great. Any idea what's wrong or am I supposed to do something else? Tx Chel

    chelliesworld.com

  6. miz.chellie
    Member
    Posted 2 years ago #

    FYI f/u I could not get it to work. I am using this one
    Google +1 (Plus One) Share Plugin and it works and passes validation

Topic Closed

This topic has been closed to new replies.

About this Topic