| @@ -768,8 +768,34 @@ | ||
| 768 | 768 | return is_scalar($var) ? sanitize_text_field(wp_unslash($var)) : $var; |
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | /** |
| 772 | + * Strips shortcodes from a string repeatedly until the output stops changing, so nested | |
| 773 | + * shortcode syntax is fully removed rather than only partially reduced by a single pass. | |
| 774 | + * | |
| 775 | + * @since 4.16.9 | |
| 776 | + * | |
| 777 | + * @param string $content Content that may contain shortcode syntax. | |
| 778 | + * | |
| 779 | + * @return string Content with registered shortcodes removed. | |
| 780 | + */ | |
| 781 | +function give_strip_shortcodes_deep($content): string | |
| 782 | +{ | |
| 783 | + $content = (string) $content; | |
| 784 | + | |
| 785 | + if ('' === $content || false === strpos($content, '[')) { | |
| 786 | + return $content; | |
| 787 | + } | |
| 788 | + | |
| 789 | + do { | |
| 790 | + $previous = $content; | |
| 791 | + $content = strip_shortcodes($content); | |
| 792 | + } while ($content !== $previous); | |
| 793 | + | |
| 794 | + return $content; | |
| 795 | +} | |
| 796 | + | |
| 797 | +/** | |
| 772 | 798 | * Transforms php.ini notation for numbers (like '2M') to an integer. |
| 773 | 799 | * |
| 774 | 800 | * @since 1.8 |
| 775 | 801 | * |