WordPress.org

Make WordPress Core

Changeset 16313


Ignore:
Timestamp:
11/11/10 22:50:36 (3 years ago)
Author:
nacin
Message:

Remove more create_function calls. props huichen, see #14424.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/plugin.php

    r16312 r16313  
    261261    } 
    262262 
    263     uasort( $wp_plugins, create_function( '$a, $b', 'return strnatcasecmp( $a["Name"], $b["Name"] );' )); 
     263    uasort( $wp_plugins, '_sort_uname_callback' ); 
    264264 
    265265    $cache_plugins[ $plugin_folder ] = $wp_plugins; 
     
    313313        unset( $wp_plugins['index.php'] ); 
    314314 
    315     uasort( $wp_plugins, create_function( '$a, $b', 'return strnatcasecmp( $a["Name"], $b["Name"] );' )); 
     315    uasort( $wp_plugins, '_sort_uname_callback' ); 
    316316 
    317317    return $wp_plugins; 
     318} 
     319 
     320/** 
     321 * Callback to sort array by a 'Name' key. 
     322 * 
     323 * @since 3.1.0 
     324 * @access private 
     325 */ 
     326function _sort_uname_callback( $a, $b ) { 
     327    return strnatcasecmp( $a['Name'], $b['Name'] ); 
    318328} 
    319329 
     
    354364    } 
    355365 
    356     uksort( $dropins, create_function( '$a, $b', 'return strnatcasecmp( $a, $b );' )); 
     366    uksort( $dropins, 'strnatcasecmp' ); 
    357367 
    358368    return $dropins; 
  • trunk/wp-admin/includes/widgets.php

    r16269 r16313  
    1616 
    1717    $sort = $wp_registered_widgets; 
    18     usort( $sort, create_function( '$a, $b', 'return strnatcasecmp( $a["name"], $b["name"] );' ) ); 
     18    usort( $sort, '_sort_name_callback' ); 
    1919    $done = array(); 
    2020 
     
    4848 
    4949/** 
     50 * Callback to sort array by a 'name' key. 
     51 * 
     52 * @since 3.1.0 
     53 * @access private 
     54 */ 
     55function _sort_name_callback( $a, $b ) { 
     56    return strnatcasecmp( $a['name'], $b['name'] ); 
     57} 
     58 
     59/** 
    5060 * Show the widgets and their settings for a sidebar. 
    5161 * Used in the the admin widget config screen. 
  • trunk/wp-includes/category-template.php

    r16307 r16313  
    678678        $tag_id = isset($tags[ $key ]->id) ? $tags[ $key ]->id : $key; 
    679679        $tag_name = $tags[ $key ]->name; 
    680         $a[] = "<a href='$tag_link' class='tag-link-$tag_id' title='" . esc_attr( $topic_count_text_callback( $real_count ) ) . "' style='font-size: " . 
     680        $a[] = "<a href='$tag_link' class='tag-link-$tag_id' title='" . esc_attr( call_user_func( 'topic_count_text_callback', $real_count ) ) . "' style='font-size: " . 
    681681            ( $smallest + ( ( $count - $min_count ) * $font_step ) ) 
    682682            . "$unit;'>$tag_name</a>"; 
     
    701701    else 
    702702        return $return; 
     703} 
     704 
     705/** 
     706 * Callback for comparing tags based on name 
     707 * 
     708 * @since 3.1.0 
     709 * @access private 
     710 */ 
     711function _wp_tag_cloud_name_sort_cb( $a, $b ) { 
     712    return strnatcasecmp( $a->name, $b->name ); 
     713} 
     714 
     715/** 
     716 * Callback for comparing tags based on count 
     717 * 
     718 * @since 3.1.0 
     719 * @access private 
     720 */ 
     721function _wp_tag_cloud_count_sort_cb( $a, $b ) { 
     722    return ( $a->count > $b->count ); 
    703723} 
    704724 
  • trunk/wp-includes/formatting.php

    r16280 r16313  
    237237    $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee); 
    238238    if ($br) { 
    239         $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', '__autop_newline_preservation_helper', $pee); 
     239        $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', '_autop_newline_preservation_helper', $pee); 
    240240        $pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks 
    241241        $pee = str_replace('<WPPreserveNewline />', "\n", $pee); 
     
    258258 * @returns string 
    259259 */ 
    260 function __autop_newline_preservation_helper( $matches ) { 
     260function _autop_newline_preservation_helper( $matches ) { 
    261261    return str_replace("\n", "<WPPreserveNewline />", $matches[0]); 
    262262} 
     
    15961596    } else { 
    15971597        $subject = str_replace('_', ' ', $matches[2]); 
    1598         $subject = preg_replace_callback('#\=([0-9a-f]{2})#i', '__wp_iso_convert', $subject); 
     1598        $subject = preg_replace_callback('#\=([0-9a-f]{2})#i', '_wp_iso_convert', $subject); 
    15991599        return $subject; 
    16001600    } 
     
    16081608 * @param $match the preg_replace_callback matches array 
    16091609 */ 
    1610 function __wp_iso_convert( $match ) {  
     1610function _wp_iso_convert( $match ) {  
    16111611    return chr( hexdec( strtolower( $match[1] ) ) );  
    16121612}  
  • trunk/wp-includes/kses.php

    r15383 r16313  
    547547    $pass_allowed_html = $allowed_html; 
    548548    $pass_allowed_protocols = $allowed_protocols; 
    549     return preg_replace_callback('%((<!--.*?(-->|$))|(<[^>]*(>|$)|>))%', 
    550         create_function('$match', 'global $pass_allowed_html, $pass_allowed_protocols; return wp_kses_split2($match[1], $pass_allowed_html, $pass_allowed_protocols);'), $string); 
     549    return preg_replace_callback( '%((<!--.*?(-->|$))|(<[^>]*(>|$)|>))%', '_wp_kses_split_callback', $string ); 
     550} 
     551 
     552/** 
     553 * Callback for wp_kses_split. 
     554 * 
     555 * @since 3.1.0 
     556 * @access private 
     557 */ 
     558function _wp_kses_split_callback( $match ) { 
     559    global $pass_allowed_html, $pass_allowed_protocols; 
     560    return wp_kses_split2( $match[1], $pass_allowed_html, $pass_allowed_protocols ); 
    551561} 
    552562 
  • trunk/wp-includes/post-template.php

    r16283 r16313  
    224224    } 
    225225    if ( $preview ) // preview fix for javascript bug with foreign languages 
    226         $output =   preg_replace_callback('/\%u([0-9A-F]{4})/', '__convert_urlencoded_to_entities', $output); 
     226        $output =   preg_replace_callback('/\%u([0-9A-F]{4})/', '_convert_urlencoded_to_entities', $output); 
    227227 
    228228    return $output; 
     
    237237 * @returns string 
    238238 */ 
    239 function __convert_urlencoded_to_entities($match) { 
    240     return '&#' . base_convert($match[1], 16, 10) . ';';  
     239function _convert_urlencoded_to_entities( $match ) { 
     240    return '&#' . base_convert( $match[1], 16, 10 ) . ';';  
    241241} 
    242242 
  • trunk/wp-includes/post.php

    r16275 r16313  
    11631163        $object->labels['menu_name'] = $object->labels['name']; 
    11641164 
    1165     $defaults = array_map( create_function( '$x', $object->hierarchical? 'return $x[1];' : 'return $x[0];' ), $nohier_vs_hier_defaults ); 
     1165    foreach ( $nohier_vs_hier_defaults as $key => $value ) 
     1166            $defaults[$key] = $object->hierarchical ? $value[1] : $value[0]; 
     1167 
    11661168    $labels = array_merge( $defaults, $object->labels ); 
    11671169    return (object)$labels; 
Note: See TracChangeset for help on using the changeset viewer.