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

git-svn-id: http://svn.automattic.com/wordpress/trunk@16313 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-11-11 22:50:36 +00:00
parent 771de1c49e
commit 5f4a583fb1
7 changed files with 67 additions and 15 deletions

View File

@ -260,7 +260,7 @@ function get_plugins($plugin_folder = '') {
$wp_plugins[plugin_basename( $plugin_file )] = $plugin_data;
}
uasort( $wp_plugins, create_function( '$a, $b', 'return strnatcasecmp( $a["Name"], $b["Name"] );' ));
uasort( $wp_plugins, '_sort_uname_callback' );
$cache_plugins[ $plugin_folder ] = $wp_plugins;
wp_cache_set('plugins', $cache_plugins, 'plugins');
@ -312,11 +312,21 @@ function get_mu_plugins() {
if ( isset( $wp_plugins['index.php'] ) && filesize( WPMU_PLUGIN_DIR . '/index.php') <= 30 ) // silence is golden
unset( $wp_plugins['index.php'] );
uasort( $wp_plugins, create_function( '$a, $b', 'return strnatcasecmp( $a["Name"], $b["Name"] );' ));
uasort( $wp_plugins, '_sort_uname_callback' );
return $wp_plugins;
}
/**
* Callback to sort array by a 'Name' key.
*
* @since 3.1.0
* @access private
*/
function _sort_uname_callback( $a, $b ) {
return strnatcasecmp( $a['Name'], $b['Name'] );
}
/**
* Check the wp-content directory and retrieve all drop-ins with any plugin data.
*
@ -353,7 +363,7 @@ function get_dropins() {
$dropins[ $plugin_file ] = $plugin_data;
}
uksort( $dropins, create_function( '$a, $b', 'return strnatcasecmp( $a, $b );' ));
uksort( $dropins, 'strnatcasecmp' );
return $dropins;
}

View File

@ -15,7 +15,7 @@ function wp_list_widgets() {
global $wp_registered_widgets, $sidebars_widgets, $wp_registered_widget_controls;
$sort = $wp_registered_widgets;
usort( $sort, create_function( '$a, $b', 'return strnatcasecmp( $a["name"], $b["name"] );' ) );
usort( $sort, '_sort_name_callback' );
$done = array();
foreach ( $sort as $widget ) {
@ -46,6 +46,16 @@ function wp_list_widgets() {
}
}
/**
* Callback to sort array by a 'name' key.
*
* @since 3.1.0
* @access private
*/
function _sort_name_callback( $a, $b ) {
return strnatcasecmp( $a['name'], $b['name'] );
}
/**
* Show the widgets and their settings for a sidebar.
* Used in the the admin widget config screen.

View File

@ -677,7 +677,7 @@ function wp_generate_tag_cloud( $tags, $args = '' ) {
$tag_link = '#' != $tag->link ? esc_url( $tag->link ) : '#';
$tag_id = isset($tags[ $key ]->id) ? $tags[ $key ]->id : $key;
$tag_name = $tags[ $key ]->name;
$a[] = "<a href='$tag_link' class='tag-link-$tag_id' title='" . esc_attr( $topic_count_text_callback( $real_count ) ) . "' style='font-size: " .
$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: " .
( $smallest + ( ( $count - $min_count ) * $font_step ) )
. "$unit;'>$tag_name</a>";
}
@ -702,6 +702,26 @@ function wp_generate_tag_cloud( $tags, $args = '' ) {
return $return;
}
/**
* Callback for comparing tags based on name
*
* @since 3.1.0
* @access private
*/
function _wp_tag_cloud_name_sort_cb( $a, $b ) {
return strnatcasecmp( $a->name, $b->name );
}
/**
* Callback for comparing tags based on count
*
* @since 3.1.0
* @access private
*/
function _wp_tag_cloud_count_sort_cb( $a, $b ) {
return ( $a->count > $b->count );
}
//
// Helper functions
//

View File

