Make WordPress Core

Opened 15 years ago

Closed 11 years ago

Last modified 11 years ago

#12368 closed enhancement (invalid)

Allow setting limit in do_shortcode()

Reported by: abelcheung's profile 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 15 years ago.

Download all attachments as: .zip

Change History (6)

#1 @Denis-de-Bernardy
15 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.

#2 follow-up: @abelcheung
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 @Denis-de-Bernardy
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.

#4 @iseulde
11 years ago

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

No feedback in over three years.

#5 @DrewAPicture
11 years ago

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