Ticket #14424: wp-create-function-changes.diff
File wp-create-function-changes.diff, 21.2 KB (added by , 13 years ago) |
---|
-
wp-includes/post-template.php
171 171 echo $content; 172 172 } 173 173 174 function _convert_urlencoded_to_entities($match) { 175 return '&#' . base_convert($match[1], 16, 10) . ';'; 176 } 177 174 178 /** 175 179 * Retrieve the post content. 176 180 * … … 225 229 226 230 } 227 231 if ( $preview ) // preview fix for javascript bug with foreign languages 228 $output = preg_replace_callback('/\%u([0-9A-F]{4})/', create_function('$match', 'return "&#" . base_convert($match[1], 16, 10) . ";";'), $output);232 $output = preg_replace_callback('/\%u([0-9A-F]{4})/', '_convert_urlencoded_to_entities', $output); 229 233 230 234 return $output; 231 235 } -
wp-includes/pomo/mo.php
30 30 function export_to_file($filename) { 31 31 $fh = fopen($filename, 'wb'); 32 32 if ( !$fh ) return false; 33 $entries = array_filter($this->entries, create_function('$e', 'return !empty($e->translations);')); 33 $entries = array(); 34 foreach ($this->entries AS $entry_key => $e) { 35 if ( empty($e->translations) ) 36 continue; 37 38 $entries[$entry_key] = $e; 39 } 34 40 ksort($entries); 35 41 $magic = 0x950412de; 36 42 $revision = 0; -
wp-includes/pomo/po.php
151 151 $lines = explode("\n", $string); 152 152 // do not prepend the string on the last empty line, artefact by explode 153 153 if ("\n" == substr($string, -1)) unset($lines[count($lines) - 1]); 154 $res = implode("\n", array_map(create_function('$x', "return $php_with.\$x;"), $lines)); 154 foreach ($lines AS $line => $x) { 155 $lines[$line] = $php_with . $x; 156 } 157 $res = implode("\n", $lines); 155 158 // give back the empty line, we ignored above 156 159 if ("\n" == substr($string, -1)) $res .= "\n"; 157 160 return $res; … … 218 221 return $res !== false; 219 222 } 220 223 224 function _is_context_final($context) { 225 return $context == "msgstr" || $context == "msgstr_plural"; 226 } 227 221 228 function read_entry($f, $lineno = 0) { 222 229 $entry = new Translation_Entry(); 223 230 // where were we in the last step 224 231 // can be: comment, msgctxt, msgid, msgid_plural, msgstr, msgstr_plural 225 232 $context = ''; 226 233 $msgstr_index = 0; 227 $is_final = create_function('$context', 'return $context == "msgstr" || $context == "msgstr_plural";');228 234 while (true) { 229 235 $lineno++; 230 236 $line = PO::read_line($f); 231 237 if (!$line) { 232 238 if (feof($f)) { 233 if ($ is_final($context))239 if ($this->_is_context_final($context)) 234 240 break; 235 241 elseif (!$context) // we haven't read a line and eof came 236 242 return null; … … 244 250 $line = trim($line); 245 251 if (preg_match('/^#/', $line, $m)) { 246 252 // the comment is the start of a new entry 247 if ($ is_final($context)) {253 if ($this->_is_context_final($context)) { 248 254 PO::read_line($f, 'put-back'); 249 255 $lineno--; 250 256 break; … … 256 262 // add comment 257 263 $this->add_comment_to_entry($entry, $line); 258 264 } elseif (preg_match('/^msgctxt\s+(".*")/', $line, $m)) { 259 if ($ is_final($context)) {265 if ($this->_is_context_final($context)) { 260 266 PO::read_line($f, 'put-back'); 261 267 $lineno--; 262 268 break; … … 267 273 $context = 'msgctxt'; 268 274 $entry->context .= PO::unpoify($m[1]); 269 275 } elseif (preg_match('/^msgid\s+(".*")/', $line, $m)) { 270 if ($ is_final($context)) {276 if ($this->_is_context_final($context)) { 271 277 PO::read_line($f, 'put-back'); 272 278 $lineno--; 273 279 break; … … 317 323 return false; 318 324 } 319 325 } 320 if (array() == array_filter($entry->translations, create_function('$t', 'return $t || "0" === $t;'))) { 326 327 $array_has_values = false; 328 foreach ($this->translations AS $t) { 329 if ($t || "0" === $t ) { 330 $array_has_values = true; 331 break; 332 } 333 } 334 if (!$array_has_values) { 321 335 $entry->translations = array(); 322 336 } 323 337 return array('entry' => $entry, 'lineno' => $lineno); -
wp-includes/pomo/translations.php
120 120 */ 121 121 function gettext_select_plural_form($count) { 122 122 if (!isset($this->_gettext_select_plural_form) || is_null($this->_gettext_select_plural_form)) { 123 list( $nplurals, $expression ) = $this->nplurals_and_expression_from_header($this->get_header('Plural-Forms'));123 list( $nplurals, $expression_cb ) = $this->nplurals_and_expression_from_header($this->get_header('Plural-Forms')); 124 124 $this->_nplurals = $nplurals; 125 $this->_gettext_select_plural_form = $ this->make_plural_form_function($nplurals, $expression);125 $this->_gettext_select_plural_form = $expression_cb; 126 126 } 127 127 return call_user_func($this->_gettext_select_plural_form, $count); 128 128 } 129 129 130 function _gettext_default_plural_cb($n) { 131 $index = (int)($n != 1); 132 return ($index < 2 ? $index : 2 - 1); 133 } 134 130 135 function nplurals_and_expression_from_header($header) { 131 136 if (preg_match('/^\s*nplurals\s*=\s*(\d+)\s*;\s+plural\s*=\s*(.+)$/', $header, $matches)) { 132 137 $nplurals = (int)$matches[1]; 133 138 $expression = trim($this->parenthesize_plural_exression($matches[2])); 134 return array($nplurals, $ expression);139 return array($nplurals, $this->make_plural_form_function($nplurals, $expression)); 135 140 } else { 136 return array(2, 'n != 1');141 return array(2, array($this, '_gettext_default_plural_cb')); 137 142 } 138 143 } 139 144 … … 197 202 function set_header($header, $value) { 198 203 parent::set_header($header, $value); 199 204 if ('Plural-Forms' == $header) { 200 list( $nplurals, $expression ) = $this->nplurals_and_expression_from_header($this->get_header('Plural-Forms'));205 list( $nplurals, $expression_cb ) = $this->nplurals_and_expression_from_header($this->get_header('Plural-Forms')); 201 206 $this->_nplurals = $nplurals; 202 $this->_gettext_select_plural_form = $ this->make_plural_form_function($nplurals, $expression);207 $this->_gettext_select_plural_form = $expression_cb; 203 208 } 204 209 } 205 210 } -
wp-includes/post.php
971 971 972 972 if ( !isset( $object->labels['singular_name'] ) && isset( $object->labels['name'] ) ) 973 973 $object->labels['singular_name'] = $object->labels['name']; 974 975 foreach ( $nohier_vs_hier_defaults AS $key => $value ) { 976 if ( $object->hierarchical ) { 977 $defaults[$key] = $value[1]; 978 } else { 979 $defaults[$key] = $value[0]; 980 } 981 } 974 982 975 $defaults = array_map( create_function( '$x', $object->hierarchical? 'return $x[1];' : 'return $x[0];' ), $nohier_vs_hier_defaults );976 983 $labels = array_merge( $defaults, $object->labels ); 977 984 return (object)$labels; 978 985 } -
wp-includes/formatting.php
164 164 return $text; 165 165 } 166 166 167 function _preserve_newlines_callback($matches) { 168 return str_replace("\n", "<WPPreserveNewline />", $matches[0]); 169 } 170 167 171 /** 168 172 * Replaces double line-breaks with paragraph elements. 169 173 * … … 208 212 $pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee); 209 213 $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*</p>!', "$1", $pee); 210 214 if ($br) { 211 $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', create_function('$matches', 'return str_replace("\n", "<WPPreserveNewline />", $matches[0]);'), $pee);215 $pee = preg_replace_callback('/<(script|style).*?<\/\\1>/s', '_preserve_newlines_callback', $pee); 212 216 $pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks 213 217 $pee = str_replace('<WPPreserveNewline />', "\n", $pee); 214 218 } … … 1538 1542 return apply_filters( 'is_email', $email, $email, null ); 1539 1543 } 1540 1544 1545 function _wp_iso_unquote($match) { 1546 return chr(hexdec(strtolower($match[1]))); 1547 } 1548 1541 1549 /** 1542 1550 * Convert to ASCII from email subjects. 1543 1551 * … … 1553 1561 return $string; 1554 1562 } else { 1555 1563 $subject = str_replace('_', ' ', $matches[2]); 1556 $subject = preg_replace_callback('#\=([0-9a-f]{2})#i', create_function('$match', 'return chr(hexdec(strtolower($match[1])));'), $subject);1564 $subject = preg_replace_callback('#\=([0-9a-f]{2})#i', '_wp_iso_unquote', $subject); 1557 1565 return $subject; 1558 1566 } 1559 1567 } … … 2674 2682 return $str; 2675 2683 } 2676 2684 2685 function _links_add_base_with_param($m) { 2686 global $wp_formatting_base_cb; 2687 return _links_add_base($m, $wp_formatting_base_cb); 2688 } 2689 2677 2690 /** 2678 2691 * Add a Base url to relative links in passed content. 2679 2692 * … … 2688 2701 * @return string The processed content. 2689 2702 */ 2690 2703 function links_add_base_url( $content, $base, $attrs = array('src', 'href') ) { 2704 global $wp_formatting_base_cb; 2691 2705 $attrs = implode('|', (array)$attrs); 2692 return preg_replace_callback("!($attrs)=(['\"])(.+?)\\2!i",2693 create_function('$m', 'return _links_add_base($m, "' . $base . '");'),2706 $wp_formatting_base_cb = $base; 2707 return preg_replace_callback("!($attrs)=(['\"])(.+?)\\2!i", '_links_add_base_with_param', 2694 2708 $content); 2695 2709 } 2696 2710 … … 2713 2727 . $m[2]; 2714 2728 } 2715 2729 2730 function _links_add_target_with_param($m) { 2731 global $wp_formatting_target_cb; 2732 return _links_add_target($m, $wp_formatting_target_cb); 2733 } 2734 2716 2735 /** 2717 2736 * Adds a Target attribute to all links in passed content. 2718 2737 * … … 2729 2748 * @return string The processed content. 2730 2749 */ 2731 2750 function links_add_target( $content, $target = '_blank', $tags = array('a') ) { 2751 global $wp_formatting_target_cb; 2732 2752 $tags = implode('|', (array)$tags); 2733 return preg_replace_callback("!<($tags)(.+?)>!i",2734 create_function('$m', 'return _links_add_target($m, "' . $target . '");'),2753 $wp_formatting_target_cb = $target; 2754 return preg_replace_callback("!<($tags)(.+?)>!i", '_links_add_target_with_param', 2735 2755 $content); 2736 2756 } 2737 2757 -
wp-includes/atomlib.php
91 91 92 92 $this->feed = new AtomFeed(); 93 93 $this->current = null; 94 $this->map_attrs_func = create_function('$k,$v', 'return "$k=\"$v\"";');95 $this->map_xmlns_func = create_function('$p,$n', '$xd = "xmlns"; if(strlen($n[0])>0) $xd .= ":{$n[0]}"; return "{$xd}=\"{$n[1]}\"";');94 $this->map_attrs_func = array('AtomParser', 'map_attrs_func'); 95 $this->map_xmlns_func = array('AtomParser', 'map_xmlns_func'); 96 96 } 97 97 98 function map_attrs_func($k, $v) { 99 return "$k=\"$v\""; 100 } 101 102 function map_xmlns_func($p, $n) { 103 $xd = 'xmlns'; 104 if (strlen($n[0]) > 0) { 105 $xd .= ":{$n[0]}"; 106 } 107 return "{$xd}=\"{$n[1]}\""; 108 } 109 98 110 function _p($msg) { 99 111 if($this->debug) { 100 112 print str_repeat(" ", $this->depth * $this->indent) . $msg ."\n"; -
wp-includes/kses.php
530 530 return '0.2.2'; 531 531 } 532 532 533 function _wp_kses_split_callback($match) { 534 global $pass_allowed_html, $pass_allowed_protocols; 535 return wp_kses_split2($match[1], $pass_allowed_html, $pass_allowed_protocols); 536 } 537 533 538 /** 534 539 * Searches for HTML tags, no matter how malformed. 535 540 * … … 546 551 global $pass_allowed_html, $pass_allowed_protocols; 547 552 $pass_allowed_html = $allowed_html; 548 553 $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); 554 return preg_replace_callback('%((<!--.*?(-->|$))|(<[^>]*(>|$)|>))%', '_wp_kses_split_callback', $string); 551 555 } 552 556 553 557 /** -
wp-includes/category-template.php
612 612 return round(log10($count + 1) * 100); 613 613 } 614 614 615 /** 616 * Callback for comparing tags based on name 617 * 618 * @param object a tag object to be compared 619 * @param object a tag object to be compared 620 * @return integer -1 for less than, 0 for the same and 1 for greater 621 */ 622 function _wp_tag_cloud_name_sort_cb($a, $b) { 623 return strnatcasecmp($a->name, $b->name); 624 } 615 625 616 626 /** 627 * Callback for comparing tags based on count 628 * 629 * @param object a tag object to be compared 630 * @param object a tag object to be compared 631 * @return integer -1 for less than, 0 for the same and 1 for greater 632 */ 633 function _wp_tag_cloud_count_sort_cb($a, $b) { 634 return ($a->count > $b->count); 635 } 636 637 class _tag_clound_topic_count_text_callback { 638 var $single_text; 639 var $multiple_text; 640 function _callback($count) { 641 return sprintf( _n( $this->single_text, $this->multiple_text, $count ), number_format_i18n( $count ) ); 642 } 643 } 644 645 /** 617 646 * Generates a tag cloud (heatmap) from provided data. 618 647 * 619 648 * The text size is set by the 'smallest' and 'largest' arguments, which will … … 654 683 ); 655 684 656 685 if ( !isset( $args['topic_count_text_callback'] ) && isset( $args['single_text'] ) && isset( $args['multiple_text'] ) ) { 657 $ body = 'return sprintf (658 _n(' . var_export($args['single_text'], true) . ', ' . var_export($args['multiple_text'], true) . ', $count),659 number_format_i18n( $count ));';660 $args['topic_count_text_callback'] = create_function('$count', $body);686 $callback = new _tag_clound_topic_count_text_callback(); 687 $callback->single_text = $args['single_text']; 688 $callback->multiple_text = $args['multiple_text']; 689 $args['topic_count_text_callback'] = array($callback, '_callback'); 661 690 } 662 691 663 692 $args = wp_parse_args( $args, $defaults ); … … 676 705 } else { 677 706 // SQL cannot save you; this is a second (potentially different) sort on a subset of data. 678 707 if ( 'name' == $orderby ) 679 uasort( $tags, create_function('$a, $b', 'return strnatcasecmp($a->name, $b->name);'));708 uasort( $tags, '_wp_tag_cloud_name_sort_cb' ); 680 709 else 681 uasort( $tags, create_function('$a, $b', 'return ($a->count > $b->count);'));710 uasort( $tags, '_wp_tag_cloud_count_sort_cb' ); 682 711 683 712 if ( 'DESC' == $order ) 684 713 $tags = array_reverse( $tags, true ); … … 712 741 $tag_link = '#' != $tag->link ? esc_url( $tag->link ) : '#'; 713 742 $tag_id = isset($tags[ $key ]->id) ? $tags[ $key ]->id : $key; 714 743 $tag_name = $tags[ $key ]->name; 715 $a[] = "<a href='$tag_link' class='tag-link-$tag_id' title='" . esc_attr( $topic_count_text_callback($real_count ) ) . "' style='font-size: " .744 $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: " . 716 745 ( $smallest + ( ( $count - $min_count ) * $font_step ) ) 717 746 . "$unit;'>$tag_name</a>"; 718 747 } -
wp-admin/includes/plugin.php
183 183 return $plugin_files; 184 184 } 185 185 186 function _plugin_sort_callback($a, $b) { 187 return strnatcasecmp( $a['Name'], $b['Name'] ); 188 } 189 186 190 /** 187 191 * Check the plugins directory and retrieve all plugin files with plugin data. 188 192 * … … 260 264 $wp_plugins[plugin_basename( $plugin_file )] = $plugin_data; 261 265 } 262 266 263 uasort( $wp_plugins, create_function( '$a, $b', 'return strnatcasecmp( $a["Name"], $b["Name"] );' ));267 uasort( $wp_plugins, '_plugin_sort_callback'); 264 268 265 269 $cache_plugins[ $plugin_folder ] = $wp_plugins; 266 270 wp_cache_set('plugins', $cache_plugins, 'plugins'); … … 312 316 if ( isset( $wp_plugins['index.php'] ) && filesize( WPMU_PLUGIN_DIR . '/index.php') <= 30 ) // silence is golden 313 317 unset( $wp_plugins['index.php'] ); 314 318 315 uasort( $wp_plugins, create_function( '$a, $b', 'return strnatcasecmp( $a["Name"], $b["Name"] );' ));319 uasort( $wp_plugins, '_plugin_sort_callback'); 316 320 317 321 return $wp_plugins; 318 322 } … … 353 357 $dropins[ $plugin_file ] = $plugin_data; 354 358 } 355 359 356 uksort( $dropins, create_function( '$a, $b', 'return strnatcasecmp( $a, $b );' ));360 uksort( $dropins, 'strnatcasecmp'); 357 361 358 362 return $dropins; 359 363 } … … 401 405 } 402 406 403 407 /** 408 * Check whether the plugin is not active by checking the active_plugins list. 409 * 410 * @since 3.0.0 411 * 412 * @param string $plugin Base plugin path from plugins directory. 413 * @return bool True, if not in the active plugins list. False, if in the list. 414 */ 415 function is_plugin_not_active( $plugin ) { 416 return !is_plugin_active( $plugin ); 417 } 418 419 /** 404 420 * Check whether the plugin is active for the entire network. 405 421 * 406 422 * @since 3.0.0 -
wp-admin/includes/widgets.php
6 6 * @subpackage Administration 7 7 */ 8 8 9 function _sort_widgets_cb($a, $b) { 10 return strnatcasecmp( $a["name"], $b["name"] ); 11 } 12 9 13 /** 10 14 * Display list of the available widgets, either all or matching search. 11 15 * … … 20 24 global $wp_registered_widgets, $sidebars_widgets, $wp_registered_widget_controls; 21 25 22 26 $sort = $wp_registered_widgets; 23 usort( $sort, create_function( '$a, $b', 'return strnatcasecmp( $a["name"], $b["name"] );' ));27 usort( $sort, '_sort_widgets_cb' ); 24 28 $done = array(); 25 29 26 30 foreach ( $sort as $widget ) { -
wp-admin/includes/import.php
6 6 * @subpackage Administration 7 7 */ 8 8 9 function _sort_importers_callback($a, $b) { 10 return strcmp($a[0], $b[0]); 11 } 12 9 13 /** 10 14 * Retrieve list of importers. 11 15 * … … 16 20 function get_importers() { 17 21 global $wp_importers; 18 22 if ( is_array($wp_importers) ) 19 uasort($wp_importers, create_function('$a, $b', 'return strcmp($a[0], $b[0]);'));23 uasort($wp_importers, '_sort_importers_callback'); 20 24 return $wp_importers; 21 25 } 22 26 -
wp-admin/includes/media.php
1837 1837 <?php 1838 1838 } 1839 1839 1840 class _media_post_limits_filter { 1841 var $start = 0; 1842 function _callback($a) { 1843 return 'LIMIT ' . $this->start . ', 10'; 1844 } 1845 } 1846 1840 1847 /** 1841 1848 * {@internal Missing Short Description}} 1842 1849 * … … 1860 1867 $start = ( $_GET['paged'] - 1 ) * 10; 1861 1868 if ( $start < 1 ) 1862 1869 $start = 0; 1863 add_filter( 'post_limits', create_function( '$a', "return 'LIMIT $start, 10';" ) ); 1870 $filter = new _media_post_limits_filter(); 1871 $filter->start = $start; 1864 1872 1873 add_filter( 'post_limits', array($filter, '_callback') ); 1874 1865 1875 list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query(); 1866 1876 1867 1877 ?> -
wp-admin/plugins.php
90 90 check_admin_referer('bulk-manage-plugins'); 91 91 92 92 $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array(); 93 $plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);')); // Only activate plugins which are not already active.93 $plugins = array_filter($plugins, 'is_plugin_not_active' ); // Only activate plugins which are not already active. 94 94 if ( empty($plugins) ) { 95 95 wp_redirect("plugins.php?plugin_status=$status&paged=$page"); 96 96 exit; … … 207 207 208 208 //$_POST = from the plugin form; $_GET = from the FTP details screen. 209 209 $plugins = isset( $_REQUEST['checked'] ) ? (array) $_REQUEST['checked'] : array(); 210 $plugins = array_filter($plugins, create_function('$plugin', 'return !is_plugin_active($plugin);')); //Do not allow to delete Activated plugins.210 $plugins = array_filter($plugins, 'is_plugin_not_active' ); //Do not allow to delete Activated plugins. 211 211 if ( empty($plugins) ) { 212 212 wp_redirect("plugins.php?plugin_status=$status&paged=$page"); 213 213 exit; -
wp-admin/widgets.php
23 23 set_user_setting( 'widgets_access', $widgets_access ); 24 24 } 25 25 26 function _widget_filter_access_cb() { 27 return ' widgets_access '; 28 } 29 26 30 if ( 'on' == $widgets_access ) 27 add_filter( 'admin_body_class', create_function('', '{return " widgets_access ";}'));31 add_filter( 'admin_body_class', '_widget_filter_access_cb' ); 28 32 else 29 33 wp_enqueue_script('admin-widgets'); 30 34 -
wp-admin/import.php
86 86 if (empty ($importers)) { 87 87 echo '<p>'.__('No importers are available.').'</p>'; // TODO: make more helpful 88 88 } else { 89 uasort($importers, create_function('$a, $b', 'return strcmp($a[0], $b[0]);'));89 uasort($importers, '_sort_importers_callback'); 90 90 ?> 91 91 <table class="widefat" cellspacing="0"> 92 92