<?php

/**
 * WooCommerce product meta tabs
 */

// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}






function woo_shrk_product_videos_tab( $product_data_tabs ) {
    $product_data_tabs['shrk-product-videos'] = array(
        'label'  => esc_html__( 'Product videos', 'ux-shop' ),
        'target' => 'woo_shrk_product_videos_data',
        'class'  => ''
    );
    return $product_data_tabs;
}
add_filter( 'woocommerce_product_data_tabs', 'woo_shrk_product_videos_tab' , 99 , 1 );

function woo_shrk_product_videos_fields() {
    global $woocommerce, $post;
    ?>
    <div id="woo_shrk_product_videos_data" class="panel woocommerce_options_panel">
        <?php
        woocommerce_wp_textarea_input( array( 
            'id'            => '_shrk_product_videos', 
            'label'         => esc_html__( 'Video URLs', 'ux-shop' ),
            'description'   => esc_html__( 'Enter YouTube/Vimeo urls. Separate multiple urls by space.', 'ux-shop' ),
            'desc_tip'      => true,
        ) );
        ?>
    </div>
    <?php
}
add_action( 'woocommerce_product_data_panels', 'woo_shrk_product_videos_fields' );

function woo_shrk_product_videos_fields_save( $post_id ){
    update_post_meta( $post_id, '_shrk_product_videos', $_POST['_shrk_product_videos'] );
}
add_action( 'woocommerce_process_product_meta', 'woo_shrk_product_videos_fields_save' );