[wp-trac] [WordPress Trac] #33473: Shortcodes + Widgets. Unified "component" API

WordPress Trac noreply at wordpress.org
Thu Aug 20 21:53:58 UTC 2015


#33473: Shortcodes + Widgets. Unified "component" API
-----------------------------+-----------------------------
 Reporter:  brentjett@…      |      Owner:
     Type:  feature request  |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Themes           |    Version:
 Severity:  normal           |   Keywords:
  Focuses:  template         |
-----------------------------+-----------------------------
 Looking ahead and seeing that Shortcake is getting a lot of support, I've
 noticed that shortcodes and widgets are beginning to look fundamentally
 the same. They are both view components that express some sort of input
 fields for dynamic "instance" data. So I'm wondering what the general
 feeling would be toward a unified "Component" API.

 Lets say you're a designer implementing a theme and you have a stylized
 block for displaying an author. At times you might want to express that in
 a sidebar, and other times you might want to use it inline in page
 content. The HTML output is fundamentally the same, and differences only
 deal with where the input data is coming from (shortcode attrs vs. widget
 data) and minor presentational differences based on context. This could be
 very simply expressed as a single class or function pattern that does the
 work of registering the shortcode and widget under the hood for you. A
 client or someone downloading a theme often won't know that they want a
 component to work inside a sidebar or inside the content until they
 realize it isn't available.

 The benefit of a unified API is that you double the usable components you
 have to work with. There are great developers making widget bundles and
 other great developers making shortcodes, but not many doing both. All
 this to say, it's actually pretty straightforward to implement a class
 version of this API that handles registering both types of object for you.
 I have a working version of this in a plugin already. I'm just curious if
 anyone else thinks this is a problem worth pursuing. Thoughts?

 Aside: You could make a case that template parts aren't all that different
 from shortcodes and widgets and might also benefit from input fields
 (customizer anyone?), at which point you'd have a component that could
 truly go anywhere.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/33473>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list