Make WordPress Core


Ignore:
File:
1 edited

Legend:

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

    r3374 r4349  
    2020                return strtr($string, $trans_tbl);
    2121        }
    22        
     22
    2323        function greet() {
     24                echo '<div class="narrow">';
    2425                echo '<p>'.__('Howdy! This importer allows you to extract posts from any RSS 2.0 file into your blog. This is useful if you want to import your posts from a system that is not handled by a custom import tool. Pick an RSS file to upload and click Import.').'</p>';
    2526                wp_import_upload_form("admin.php?import=rss&amp;step=1");
     27                echo '</div>';
    2628        }
    2729
    2830        function get_posts() {
    2931                global $wpdb;
    30                
     32
    3133                set_magic_quotes_runtime(0);
    3234                $datalines = file($this->file); // Read the file into an array
     
    3941                foreach ($this->posts as $post) {
    4042                        preg_match('|<title>(.*?)</title>|is', $post, $post_title);
    41                         $post_title = $wpdb->escape(trim($post_title[1]));
     43                        $post_title = str_replace(array('<![CDATA[', ']]>'), '', $wpdb->escape( trim($post_title[1]) ));
    4244
    43                         preg_match('|<pubdate>(.*?)</pubdate>|is', $post, $post_date);
     45                        preg_match('|<pubdate>(.*?)</pubdate>|is', $post, $post_date_gmt);
    4446
    45                         if ($post_date) {
    46                                 $post_date = strtotime($post_date[1]);
     47                        if ($post_date_gmt) {
     48                                $post_date_gmt = strtotime($post_date_gmt[1]);
    4749                        } else {
    4850                                // if we don't already have something from pubDate
    49                                 preg_match('|<dc:date>(.*?)</dc:date>|is', $post, $post_date);
    50                                 $post_date = preg_replace('|([-+])([0-9]+):([0-9]+)$|', '\1\2\3', $post_date[1]);
    51                                 $post_date = str_replace('T', ' ', $post_date);
    52                                 $post_date = strtotime($post_date);
     51                                preg_match('|<dc:date>(.*?)</dc:date>|is', $post, $post_date_gmt);
     52                                $post_date_gmt = preg_replace('|([-+])([0-9]+):([0-9]+)$|', '\1\2\3', $post_date_gmt[1]);
     53                                $post_date_gmt = str_replace('T', ' ', $post_date_gmt);
     54                                $post_date_gmt = strtotime($post_date_gmt);
    5355                        }
    5456
    55                         $post_date = gmdate('Y-m-d H:i:s', $post_date);
     57                        $post_date_gmt = gmdate('Y-m-d H:i:s', $post_date_gmt);
     58                        $post_date = get_date_from_gmt( $post_date_gmt );
    5659
    5760                        preg_match_all('|<category>(.*?)</category>|is', $post, $categories);
     
    9194                        $post_author = 1;
    9295                        $post_status = 'publish';
    93                         $this->posts[$index] = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status', 'guid', 'categories');
     96                        $this->posts[$index] = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_status', 'guid', 'categories');
    9497                        $index++;
    9598                }
     
    135138                $this->import_posts();
    136139                wp_import_cleanup($file['id']);
    137                
     140
    138141                echo '<h3>';
    139142                printf(__('All done. <a href="%s">Have fun!</a>'), get_option('home'));
     
    148151
    149152                $this->header();
    150                
     153
    151154                switch ($step) {
    152155                        case 0 :
     
    157160                                break;
    158161                }
    159                
     162
    160163                $this->footer();
    161164        }
    162165
    163166        function RSS_Import() {
    164                 // Nothing.     
     167                // Nothing.
    165168        }
    166169}
     
    168171$rss_import = new RSS_Import();
    169172
    170 register_importer('rss', 'RSS', __('Import posts from an RSS feed'), array ($rss_import, 'dispatch'));
     173register_importer('rss', __('RSS'), __('Import posts from an RSS feed'), array ($rss_import, 'dispatch'));
    171174?>
Note: See TracChangeset for help on using the changeset viewer.