WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 2 years ago

Last modified 2 years ago

#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)

shortcode-limit.patch (978 bytes) - added by abelcheung 5 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 @Denis-de-Bernardy5 years ago

  • Keywords reporter-feedback added; has-patch removed
  • Milestone changed from Unassigned to Future Release

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.

comment:2 follow-up: @abelcheung5 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?

comment:3 in reply to: ↑ 2 @Denis-de-Bernardy5 years ago

Replying to abelcheung:

Do you mean using a static counter to record number of shortcode instances already parsed?

pretty much exactly, yes.

comment:4 @iseulde2 years ago

  • Resolution set to invalid
  • Status changed from new to closed

No feedback in over three years.

comment:5 @DrewAPicture2 years ago

  • Milestone Future Release deleted
Note: See TracTickets for help on using tickets.