Skip to content

Commit 24a68a4

Browse files
committed
Revert [7700] from trunk in preparation for a different WordPress#6444 solution
git-svn-id: https://develop.svn.wordpress.org/trunk@7814 602fd350-edb4-49c9-b593-d223f7449a82
1 parent eae779d commit 24a68a4

3 files changed

Lines changed: 21 additions & 41 deletions

File tree

wp-includes/formatting.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function wptexturize($text) {
2626
for ( $i = 0; $i < $stop; $i++ ) {
2727
$curl = $textarr[$i];
2828

29-
if (isset($curl{0}) && '<' != $curl{0} && '[' != $curl{0} && $next) { // If it's not a tag or shortcode
29+
if (isset($curl{0}) && '<' != $curl{0} && '[' != $curl{0} && $next) { // If it's not a tag
3030
// static strings
3131
$curl = str_replace($static_characters, $static_replacements, $curl);
3232
// regular expressions
@@ -74,7 +74,6 @@ function wpautop($pee, $br = 1) {
7474
$pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates
7575
$pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end
7676
$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 shortcodes
7877
$pee = preg_replace('!<p>([^<]+)\s*?(</(?:div|address|form)[^>]*>)!', "<p>$1</p>$2", $pee);
7978
$pee = preg_replace( '|<p>|', "$1<p>", $pee );
8079
$pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag
@@ -841,7 +840,6 @@ function wp_trim_excerpt($text) { // Fakes an excerpt if needed
841840
$text = get_the_content('');
842841
$text = apply_filters('the_content', $text);
843842
$text = str_replace(']]>', ']]&gt;', $text);
844-
$text = preg_replace('|//\s*<!\[CDATA\[|', '<![CDATA[', $text);
845843
$text = strip_tags($text);
846844
$excerpt_length = 55;
847845
$words = explode(' ', $text, $excerpt_length + 1);

wp-includes/media.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ function image_get_intermediate_size($post_id, $size='thumbnail') {
287287

288288
if ( is_array($size) || empty($size) || empty($imagedata['sizes'][$size]) )
289289
return false;
290-
290+
291291
$data = $imagedata['sizes'][$size];
292292
// include the full filesystem path of the intermediate file
293293
if ( empty($data['path']) && !empty($data['file']) ) {
@@ -301,7 +301,7 @@ function image_get_intermediate_size($post_id, $size='thumbnail') {
301301
// get an image to represent an attachment - a mime icon for files, thumbnail or intermediate size for images
302302
// returns an array (url, width, height), or false if no image is available
303303
function wp_get_attachment_image_src($attachment_id, $size='thumbnail', $icon = false) {
304-
304+
305305
// get a thumbnail or intermediate image if there is one
306306
if ( $image = image_downsize($attachment_id, $size) )
307307
return $image;
@@ -328,11 +328,11 @@ function wp_get_attachment_image($attachment_id, $size='thumbnail', $icon = fals
328328
$size = join('x', $size);
329329
$html = '<img src="'.attribute_escape($src).'" '.$hwstring.'class="attachment-'.attribute_escape($size).'" alt="" />';
330330
}
331-
331+
332332
return $html;
333333
}
334334

335-
add_shortcode('gallery', 'gallery_shortcode', true);
335+
add_shortcode('gallery', 'gallery_shortcode');
336336

337337
function gallery_shortcode($attr) {
338338
global $post;
@@ -377,7 +377,7 @@ function gallery_shortcode($attr) {
377377
$captiontag = tag_escape($captiontag);
378378
$columns = intval($columns);
379379
$itemwidth = $columns > 0 ? floor(100/$columns) : 100;
380-
380+
381381
$output = apply_filters('gallery_style', "
382382
<style type='text/css'>
383383
.gallery {

wp-includes/shortcodes.php

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,17 @@ function baztag_func($atts, $content='') {
4747

4848
$shortcode_tags = array();
4949

50-
function add_shortcode($tag, $func, $after_formatting = false) {
50+
function add_shortcode($tag, $func) {
5151
global $shortcode_tags;
5252

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;
5655
}
5756

5857
function remove_shortcode($tag) {
5958
global $shortcode_tags;
6059

61-
unset($shortcode_tags[9][$tag], $shortcode_tags[11][$tag]);
60+
unset($shortcode_tags[$tag]);
6261
}
6362

6463
function remove_all_shortcodes() {
@@ -67,48 +66,32 @@ function remove_all_shortcodes() {
6766
$shortcode_tags = array();
6867
}
6968

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) {
8670
global $shortcode_tags;
8771

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;
9074

91-
$tagnames = array_keys($shortcode_tags[($after_formatting)? 11:9]);
75+
$tagnames = array_keys($shortcode_tags);
9276
$tagregexp = join( '|', array_map('preg_quote', $tagnames) );
9377

94-
return '\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\1\])?';
95-
}
78+
$pattern = '/\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\1\])?/s';
9679

97-
function do_shortcode_tag_after_formatting($m) {
98-
return do_shortcode_tag($m, true);
80+
return preg_replace_callback($pattern, 'do_shortcode_tag', $content);
9981
}
100-
function do_shortcode_tag($m, $after_formatting = false) {
82+
83+
function do_shortcode_tag($m) {
10184
global $shortcode_tags;
10285

10386
$tag = $m[1];
10487
$attr = shortcode_parse_atts($m[2]);
10588

10689
if ( isset($m[4]) ) {
10790
// 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]);
10992
} else {
11093
// 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);
11295
}
11396
}
11497

@@ -147,7 +130,6 @@ function shortcode_atts($pairs, $atts) {
147130
return $out;
148131
}
149132

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()
152134

153135
?>

0 commit comments

Comments
 (0)