The idea is that any objects embedded in a post’s content have their own home and should be seen as separate resources. Data would be stored elsewhere.
Examples
https://example.com/resources/contact-forms/email-ella/
https://example.com/resources/charts/php-versions-wordpress/
https://example.com/author/iseulde/
https://example.com/galleries/yummy-chocolates/
https://example.com/surveys/wordpress-editor-2016/
https://external.com/some-map-or-form/
Object Types
This approach could be good for:
- Forms such as contact forms, surveys and polls.
- Visualised data such as diagrams, charts, graphs and tables.
- Lists of items such as a galleries, playlists and lists of posts.
- Albums or manually composed collections of items where the presentation is uniquely different from a normal list.
- Any content that needs to be reused or organised separately. Anything that can be re-sourced. 😉
- Any external resources.
This is not good for:
- Layout.
- Text conversions.
Inspiration
- External embeds work similarly in WordPress through oEmbed.
- Images, audio and video are embedded by their URL in HTML.
- Media have their own “attachment” post type in WordPress.
- Many plugins already have a separate post type to store their data.
- I’ve seen some news media do this already for things for like graphs (post, resource).
Benefits
- A URL (or “link”) is a concept that is already familiar to many users.
- URIs are designed for these sort of things. Think about images — it would follow the same paradigm.
- The content is treated as a separate resource, and can be reused, just like shortcodes, but it forces separation.
- WordPress allows you to create “pretty” semantic URIs, so the resource can be described for a better experience.
- A cool side effect is that others could embed these easily on their site through oEmbed. WordPress already supports this.
- If there’s a problem, the URL will act as a fallback.
Implementation
A quick way to implement this for WordPress 4.4 and higher is registering a new post type. This will handle most things, you just need to provide a custom embed template with the template_include filter. An external resource can be filtered with the Embed API and TinyMCE View API, even if it doesn’t support oEmbed.
Challenge: Variants and Settings
Either each variant of an resource needs its own ID, or settings could be passed with a query string. I think the use of settings should be minimised — for example, columns for a gallery object may be better set per ID. Settings can certainly be useful for things like autoplay, for example YouTube allows you to set the start time.
Challenge: Alignment
This is great if the URL is added on a separate line, but aligning the object is not evident. This is a challenge for shortcodes too. At the moment the core galery shortcode does not allow you to allign it, and the caption shortcode has an attribute for it. Similarly the URl could have a query parameter for alignment, but that doesn’t sound ideal. Alternatively the paragraph could be floated, or it needs to be wrapped in a `div` element to float mid-text. Another approach is to always wrap the URLs in a (custom) tag that can have display information. Again, think about how images are embedded in HTML.
Challenge: Namespace
Shortcodes would have a similar problem, though slug clashes are probably more likely. Ideally plugins should use their own prefix, but this may be seen as ugly. Another way to avoid clashes with other post types is a sub type for “attachments” or “resources”.
Challenge: Extra Queries
I don’t see this exactly as a challenge, as it’s the nature of the concept, but it may be used as an argument against it. Many shortcodes already make use of custom post types to store data and embedding media (or anything else) also requires extra queries. If and how this should be cached is another problem.
I would love to hear your thoughts on this alternative, especially from those who use shortcodes for this type of objects in the post content. If you already use a custom post type, why not take advantage of embedding instead of creating shortcodes? If you want to embed external resources, why wrap it in a shortcode?
If you have other alternatives, I’d love to hear about those too!
dMpmJ 9:38 pm on December 28, 2016 Permalink | Log in to Reply
Please add a capital_H_dangit filter to wp.org to fix misspellings of “GitHub”
Ipstenu (Mika Epstein) 9:39 pm on December 28, 2016 Permalink | Log in to Reply
👍🏾 – I’m glad to see the future is ongoing for this.
Mustafa Uysal 9:40 pm on December 28, 2016 Permalink | Log in to Reply
Great news! 👏
David Bisset 9:40 pm on December 28, 2016 Permalink | Log in to Reply
VERY happy to hear. This is a win-win for all.
Jami Gibbs 9:41 pm on December 28, 2016 Permalink | Log in to Reply
Fantastic news!
Austin Passy 9:42 pm on December 28, 2016 Permalink | Log in to Reply
Wow, awesome!
Guga Alves 9:42 pm on December 28, 2016 Permalink | Log in to Reply
Really great news, I’m glad to see it happen!
LewisCowles 9:42 pm on December 28, 2016 Permalink | Log in to Reply
Pretty much WOW. I get it!
Borek Bernard 9:49 pm on December 28, 2016 Permalink | Log in to Reply
Great news for the project! Will it stay on GitHub?
Daniel Bachhuber 9:50 pm on December 28, 2016 Permalink | Log in to Reply
Yep. WP-CLI and its’ future packages will be on Github for the foreseeable future.
Chad Butler 9:49 pm on December 28, 2016 Permalink | Log in to Reply
Awesome!! That is fantastic news!
Nashwan Doaqan 9:53 pm on December 28, 2016 Permalink | Log in to Reply
Great news! .. and nice support for WP-CLI.
Thanks Matt and everyone. 🙂
davidshq 10:21 pm on December 28, 2016 Permalink | Log in to Reply
Great news!
Henry Wright 10:27 pm on December 28, 2016 Permalink | Log in to Reply
Fantastic news 😀
Philip Ingram 10:38 pm on December 28, 2016 Permalink | Log in to Reply
Thanks for the wonderful news Matt and team! WP-CLI has become indispensable to my tool set and workflow!
Chuck Reynolds 10:54 pm on December 28, 2016 Permalink | Log in to Reply
BOOM! yesssss. I was hoping this would maybe happen after the fundraising questions… It makes complete sense and I’m stoked to see it happening. Good move Matt. And thanks again Daniel Bachhuber for WP-CLI.
Carry on.
rclilly 10:55 pm on December 28, 2016 Permalink | Log in to Reply
Yay! I’m really glad to see that wp-cli’s future is now more secure and that Daniel will be able to afford to be able to continue to shepherd its development.
John James Jacoby 11:03 pm on December 28, 2016 Permalink | Log in to Reply
This is really great news, all around. Very pleased to see this.
Sérgio Santos 11:15 pm on December 28, 2016 Permalink | Log in to Reply
Wow, awesome news!
mcdwayne 11:16 pm on December 28, 2016 Permalink | Log in to Reply
Very exciting news! Good stuff, congrats.
danhgilmore 11:56 pm on December 28, 2016 Permalink | Log in to Reply
This makes me very very happy…If you need a WordPress dev forced to use Windows for testing, lemme know 😉
Luke Cavanagh 12:05 am on December 29, 2016 Permalink | Log in to Reply
This is awesome news.
Joey Kudish 12:23 am on December 29, 2016 Permalink | Log in to Reply
This is awesome. Great news for the project!
Mizner 1:42 am on December 29, 2016 Permalink | Log in to Reply
Thank you Daniel Bachhuber for all the work, and thank you Matt and the team for taking it on!
Jack Wu 2:15 am on December 29, 2016 Permalink | Log in to Reply
So happy to see this!
jteague 3:44 am on December 29, 2016 Permalink | Log in to Reply
Wonderful news. Great for everyone involved. GEMServers will lend support for this. Please let me know how we can help.
evisiontheme 4:29 am on December 29, 2016 Permalink | Log in to Reply
wow! great to hear 🙂 Awesome for all!
Mustaasam Saleem 7:12 am on December 29, 2016 Permalink | Log in to Reply
Glad to hear that!
Sounds like WordPress will cross 27% 😉
Joseph 7:21 am on December 29, 2016 Permalink | Log in to Reply
Great news
Rene Hermenau 7:25 am on December 29, 2016 Permalink | Log in to Reply
Excellent. Have a pleasant holiday!
Collizo4sky 7:50 am on December 29, 2016 Permalink | Log in to Reply
Great news. Thanks Matt for doing this.
Florian TIAR 9:09 am on December 29, 2016 Permalink | Log in to Reply
Great news
Martin Sotirov 9:18 am on December 29, 2016 Permalink | Log in to Reply
That’s great news but how about moving WP core to git instead of other git projects to svn? It’s almost 2017 after all.
Aaron Jorbin 5:01 pm on December 29, 2016 Permalink | Log in to Reply
Git mirrors have been available for just shy of three years. You do not need to use SVN to submit a patch to WordPress core.
Daniel Bachhuber 5:01 pm on December 29, 2016 Permalink | Log in to Reply
Just to clarify, WP-CLI will remain in Git.
yivi 10:54 am on December 29, 2016 Permalink | Log in to Reply
Will wp-cli be distributed alongside with WP as well? I’m on two minds about this. On one part I mostly use wp-cli as a system command, so having one copy per wp installation wouldn’t gel greatly with that workflow… but on the other hand having the tool featured by default more or less prominently to as many devs as possible couldn’t be a bad thing.
Daniel Bachhuber 5:03 pm on December 29, 2016 Permalink | Log in to Reply
No plans to include WP-CLI in WordPress directly. WP-CLI only needs to be installed once per system, works great across multiple WordPress installs, and even works independently of WordPress (e.g.
wp core download)Thierry Pigot 11:21 am on December 29, 2016 Permalink | Log in to Reply
Awesome!
Demian Seiler 3:27 pm on December 29, 2016 Permalink | Log in to Reply
Fantastic news!
Ahmad Awais 8:05 pm on December 29, 2016 Permalink | Log in to Reply
This is such a great move. Much deserved David, and one of the best projects I must add. Looking forward to contribute.
Ahmad Awais 8:08 pm on December 29, 2016 Permalink | Log in to Reply
Not sure, what I was thinking when I wrote, David instead of Daniel. It’s 1AM that must be it.
Shawn Hooper 7:06 am on December 30, 2016 Permalink | Log in to Reply
This is fantastic news!