[WordPress] 外掛分享: Hum

前言介紹

  • 這款 WordPress 外掛「Hum」是 2011-01-26 上架。
  • 目前有 800 個安裝啟用數。
  • 上一次更新是 2024-11-17,距離現在已有 168 天。
  • 外掛最低要求 WordPress 3.0 以上版本才可以安裝。
  • 外掛要求網站主機運作至少需要 PHP 版本 5.6 以上。
  • 有 8 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

pfefferle | willnorris |

外掛標籤

diso | whistle | shortlink |

內容簡介

Hum 是一個針對 WordPress 的個人網址短縮器,旨在提供短網址給您個人內容,無論是托管在 WordPress 上還是其他地方。例如,與其使用 WordPress 文章的長網址,例如 http://willnorris.com/2011/01/hum-personal-url-shortener-wordpress,您可以使用短網址,如 http://willnorris.com/b/FJ。此外,如果您有自訂的短網址域名,您可以進一步縮短網址,例如 http://wjn.me/b/FJ。一旦啟用外掛,頁面或文章的短連結可以在 WordPress 管理工具欄中的「短連結」項目中找到。

WordPress 文章 ID 是使用特定為簡潔易讀而優化的 NewBase60 編碼方案縮短的,具有內置錯誤校正功能,可針對常見混淆字元,例如「1」、「l」和「I」。

Hum 不是一個類似於 http://bit.ly 或 http://goo.gl 的通用網址短縮器。相反,它是專為個人內容設計的短網址。

有關使用個人網址縮短器的原因,請參閱 Tantek Celik 的 Whistle 頁面,該頁面是 Hum 的靈感來源。

開發人員文件
添加 Amazon 廣告聯盟 ID

如果您想在 /i/ 重定向網址中包含 Amazon 廣告聯盟 ID,請實施 amazon_affiliate_id 過濾器。例如:

add_filter('amazon_affiliate_id', create_function('', 'return "willnorris-20";'));

其他本地類型

Hum 預設僅註冊 b、t、a 和 p 前綴用於由 WordPress 本地提供。如果您想註冊其他前綴,請實現 hum_local_types 過濾器。例如,如果您還想註冊「p」以供照片使用:

function myplugin_hum_local_types( $types ) {
$types[] = 'p';
return $types;
}
add_filter('hum_local_types', 'myplugin_hum_local_types');

這將告訴 Hum 從 WordPress 服務任何 /p/{id} 的 URL。此外,您還需要指示 Hum 使用該特定內容類型的前綴。這裡,我們註冊了用於照片的「p」。

function myplugin_hum_type_prefix( $prefix, $post_id ) {
$post = get_post( $post_id );

if ( $post->post_type == 'attachment' &&
strpos($post->post_mime_type, 'image') === 0 ) {
$prefix = 'p';
}

return $prefix;
}
add_filter('hum_type_prefix', 'myplugin_hum_type_prefix', 10, 2);

簡單重定向

您可以使用一行 PHP 代碼來重定向屬於特定前綴的所有流量,只需實現 hum_redirect_base_{type} 過濾器,其中 {type} 是要重定向的前綴。例如,我把所有 /w/ 的 URL 重定向到 wiki.willnorris.com,使用以下代碼:

add_filter('hum_redirect_base_w',
create_function('', 'return "http://wiki.willnorris.com/";'));

原文外掛簡介

Hum is a personal URL shortener for WordPress, designed to provide short URLs to your personal content, both hosted on WordPress and elsewhere. For example, rather than a long URL for a WordPress post such as http://willnorris.com/2011/01/hum-personal-url-shortener-wordpress, you could have a short URL like http://willnorris.com/b/FJ. Additionally, if you have a custom domain for short URLs, you can shorten things further like http://wjn.me/b/FJ. Once the plugin is enabled, the shortlink for a page or post can be found in the “Shortlink” item in the WordPress Admin Bar.
WordPress post IDs are shortened using the NewBase60 encoding scheme which is specifically optimized for brevity and readability, with built-in error correction for commonly confused characters like ‘1’, ‘l’, and ‘I’.
Hum is not designed as a general purpose URL shortener along the lines of http://bit.ly or http://goo.gl. Rather, it is specifically intended as a personal shortener for your own content.
Read more about the reasoning for a personal URL shortener at Tantek Celik‘s page for Whistle, which served as the inspiration for Hum.
Developer Documentation
Adding your Amazon Affiliate ID
If you’d like to include your Amazone Affiliate ID in the /i/ redirect URLs, implement the amazon_affiliate_id filter. For example:
add_filter('amazon_affiliate_id', fn() => "willnorris-20");

Additional Local Types
Out of the box, Hum only registers the b, t, a and p prefix to be served locally by WordPress. If you would like to register additional prefixes, implement the hum_local_types filter. For example, to include ‘p’ as well for photos:
function myplugin_hum_local_types( $types ) {
$types[] = 'p';
return $types;
}
add_filter('hum_local_types', 'myplugin_hum_local_types');

This will tell Hum to serve any /p/{id} URLs from WordPress. Additionally, you’ll want to instruct Hum to use your prefix for that particular content type. Here, we’re registering ‘p’ which is normally used for photos.
function myplugin_hum_type_prefix( $prefix, $post_id ) {
$post = get_post( $post_id );

if ( $post->post_type ## 'attachment' &&
strpos($post->post_mime_type, 'image') =## 0 ) {
$prefix = 'p';
}

return $prefix;
}
add_filter('hum_type_prefix', 'myplugin_hum_type_prefix', 10, 2);

Simple Redirect
You can redirect all traffic for a prefix using a single line of PHP my implementing the hum_redirect_base_{type} filter where {type} is the prefix to redirect. For example, I redirect all /w/ URLs to wiki.willnorris.com using:
add_filter('hum_redirect_base_w', fn() => "http://wiki.willnorris.com/");

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Hum」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


1.0 | 1.1 | 1.2 | 1.2.1 | 1.2.2 | 1.2.3 | 1.2.4 | 1.2.5 | 1.2.6 | 1.2.7 | 1.2.8 | 1.3.0 | 1.3.1 | 1.3.2 | 1.3.3 | 1.3.4 | 1.3.5 | 1.3.6 | trunk |

延伸相關外掛(你可能也想知道)

暫無相關外掛推薦。

文章
Filter
Apply Filters
Mastodon