Ticket #10490: shortcodes_wpautop_patch_2009_07_26.diff
File shortcodes_wpautop_patch_2009_07_26.diff, 2.2 KB (added by , 14 years ago) |
---|
-
wp-includes/shortcodes.php
175 175 $tagnames = array_keys($shortcode_tags); 176 176 $tagregexp = join( '|', array_map('preg_quote', $tagnames) ); 177 177 178 return '(.?)\[('.$tagregexp.')\b( .*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)';178 return '(.?)\[('.$tagregexp.')\b([^\]]*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)'; 179 179 } 180 180 181 181 /** 182 * Retrieve the shortcode regular expression for searching for start tag only. 183 * 184 * @uses $shortcode_tags 185 * 186 * @return string The shortcode start tag search regular expression 187 */ 188 function get_shortcode_start_regex() { 189 global $shortcode_tags; 190 $tagnames = array_keys($shortcode_tags); 191 $tagregexp = join( '|', array_map('preg_quote', $tagnames) ); 192 193 return '\[('.$tagregexp.')\b([^\]]*?)(?:(\/))?\]'; 194 } 195 196 /** 197 * Retrieve the shortcode regular expression for searching for end tag only. 198 * 199 * @uses $shortcode_tags 200 * 201 * @return string The shortcode end tag search regular expression 202 */ 203 function get_shortcode_end_regex() { 204 global $shortcode_tags; 205 $tagnames = array_keys($shortcode_tags); 206 $tagregexp = join( '|', array_map('preg_quote', $tagnames) ); 207 208 return '\[\/('.$tagregexp.')\]'; 209 } 210 211 /** 182 212 * Regular Expression callable for do_shortcode() for calling shortcode hook. 183 213 * @see get_shortcode_regex for details of the match array contents. 184 214 * -
wp-includes/formatting.php
170 170 if (strpos($pee, '<pre') !== false) 171 171 $pee = preg_replace_callback('!(<pre[^>]*>)(.*?)</pre>!is', 'clean_pre', $pee ); 172 172 $pee = preg_replace( "|\n</p>$|", '</p>', $pee ); 173 $pee = preg_replace('/<p>\s*?(' . get_shortcode_regex() . ')\s*<\/p>/s', '$1', $pee); // don't auto-p wrap shortcodes that stand alone 173 $pee = preg_replace('/<p>\s*?(' . get_shortcode_start_regex() . ')\s*<\/p>/s', '$1', $pee); // don't auto-p wrap shortcodes that stand alone 174 $pee = preg_replace('/<p>\s*?(' . get_shortcode_end_regex() . ')\s*<\/p>/s', '$1', $pee); // check both start and end tags 174 175 175 176 return $pee; 176 177 }