PluginProbe
Hum / trunk
Hum vtrunk
trunk 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
hum / readme.md

readme.md in Hum trunk, at readme.md

239 lines 8.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 # Hum
2
3 - Contributors: willnorris, pfefferle
4 - Tags: shortlink, whistle, diso
5 - Requires at least: 3.0
6 - Tested up to: 7.1
7 - Stable tag: 1.3.6
8 - Requires PHP: 7.4
9 - License: MIT
10 - License URI: http://opensource.org/licenses/MIT
11
12 Personal URL shortener for WordPress
13
14
15 ## Description
16
17 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.
18
19
20 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'.
21
22 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.
23
24 Read more about the reasoning for a personal URL shortener at [Tantek Celik][]'s page for [Whistle][], which served as the inspiration for Hum.
25
26 [NewBase60]: http://ttk.me/w/NewBase60
27 [Tantek Celik]: http://tantek.com/
28 [Whistle]: http://ttk.me/w/Whistle
29
30
31 ## Installation
32
33 Follow the normal instructions for [installing WordPress plugins][install].
34
35 [install]: http://codex.wordpress.org/Managing_Plugins#Installing_Plugins
36
37 ### Using a custom domain
38
39 If you have a custom domain you'd like to use with Hum, add it as the 'Shortlink Base (URL)' on the 'General Settings' WordPress admin page or define the `HUM_SHORTLINK_BASE` constant in your `wp-config.php`:
40
41 define('HUM_SHORTLINK_BASE', 'http://wjn.me');
42
43 You will also need to setup your short domain to redirect to your normal domain. Many domain registrars provide free redirection services that work well for this, so you don't need to setup a new domain with your web host. Just make sure that you are **not** using an iframe style redirect.
44
45
46 ## Frequently Asked Questions
47
48 ### What types of content does Hum support?
49
50 Out of the box, Hum will provide shortlinks for any content locally hosted on WordPress. Most shortlinks will use the `b` type prefix, with the exception of posts with a 'status' [post format][], which have shortlinks using the `t` type prefix. For example:
51
52 - <http://wjn.me/b/FJ>
53 - <http://wjn.me/t/FR>
54
55 Additionally, the `i` type prefix, along with one of four subtypes, is supported as follows:
56
57 - `asin` or `a` for Amazon ASIN numbers
58 - `isbn` or `i` for ISBN numbers
59
60 All `i` URLs are redirected to Amazon.com. For example:
61
62 - <http://wjn.me/i/a/B003QP4NPE>
63
64 Additional type prefixes can be registered to serve WordPress hosted content or to redirect to an external service. See more in the developer documentation.
65
66 [post format]: http://codex.wordpress.org/Post_Formats
67
68 ### Redirects are not working and result in a 404.
69
70 This can happen if the rewrite rules were not flushed. This most likely happens if you are using Hum on a Multisite. This can be fixed by flushing the rewrite rules, just go to Settings->Permalinks and hit `Save Changes` on each instance where Hum does not work as intended.
71
72
73 ## Developer Documentation
74
75 ### Adding your Amazon Affiliate ID
76
77 If you'd like to include your Amazone Affiliate ID in the `/i/` redirect URLs, implement the `amazon_affiliate_id` filter. For example:
78
79 add_filter('amazon_affiliate_id', fn() => "willnorris-20");
80
81 ### Additional Local Types
82
83 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:
84
85 function myplugin_hum_local_types( $types ) {
86 $types[] = 'p';
87 return $types;
88 }
89 add_filter('hum_local_types', 'myplugin_hum_local_types');
90
91 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.
92
93 function myplugin_hum_type_prefix( $prefix, $post_id ) {
94 $post = get_post( $post_id );
95
96 if ( $post->post_type ## 'attachment' &&
97 strpos($post->post_mime_type, 'image') =## 0 ) {
98 $prefix = 'p';
99 }
100
101 return $prefix;
102 }
103 add_filter('hum_type_prefix', 'myplugin_hum_type_prefix', 10, 2);
104
105 ### Simple Redirect
106
107 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:
108
109 add_filter('hum_redirect_base_w', fn() => "http://wiki.willnorris.com/");
110
111
112 ## Changelog
113
114 Project maintined on github at [](https://github.com/willnorris/wordpress-humwillnorris/wordpress-hum](https://github.com/willnorris/wordpress-hum](https://github.com/willnorris/wordpress-hum).
115
116 ### 1.3.6
117
118 - optimized Block Editor integration
119
120 ### 1.3.5
121
122 - update JS dependencies and code
123
124 ### 1.3.4
125
126 - fix broken `wp_get_shortlink` hook, when loaded in the frontend
127
128 ### 1.3.3
129
130 - fix PHP warning in combination with widgets
131
132 ### 1.3.2
133
134 - update documentation
135
136 ### 1.3.1
137
138 - change the priority of the rewrite rules action
139
140 ### 1.3.0
141
142 - redirect types are now also filterable
143
144 ### 1.2.8
145
146 - add shortlink panel to block editor (props [@florianbrinkmann][])
147
148 ### 1.2.7
149
150 - redirect only known types (see [#wp180868][])
151
152 [](https://github.com/willnorris/wordpress-hum/compare/1.2.6...1.2.7full changelog](https://github.com/willnorris/wordpress-hum/compare/1.2.6...1.2.7](https://github.com/willnorris/wordpress-hum/compare/1.2.6...1.2.7)
153
154 ### 1.2.6
155
156 - fix PHP 7.4 deprecation warning
157 - WordPress coding style changes
158
159 [](https://github.com/willnorris/wordpress-hum/compare/1.2.5...1.2.6full changelog](https://github.com/willnorris/wordpress-hum/compare/1.2.5...1.2.6](https://github.com/willnorris/wordpress-hum/compare/1.2.5...1.2.6)
160
161 ### 1.2.5
162
163 - add shortlink to post/page overview pages
164
165 [](https://github.com/willnorris/wordpress-hum/compare/1.2.4...1.2.5full changelog](https://github.com/willnorris/wordpress-hum/compare/1.2.4...1.2.5](https://github.com/willnorris/wordpress-hum/compare/1.2.4...1.2.5)
166
167 ### 1.2.4
168
169 - finally fixed "flush rewrite rules"
170
171 [](https://github.com/willnorris/wordpress-hum/compare/1.2.3...1.2.4full changelog](https://github.com/willnorris/wordpress-hum/compare/1.2.3...1.2.4](https://github.com/willnorris/wordpress-hum/compare/1.2.3...1.2.4)
172
173 ### 1.2.3
174
175 - fixed "flush rewrite rules"
176
177 [](https://github.com/willnorris/wordpress-hum/compare/1.2.2...1.2.3full changelog](https://github.com/willnorris/wordpress-hum/compare/1.2.2...1.2.3](https://github.com/willnorris/wordpress-hum/compare/1.2.2...1.2.3)
178
179 ### 1.2.2
180
181 - version bump
182
183 [](https://github.com/willnorris/wordpress-hum/compare/1.2.1...1.2.2full changelog](https://github.com/willnorris/wordpress-hum/compare/1.2.1...1.2.2](https://github.com/willnorris/wordpress-hum/compare/1.2.1...1.2.2)
184
185 ### 1.2.1
186
187 - add `amazon_domain` filter, to support different countries
188 - add `hum_process_redirect` action, to overwrite default rewrite method (see [#17][])
189
190 [](https://github.com/willnorris/wordpress-hum/compare/1.2...1.2.1full changelog](https://github.com/willnorris/wordpress-hum/compare/1.2...1.2.1](https://github.com/willnorris/wordpress-hum/compare/1.2...1.2.1)
191
192 ### 1.2
193
194 - move link post format to use 't' prefix instead of 'h' and add support for
195 image post format
196 - add support for WordPress media attachments
197 - add shortlinks to Atom feeds
198 - add support for legacy short url schemes (see [#6][])
199 - switch to using WordPress filters instead of actions for hum extensions (see
200 [#3][])
201
202 [](https://github.com/willnorris/wordpress-hum/compare/1.1...1.2full changelog](https://github.com/willnorris/wordpress-hum/compare/1.1...1.2](https://github.com/willnorris/wordpress-hum/compare/1.1...1.2)
203
204 ### 1.1
205
206 - allow custom domain to be configured using `HUM_SHORTLINK_BASE` constant or
207 via the General Settings admin page.
208 - strip some punctuation at the end of URLs (see [#4][])
209 - smarter URL matching (see [#1][] and [#2][])
210 - add support for `/i/` URLs (redirects to Amazon for ASIN or ISBN
211 identifiers, optionally including an Amazon affiliate ID)
212 - standard 404 handling if hum can't find a proper redirect
213 - add new `hum_local_types` filter for registering other prefixes thatt are
214 served locally by WordPress
215 - reduce extra redirect for local content
216
217 [](https://github.com/willnorris/wordpress-hum/compare/1.0...1.1full changelog](https://github.com/willnorris/wordpress-hum/compare/1.0...1.1](https://github.com/willnorris/wordpress-hum/compare/1.0...1.1)
218
219 [#1]: https://github.com/willnorris/wordpress-hum/issues/1
220 [#2]: https://github.com/willnorris/wordpress-hum/issues/2
221 [#3]: https://github.com/willnorris/wordpress-hum/issues/3
222 [#4]: https://github.com/willnorris/wordpress-hum/issues/4
223 [#6]: https://github.com/willnorris/wordpress-hum/issues/6
224 [#17]: https://github.com/willnorris/wordpress-hum/pull/17
225 [#wp180868]: https://wordpress.org/support/topic/causing-404-on-category-tag-pages/
226 [@florianbrinkmann]: https://profiles.wordpress.org/florianbrinkmann/
227
228 ### 1.0
229
230 - initial public release
231
232
233 ## Upgrade Notice
234
235 ### 1.1
236
237 Adds a new admin UI for setting a custom domain for shortlinks, includes
238 smarter URL matching, and adds various small improvements and bug fixes.
239