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