Changeset 7814
- Timestamp:
- 04/25/2008 12:43:44 AM (18 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 3 edited
-
formatting.php (modified) (3 diffs)
-
media.php (modified) (4 diffs)
-
shortcodes.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/formatting.php
r7699 r7814 27 27 $curl = $textarr[$i]; 28 28 29 if (isset($curl{0}) && '<' != $curl{0} && '[' != $curl{0} && $next) { // If it's not a tag or shortcode29 if (isset($curl{0}) && '<' != $curl{0} && '[' != $curl{0} && $next) { // If it's not a tag 30 30 // static strings 31 31 $curl = str_replace($static_characters, $static_replacements, $curl); … … 75 75 $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end 76 76 $pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace 77 $pee = preg_replace('/<p>(\s*?' . get_shortcode_regex(true) . '\s*)<\/p>/s', '$1', $pee); // don't auto-p wrap post-formatting shortcodes78 77 $pee = preg_replace('!<p>([^<]+)\s*?(</(?:div|address|form)[^>]*>)!', "<p>$1</p>$2", $pee); 79 78 $pee = preg_replace( '|<p>|', "$1<p>", $pee ); … … 842 841 $text = apply_filters('the_content', $text); 843 842 $text = str_replace(']]>', ']]>', $text); 844 $text = preg_replace('|//\s*<!\[CDATA\[|', '<![CDATA[', $text);845 843 $text = strip_tags($text); 846 844 $excerpt_length = 55; -
trunk/wp-includes/media.php
r7703 r7814 288 288 if ( is_array($size) || empty($size) || empty($imagedata['sizes'][$size]) ) 289 289 return false; 290 290 291 291 $data = $imagedata['sizes'][$size]; 292 292 // include the full filesystem path of the intermediate file … … 302 302 // returns an array (url, width, height), or false if no image is available 303 303 function wp_get_attachment_image_src($attachment_id, $size='thumbnail', $icon = false) { 304 304 305 305 // get a thumbnail or intermediate image if there is one 306 306 if ( $image = image_downsize($attachment_id, $size) ) … … 329 329 $html = '<img src="'.attribute_escape($src).'" '.$hwstring.'class="attachment-'.attribute_escape($size).'" alt="" />'; 330 330 } 331 331 332 332 return $html; 333 333 } 334 334 335 add_shortcode('gallery', 'gallery_shortcode' , true);335 add_shortcode('gallery', 'gallery_shortcode'); 336 336 337 337 function gallery_shortcode($attr) { … … 378 378 $columns = intval($columns); 379 379 $itemwidth = $columns > 0 ? floor(100/$columns) : 100; 380 380 381 381 $output = apply_filters('gallery_style', " 382 382 <style type='text/css'> -
trunk/wp-includes/shortcodes.php
r7769 r7814 48 48 $shortcode_tags = array(); 49 49 50 function add_shortcode($tag, $func , $after_formatting = false) {50 function add_shortcode($tag, $func) { 51 51 global $shortcode_tags; 52 52 53 if ( is_callable($func) ) { 54 $shortcode_tags[($after_formatting)? 11:9][$tag] = $func; 55 } 53 if ( is_callable($func) ) 54 $shortcode_tags[$tag] = $func; 56 55 } 57 56 … … 59 58 global $shortcode_tags; 60 59 61 unset($shortcode_tags[ 9][$tag], $shortcode_tags[11][$tag]);60 unset($shortcode_tags[$tag]); 62 61 } 63 62 … … 68 67 } 69 68 70 function do_shortcode_after_formatting($content) { 71 return do_shortcode($content, true); 72 } 73 function do_shortcode($content, $after_formatting = false) { 74 $pattern = get_shortcode_regex($after_formatting); 75 if (!$pattern) { 76 return $content; 77 } else { 78 $callback_func = 'do_shortcode_tag'; 79 if ($after_formatting) 80 $callback_func .= '_after_formatting'; 81 82 return preg_replace_callback('/' . $pattern . '/s', $callback_func, $content); 83 } 84 } 85 function get_shortcode_regex($after_formatting) { 69 function do_shortcode($content) { 86 70 global $shortcode_tags; 87 71 88 if (empty($shortcode_tags [($after_formatting)? 11:9]) || !is_array($shortcode_tags[($after_formatting)? 11:9]))89 return false;72 if (empty($shortcode_tags) || !is_array($shortcode_tags)) 73 return $content; 90 74 91 $tagnames = array_keys($shortcode_tags [($after_formatting)? 11:9]);75 $tagnames = array_keys($shortcode_tags); 92 76 $tagregexp = join( '|', array_map('preg_quote', $tagnames) ); 93 77 94 return '\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\1\])?'; 78 $pattern = '/\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\1\])?/s'; 79 80 return preg_replace_callback($pattern, 'do_shortcode_tag', $content); 95 81 } 96 82 97 function do_shortcode_tag_after_formatting($m) { 98 return do_shortcode_tag($m, true); 99 } 100 function do_shortcode_tag($m, $after_formatting = false) { 83 function do_shortcode_tag($m) { 101 84 global $shortcode_tags; 102 85 … … 106 89 if ( isset($m[4]) ) { 107 90 // enclosing tag - extra parameter 108 return call_user_func($shortcode_tags[ ($after_formatting)? 11:9][$tag], $attr, $m[4]);91 return call_user_func($shortcode_tags[$tag], $attr, $m[4]); 109 92 } else { 110 93 // self-closing tag 111 return call_user_func($shortcode_tags[ ($after_formatting)? 11:9][$tag], $attr);94 return call_user_func($shortcode_tags[$tag], $attr); 112 95 } 113 96 } … … 148 131 } 149 132 150 add_filter( 'the_content', 'do_shortcode', 9 ); 151 add_filter( 'the_content', 'do_shortcode_after_formatting', 11 ); 133 add_filter('the_content', 'do_shortcode', 11); // AFTER wpautop() 152 134 153 135 ?>
Note: See TracChangeset
for help on using the changeset viewer.