WordPress.org

Make WordPress Core

Changeset 7814


Ignore:
Timestamp:
04/25/2008 12:43:44 AM (10 years ago)
Author:
markjaquith
Message:

Revert [7700] from trunk in preparation for a different #6444 solution

Location:
trunk/wp-includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/formatting.php

    r7699 r7814  
    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);
     
    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 );
     
    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;
  • trunk/wp-includes/media.php

    r7703 r7814  
    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
     
    302302// returns an array (url, width, height), or false if no image is available
    303303function 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) )
     
    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);
     335add_shortcode('gallery', 'gallery_shortcode');
    336336
    337337function gallery_shortcode($attr) {
     
    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'>
  • trunk/wp-includes/shortcodes.php

    r7769 r7814  
    4848$shortcode_tags = array();
    4949
    50 function add_shortcode($tag, $func, $after_formatting = false) {
     50function 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
     
    5958    global $shortcode_tags;
    6059
    61     unset($shortcode_tags[9][$tag], $shortcode_tags[11][$tag]);
     60    unset($shortcode_tags[$tag]);
    6261}
    6362
     
    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) {
     69function 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\])?';
     78    $pattern = '/\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\1\])?/s';
     79
     80    return preg_replace_callback($pattern, 'do_shortcode_tag', $content);
    9581}
    9682
    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) {
     83function do_shortcode_tag($m) {
    10184    global $shortcode_tags;
    10285
     
    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}
     
    148131}
    149132
    150 add_filter( 'the_content', 'do_shortcode', 9 );
    151 add_filter( 'the_content', 'do_shortcode_after_formatting', 11 );
     133add_filter('the_content', 'do_shortcode', 11); // AFTER wpautop()
    152134
    153135?>
Note: See TracChangeset for help on using the changeset viewer.