Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Only run this code if WooCommerce Featured Video is active.
- *
- * Plugin available from : https://wordpress.org/plugins/woo-featured-video/
- */
- if ( class_exists( 'WooCommerce_Featured_Video' ) ) {
- add_action( 'wcv_after_product_media', 'featured_video' );
- function featured_video( $post_id ) {
- $woofv_video_embed = maybe_unserialize( get_post_meta( $post_id, '_woofv_video_embed', true ) );
- $url = isset( $woofv_video_embed['url'] ) ? $woofv_video_embed['url'] : '';
- $source = isset( $woofv_video_embed['source'] ) ? $woofv_video_embed['source'] : '';
- WCVendors_Pro_Form_Helper::input(
- array(
- 'id' => 'woofv_video_embed_url',
- 'name' => 'woofv_video_embed[url]',
- 'label' => __( 'Featured Video URL', 'wcvendors-pro' ),
- 'placeholder' => __( 'Video url', 'wcvendors-pro' ),
- 'type' => 'text',
- 'value' => $url,
- )
- );
- WCVendors_Pro_Form_Helper::select(
- array(
- 'id' => 'woofv_video_embed_source',
- 'name' => 'woofv_video_embed[source]',
- 'label' => __( 'Source Type', 'wcvendors-pro' ),
- 'options' => array(
- 'local' => __( 'Local media URL', 'wcvendors-pro' ),
- 'external' => __( 'External URL', 'wcvendors-pro' ),
- ),
- 'value' => $source,
- 'custom_attributes' => array(
- 'class' => 'select2',
- ),
- )
- );
- }
- add_action( 'wcv_save_product', 'save_featured_video' );
- function save_featured_video( $post_id ) {
- // Sanitize the user input.
- $woofv_data = array_map('sanitize_text_field', $_POST['woofv_video_embed'] );
- // Update the meta field.
- update_post_meta( $post_id, '_woofv_video_embed', $woofv_data );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement