Check for WP Error when uploading placeholder

This commit is contained in:
Marcos 2021-04-28 14:04:47 -03:00 committed by GitHub
parent 8e45860732
commit 971f41a89e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -1333,6 +1333,10 @@ CREATE TABLE {$wpdb->prefix}wc_reserved_stock (
'post_status' => 'inherit',
);
$attach_id = wp_insert_attachment( $attachment, $filename );
if ( is_wp_error( $attach_id ) ) {
update_option( 'woocommerce_placeholder_image', 0 );
return;
}
update_option( 'woocommerce_placeholder_image', $attach_id );