[WordPress] 外掛分享: Complete Open Graph

首頁外掛目錄 › Complete Open Graph
WordPress 外掛 Complete Open Graph 的封面圖片
⚠ 此外掛已下架 — 不再更新維護,建議勿安裝。
5,000+
安裝啟用
★★★★★
5/5 分(20 則評價)
2606 天前
最後更新
問題解決
WordPress 3.9+ PHP 5.6+ v3.4.5 上架:2016-11-07

內容簡介

有很多外掛承諾是全能的 SEO 解決方案,但往往缺乏彈性、實施方法不清或是附帶了您不需要的過多功能。

這個外掛是建立在替代哲學之上:專注做好一件事。Complete Open Graph 提供自動、全面、合理的 Open Graph 管理,不論您是在運用簡易的部落格還是複雜的網站,擁有相當豐富的內容。

Complete Open Graph 可立即提供完整的基本標籤,讓您的網站可以分享至 Twitter、Facebook、LinkedIn、Google+ 等平台,而您也可以對此數據進行各種程式化篩選。

簡而言之:這個外掛專注於 Open Graph,做得非常優秀。

使用外掛

啟動 Complete Open Graph 外掛後,它將開始生成 Open Graph 元標籤並安排顯示優先級。完全不需要設定即可使您的網站具有社群分享功能。

可用欄位

在每個頁面和文章上,以下欄位將自動生成,基於可用頁面數據。其中部分欄位也可以在頁面或文章層級上手動設定。

og:site_name
og:locale
og:type
og:title
og:url
og:description
og:image
og:image:width
og:image:height
twitter:card
twitter:creator
twitter:title
twitter:description
twitter:image
twitter:url
twitter:site
profile:first_name(目前僅顯示在個別作者頁面。)
profile:last_name(目前僅顯示在個別作者頁面。)

預設設置

作為未填寫頁面或文章數據的備用,您可以為 Open Graph 數據設置預設值。若想要,您可以在全局範圍內強制使用這些個別數據設置,並覆蓋在頁面或文章層級上的任何設置。您可以強制使用個別欄位,或一次強制使用所有欄位。

og:type
og:title
og:image
og:image:width
og:image:height
og:description
twitter:card
twitter:description
twitter:creator
twitter:site
fb:admins
fb:app_id

篩選

Complete Open Graph 的 complete_open_graph_all_data 篩選器可讓您自定義整組 Open Graph 值,並添加新的元標籤(包括不屬於 Open Graph 的標籤)。

以下是自訂預設的 Open Graph 數據範例:

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');

以下是添加標準舊樣式元標籤的範例:

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');

Complete Open Graph 的 complete_open_graph_processed_value 篩選器可讓您在進行優先級進階處理之後,修改單一欄位數據。因此它僅適用於以下欄位:

og:description
og:title
og:type
og:image

外掛標籤

開發者團隊

⬇ 下載最新版 (v3.4.5) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Complete Open Graph」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

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.
Using the Plugin
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.
Available Fields
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.

og:site_name
og:locale
og:type
og:title
og:url
og:description
og:image
og:image:width
og:image:height
twitter:card
twitter:creator
twitter:title
twitter:description
twitter:image
twitter:url
twitter:site
profile:first_name (Currently only displayed on individual author pages.)
profile:last_name (Currently only displayed on individual author pages.)

Default Settings
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. You’re able to force individual fields, or force all of them at once.

og:type
og:title
og:image
og:image:width
og:image:height
og:description
twitter:card
twitter:description
twitter:creator
twitter:site
fb:admins
fb:app_id

Filters
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:

og:description
og:title
og:type
og:image
twitter:card
twitter:title
twitter:image
twitter:description
twitter:creator

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;
});

Order of Priority
There’s a fallback system set in place for you to effectively leverage this plugin. Below is the order of priority:

Filters – Any filters you apply in your code will take priority over any fields you have filled in the admin.
Forced Global Settings – If you’ve checked the box on these fields on the settings page, they’ll override everything non-filtered.
Post/Page COG Fields – Filling out the meta box fields on a page or post in the WordPress Admin will give it priority over any default settings (unless they’re forced).
Post/Page Content – If no specific COG fields on the post/page are set, the post/page content itself will be used. For the Open Graph description, the excerpt will be respected if it’s filled.
Default COG Settings – Next, the default COG global settings will used to populate Open Graph tags.
Blog Info – When nothing else is overriding them, Open Graph fields will default to your general WordPress site settings.

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.
Feedback
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!

延伸相關外掛

文章
Filter
Apply Filters
Mastodon