web/wp-admin/import/rss.php
branchwordpress
changeset 132 4d4862461b8d
parent 109 03b0d1493584
equal deleted inserted replaced
131:a4642baaf829 132:4d4862461b8d
    41 		echo '<p>'.__('Howdy! This importer allows you to extract posts from an 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>';
    41 		echo '<p>'.__('Howdy! This importer allows you to extract posts from an 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>';
    42 		wp_import_upload_form("admin.php?import=rss&amp;step=1");
    42 		wp_import_upload_form("admin.php?import=rss&amp;step=1");
    43 		echo '</div>';
    43 		echo '</div>';
    44 	}
    44 	}
    45 
    45 
       
    46 	function _normalize_tag( $matches ) {
       
    47 		return '<' . strtolower( $matches[1] );
       
    48 	}
       
    49 
    46 	function get_posts() {
    50 	function get_posts() {
    47 		global $wpdb;
    51 		global $wpdb;
    48 
    52 
    49 		set_magic_quotes_runtime(0);
    53 		set_magic_quotes_runtime(0);
    50 		$datalines = file($this->file); // Read the file into an array
    54 		$datalines = file($this->file); // Read the file into an array
   101 				preg_match('|<description>(.*?)</description>|is', $post, $post_content);
   105 				preg_match('|<description>(.*?)</description>|is', $post, $post_content);
   102 				$post_content = $wpdb->escape($this->unhtmlentities(trim($post_content[1])));
   106 				$post_content = $wpdb->escape($this->unhtmlentities(trim($post_content[1])));
   103 			}
   107 			}
   104 
   108 
   105 			// Clean up content
   109 			// 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);
   107 			$post_content = str_replace('<br>', '<br />', $post_content);
   111 			$post_content = str_replace('<br>', '<br />', $post_content);
   108 			$post_content = str_replace('<hr>', '<hr />', $post_content);
   112 			$post_content = str_replace('<hr>', '<hr />', $post_content);
   109 
   113 
   110 			$post_author = 1;
   114 			$post_author = 1;
   111 			$post_status = 'publish';
   115 			$post_status = 'publish';