WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 19 months ago

#20659 new feature request

Document available shortcodes in eg. new post page

Reported by: voxpelli Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Shortcodes Keywords:
Focuses: Cc:

Description

It would be useful if a plugin defining shortcodes also could describe the usecase for the shortcode and the available attributes and the usecases for those attributes in a way that could be exposed in the interface on eg. the new post page.

One could take inspiration from eg. the Drupal Token module which has a token_list() hook that a Drupal module uses to describe every token it describes so that they can be presented to the user in the interface.

Something like:

add_shortcode_description('shortcodename')

That returns something like this would be nice:

array(
  'description' => 'This is used to do foo',
  'attr' => array(
    'bar' => 'A text that will be presented as bar'
  ),
);

Attachments (1)

wp-shortcode-desc-1.patch (4.3 KB) - added by voxpelli 3 years ago.
Sketch of what an implementation of something like this could look codewise - interface not worked on and code not complete

Download all attachments as: .zip

Change History (9)

comment:1 follow-up: @scribu3 years ago

This would be useful only if we actually show it somewhere in the UI. Shortcodes are just magic strings, at the moment.

comment:2 in reply to: ↑ 1 @nacin3 years ago

Replying to scribu:

This would be useful only if we actually show it somewhere in the UI. Shortcodes are just magic strings, at the moment.

Agreed. This is a nice idea, however.

comment:3 @helenyhou3 years ago

Maybe a consolidated tab in contextual help?

comment:4 @DrewAPicture3 years ago

  • Cc xoodrew@… added

@voxpelli3 years ago

Sketch of what an implementation of something like this could look codewise - interface not worked on and code not complete

comment:5 @bananastalktome3 years ago

  • Cc bananastalktome@… added

Confluence (a product by Atlassian) does an interesting job with presenting shortcodes (they call them macros) to users through their WYSIWYG editor. I'm not affiliated/associated/even really care much for Atlassian, I just have used Confluence and rather enjoy the way they deal with shortcodes.

I'd be glad to follow up this comment with a description and/or screenshots, but I am not sure if doing so would introduce any legal issues for WordPress (I am rather naive when it comes to these things) or if it would even be helpful here.

comment:6 @helen19 months ago

I thought this was pretty interesting, maybe worth exploring in conjunction with the awesome TinyMCE 4 update in 3.9: https://github.com/scottsweb/shortcode-suggest/

comment:7 @ircbot19 months ago

This ticket was mentioned in IRC in #wordpress-dev by helen. View the logs.

Note: See TracTickets for help on using tickets.