<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[16313] trunk: Remove more create_function calls.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/16313">16313</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-11-11 22:50:36 +0000 (Thu, 11 Nov 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Remove more create_function calls. props huichen, see <a href="http://trac.wordpress.org/ticket/14424">#14424</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludespluginphp">trunk/wp-admin/includes/plugin.php</a></li>
<li><a href="#trunkwpadminincludeswidgetsphp">trunk/wp-admin/includes/widgets.php</a></li>
<li><a href="#trunkwpincludescategorytemplatephp">trunk/wp-includes/category-template.php</a></li>
<li><a href="#trunkwpincludesformattingphp">trunk/wp-includes/formatting.php</a></li>
<li><a href="#trunkwpincludesksesphp">trunk/wp-includes/kses.php</a></li>
<li><a href="#trunkwpincludesposttemplatephp">trunk/wp-includes/post-template.php</a></li>
<li><a href="#trunkwpincludespostphp">trunk/wp-includes/post.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludespluginphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/plugin.php (16312 => 16313)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/plugin.php        2010-11-11 22:21:04 UTC (rev 16312)
+++ trunk/wp-admin/includes/plugin.php        2010-11-11 22:50:36 UTC (rev 16313)
</span><span class="lines">@@ -260,7 +260,7 @@
</span><span class="cx">                 $wp_plugins[plugin_basename( $plugin_file )] = $plugin_data;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        uasort( $wp_plugins, create_function( '$a, $b', 'return strnatcasecmp( $a[&quot;Name&quot;], $b[&quot;Name&quot;] );' ));
</del><ins>+        uasort( $wp_plugins, '_sort_uname_callback' );
</ins><span class="cx"> 
</span><span class="cx">         $cache_plugins[ $plugin_folder ] = $wp_plugins;
</span><span class="cx">         wp_cache_set('plugins', $cache_plugins, 'plugins');
</span><span class="lines">@@ -312,12 +312,22 @@
</span><span class="cx">         if ( isset( $wp_plugins['index.php'] ) &amp;&amp; filesize( WPMU_PLUGIN_DIR . '/index.php') &lt;= 30 ) // silence is golden
</span><span class="cx">                 unset( $wp_plugins['index.php'] );
</span><span class="cx"> 
</span><del>-        uasort( $wp_plugins, create_function( '$a, $b', 'return strnatcasecmp( $a[&quot;Name&quot;], $b[&quot;Name&quot;] );' ));
</del><ins>+        uasort( $wp_plugins, '_sort_uname_callback' );
</ins><span class="cx"> 
</span><span class="cx">         return $wp_plugins;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><ins>+ * 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'] );
+}
+
+/**
</ins><span class="cx">  * Check the wp-content directory and retrieve all drop-ins with any plugin data.
</span><span class="cx">  *
</span><span class="cx">  * @since 3.0.0
</span><span class="lines">@@ -353,7 +363,7 @@
</span><span class="cx">                 $dropins[ $plugin_file ] = $plugin_data;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        uksort( $dropins, create_function( '$a, $b', 'return strnatcasecmp( $a, $b );' ));
</del><ins>+        uksort( $dropins, 'strnatcasecmp' );
</ins><span class="cx"> 
</span><span class="cx">         return $dropins;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpadminincludeswidgetsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/widgets.php (16312 => 16313)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/widgets.php        2010-11-11 22:21:04 UTC (rev 16312)
+++ trunk/wp-admin/includes/widgets.php        2010-11-11 22:50:36 UTC (rev 16313)
</span><span class="lines">@@ -15,7 +15,7 @@
</span><span class="cx">         global $wp_registered_widgets, $sidebars_widgets, $wp_registered_widget_controls;
</span><span class="cx"> 
</span><span class="cx">         $sort = $wp_registered_widgets;
</span><del>-        usort( $sort, create_function( '$a, $b', 'return strnatcasecmp( $a[&quot;name&quot;], $b[&quot;name&quot;] );' ) );
</del><ins>+        usort( $sort, '_sort_name_callback' );
</ins><span class="cx">         $done = array();
</span><span class="cx"> 
</span><span class="cx">         foreach ( $sort as $widget ) {
</span><span class="lines">@@ -47,6 +47,16 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><ins>+ * 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'] );
+}
+
+/**
</ins><span class="cx">  * Show the widgets and their settings for a sidebar.
</span><span class="cx">  * Used in the the admin widget config screen.
</span><span class="cx">  *
</span></span></pre></div>
<a id="trunkwpincludescategorytemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/category-template.php (16312 => 16313)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/category-template.php        2010-11-11 22:21:04 UTC (rev 16312)
+++ trunk/wp-includes/category-template.php        2010-11-11 22:50:36 UTC (rev 16313)
</span><span class="lines">@@ -677,7 +677,7 @@
</span><span class="cx">                 $tag_link = '#' != $tag-&gt;link ? esc_url( $tag-&gt;link ) : '#';
</span><span class="cx">                 $tag_id = isset($tags[ $key ]-&gt;id) ? $tags[ $key ]-&gt;id : $key;
</span><span class="cx">                 $tag_name = $tags[ $key ]-&gt;name;
</span><del>-                $a[] = &quot;&lt;a href='$tag_link' class='tag-link-$tag_id' title='&quot; . esc_attr( $topic_count_text_callback( $real_count ) ) . &quot;' style='font-size: &quot; .
</del><ins>+                $a[] = &quot;&lt;a href='$tag_link' class='tag-link-$tag_id' title='&quot; . esc_attr( call_user_func( 'topic_count_text_callback', $real_count ) ) . &quot;' style='font-size: &quot; .
</ins><span class="cx">                         ( $smallest + ( ( $count - $min_count ) * $font_step ) )
</span><span class="cx">                         . &quot;$unit;'&gt;$tag_name&lt;/a&gt;&quot;;
</span><span class="cx">         }
</span><span class="lines">@@ -702,6 +702,26 @@
</span><span class="cx">                 return $return;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/**
+ * 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-&gt;name, $b-&gt;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-&gt;count &gt; $b-&gt;count );
+}
+
</ins><span class="cx"> //
</span><span class="cx"> // Helper functions
</span><span class="cx"> //
</span></span></pre></div>
<a id="trunkwpincludesformattingphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/formatting.php (16312 => 16313)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/formatting.php        2010-11-11 22:21:04 UTC (rev 16312)
+++ trunk/wp-includes/formatting.php        2010-11-11 22:50:36 UTC (rev 16313)
</span><span class="lines">@@ -236,7 +236,7 @@
</span><span class="cx">         $pee = preg_replace('!&lt;p&gt;\s*(&lt;/?' . $allblocks . '[^&gt;]*&gt;)!', &quot;$1&quot;, $pee);
</span><span class="cx">         $pee = preg_replace('!(&lt;/?' . $allblocks . '[^&gt;]*&gt;)\s*&lt;/p&gt;!', &quot;$1&quot;, $pee);
</span><span class="cx">         if ($br) {
</span><del>-                $pee = preg_replace_callback('/&lt;(script|style).*?&lt;\/\\1&gt;/s', '__autop_newline_preservation_helper', $pee);
</del><ins>+                $pee = preg_replace_callback('/&lt;(script|style).*?&lt;\/\\1&gt;/s', '_autop_newline_preservation_helper', $pee);
</ins><span class="cx">                 $pee = preg_replace('|(?&lt;!&lt;br /&gt;)\s*\n|', &quot;&lt;br /&gt;\n&quot;, $pee); // optionally make line breaks
</span><span class="cx">                 $pee = str_replace('&lt;WPPreserveNewline /&gt;', &quot;\n&quot;, $pee);
</span><span class="cx">         }
</span><span class="lines">@@ -257,7 +257,7 @@
</span><span class="cx">  * @param array $matches preg_replace_callback matches array
</span><span class="cx">  * @returns string
</span><span class="cx">  */
</span><del>-function __autop_newline_preservation_helper( $matches ) {
</del><ins>+function _autop_newline_preservation_helper( $matches ) {
</ins><span class="cx">         return str_replace(&quot;\n&quot;, &quot;&lt;WPPreserveNewline /&gt;&quot;, $matches[0]);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1595,7 +1595,7 @@
</span><span class="cx">                 return $string;
</span><span class="cx">         } else {
</span><span class="cx">                 $subject = str_replace('_', ' ', $matches[2]);
</span><del>-                $subject = preg_replace_callback('#\=([0-9a-f]{2})#i', '__wp_iso_convert', $subject);
</del><ins>+                $subject = preg_replace_callback('#\=([0-9a-f]{2})#i', '_wp_iso_convert', $subject);
</ins><span class="cx">                 return $subject;
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="lines">@@ -1607,7 +1607,7 @@
</span><span class="cx">  * @access private
</span><span class="cx">  * @param $match the preg_replace_callback matches array
</span><span class="cx">  */
</span><del>-function __wp_iso_convert( $match ) { 
</del><ins>+function _wp_iso_convert( $match ) { 
</ins><span class="cx">         return chr( hexdec( strtolower( $match[1] ) ) ); 
</span><span class="cx"> } 
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpincludesksesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/kses.php (16312 => 16313)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/kses.php        2010-11-11 22:21:04 UTC (rev 16312)
+++ trunk/wp-includes/kses.php        2010-11-11 22:50:36 UTC (rev 16313)
</span><span class="lines">@@ -546,11 +546,21 @@
</span><span class="cx">         global $pass_allowed_html, $pass_allowed_protocols;
</span><span class="cx">         $pass_allowed_html = $allowed_html;
</span><span class="cx">         $pass_allowed_protocols = $allowed_protocols;
</span><del>-        return preg_replace_callback('%((&lt;!--.*?(--&gt;|$))|(&lt;[^&gt;]*(&gt;|$)|&gt;))%',
-                create_function('$match', 'global $pass_allowed_html, $pass_allowed_protocols; return wp_kses_split2($match[1], $pass_allowed_html, $pass_allowed_protocols);'), $string);
</del><ins>+        return preg_replace_callback( '%((&lt;!--.*?(--&gt;|$))|(&lt;[^&gt;]*(&gt;|$)|&gt;))%', '_wp_kses_split_callback', $string );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><ins>+ * 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 );
+}
+
+/**
</ins><span class="cx">  * Callback for wp_kses_split for fixing malformed HTML tags.
</span><span class="cx">  *
</span><span class="cx">  * This function does a lot of work. It rejects some very malformed things like
</span></span></pre></div>
<a id="trunkwpincludesposttemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post-template.php (16312 => 16313)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post-template.php        2010-11-11 22:21:04 UTC (rev 16312)
+++ trunk/wp-includes/post-template.php        2010-11-11 22:50:36 UTC (rev 16313)
</span><span class="lines">@@ -223,7 +223,7 @@
</span><span class="cx"> 
</span><span class="cx">         }
</span><span class="cx">         if ( $preview ) // preview fix for javascript bug with foreign languages
</span><del>-                $output =        preg_replace_callback('/\%u([0-9A-F]{4})/', '__convert_urlencoded_to_entities', $output);
</del><ins>+                $output =        preg_replace_callback('/\%u([0-9A-F]{4})/', '_convert_urlencoded_to_entities', $output);
</ins><span class="cx"> 
</span><span class="cx">         return $output;
</span><span class="cx"> }
</span><span class="lines">@@ -236,8 +236,8 @@
</span><span class="cx">  * @param array $match Match array from preg_replace_callback
</span><span class="cx">  * @returns string
</span><span class="cx">  */
</span><del>-function __convert_urlencoded_to_entities($match) {
-        return '&amp;#' . base_convert($match[1], 16, 10) . ';'; 
</del><ins>+function _convert_urlencoded_to_entities( $match ) {
+        return '&amp;#' . base_convert( $match[1], 16, 10 ) . ';'; 
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span></span></pre></div>
<a id="trunkwpincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post.php (16312 => 16313)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post.php        2010-11-11 22:21:04 UTC (rev 16312)
+++ trunk/wp-includes/post.php        2010-11-11 22:50:36 UTC (rev 16313)
</span><span class="lines">@@ -1162,7 +1162,9 @@
</span><span class="cx">         if ( !isset( $object-&gt;labels['menu_name'] ) &amp;&amp; isset( $object-&gt;labels['name'] ) )
</span><span class="cx">                 $object-&gt;labels['menu_name'] = $object-&gt;labels['name'];
</span><span class="cx"> 
</span><del>-        $defaults = array_map( create_function( '$x', $object-&gt;hierarchical? 'return $x[1];' : 'return $x[0];' ), $nohier_vs_hier_defaults );
</del><ins>+        foreach ( $nohier_vs_hier_defaults as $key =&gt; $value )
+                        $defaults[$key] = $object-&gt;hierarchical ? $value[1] : $value[0];
+
</ins><span class="cx">         $labels = array_merge( $defaults, $object-&gt;labels );
</span><span class="cx">         return (object)$labels;
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>