Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. /**
  2. * Only run this code if WooCommerce Featured Video is active.
  3. *
  4. * Plugin available from : https://wordpress.org/plugins/woo-featured-video/
  5. */
  6. if ( class_exists( 'WooCommerce_Featured_Video' ) ) {
  7. add_action( 'wcv_after_product_media', 'featured_video' );
  8. function featured_video( $post_id ) {
  9. $woofv_video_embed = maybe_unserialize( get_post_meta( $post_id, '_woofv_video_embed', true ) );
  10. $url = isset( $woofv_video_embed['url'] ) ? $woofv_video_embed['url'] : '';
  11. $source = isset( $woofv_video_embed['source'] ) ? $woofv_video_embed['source'] : '';
  12. WCVendors_Pro_Form_Helper::input(
  13. array(
  14. 'id' => 'woofv_video_embed_url',
  15. 'name' => 'woofv_video_embed[url]',
  16. 'label' => __( 'Featured Video URL', 'wcvendors-pro' ),
  17. 'placeholder' => __( 'Video url', 'wcvendors-pro' ),
  18. 'type' => 'text',
  19. 'value' => $url,
  20. )
  21. );
  22. WCVendors_Pro_Form_Helper::select(
  23. array(
  24. 'id' => 'woofv_video_embed_source',
  25. 'name' => 'woofv_video_embed[source]',
  26. 'label' => __( 'Source Type', 'wcvendors-pro' ),
  27. 'options' => array(
  28. 'local' => __( 'Local media URL', 'wcvendors-pro' ),
  29. 'external' => __( 'External URL', 'wcvendors-pro' ),
  30. ),
  31. 'value' => $source,
  32. 'custom_attributes' => array(
  33. 'class' => 'select2',
  34. ),
  35. )
  36. );
  37. }
  38. add_action( 'wcv_save_product', 'save_featured_video' );
  39. function save_featured_video( $post_id ) {
  40. // Sanitize the user input.
  41. $woofv_data = array_map('sanitize_text_field', $_POST['woofv_video_embed'] );
  42. // Update the meta field.
  43. update_post_meta( $post_id, '_woofv_video_embed', $woofv_data );
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement