A WordPress plugin for simple, comprehensive, customizable Open Graph management.
A WordPress plugin for simple, comprehensive, customizable Open Graph management.
There's no shortage of plugins that promise to be THE all-in-one solution for all things SEO. Unfortunately, this often means lack of flexibility, confusing implementation, or just a big, bloated plugin that carries way too many features for your needs.
This plugin is built on an alternative philosophy: do one thing and one thing well. Complete Open Graph provides automatic, comprehensive, just-makes-sense Open Graph management, whether it's for a simple blog or a complex site with diverse sets of content.
Out of the box, Complete Open Graph generates all the basic tags your site should have, making it ready for social sharing on platforms including Twitter, Facebook, LinkedIn and Google+, and gives you full programmatic access to filter this data as you need.
TL;DR: This plugin does Open Graph. Freaking good Open Graph.
Upon activation, Complete Open Graph is ready to generate Open Graph meta tags, with an intuitive set of fallbacks in place. Literally no configuration is required to begin making your site socially shareable.
On each page and post, the following fields are automatically generated, based on available page data. Many of these can be manually set at the page/post level.
As a fallback for values that aren't filled automatically by a page or post, you can set default values for Open Graph data. If desired, you can force these individual values to be used globally, overriding whatever is set at a page/post level.
The complete_open_graph_all_data
filter allows the customization of the entire set of Open Graph values, as well as the addition of new meta tags (including those that aren't Open Graph).
Example for customizing out-of-the-box Open Graph data:
function modify_open_graph_data($data) {
$data['og:site_name']['value'] = 'whatevs';
return $data;
}
add_filter('complete_open_graph_all_data', 'modify_open_graph_data');
Example for adding a standard, old meta tag:
function add_new_open_graph_fields($data) {
$data['keywords']['attribute'] = 'name';
$data['keywords']['value'] = 'keyword1,keyword2,keyword3';
return $data;
}
add_filter('complete_open_graph_all_data', 'add_new_open_graph_fields');
The complete_open_graph_processed_value
filter allows you to modify a single field after it's gone through the progression of priorities. For that reason, it will only be effective on the following fields:
Example for manipulating a processed value:
function manipulate_processed_value($value, $field_name) {
if($field_name === 'og:description') {
return 'WHATEVER I WANT.';
}
return $value;
}
add_filter('complete_open_graph_processed_value', 'manipulate_processed_value', 10, 2);
The complete_open_graph_{$tagName}
filter allows you to modify a single field by identifying it by name and returning a modified value. These names are the "name" or "property" attributes on the meta tags. See "Available Fields" above for these names.
Example for manipulating a single value by name:
function modify_title($value, $field_name) {
return 'My Newly Modified Title!'
}
add_filter('complete_open_graph_og:title', 'modify_title', 10, 2);
The complete_open_graph_maybe_enable
filter allows you to disable tag generation altogether by returning a boolean.
Example for disabling generation altogether:
add_filter('complete_open_graph_maybe_enable', '__return_false');
Example for disabling generation on a specific page:
add_filter('complete_open_graph_maybe_enable', function ($maybeEnable) {
global $post;
if($post->post_name === 'my-page') {
return false;
}
return $maybeEnable;
});
There's a fallback system set in place for you to effectively leverage this plugin. Below is the order of priority:
After flowing through this order of priority, if there is still no content to be pulled, those respective Open Graph tags will not be generated. So, don't worry about having extra, useless tags just sitting there in your markup.
cog_open_graph_data
filter name to complete_open_graph_all_data
.complete_open_graph_single_value
filter.complete_open_graph
key, making for a slightly tidier database.twitter:card
(currently only supports "summary").twitter:creator
.twitter:site
.og:image:width
.og:image:height
.fb:app_id
and fb:admins
.complete_open_graph_single_value
filter to complete_open_graph_processed_value
.complete_open_graph_{$tagName}
filter to target specific fields.large
image sizes for images uploaded before plugin was installed.$GLOBALS
superglobal.post
object wasn't set.empty()
function which is unsupported in older versions of PHP and causing a few errors.og:image
tags on blog list pages.loadHTML()
for parsing certain types of content.?
and !
.get_locale()
method instead of hard-coding the value for the og:locale meta tag.CompleteOpenGraph\App
into $GLOBALS
to allow easier filtering and access within themes and plugins.media-upload
script enqueued.array_filter
that relies on ARRAY_FILTER_USE_KEY constant for greater PHP backwards compatibility.og:type
tag, which was not displaying at all.twitter:description
tags.twitter:description
exists on an archive page, use the og:description
.You like it? Email or tweet me. You hate it? Email or tweet me.
Regardless of how you feel, your review would be greatly appreciated!
After running composer install
and configuring the tests/bootstrap.php
file to load WordPress, run the following command inside your container to run all tests.
vendor/bin/phpunit