Skip to content

Instantly share code, notes, and snippets.

@farookibrahim
Created July 21, 2020 12:38
Show Gist options
  • Save farookibrahim/366e09567886309120bef575156c129a to your computer and use it in GitHub Desktop.
Save farookibrahim/366e09567886309120bef575156c129a to your computer and use it in GitHub Desktop.
Vodi - Customize Video Upload Fields
if( ! function_exists( 'vi_child_customize_upload_video_fields' ) ) {
function vi_child_customize_upload_video_fields( $fields ) {
$status_options = array(
'publish' => __( 'Publish', 'masvideos' ),
'pending' => __( 'Pending', 'masvideos' ),
'draft' => __( 'Draft', 'masvideos' ),
'private' => __( 'Private', 'masvideos' ),
);
if( ! apply_filters( 'masvideos_allow_users_to_publish_video', false ) ) {
unset( $status_options['publish'] );
}
$fields = array(
'title' => array(
'label' => __( 'Title', 'masvideos' ),
'required' => true,
'class' => array( 'form-row-title' ),
'priority' => 10,
),
'description' => array(
'type' => 'textarea',
'label' => __( 'Description', 'masvideos' ),
'required' => false,
'class' => array( 'form-row-description' ),
'priority' => 20,
),
'category_ids' => array(
'type' => 'term-multiselect',
'taxonomy' => 'video_cat',
'label' => __( 'Categories', 'masvideos' ),
'required' => false,
'class' => array( 'form-row-category_ids' ),
'priority' => 30,
),
'tag_ids' => array(
'type' => 'term-multiselect',
'taxonomy' => 'video_tag',
'label' => __( 'Tags', 'masvideos' ),
'required' => false,
'class' => array( 'form-row-tag_ids' ),
'priority' => 40,
),
'status' => array(
'type' => 'select',
'options' => $status_options,
'label' => __( 'Privacy', 'masvideos' ),
'required' => true,
'class' => array( 'form-row-status' ),
'priority' => 50,
),
'reviews_allowed' => array(
'type' => 'checkbox',
'label' => __( 'Enable Video Comments', 'masvideos' ),
'required' => false,
'class' => array( 'form-row-reviews_allowed' ),
'priority' => 55,
),
'video_choice' => array(
'type' => 'select',
'options' => array(
'video_file' => __( 'Upload Video', 'masvideos' ),
'video_embed' => __( 'Embed Video', 'masvideos' ),
'video_url' => __( 'Video URL', 'masvideos' ),
),
'label' => __( 'Video Method', 'masvideos' ),
'required' => false,
'class' => array( 'form-row-video_choice' ),
'priority' => 60,
),
'video_attachment_id' => array(
'type' => 'video',
'label' => __( 'Video', 'masvideos' ),
'required' => false,
'class' => array( 'hide show_if_video_file form-row-video_attachment_id', 'form-field' ),
'priority' => 65,
),
'video_embed_content' => array(
'type' => 'textarea',
'label' => __( 'Embed Video', 'masvideos' ),
'required' => false,
'class' => array( 'hide show_if_video_embed form-row-video_embed_content', 'form-field' ),
'priority' => 70,
),
'video_url_link' => array(
'type' => 'text',
'label' => __( 'Video URL', 'masvideos' ),
'required' => false,
'class' => array( 'hide show_if_video_url form-row-video_url_link', 'form-field' ),
'priority' => 75,
),
'image_id' => array(
'type' => 'image',
'label' => __( 'Image', 'masvideos' ),
'required' => false,
'class' => array( 'form-row-image_id', 'form-field' ),
'priority' => 80,
),
'gallery_image_ids'=> array(
'type' => 'video-gallery-image',
'label' => __( 'Gallery Image', 'masvideos' ),
'required' => false,
'class' => array( 'form-row-gallery_image_ids' ),
'priority' => 90,
),
);
return $fields;
}
}
add_filter( 'masvideos_upload_video_fields', 'vi_child_customize_upload_video_fields', 20 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment