WordPress.org

Make WordPress Core

Opened 4 months ago

Last modified 4 months ago

#47616 new enhancement

Enhancement: doing_shortcode() function similar to doing_filter()

Reported by: keraweb Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Shortcodes Keywords: has-patch
Focuses: Cc:
PR Number:

Description

Currently there is no way to determine whether the current code is run from a shortcode callback.
Similar to actions and filters it would be nice to have a doing_shortcode() function.

My idea is to have an optional parameter for the shortcode tag.
If the parameter is passed it will check if that exact shortcode is running.
If no parameter is passed it will return true if any shortcode is running.

Though I believe it's not officially supported, if shortcodes are triggered within shortcodes it would be best to keep an array of current shortcodes and only remove an active shortcode tag if the callback is finished.

Attachments (1)

47616.patch (2.9 KB) - added by keraweb 4 months ago.
Add doing_shortcode() and current_shortcode() functions

Download all attachments as: .zip

Change History (3)

@keraweb
4 months ago

Add doing_shortcode() and current_shortcode() functions

#1 @keraweb
4 months ago

  • Keywords has-patch added

#2 @afercia
4 months ago

  • Focuses accessibility removed

Removing the accessibility focus, as seems to me this issue is not related to web content accessibility. Please do feel free to re-add it if I'm missing something.

Note: See TracTickets for help on using tickets.