diff --git a/includes/ContentImport/ContentImporter.php b/includes/ContentImport/ContentImporter.php index 761ba89f5..b6530ee3f 100644 --- a/includes/ContentImport/ContentImporter.php +++ b/includes/ContentImport/ContentImporter.php @@ -110,6 +110,15 @@ public function handle_import( array $data = array() ) { return $data; } + switch_to_blog( $source_blog_id ); + $can_read = current_user_can( 'read_post', $source_post_id ); + $source_post = get_post( $source_post_id ); + restore_current_blog(); + + if ( ! $can_read || ! $source_post instanceof \WP_Post ) { + return $data; + } + $source_lang = MslsBlogCollection::get_blog_language( $source_blog_id ); $dest_blog_id = get_current_blog_id(); $dest_lang = MslsBlogCollection::get_blog_language( get_current_blog_id() ); @@ -120,14 +129,6 @@ public function handle_import( array $data = array() ) { return $data; } - switch_to_blog( $source_blog_id ); - $source_post = get_post( $source_post_id ); - restore_current_blog(); - - if ( ! $source_post instanceof \WP_Post ) { - return $data; - } - $import_coordinates = new ImportCoordinates(); $import_coordinates->source_blog_id = $source_blog_id; @@ -234,6 +235,12 @@ protected function insert_blog_post( $blog_id, array $data = array() ) { switch_to_blog( $blog_id ); + if ( ! empty( $data['post_type'] ) && ! post_type_exists( $data['post_type'] ) ) { + restore_current_blog(); + + return false; + } + $this->handle( false ); if ( isset( $data['ID'] ) ) { $post_id = wp_update_post( $data );