Make WordPress Core

Ticket #10836: 10836.diff

File 10836.diff, 7.9 KB (added by mdawaffe, 15 years ago)
  • wp-admin/import/livejournal.php

     
    324324                echo '</ol>';
    325325        }
    326326
     327        function _normalize_tag( $matches ) {
     328                return '<' . strtolower( $match[1] );
     329        }
     330
    327331        function import_post( $post ) {
    328332                global $wpdb;
    329333
     
    350354
    351355                // Clean up content
    352356                $post_content = $post['event'];
    353                 $post_content = preg_replace_callback( '|<(/?[A-Z]+)|', create_function( '$match', 'return "<" . strtolower( $match[1] );' ), $post_content );
     357                $post_content = preg_replace_callback( '|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $post_content );
    354358                // XHTMLize some tags
    355359                $post_content = str_replace( '<br>', '<br />', $post_content );
    356360                $post_content = str_replace( '<hr>', '<hr />', $post_content );
     
    581585                $comment_content = wpautop( $comment_content );
    582586                $comment_content = str_replace( '<br>', '<br />', $comment_content );
    583587                $comment_content = str_replace( '<hr>', '<hr />', $comment_content );
    584                 $comment_content = preg_replace_callback( '|<(/?[A-Z]+)|', create_function( '$match', 'return "<" . strtolower( $match[1] );' ), $comment_content );
     588                $comment_content = preg_replace_callback( '|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $comment_content );
    585589                $comment_content = $wpdb->escape( trim( $comment_content ) );
    586590
    587591                // Get and convert the date
  • wp-admin/import/blogger.php

     
    529529                return preg_replace( '|\s+|', ' ', $string );
    530530        }
    531531
     532        function _normalize_tag( $matches ) {
     533                return '<' . strtolower( $match[1] );
     534        }
     535
    532536        function import_post( $entry ) {
    533537                global $importing_blog;
    534538
     
    551555                $post_status  = isset( $entry->draft ) ? 'draft' : 'publish';
    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);
    557561
     
    604608                $comment_content = addslashes( $this->no_apos( @html_entity_decode( $entry->content, ENT_COMPAT, get_option('blog_charset') ) ) );
    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);
    610614
     
    905909        var $entry;
    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]}\"";');
    912913        }
    913914
     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]}\"";
     925        }
     926
    914927        function parse($xml) {
    915928
    916929                global $app_logging;
     
    950963                        foreach($attrs as $key => $value) {
    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;
    961974                        }
  • wp-admin/import/blogware.php

     
    4242                echo '</div>';
    4343        }
    4444
     45        function _normalize_tag( $matches ) {
     46                return '<' . strtolower( $match[1] );
     47        }
     48
    4549        function import_posts() {
    4650                global $wpdb, $current_user;
    4751
     
    8993                        }
    9094
    9195                        // Clean up content
    92                         $post_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_content);
     96                        $post_content = preg_replace_callback('|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $post_content);
    9397                        $post_content = str_replace('<br>', '<br />', $post_content);
    9498                        $post_content = str_replace('<hr>', '<hr />', $post_content);
    9599                        $post_content = $wpdb->escape($post_content);
     
    129133                                        $comment_content = $this->unhtmlentities($comment_content);
    130134
    131135                                        // Clean up content
    132                                         $comment_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $comment_content);
     136                                        $comment_content = preg_replace_callback('|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $comment_content);
    133137                                        $comment_content = str_replace('<br>', '<br />', $comment_content);
    134138                                        $comment_content = str_replace('<hr>', '<hr />', $comment_content);
    135139                                        $comment_content = $wpdb->escape($comment_content);
  • wp-admin/import/rss.php

     
    4343                echo '</div>';
    4444        }
    4545
     46        function _normalize_tag( $matches ) {
     47                return '<' . strtolower( $match[1] );
     48        }
     49
    4650        function get_posts() {
    4751                global $wpdb;
    4852
     
    103107                        }
    104108
    105109                        // Clean up content
    106                         $post_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_content);
     110                        $post_content = preg_replace_callback('|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $post_content);
    107111                        $post_content = str_replace('<br>', '<br />', $post_content);
    108112                        $post_content = str_replace('<hr>', '<hr />', $post_content);
    109113
  • wp-admin/import/wordpress.php

     
    357357                echo '<h3>'.sprintf(__('All done.').' <a href="%s">'.__('Have fun!').'</a>', get_option('home')).'</h3>';
    358358        }
    359359
     360        function _normalize_tag( $matches ) {
     361                return '<' . strtolower( $match[1] );
     362        }
     363
    360364        function process_post($post) {
    361365                global $wpdb;
    362366
     
    383387                $post_author    = $this->get_tag( $post, 'dc:creator' );
    384388
    385389                $post_excerpt = $this->get_tag( $post, 'excerpt:encoded' );
    386                 $post_excerpt = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_excerpt);
     390                $post_excerpt = preg_replace_callback('|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $post_excerpt);
    387391                $post_excerpt = str_replace('<br>', '<br />', $post_excerpt);
    388392                $post_excerpt = str_replace('<hr>', '<hr />', $post_excerpt);
    389393
    390394                $post_content = $this->get_tag( $post, 'content:encoded' );
    391                 $post_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_content);
     395                $post_content = preg_replace_callback('|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $post_content);
    392396                $post_content = str_replace('<br>', '<br />', $post_content);
    393397                $post_content = str_replace('<hr>', '<hr />', $post_content);
    394398