Automattic\WooCommerce\Internal\ProductGallery

ProductMediaGallery::update_video_gallery_meta │ private static │ WC 1.0

Update video gallery post meta.

Method of the class: ProductMediaGallery{}

No Hooks.

Returns

void. Nothing (null).

Usage

$result = ProductMediaGallery::update_video_gallery_meta( $product, $video_gallery ): void;
$product(WC_Product) (required)
Product object.
$video_gallery(array) (required)
Video gallery items.

ProductMediaGallery::update_video_gallery_meta() code WC 11.1.2

private static function update_video_gallery_meta( WC_Product $product, array $video_gallery ): void {
	if ( empty( $video_gallery ) ) {
		if ( $product->get_id() ) {
			delete_post_meta( $product->get_id(), self::VIDEO_GALLERY_META_KEY );
		} else {
			$product->delete_meta_data( self::VIDEO_GALLERY_META_KEY );
		}
		return;
	}

	$value = wp_json_encode( $video_gallery );

	if ( false === $value ) {
		return;
	}

	if ( $product->get_id() ) {
		update_post_meta( $product->get_id(), self::VIDEO_GALLERY_META_KEY, wp_slash( $value ) );
	} else {
		$product->update_meta_data( self::VIDEO_GALLERY_META_KEY, $value );
	}
}