X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/c46e6dd20c438dddfea40c35935b877ac3e67daa..e0feb3b2e5b436a06bbb04fbc838d1cd6ec95399:/wp-includes/shortcodes.php diff --git a/wp-includes/shortcodes.php b/wp-includes/shortcodes.php index 2661201b..c63958b1 100644 --- a/wp-includes/shortcodes.php +++ b/wp-includes/shortcodes.php @@ -81,16 +81,14 @@ $shortcode_tags = array(); * * @since 2.5.0 * - * @uses $shortcode_tags + * @global array $shortcode_tags * - * @param string $tag Shortcode tag to be searched in post content. + * @param string $tag Shortcode tag to be searched in post content. * @param callable $func Hook to run when shortcode is found. */ function add_shortcode($tag, $func) { global $shortcode_tags; - - if ( is_callable($func) ) - $shortcode_tags[$tag] = $func; + $shortcode_tags[ $tag ] = $func; } /** @@ -98,7 +96,7 @@ function add_shortcode($tag, $func) { * * @since 2.5.0 * - * @uses $shortcode_tags + * @global array $shortcode_tags * * @param string $tag Shortcode tag to remove hook for. */ @@ -117,7 +115,7 @@ function remove_shortcode($tag) { * * @since 2.5.0 * - * @uses $shortcode_tags + * @global array $shortcode_tags */ function remove_all_shortcodes() { global $shortcode_tags; @@ -210,10 +208,10 @@ function do_shortcode( $content, $ignore_html = false ) { $pattern = get_shortcode_regex(); $content = preg_replace_callback( "/$pattern/s", 'do_shortcode_tag', $content ); - + // Always restore square braces so we don't break things like is found. - . '-(?!->)' // Dash not followed by end of comment. - . '[^\-]*+' // Consume non-dashes. - . ')*+' // Loop possessively. - . '(?:-->)?'; // End of comment. If not found, match all input. - - $regex = - '/(' // Capture the entire match. - . '<' // Find start of element. - . '(?(?=!--)' // Is this a comment? - . $comment_regex // Find end of comment. - . '|' - . '[^>]*>?' // Find end of element. If not found, match all input. - . ')' - . ')/s'; - - $textarr = preg_split( $regex, $content, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ); + $pattern = get_shortcode_regex(); + $textarr = wp_html_split( $content ); foreach ( $textarr as &$element ) { - if ( '<' !== $element[0] ) { + if ( '' == $element || '<' !== $element[0] ) { continue; } @@ -365,7 +351,7 @@ function do_shortcodes_in_html_tags( $content, $ignore_html ) { continue; } - if ( $ignore_html || '