array(
'id' => array(),
'href' => array(),
'title' => array(),
'onclick' => array(),
'class' => array(),
),
'div' => array(
'id' => array(),
'title' => array(),
'onclick' => array(),
'class' => array(),
),
'input' => array(
'type' => array(),
'name' => array(),
'id' => array(),
'value' => array(),
'class' => array(),
),
);
$thepostid = $post->ID;
$product_object = $thepostid ? wc_get_product( $thepostid ) : new WC_Product();
wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' );
?>
get_gallery_image_ids( 'edit' );
$attachments = array_filter( $product_image_gallery );
$update_meta = false;
$updated_gallery_ids = array();
if ( ! empty( $attachments ) ) {
foreach ( $attachments as $attachment_id ) {
$attachment = wp_get_attachment_image( $attachment_id, 'thumbnail' );
// if attachment is empty skip.
if ( empty( $attachment ) ) {
$update_meta = true;
continue;
}
// Allow for extra info or action to be exposed for this attachment, but restrict it's output.
$attachment_info_action = wp_kses(
apply_filters( 'woocommerce_product_gallery_item_info_action', '', $thepostid, $attachment_id ),
$allow_markup
);
echo '
' . $attachment . '
' . $attachment_info_action . '
';
// rebuild ids to be saved.
$updated_gallery_ids[] = $attachment_id;
}
// need to update product meta to set new gallery ids
if ( $update_meta ) {
update_post_meta( $post->ID, '_product_image_gallery', implode( ',', $updated_gallery_ids ) );
}
}
?>
set_gallery_image_ids( $attachment_ids );
$product->save();
}
}