Make WordPress Core


Ignore:
Timestamp:
09/23/2009 10:03:39 PM (17 years ago)
Author:
ryan
Message:

Use hard-coded functions instead of create_function() in importers. Props mdawaffe. fixes #10836

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/import/blogger.php

    r11245 r11964  
    530530        }
    531531
     532        function _normalize_tag( $matches ) {
     533                return '<' . strtolower( $match[1] );
     534        }
     535
    532536        function import_post( $entry ) {
    533537                global $importing_blog;
    … …  
    552556
    553557                // Clean up content
    554                 $post_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_content);
     558                $post_content = preg_replace_callback('|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $post_content);
    555559                $post_content = str_replace('<br>', '<br />', $post_content);
    556560                $post_content = str_replace('<hr>', '<hr />', $post_content);
    … …  
    605609
    606610                // Clean up content
    607                 $comment_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $comment_content);
     611                $comment_content = preg_replace_callback('|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $comment_content);
    608612                $comment_content = str_replace('<br>', '<br />', $comment_content);
    609613                $comment_content = str_replace('<hr>', '<hr />', $comment_content);
    … …  
    906910
    907911        function AtomParser() {
    908 
    909912                $this->entry = new AtomEntry();
    910                 $this->map_attrs_func = create_function('$k,$v', 'return "$k=\"$v\"";');
    911                 $this->map_xmlns_func = create_function('$p,$n', '$xd = "xmlns"; if(strlen($n[0])>0) $xd .= ":{$n[0]}"; return "{$xd}=\"{$n[1]}\"";');
     913        }
     914
     915        function _map_attrs_func( $k, $v ) {
     916                return "$k=\"$v\"";
     917        }
     918
     919        function _map_xmlns_func( $p, $n ) {
     920                $xd = "xmlns";
     921                if ( strlen( $n[0] ) > 0 )
     922                        $xd .= ":{$n[0]}";
     923
     924                return "{$xd}=\"{$n[1]}\"";
    912925        }
    913926
    … …  
    951964                                $attrs_prefix[$this->ns_to_prefix($key)] = $this->xml_escape($value);
    952965                        }
    953                         $attrs_str = join(' ', array_map($this->map_attrs_func, array_keys($attrs_prefix), array_values($attrs_prefix)));
     966                        $attrs_str = join(' ', array_map( array( &$this, '_map_attrs_func' ), array_keys($attrs_prefix), array_values($attrs_prefix)));
    954967                        if(strlen($attrs_str) > 0) {
    955968                                $attrs_str = " " . $attrs_str;
    956969                        }
    957970
    958                         $xmlns_str = join(' ', array_map($this->map_xmlns_func, array_keys($this->ns_contexts[0]), array_values($this->ns_contexts[0])));
     971                        $xmlns_str = join(' ', array_map( array( &$this, '_map_xmlns_func' ), array_keys($this->ns_contexts[0]), array_values($this->ns_contexts[0])));
    959972                        if(strlen($xmlns_str) > 0) {
    960973                                $xmlns_str = " " . $xmlns_str;
Note: See TracChangeset for help on using the changeset viewer.