<?php
/**
 * Include and setup custom metaboxes and fields.
 *
 * @category YourThemeOrPlugin
 * @package  Metaboxes
 * @license  http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)
 * @link     https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress
 */

add_filter( 'cmb_meta_boxes', 'cmb_sample_metaboxes' );
/**
 * Define the metabox and field configurations.
 *
 * @param  array $meta_boxes
 * @return array
 */
function cmb_sample_metaboxes( array $meta_boxes ) {

	$prefix = '_standard_';

	$meta_boxes[] = array(
		'id'         => 'imagepost_metabox',
		'title'      => 'Custom info for standard image post',
		'pages'      => array( 'post', ), // Post type
		'context'    => 'normal',
		'priority'   => 'high',
		'show_names' => true, // Show field names on the left
		'fields' => array(
			array( // Text Input
			    'name' => 'Post image', // <label>
			    'desc'  => 'Use the WordPress uploader to add the post', // description
			    'id'    => $prefix . 'image', // field id and name
			    'type'  => 'file', // type of field,
			    ),
			array(
                'name'    => 'NSFW filter?',
                'desc'    => 'If you say yes, the user will need to disable the NSFW filter to see the image. Default is No.',
                'id'      => $prefix . 'nsfw',
                'type'    => 'radio_inline',
                'options' => array(
                        array( 'name' => 'Yes', 'value' => 1, ),
                        array( 'name' => 'No', 'value' => 2, ),
                ),
                'std' => 2
        ),

		)
	);

	$prefix = '_quote_';

	$meta_boxes[] = array(
		'id'         => 'quotepost_metabox',
		'title'      => 'Custom info for quote post',
		'pages'      => array( 'post', ), // Post type
		'context'    => 'normal',
		'priority'   => 'high',
		'show_names' => true, // Show field names on the left
		'fields' => array(
			array( // Text Input
			    'name' => 'Quote text', // <label>
			    'desc'  => 'The text of the quote', // description
			    'id'    => $prefix . 'text', // field id and name
			    'type'  => 'textarea_small', // type of field,
			    ),
			array( // Text Input
			    'name' => 'Quote author (optional)', // <label>
			    'desc'  => 'The author of the quote', // description
			    'id'    => $prefix . 'author', // field id and name
			    'type'  => 'text', // type of field,
			    ),
			array( // Text Input
			    'name' => 'Quote source URL (optional)', // <label>
			    'desc'  => 'The source URL of the quote', // description
			    'id'    => $prefix . 'source', // field id and name
			    'type'  => 'text', // type of field,
			    ),
			array( // Text Input
			    'name' => 'Post image (optional)', // <label>
			    'desc'  => 'If you want to also show an image attached to the quote, use this field(optional)', // description
			    'id'    => $prefix . 'image', // field id and name
			    'type'  => 'file', // type of field,
			    ),
			array(
                'name'    => 'NSFW filter?',
                'desc'    => 'If you say yes, the user will need to disable the NSFW filter to see the image. Default is No.',
                'id'      => $prefix . 'nsfw',
                'type'    => 'radio_inline',
                'options' => array(
                        array( 'name' => 'Yes', 'value' => 1, ),
                        array( 'name' => 'No', 'value' => 2, ),
                ),
                'std' => 2
            )
		)
	);

	$prefix = '_video_';

	$meta_boxes[] = array(
		'id'         => 'videopost_metabox',
		'title'      => 'Custom info for video post',
		'pages'      => array( 'post', ), // Post type
		'context'    => 'normal',
		'priority'   => 'high',
		'show_names' => true, // Show field names on the left
		'fields' => array(
			array( // Text Input
			    'name' => 'External video URL', // <label>
			    'desc'  => 'Use this field if you want to use a video from Vimeo or Youtube!', // description
			    'id'    => $prefix . 'externalvideo', // field id and name
			    'type'  => 'oembed', // type of field,
			    ),
			array( // Text Input
			    'name' => 'Local video URL', // <label>
			    'desc'  => 'If you don\'t want to use a video from Vimeo or Youtube, add the URL of the local video uploaded via the media library here.', // description
			    'id'    => $prefix . 'localvideo', // field id and name
			    'type'  => 'text', // type of field,
			    ),
			array(
                'name'    => 'NSFW filter?',
                'desc'    => 'If you say yes, the user will need to disable the NSFW filter to see the video. Default is No.',
                'id'      => $prefix . 'nsfw',
                'type'    => 'radio_inline',
                'options' => array(
                        array( 'name' => 'Yes', 'value' => 1, ),
                        array( 'name' => 'No', 'value' => 2, ),
                ),
                'std' => 2
            )
		)
	);

	$prefix = '_audio_';

	$meta_boxes[] = array(
		'id'         => 'audiopost_metabox',
		'title'      => 'Custom info for audio post',
		'pages'      => array( 'post', ), // Post type
		'context'    => 'normal',
		'priority'   => 'high',
		'show_names' => true, // Show field names on the left
		'fields' => array(
			array( // Text Input
			    'name' => 'External audio URL', // <label>
			    'desc'  => 'Use this field if you want to use a audio from SoundCloud!', // description
			    'id'    => $prefix . 'externalaudio', // field id and name
			    'type'  => 'oembed', // type of field,
			    ),
			array( // Text Input
			    'name' => 'Local audio URL', // <label>
			    'desc'  => 'If you don\'t want to use an audio from SoundCloud, add the URL of the local audio uploaded via the media library here.', // description
			    'id'    => $prefix . 'localaudio', // field id and name
			    'type'  => 'file', // type of field,
			    ),
			array(
                'name'    => 'NSFW filter?',
                'desc'    => 'If you say yes, the user will need to disable the NSFW filter to listen to the audio. Default is No.',
                'id'      => $prefix . 'nsfw',
                'type'    => 'radio_inline',
                'options' => array(
                        array( 'name' => 'Yes', 'value' => 1, ),
                        array( 'name' => 'No', 'value' => 2, ),
                ),
                'std' => 2
            )
		)
	);

	$prefix = '_slider_';

	$meta_boxes[] = array(
		'id'         => 'sliderpost_metabox',
		'title'      => 'Custom info for a slider post',
		'pages'      => array( 'post', ), // Post type
		'context'    => 'normal',
		'priority'   => 'high',
		'show_names' => true, // Show field names on the left
		'fields' => array(
			array( // Text Input
			    'name' => 'Image #1 (mandatory)', // <label>
			    'desc'  => 'The first image of the slider', // description
			    'id'    => $prefix . 'image1', // field id and name
			    'type'  => 'file', // type of field,
			    ),
			array( // Text Input
			    'name' => 'Slide 1 title (mandatory)', // <label>
			    'desc'  => 'The title of the 1st slider image', // description
			    'id'    => $prefix . 'title1', // field id and name
			    'type'  => 'text', // type of field,
			    ),
			array( // Text Input
			    'name' => 'Image #2 (optional)', // <label>
			    'desc'  => 'The second image of the slider', // description
			    'id'    => $prefix . 'image2', // field id and name
			    'type'  => 'file', // type of field,
			    ),
			array( // Text Input
			    'name' => 'Slide 2 title (optional)', // <label>
			    'desc'  => 'The title of the 2nd slider image', // description
			    'id'    => $prefix . 'title2', // field id and name
			    'type'  => 'text', // type of field,
			    ),
			array( // Text Input
			    'name' => 'Image #3 (optional)', // <label>
			    'desc'  => 'The third image of the slider', // description
			    'id'    => $prefix . 'image3', // field id and name
			    'type'  => 'file', // type of field,
			    ),
			array( // Text Input
			    'name' => 'Slide 3 title (optional)', // <label>
			    'desc'  => 'The title of the 3rd slider image', // description
			    'id'    => $prefix . 'title3', // field id and name
			    'type'  => 'text', // type of field,
			    ),
			array( // Text Input
			    'name' => 'Image #4 (optional)', // <label>
			    'desc'  => 'The 4th image of the slider', // description
			    'id'    => $prefix . 'image4', // field id and name
			    'type'  => 'file', // type of field,
			    ),
			array( // Text Input
			    'name' => 'Slide 4 title (optional)', // <label>
			    'desc'  => 'The title of the 4th slider image', // description
			    'id'    => $prefix . 'title4', // field id and name
			    'type'  => 'text', // type of field,
			    ),
			array( // Text Input
			    'name' => 'Image #5 (optional)', // <label>
			    'desc'  => 'The 5th image of the slider', // description
			    'id'    => $prefix . 'image5', // field id and name
			    'type'  => 'file', // type of field,
			    ),
			array( // Text Input
			    'name' => 'Slide 5 title (optional)', // <label>
			    'desc'  => 'The title of the 5th slider image', // description
			    'id'    => $prefix . 'title5', // field id and name
			    'type'  => 'text', // type of field,
			    ),
			array( // Text Input
			    'name' => 'Image #6 (optional)', // <label>
			    'desc'  => 'The 6th image of the slider', // description
			    'id'    => $prefix . 'image6', // field id and name
			    'type'  => 'file', // type of field,
			    ),
			array( // Text Input
			    'name' => 'Slide 6 title (optional)', // <label>
			    'desc'  => 'The title of the 6th slider image', // description
			    'id'    => $prefix . 'title6', // field id and name
			    'type'  => 'text', // type of field,
			    ),
			array( // Text Input
			    'name' => 'Image #7 (optional)', // <label>
			    'desc'  => 'The 7th image of the slider', // description
			    'id'    => $prefix . 'image7', // field id and name
			    'type'  => 'file', // type of field,
			    ),
			array( // Text Input
			    'name' => 'Slide 7 title (optional)', // <label>
			    'desc'  => 'The title of the 7th slider image', // description
			    'id'    => $prefix . 'title7', // field id and name
			    'type'  => 'text', // type of field,
			    ),
			array( // Text Input
			    'name' => 'Image #8 (optional)', // <label>
			    'desc'  => 'The 8th image of the slider', // description
			    'id'    => $prefix . 'image8', // field id and name
			    'type'  => 'file', // type of field,
			    ),
			array( // Text Input
			    'name' => 'Slide 8 title (optional)', // <label>
			    'desc'  => 'The title of the 8th slider image', // description
			    'id'    => $prefix . 'title8', // field id and name
			    'type'  => 'text', // type of field,
			    ),
			array( // Text Input
			    'name' => 'Image #9 (optional)', // <label>
			    'desc'  => 'The 9th image of the slider', // description
			    'id'    => $prefix . 'image9', // field id and name
			    'type'  => 'file', // type of field,
			    ),
			array( // Text Input
			    'name' => 'Slide 9 title (optional)', // <label>
			    'desc'  => 'The title of the 9th slider image', // description
			    'id'    => $prefix . 'title9', // field id and name
			    'type'  => 'text', // type of field,
			    ),
			array( // Text Input
			    'name' => 'Image #10 (optional)', // <label>
			    'desc'  => 'The 10th image of the slider', // description
			    'id'    => $prefix . 'image10', // field id and name
			    'type'  => 'file', // type of field,
			    ),
			array( // Text Input
			    'name' => 'Slide 10 title (optional)', // <label>
			    'desc'  => 'The title of the 10th slider image', // description
			    'id'    => $prefix . 'title10', // field id and name
			    'type'  => 'text', // type of field,
			    ),
			array(
                'name'    => 'NSFW filter?',
                'desc'    => 'If you say yes, the user will need to disable the NSFW filter to see the image. Default is No.',
                'id'      => $prefix . 'nsfw',
                'type'    => 'radio_inline',
                'options' => array(
                        array( 'name' => 'Yes', 'value' => 1, ),
                        array( 'name' => 'No', 'value' => 2, ),
                ),
                'std' => 2
            )
		)
	);

	return $meta_boxes;
}

add_action( 'init', 'cmb_initialize_cmb_meta_boxes', 9999 );
/**
 * Initialize the metabox class.
 */
function cmb_initialize_cmb_meta_boxes() {

	if ( ! class_exists( 'cmb_Meta_Box' ) )
		require_once 'init.php';

}