Changes in trunk/wp-admin/import/rss.php [4349:3374]
- File:
-
- 1 edited
-
trunk/wp-admin/import/rss.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/import/rss.php
r4349 r3374 20 20 return strtr($string, $trans_tbl); 21 21 } 22 22 23 23 function greet() { 24 echo '<div class="narrow">';25 24 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>'; 26 25 wp_import_upload_form("admin.php?import=rss&step=1"); 27 echo '</div>';28 26 } 29 27 30 28 function get_posts() { 31 29 global $wpdb; 32 30 33 31 set_magic_quotes_runtime(0); 34 32 $datalines = file($this->file); // Read the file into an array … … 41 39 foreach ($this->posts as $post) { 42 40 preg_match('|<title>(.*?)</title>|is', $post, $post_title); 43 $post_title = str_replace(array('<![CDATA[', ']]>'), '', $wpdb->escape( trim($post_title[1])));41 $post_title = $wpdb->escape(trim($post_title[1])); 44 42 45 preg_match('|<pubdate>(.*?)</pubdate>|is', $post, $post_date _gmt);43 preg_match('|<pubdate>(.*?)</pubdate>|is', $post, $post_date); 46 44 47 if ($post_date _gmt) {48 $post_date _gmt = strtotime($post_date_gmt[1]);45 if ($post_date) { 46 $post_date = strtotime($post_date[1]); 49 47 } else { 50 48 // if we don't already have something from pubDate 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);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); 55 53 } 56 54 57 $post_date_gmt = gmdate('Y-m-d H:i:s', $post_date_gmt); 58 $post_date = get_date_from_gmt( $post_date_gmt ); 55 $post_date = gmdate('Y-m-d H:i:s', $post_date); 59 56 60 57 preg_match_all('|<category>(.*?)</category>|is', $post, $categories); … … 94 91 $post_author = 1; 95 92 $post_status = 'publish'; 96 $this->posts[$index] = compact('post_author', 'post_date', 'post_ date_gmt', 'post_content', 'post_title', 'post_status', 'guid', 'categories');93 $this->posts[$index] = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status', 'guid', 'categories'); 97 94 $index++; 98 95 } … … 138 135 $this->import_posts(); 139 136 wp_import_cleanup($file['id']); 140 137 141 138 echo '<h3>'; 142 139 printf(__('All done. <a href="%s">Have fun!</a>'), get_option('home')); … … 151 148 152 149 $this->header(); 153 150 154 151 switch ($step) { 155 152 case 0 : … … 160 157 break; 161 158 } 162 159 163 160 $this->footer(); 164 161 } 165 162 166 163 function RSS_Import() { 167 // Nothing. 164 // Nothing. 168 165 } 169 166 } … … 171 168 $rss_import = new RSS_Import(); 172 169 173 register_importer('rss', __('RSS'), __('Import posts from an RSS feed'), array ($rss_import, 'dispatch'));170 register_importer('rss', 'RSS', __('Import posts from an RSS feed'), array ($rss_import, 'dispatch')); 174 171 ?>
Note: See TracChangeset
for help on using the changeset viewer.