This post is work related, and as you can tell by the title, relates to wordpress.
On the work blog, we had social media sharing buttons. One of the bosses used an SEO program to scan the site, and the social media buttons returned less than favorable data. (I am purposefully not mentioning the site, the SEO software and the buttons used…) For some reason, the plugin was creating invisible buttons with links in the space between the actual buttons.
I attempted to remove the unseen links to no avail. I was put on the trail of other social media items to use that are in conjunction with another plugin, but the instructions were less than favorable for those of us not strong in php.
So, I turned to my good buddy Google. Approximately 3 minutes later, I found 2 posts that I believe solved my problem! (I say “believe” because I will not know for sure until our SEO person takes a look and gives me the thumbs up.)
The first article is by Carrie Dils, and explains the functions.php file needs to be updated with the following:
// Enable PHP in widgets add_filter('widget_text','execute_php',100); function execute_php($html){ if(strpos($html,"<"."?php")!==false){ ob_start(); eval("?".">".$html); $html=ob_get_contents(); ob_end_clean(); } return $html; }
This will allow the widgets to run php code (I used a standard sidebar text widget field). She does include a warning -> Warning: Use PHP in widgets very judiciously as this is a potential security vulnerability you open by enabling code execution from a widget, versus a file on the server.
The second post is ClickNathan. This supplies the code to insert the links of Facebook, Twitter, and Google Plus. I altered them slightly as I used an image instead of icons for each link, but I am only posting the minimal links here with text:
<a href="http://www.facebook.com/sharer/sharer.php?s=100&p[url]=<?php echo urlencode(get_permalink()); ?>" target="_blank">Like This Page on Facebook</a>
<a href="https://twitter.com/intent/tweet?text=<?php echo urlencode(get_the_title()); ?>+<?php echo get_permalink(); ?>" target="_blank">Tweet This Page</a>
<a href="https://plus.google.com/share?url=<?php echo urlencode(get_permalink()); ?>" target="_blank">Plus One on Google</a>
I do hope this works as I expect, as I prefer this implementation to adding another widget.