@ -236,7 +236,7 @@ function wpautop($pee, $br = 1) {
$pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee);
$pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee);
if ($br) {
$pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', '__autop_newline_preservation_helper', $pee);
$pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', '_autop_newline_preservation_helper', $pee);
$pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks
$pee = str_replace('<WPPreserveNewline />', "\n", $pee);
}
@ -257,7 +257,7 @@ function wpautop($pee, $br = 1) {
* @param array $matches preg_replace_callback matches array
* @returns string
*/
function __autop_newline_preservation_helper( $matches ) {
function _autop_newline_preservation_helper( $matches ) {
return str_replace("\n", "<WPPreserveNewline />", $matches[0]);
}
@ -1595,7 +1595,7 @@ function wp_iso_descrambler($string) {
return $string;
} else {
$subject = str_replace('_', ' ', $matches[2]);
$subject = preg_replace_callback('#\=([0-9a-f]{2})#i', '__wp_iso_convert', $subject);
$subject = preg_replace_callback('#\=([0-9a-f]{2})#i', '_wp_iso_convert', $subject);
return $subject;
}
}
@ -1607,7 +1607,7 @@ function wp_iso_descrambler($string) {
* @access private
* @param $match the preg_replace_callback matches array
*/
function __wp_iso_convert( $match ) {
function _wp_iso_convert( $match ) {
return chr( hexdec( strtolower( $match[1] ) ) );
}

View File

@ -546,8 +546,18 @@ function wp_kses_split($string, $allowed_html, $allowed_protocols) {
global $pass_allowed_html, $pass_allowed_protocols;
$pass_allowed_html = $allowed_html;
$pass_allowed_protocols = $allowed_protocols;
return preg_replace_callback('%((<!--.*?(-->|$))|(<[^>]*(>|$)|>))%',
create_function('$match', 'global $pass_allowed_html, $pass_allowed_protocols; return wp_kses_split2($match[1], $pass_allowed_html, $pass_allowed_protocols);'), $string);
return preg_replace_callback( '%((<!--.*?(-->|$))|(<[^>]*(>|$)|>))%', '_wp_kses_split_callback', $string );
}
/**
* Callback for wp_kses_split.
*
* @since 3.1.0
* @access private
*/
function _wp_kses_split_callback( $match ) {
global $pass_allowed_html, $pass_allowed_protocols;
return wp_kses_split2( $match[1], $pass_allowed_html, $pass_allowed_protocols );
}
/**

View File

@ -223,7 +223,7 @@ function get_the_content($more_link_text = null, $stripteaser = 0) {
}
if ( $preview ) // preview fix for javascript bug with foreign languages
$output = preg_replace_callback('/\%u([0-9A-F]{4})/', '__convert_urlencoded_to_entities', $output);
$output = preg_replace_callback('/\%u([0-9A-F]{4})/', '_convert_urlencoded_to_entities', $output);
return $output;
}
@ -236,8 +236,8 @@ function get_the_content($more_link_text = null, $stripteaser = 0) {
* @param array $match Match array from preg_replace_callback
* @returns string
*/
function __convert_urlencoded_to_entities($match) {
return '&#' . base_convert($match[1], 16, 10) . ';';
function _convert_urlencoded_to_entities( $match ) {
return '&#' . base_convert( $match[1], 16, 10 ) . ';';
}
/**

View File

@ -1162,7 +1162,9 @@ function _get_custom_object_labels( $object, $nohier_vs_hier_defaults ) {
if ( !isset( $object->labels['menu_name'] ) && isset( $object->labels['name'] ) )
$object->labels['menu_name'] = $object->labels['name'];
$defaults = array_map( create_function( '$x', $object->hierarchical? 'return $x[1];' : 'return $x[0];' ), $nohier_vs_hier_defaults );
foreach ( $nohier_vs_hier_defaults as $key => $value )
$defaults[$key] = $object->hierarchical ? $value[1] : $value[0];
$labels = array_merge( $defaults, $object->labels );
return (object)$labels;
}