Index: wp-includes/post-template.php
===================================================================
--- wp-includes/post-template.php (revision 15471)
+++ wp-includes/post-template.php (working copy)
@@ -171,6 +171,10 @@
echo $content;
}
+function _convert_urlencoded_to_entities($match) {
+ return '' . base_convert($match[1], 16, 10) . ';';
+}
+
/**
* Retrieve the post content.
*
@@ -225,7 +229,7 @@
}
if ( $preview ) // preview fix for javascript bug with foreign languages
- $output = preg_replace_callback('/\%u([0-9A-F]{4})/', create_function('$match', 'return "" . base_convert($match[1], 16, 10) . ";";'), $output);
+ $output = preg_replace_callback('/\%u([0-9A-F]{4})/', '_convert_urlencoded_to_entities', $output);
return $output;
}
Index: wp-includes/pomo/mo.php
===================================================================
--- wp-includes/pomo/mo.php (revision 15471)
+++ wp-includes/pomo/mo.php (working copy)
@@ -30,7 +30,13 @@
function export_to_file($filename) {
$fh = fopen($filename, 'wb');
if ( !$fh ) return false;
- $entries = array_filter($this->entries, create_function('$e', 'return !empty($e->translations);'));
+ $entries = array();
+ foreach ($this->entries AS $entry_key => $e) {
+ if ( empty($e->translations) )
+ continue;
+
+ $entries[$entry_key] = $e;
+ }
ksort($entries);
$magic = 0x950412de;
$revision = 0;
Index: wp-includes/pomo/po.php
===================================================================
--- wp-includes/pomo/po.php (revision 15471)
+++ wp-includes/pomo/po.php (working copy)
@@ -151,7 +151,10 @@
$lines = explode("\n", $string);
// do not prepend the string on the last empty line, artefact by explode
if ("\n" == substr($string, -1)) unset($lines[count($lines) - 1]);
- $res = implode("\n", array_map(create_function('$x', "return $php_with.\$x;"), $lines));
+ foreach ($lines AS $line => $x) {
+ $lines[$line] = $php_with . $x;
+ }
+ $res = implode("\n", $lines);
// give back the empty line, we ignored above
if ("\n" == substr($string, -1)) $res .= "\n";
return $res;
@@ -218,19 +221,22 @@
return $res !== false;
}
+ function _is_context_final($context) {
+ return $context == "msgstr" || $context == "msgstr_plural";
+ }
+
function read_entry($f, $lineno = 0) {
$entry = new Translation_Entry();
// where were we in the last step
// can be: comment, msgctxt, msgid, msgid_plural, msgstr, msgstr_plural
$context = '';
$msgstr_index = 0;
- $is_final = create_function('$context', 'return $context == "msgstr" || $context == "msgstr_plural";');
while (true) {
$lineno++;
$line = PO::read_line($f);
if (!$line) {
if (feof($f)) {
- if ($is_final($context))
+ if ($this->_is_context_final($context))
break;
elseif (!$context) // we haven't read a line and eof came
return null;
@@ -244,7 +250,7 @@
$line = trim($line);
if (preg_match('/^#/', $line, $m)) {
// the comment is the start of a new entry
- if ($is_final($context)) {
+ if ($this->_is_context_final($context)) {
PO::read_line($f, 'put-back');
$lineno--;
break;
@@ -256,7 +262,7 @@
// add comment
$this->add_comment_to_entry($entry, $line);
} elseif (preg_match('/^msgctxt\s+(".*")/', $line, $m)) {
- if ($is_final($context)) {
+ if ($this->_is_context_final($context)) {
PO::read_line($f, 'put-back');
$lineno--;
break;
@@ -267,7 +273,7 @@
$context = 'msgctxt';
$entry->context .= PO::unpoify($m[1]);
} elseif (preg_match('/^msgid\s+(".*")/', $line, $m)) {
- if ($is_final($context)) {
+ if ($this->_is_context_final($context)) {
PO::read_line($f, 'put-back');
$lineno--;
break;
@@ -317,7 +323,15 @@
return false;
}
}
- if (array() == array_filter($entry->translations, create_function('$t', 'return $t || "0" === $t;'))) {
+
+ $array_has_values = false;
+ foreach ($this->translations AS $t) {
+ if ($t || "0" === $t ) {
+ $array_has_values = true;
+ break;
+ }
+ }
+ if (!$array_has_values) {
$entry->translations = array();
}
return array('entry' => $entry, 'lineno' => $lineno);
Index: wp-includes/pomo/translations.php
===================================================================
--- wp-includes/pomo/translations.php (revision 15471)
+++ wp-includes/pomo/translations.php (working copy)
@@ -120,20 +120,25 @@
*/
function gettext_select_plural_form($count) {
if (!isset($this->_gettext_select_plural_form) || is_null($this->_gettext_select_plural_form)) {
- list( $nplurals, $expression ) = $this->nplurals_and_expression_from_header($this->get_header('Plural-Forms'));
+ list( $nplurals, $expression_cb ) = $this->nplurals_and_expression_from_header($this->get_header('Plural-Forms'));
$this->_nplurals = $nplurals;
- $this->_gettext_select_plural_form = $this->make_plural_form_function($nplurals, $expression);
+ $this->_gettext_select_plural_form = $expression_cb;
}
return call_user_func($this->_gettext_select_plural_form, $count);
}
+ function _gettext_default_plural_cb($n) {
+ $index = (int)($n != 1);
+ return ($index < 2 ? $index : 2 - 1);
+ }
+
function nplurals_and_expression_from_header($header) {
if (preg_match('/^\s*nplurals\s*=\s*(\d+)\s*;\s+plural\s*=\s*(.+)$/', $header, $matches)) {
$nplurals = (int)$matches[1];
$expression = trim($this->parenthesize_plural_exression($matches[2]));
- return array($nplurals, $expression);
+ return array($nplurals, $this->make_plural_form_function($nplurals, $expression));
} else {
- return array(2, 'n != 1');
+ return array(2, array($this, '_gettext_default_plural_cb'));
}
}
@@ -197,9 +202,9 @@
function set_header($header, $value) {
parent::set_header($header, $value);
if ('Plural-Forms' == $header) {
- list( $nplurals, $expression ) = $this->nplurals_and_expression_from_header($this->get_header('Plural-Forms'));
+ list( $nplurals, $expression_cb ) = $this->nplurals_and_expression_from_header($this->get_header('Plural-Forms'));
$this->_nplurals = $nplurals;
- $this->_gettext_select_plural_form = $this->make_plural_form_function($nplurals, $expression);
+ $this->_gettext_select_plural_form = $expression_cb;
}
}
}
Index: wp-includes/post.php
===================================================================
--- wp-includes/post.php (revision 15471)
+++ wp-includes/post.php (working copy)
@@ -971,8 +971,15 @@
if ( !isset( $object->labels['singular_name'] ) && isset( $object->labels['name'] ) )
$object->labels['singular_name'] = $object->labels['name'];
+
+ foreach ( $nohier_vs_hier_defaults AS $key => $value ) {
+ if ( $object->hierarchical ) {
+ $defaults[$key] = $value[1];
+ } else {
+ $defaults[$key] = $value[0];
+ }
+ }
- $defaults = array_map( create_function( '$x', $object->hierarchical? 'return $x[1];' : 'return $x[0];' ), $nohier_vs_hier_defaults );
$labels = array_merge( $defaults, $object->labels );
return (object)$labels;
}
Index: wp-includes/formatting.php
===================================================================
--- wp-includes/formatting.php (revision 15471)
+++ wp-includes/formatting.php (working copy)
@@ -164,6 +164,10 @@
return $text;
}
+function _preserve_newlines_callback($matches) {
+ return str_replace("\n", "", $matches[0]);
+}
+
/**
* Replaces double line-breaks with paragraph elements.
*
@@ -208,7 +212,7 @@
$pee = preg_replace('!
\s*(?' . $allblocks . '[^>]*>)!', "$1", $pee);
$pee = preg_replace('!(?' . $allblocks . '[^>]*>)\s*
!', "$1", $pee);
if ($br) {
- $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', create_function('$matches', 'return str_replace("\n", "", $matches[0]);'), $pee);
+ $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', '_preserve_newlines_callback', $pee);
$pee = preg_replace('|(?)\s*\n|', "
\n", $pee); // optionally make line breaks
$pee = str_replace('', "\n", $pee);
}
@@ -1538,6 +1542,10 @@
return apply_filters( 'is_email', $email, $email, null );
}
+function _wp_iso_unquote($match) {
+ return chr(hexdec(strtolower($match[1])));
+}
+
/**
* Convert to ASCII from email subjects.
*
@@ -1553,7 +1561,7 @@
return $string;
} else {
$subject = str_replace('_', ' ', $matches[2]);
- $subject = preg_replace_callback('#\=([0-9a-f]{2})#i', create_function('$match', 'return chr(hexdec(strtolower($match[1])));'), $subject);
+ $subject = preg_replace_callback('#\=([0-9a-f]{2})#i', '_wp_iso_unquote', $subject);
return $subject;
}
}
@@ -2674,6 +2682,11 @@
return $str;
}
+function _links_add_base_with_param($m) {
+ global $wp_formatting_base_cb;
+ return _links_add_base($m, $wp_formatting_base_cb);
+}
+
/**
* Add a Base url to relative links in passed content.
*
@@ -2688,9 +2701,10 @@
* @return string The processed content.
*/
function links_add_base_url( $content, $base, $attrs = array('src', 'href') ) {
+ global $wp_formatting_base_cb;
$attrs = implode('|', (array)$attrs);
- return preg_replace_callback("!($attrs)=(['\"])(.+?)\\2!i",
- create_function('$m', 'return _links_add_base($m, "' . $base . '");'),
+ $wp_formatting_base_cb = $base;
+ return preg_replace_callback("!($attrs)=(['\"])(.+?)\\2!i", '_links_add_base_with_param',
$content);
}
@@ -2713,6 +2727,11 @@
. $m[2];
}
+function _links_add_target_with_param($m) {
+ global $wp_formatting_target_cb;
+ return _links_add_target($m, $wp_formatting_target_cb);
+}
+
/**
* Adds a Target attribute to all links in passed content.
*
@@ -2729,9 +2748,10 @@
* @return string The processed content.
*/
function links_add_target( $content, $target = '_blank', $tags = array('a') ) {
+ global $wp_formatting_target_cb;
$tags = implode('|', (array)$tags);
- return preg_replace_callback("!<($tags)(.+?)>!i",
- create_function('$m', 'return _links_add_target($m, "' . $target . '");'),
+ $wp_formatting_target_cb = $target;
+ return preg_replace_callback("!<($tags)(.+?)>!i", '_links_add_target_with_param',
$content);
}
Index: wp-includes/atomlib.php
===================================================================
--- wp-includes/atomlib.php (revision 15471)
+++ wp-includes/atomlib.php (working copy)
@@ -91,10 +91,22 @@
$this->feed = new AtomFeed();
$this->current = null;
- $this->map_attrs_func = create_function('$k,$v', 'return "$k=\"$v\"";');
- $this->map_xmlns_func = create_function('$p,$n', '$xd = "xmlns"; if(strlen($n[0])>0) $xd .= ":{$n[0]}"; return "{$xd}=\"{$n[1]}\"";');
+ $this->map_attrs_func = array('AtomParser', 'map_attrs_func');
+ $this->map_xmlns_func = array('AtomParser', 'map_xmlns_func');
}
+ function map_attrs_func($k, $v) {
+ return "$k=\"$v\"";
+ }
+
+ function map_xmlns_func($p, $n) {
+ $xd = 'xmlns';
+ if (strlen($n[0]) > 0) {
+ $xd .= ":{$n[0]}";
+ }
+ return "{$xd}=\"{$n[1]}\"";
+ }
+
function _p($msg) {
if($this->debug) {
print str_repeat(" ", $this->depth * $this->indent) . $msg ."\n";
Index: wp-includes/kses.php
===================================================================
--- wp-includes/kses.php (revision 15471)
+++ wp-includes/kses.php (working copy)
@@ -530,6 +530,11 @@
return '0.2.2';
}
+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);
+}
+
/**
* Searches for HTML tags, no matter how malformed.
*
@@ -546,8 +551,7 @@
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);
}
/**
Index: wp-includes/category-template.php
===================================================================
--- wp-includes/category-template.php (revision 15471)
+++ wp-includes/category-template.php (working copy)
@@ -612,8 +612,37 @@
return round(log10($count + 1) * 100);
}
+/**
+ * Callback for comparing tags based on name
+ *
+ * @param object a tag object to be compared
+ * @param object a tag object to be compared
+ * @return integer -1 for less than, 0 for the same and 1 for greater
+ */
+function _wp_tag_cloud_name_sort_cb($a, $b) {
+ return strnatcasecmp($a->name, $b->name);
+}
/**
+ * Callback for comparing tags based on count
+ *
+ * @param object a tag object to be compared
+ * @param object a tag object to be compared
+ * @return integer -1 for less than, 0 for the same and 1 for greater
+ */
+function _wp_tag_cloud_count_sort_cb($a, $b) {
+ return ($a->count > $b->count);
+}
+
+class _tag_clound_topic_count_text_callback {
+ var $single_text;
+ var $multiple_text;
+ function _callback($count) {
+ return sprintf( _n( $this->single_text, $this->multiple_text, $count ), number_format_i18n( $count ) );
+ }
+}
+
+/**
* Generates a tag cloud (heatmap) from provided data.
*
* The text size is set by the 'smallest' and 'largest' arguments, which will
@@ -654,10 +683,10 @@
);
if ( !isset( $args['topic_count_text_callback'] ) && isset( $args['single_text'] ) && isset( $args['multiple_text'] ) ) {
- $body = 'return sprintf (
- _n(' . var_export($args['single_text'], true) . ', ' . var_export($args['multiple_text'], true) . ', $count),
- number_format_i18n( $count ));';
- $args['topic_count_text_callback'] = create_function('$count', $body);
+ $callback = new _tag_clound_topic_count_text_callback();
+ $callback->single_text = $args['single_text'];
+ $callback->multiple_text = $args['multiple_text'];
+ $args['topic_count_text_callback'] = array($callback, '_callback');
}
$args = wp_parse_args( $args, $defaults );
@@ -676,9 +705,9 @@
} else {
// SQL cannot save you; this is a second (potentially different) sort on a subset of data.
if ( 'name' == $orderby )
- uasort( $tags, create_function('$a, $b', 'return strnatcasecmp($a->name, $b->name);') );
+ uasort( $tags, '_wp_tag_cloud_name_sort_cb' );
else
- uasort( $tags, create_function('$a, $b', 'return ($a->count > $b->count);') );
+ uasort( $tags, '_wp_tag_cloud_count_sort_cb' );
if ( 'DESC' == $order )
$tags = array_reverse( $tags, true );
@@ -712,7 +741,7 @@
$tag_link = '#' != $tag->link ? esc_url( $tag->link ) : '#';
$tag_id = isset($tags[ $key ]->id) ? $tags[ $key ]->id : $key;
$tag_name = $tags[ $key ]->name;
- $a[] = "$tag_name";
}
Index: wp-admin/includes/plugin.php
===================================================================
--- wp-admin/includes/plugin.php (revision 15471)
+++ wp-admin/includes/plugin.php (working copy)
@@ -183,6 +183,10 @@
return $plugin_files;
}
+function _plugin_sort_callback($a, $b) {
+ return strnatcasecmp( $a['Name'], $b['Name'] );
+}
+
/**
* Check the plugins directory and retrieve all plugin files with plugin data.
*
@@ -260,7 +264,7 @@
$wp_plugins[plugin_basename( $plugin_file )] = $plugin_data;
}
- uasort( $wp_plugins, create_function( '$a, $b', 'return strnatcasecmp( $a["Name"], $b["Name"] );' ));
+ uasort( $wp_plugins, '_plugin_sort_callback');
$cache_plugins[ $plugin_folder ] = $wp_plugins;
wp_cache_set('plugins', $cache_plugins, 'plugins');
@@ -312,7 +316,7 @@
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, '_plugin_sort_callback');
return $wp_plugins;
}
@@ -353,7 +357,7 @@
$dropins[ $plugin_file ] = $plugin_data;
}
- uksort( $dropins, create_function( '$a, $b', 'return strnatcasecmp( $a, $b );' ));
+ uksort( $dropins, 'strnatcasecmp');
return $dropins;
}
@@ -401,6 +405,18 @@
}
/**
+ * Check whether the plugin is not active by checking the active_plugins list.
+ *
+ * @since 3.0.0
+ *
+ * @param string $plugin Base plugin path from plugins directory.
+ * @return bool True, if not in the active plugins list. False, if in the list.
+ */
+function is_plugin_not_active( $plugin ) {
+ return !is_plugin_active( $plugin );
+}
+
+/**
* Check whether the plugin is active for the entire network.
*
* @since 3.0.0
Index: wp-admin/includes/widgets.php
===================================================================
--- wp-admin/includes/widgets.php (revision 15471)
+++ wp-admin/includes/widgets.php (working copy)
@@ -6,6 +6,10 @@
* @subpackage Administration
*/
+function _sort_widgets_cb($a, $b) {
+ return strnatcasecmp( $a["name"], $b["name"] );
+}
+
/**
* Display list of the available widgets, either all or matching search.
*
@@ -20,7 +24,7 @@
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_widgets_cb' );
$done = array();
foreach ( $sort as $widget ) {
Index: wp-admin/includes/import.php
===================================================================
--- wp-admin/includes/import.php (revision 15471)
+++ wp-admin/includes/import.php (working copy)
@@ -6,6 +6,10 @@
* @subpackage Administration
*/
+function _sort_importers_callback($a, $b) {
+ return strcmp($a[0], $b[0]);
+}
+
/**
* Retrieve list of importers.
*
@@ -16,7 +20,7 @@
function get_importers() {
global $wp_importers;
if ( is_array($wp_importers) )
- uasort($wp_importers, create_function('$a, $b', 'return strcmp($a[0], $b[0]);'));
+ uasort($wp_importers, '_sort_importers_callback');
return $wp_importers;
}
Index: wp-admin/includes/media.php
===================================================================
--- wp-admin/includes/media.php (revision 15471)
+++ wp-admin/includes/media.php (working copy)
@@ -1837,6 +1837,13 @@
start . ', 10';
+ }
+}
+
/**
* {@internal Missing Short Description}}
*
@@ -1860,8 +1867,11 @@
$start = ( $_GET['paged'] - 1 ) * 10;
if ( $start < 1 )
$start = 0;
- add_filter( 'post_limits', create_function( '$a', "return 'LIMIT $start, 10';" ) );
+ $filter = new _media_post_limits_filter();
+ $filter->start = $start;
+ add_filter( 'post_limits', array($filter, '_callback') );
+
list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query();
?>
Index: wp-admin/plugins.php
===================================================================
--- wp-admin/plugins.php (revision 15471)
+++ wp-admin/plugins.php (working copy)
@@ -90,7 +90,7 @@
check_admin_referer('bulk-manage-plugins');
$plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
- $plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); // Only activate plugins which are not already active.
+ $plugins = array_filter($plugins, 'is_plugin_not_active' ); // Only activate plugins which are not already active.
if ( empty($plugins) ) {
wp_redirect("plugins.php?plugin_status=$status&paged=$page");
exit;
@@ -207,7 +207,7 @@
//$_POST = from the plugin form; $_GET = from the FTP details screen.
$plugins = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array();
- $plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);') ); //Do not allow to delete Activated plugins.
+ $plugins = array_filter($plugins, 'is_plugin_not_active' ); //Do not allow to delete Activated plugins.
if ( empty($plugins) ) {
wp_redirect("plugins.php?plugin_status=$status&paged=$page");
exit;
Index: wp-admin/widgets.php
===================================================================
--- wp-admin/widgets.php (revision 15471)
+++ wp-admin/widgets.php (working copy)
@@ -23,8 +23,12 @@
set_user_setting( 'widgets_access', $widgets_access );
}
+function _widget_filter_access_cb() {
+ return ' widgets_access ';
+}
+
if ( 'on' == $widgets_access )
- add_filter( 'admin_body_class', create_function('', '{return " widgets_access ";}') );
+ add_filter( 'admin_body_class', '_widget_filter_access_cb' );
else
wp_enqueue_script('admin-widgets');
Index: wp-admin/import.php
===================================================================
--- wp-admin/import.php (revision 15471)
+++ wp-admin/import.php (working copy)
@@ -86,7 +86,7 @@
if (empty ($importers)) {
echo ''.__('No importers are available.').'
'; // TODO: make more helpful
} else {
- uasort($importers, create_function('$a, $b', 'return strcmp($a[0], $b[0]);'));
+ uasort($importers, '_sort_importers_callback');
?>