Ticket #14847: featured_image_import.2.diff
| File featured_image_import.2.diff, 1.3 KB (added by Nano8Blazex, 2 years ago) |
|---|
-
wordpress-importer.php
54 54 55 55 var $fetch_attachments = false; 56 56 var $url_remap = array(); 57 var $thumb_posts = array(); 57 58 58 59 function WP_Import() { /* nothing */ } 59 60 … … 600 601 601 602 update_post_meta( $post_id, $key, $value ); 602 603 do_action( 'import_post_meta', $post_id, $key, $value ); 604 605 // if the post has a featured image, take note of this in case of remap 606 if ( $key == '_thumbnail_id' ) { 607 // store the post id and value 608 $this->thumb_posts[$post_id] = $value; 609 } 603 610 } 604 611 } 605 612 } … … 852 859 // remap enclosure urls 853 860 $result = $wpdb->query( $wpdb->prepare("UPDATE {$wpdb->postmeta} SET meta_value = REPLACE(meta_value, %s, %s) WHERE meta_key='enclosure'", $from_url, $to_url) ); 854 861 } 862 863 // Cycle through posts that have a featured image 864 foreach ( $this->thumb_posts as $post_id => $value ) { 865 // Check if its metadata needs updating 866 if ( isset( $this->processed_posts[$value] ) ) { 867 $new_id = $this->processed_posts[$value]; 868 869 if ( $new_id != $value ) { 870 // update metadata 871 $value = $new_id; 872 update_post_meta( $post_id, '_thumbnail_id', $new_id ); 873 } 874 } 875 } 855 876 } 856 877 857 878 /**
