{"id":87725,"date":"2011-01-27T08:00:00","date_gmt":"2011-01-27T08:00:00","guid":{"rendered":"https:\/\/www.weixiaoduo.com\/plugins\/2024\/02\/22\/hum\/"},"modified":"2024-11-17T20:06:00","modified_gmt":"2024-11-17T20:06:00","slug":"hum","status":"publish","type":"post","link":"https:\/\/www.weixiaoduo.com\/plugins\/hum\/","title":{"rendered":"Hum"},"content":{"rendered":"<p>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 <a href=\"http:\/\/willnorris.com\/2011\/01\/hum-personal-url-shortener-wordpress\" rel=\"nofollow ugc\">http:\/\/willnorris.com\/2011\/01\/hum-personal-url-shortener-wordpress<\/a>, you could have a short URL like <a href=\"http:\/\/willnorris.com\/b\/FJ\" rel=\"nofollow ugc\">http:\/\/willnorris.com\/b\/FJ<\/a>.  Additionally, if you have a custom domain for short URLs, you can shorten things further like <a href=\"http:\/\/wjn.me\/b\/FJ\" rel=\"nofollow ugc\">http:\/\/wjn.me\/b\/FJ<\/a>.  Once the plugin is enabled, the shortlink for a page or post can be found in the \u201cShortlink\u201d item in the WordPress Admin Bar.<\/p>\n<p>WordPress post IDs are shortened using the <a href=\"http:\/\/ttk.me\/w\/NewBase60\" rel=\"nofollow ugc\">NewBase60<\/a> encoding scheme which is specifically optimized for brevity and readability, with built-in error correction for commonly confused characters like \u20181\u2019, \u2018l\u2019, and \u2018I\u2019.<\/p>\n<p>Hum is not designed as a general purpose URL shortener along the lines of <a href=\"http:\/\/bit.ly\" rel=\"nofollow ugc\">http:\/\/bit.ly<\/a> or <a href=\"http:\/\/goo.gl\" rel=\"nofollow ugc\">http:\/\/goo.gl<\/a>.  Rather, it is specifically intended as a personal shortener for your own content.<\/p>\n<p>Read more about the reasoning for a personal URL shortener at <a href=\"http:\/\/tantek.com\/\" rel=\"nofollow ugc\">Tantek Celik<\/a>\u2018s page for <a href=\"http:\/\/ttk.me\/w\/Whistle\" rel=\"nofollow ugc\">Whistle<\/a>, which served as the inspiration for Hum.<\/p>\n<h3>Developer Documentation<\/h3>\n<h3>Adding your Amazon Affiliate ID<\/h3>\n<p>If you\u2019d like to include your Amazone Affiliate ID in the <code>\/i\/<\/code> redirect URLs, implement the <code>amazon_affiliate_id<\/code> filter.  For example:<\/p>\n<pre><code>add_filter('amazon_affiliate_id', fn() => \"willnorris-20\");\n<\/code><\/pre>\n<h3>Additional Local Types<\/h3>\n<p>Out of the box, Hum only registers the <code>b<\/code>, <code>t<\/code>, <code>a<\/code> and <code>p<\/code> prefix to be served locally by WordPress.  If you would like to register additional prefixes, implement the <code>hum_local_types<\/code> filter.  For example, to include \u2018p\u2019 as well for photos:<\/p>\n<pre><code>function myplugin_hum_local_types( $types ) {\n  $types[] = 'p';\n  return $types;\n}\nadd_filter('hum_local_types', 'myplugin_hum_local_types');\n<\/code><\/pre>\n<p>This will tell Hum to serve any <code>\/p\/{id}<\/code> URLs from WordPress.  Additionally, you\u2019ll want to instruct Hum to use your prefix for that particular content type.  Here, we\u2019re registering \u2018p\u2019 which is normally used for photos.<\/p>\n<pre><code>function myplugin_hum_type_prefix( $prefix, $post_id ) {\n  $post = get_post( $post_id );\n\n  if ( $post->post_type ## 'attachment' &&\n       strpos($post->post_mime_type, 'image') =## 0 ) {\n    $prefix = 'p';\n  }\n\n  return $prefix;\n}\nadd_filter('hum_type_prefix', 'myplugin_hum_type_prefix', 10, 2);\n<\/code><\/pre>\n<h3>Simple Redirect<\/h3>\n<p>You can redirect all traffic for a prefix using a single line of PHP my implementing the <code>hum_redirect_base_{type}<\/code> filter where <code>{type}<\/code> is the prefix to redirect.  For example, I redirect all <code>\/w\/<\/code> URLs to wiki.willnorris.com using:<\/p>\n<pre><code>add_filter('hum_redirect_base_w', fn() => \"http:\/\/wiki.willnorris.com\/\");\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Personal URL shortener for WordPress<\/p>\n","protected":false},"author":65,"featured_media":290907,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"Hum - \u8587\u6653\u6735\u63d2\u4ef6\u76ee\u5f55","description":"Personal URL shortener for WordPress"},"footnotes":""},"categories":[1],"tags":[25694,2129,25695],"class_list":["post-87725","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-diso","tag-shortlink","tag-whistle"],"_links":{"self":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts\/87725","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/comments?post=87725"}],"version-history":[{"count":0,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts\/87725\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/media\/290907"}],"wp:attachment":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/media?parent=87725"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/categories?post=87725"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/tags?post=87725"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}