WXR Importer fix to resolve absolute urls without protocol and domain. fixes #7595
git-svn-id: http://svn.automattic.com/wordpress/trunk@8799 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c38f460aa6
commit
c7e516b25d
@ -106,6 +106,11 @@ class WP_Import {
|
|||||||
if ( !$is_wxr_file && preg_match('|xmlns:wp="http://wordpress[.]org/export/\d+[.]\d+/"|', $importline) )
|
if ( !$is_wxr_file && preg_match('|xmlns:wp="http://wordpress[.]org/export/\d+[.]\d+/"|', $importline) )
|
||||||
$is_wxr_file = true;
|
$is_wxr_file = true;
|
||||||
|
|
||||||
|
if ( false !== strpos($importline, '<wp:base_site_url>') ) {
|
||||||
|
preg_match('|<wp:base_site_url>(.*?)</wp:base_site_url>|is', $importline, $url);
|
||||||
|
$this->base_url = $url[1];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if ( false !== strpos($importline, '<wp:category>') ) {
|
if ( false !== strpos($importline, '<wp:category>') ) {
|
||||||
preg_match('|<wp:category>(.*?)</wp:category>|is', $importline, $category);
|
preg_match('|<wp:category>(.*?)</wp:category>|is', $importline, $category);
|
||||||
$this->categories[] = $category[1];
|
$this->categories[] = $category[1];
|
||||||
@ -539,6 +544,11 @@ class WP_Import {
|
|||||||
function process_attachment($postdata, $remote_url) {
|
function process_attachment($postdata, $remote_url) {
|
||||||
if ($this->fetch_attachments and $remote_url) {
|
if ($this->fetch_attachments and $remote_url) {
|
||||||
printf( __('Importing attachment <em>%s</em>... '), htmlspecialchars($remote_url) );
|
printf( __('Importing attachment <em>%s</em>... '), htmlspecialchars($remote_url) );
|
||||||
|
|
||||||
|
// If the URL is absolute, but does not contain http, upload it assuming the base_site_url variable
|
||||||
|
if ( preg_match('/^\/[\w\W]+$/', $remote_url) )
|
||||||
|
$remote_url = rtrim($this->base_url,'/').$remote_url;
|
||||||
|
|
||||||
$upload = $this->fetch_remote_file($postdata, $remote_url);
|
$upload = $this->fetch_remote_file($postdata, $remote_url);
|
||||||
if ( is_wp_error($upload) ) {
|
if ( is_wp_error($upload) ) {
|
||||||
printf( __('Remote file error: %s'), htmlspecialchars($upload->get_error_message()) );
|
printf( __('Remote file error: %s'), htmlspecialchars($upload->get_error_message()) );
|
||||||
|
Loading…
Reference in New Issue
Block a user