There are many plugins that insert
meta
tags for Facebook/google/twitter (like og:title
...) in header of website (like Heateor or Webdados or WPFOP, which offer many customizations). However, many of existing plugins doesnt include the correct logic and are incomplete plugins. I think the complete and useful plugin should have:====1) The logic of tags====
First of all, I think those plugins SHOULD HAVE individual fields on each post/page/custom-post EDITOR page, where we can fill open-graph title,description, url and image fields (like "Complete Open Graph" plugin has). In case we don't fill it, those fields should be defaulted to post-title, excerpt of content(in case excerpt not filled, then grab sanitized text from content, like TGFMT does) and featured image (plugin should enable 'featured-images' using this commandadd_theme_support('post-thumbnails');
).Also, all those plugins should add a special separate SETTINGS page in Dashboard.Because:
In case featured image is not chosen too, then it should be defaulted to the DEFAULT IMAGE - that option should be available in "settings" page. Also, there should be special fields for HOMEPAGE (where we can set default TITLE, Description and image for Homepage... if title and description fields are not filled, then it should defaulted to website TITLE/DESCRIPTION phrases).
Also, there should be conditional tags for each is_BLABLA() types:
Categories [ if (is_archive()) { echo '<og:image url=".$img ." />'; } ]
Tags [ if (is_tag()) { echo '<og:image url=".$img ." />'; } ]
- etc....( See the list: https://codex.wordpress.org/Conditional_Tags#Function_Reference . Note, not all of them are needed, but only the essential ones)
====2) Description tag ====
At first, many of those plugins doesnt offer to include the "description" tag for general purpose (<meta name="description" content="....">
). I know, google probably no longer uses that tag, but at least, plugin should have options page, where we can enable/disable that field.====3) Let me Change them! ====
all those fields before output, should be editable with filter (we should be able to modify output using hooks..)====4) encode images ! ====
image urls (only the name of image, or maybe the other parts too?) should be encoded, for example, instead of:http://example.com/folder+name/image+name.jpg should be:
http://example.com/folder+name/image%20name.jpg
i used this function to filter url://echo myIMGurlencode('http://example.com/folder+name/image+name.jpg'); function myIMGurlencode($imgUrl){ return str_replace('/'.basename($imgURL) , '/'.str_replace('+','%20',basename($imgURL)), $imgURL); }