#12368 closed enhancement (invalid)
Allow setting limit in do_shortcode()
Reported by: | abelcheung | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Shortcodes | Keywords: | reporter-feedback |
Focuses: | Cc: |
Description
Sometimes it is useful to limit the number of shortcode conversion occuring in do_shortcode(), such as preventing overuse of shortcode in untrusted content, or whatever reason. This patch adds a new int parameter to do_shortcode(), which is used as the $limit parameter in preg_replace_callback().
Attachments (1)
Change History (6)
#1
@
15 years ago
- Keywords reporter-feedback added; has-patch removed
- Milestone changed from Unassigned to Future Release
#2
follow-up:
↓ 3
@
15 years ago
In my plugin's case, it converts shortcode enclosed content into images, but the process is resource hungry and time consuming, so I want to limit number of instances of shortcode parsed, and print others as vanilla text. That's the primary reason of this patch.
Do you mean using a static counter to record number of shortcode instances already parsed?
#3
in reply to:
↑ 2
@
15 years ago
Replying to abelcheung:
Do you mean using a static counter to record number of shortcode instances already parsed?
pretty much exactly, yes.
I fail to see how the argument ever gets passed short of manually calling it in a function that overrides the shortcode function in the first place. in such a case, you might as well override this directly in your plugin.