<?php

if(!class_exists('Intense_Post_Type_Music')) {
  class Intense_Post_Type_Music extends Intense_Post_Type {  
    function __construct() {
      global $intense_visions_options;
      $name_singular = ( isset( $intense_visions_options['intense_cpt_music_singular'] ) ? $intense_visions_options['intense_cpt_music_singular'] : __( 'Music', 'intense' ) );    
      $name_plural = ( isset( $intense_visions_options['intense_cpt_music_plural'] ) ? $intense_visions_options['intense_cpt_music_plural'] : __( 'Music', 'intense' ) );
      
      $this->type = 'intense_music';
      $this->title = 'Enter ' . $name_singular . ' Title';
      $this->singular = $name_singular;
      $this->plural = $name_plural;    
      $this->icon = 'dashicons-format-audio';
      $this->category_taxonomy_key = 'intense_music_category';
      $this->hierarchical = true;
      $this->taxonomies = array(
        array(
          'key' => 'intense_music_artist',
          'singular' => __( 'Artist', "intense" ),
          'plural' => __( 'Artists', "intense" )
        ),
        array(
          'key' => 'intense_music_genre',
          'singular' => __( 'Genre', "intense" ),
          'plural' => __( 'Genres', "intense" )
        ),
        array(
          'key' => 'intense_music_style',
          'singular' => __( 'Style', "intense" ),
          'plural' => __( 'Styles', "intense" )
        ),
        array(
          'key' => 'intense_music_label',
          'singular' => __( 'Record Label', "intense" ),
          'plural' => __( 'Record Labels', "intense" )
        ),
        array(
          'key' => 'intense_music_studio',
          'singular' => __( 'Studio', "intense" ),
          'plural' => __( 'Studios', "intense" )
        ),
        array(
          'key' => 'intense_music_remixer',
          'singular' => __( 'Remixer', "intense" ),
          'plural' => __( 'Remixers', "intense" )
        ),
        array(
          'key' => 'intense_music_producer',
          'singular' => __( 'Producer', "intense" ),
          'plural' => __( 'Producers', "intense" )
        ),
        array(
          'key' => 'intense_music_catalog',
          'singular' => __( 'Catalog Number', "intense" ),
          'plural' => __( 'Catalog Numbers', "intense" )
        ),
        array(
          'key' => 'intense_music_album',
          'singular' => __( 'Album', "intense" ),
          'plural' => __( 'Albums', "intense" )
        ),
        array(
          'key' => 'intense_music_language',
          'singular' => __( 'Language', "intense" ),
          'plural' => __( 'Languages', "intense" )
        )
      );
      $this->fields = array(
        array (
                'key' => 'field_52f6d5ae8n9ki6',
                'label' => __( 'Subtitle', "intense" ),
                'name' => 'intense_music_subtitle',
                'type' => 'text',
                'default_value' => '',
                'placeholder' => '',
                'prepend' => '',
                'append' => '',
                'formatting' => 'html',
                'maxlength' => '',
              ),
              array (
                'key' => 'field_52f6d77g8amju7',
                'label' => __( 'Single Post Template', "intense" ),
                'name' => 'intense_music_single_template',
                'type' => 'select',
                'choices' => array_merge(
                  array( '' => '' ),
                  intense_locate_available_plugin_templates('/custom-post/intense_music/single/'),
                  intense_locate_single_cpt_templates( 'music', true )
                ),
                'default_value' => '',
                'allow_null' => 0,
                'multiple' => 0,
              ),
              array (
                'key' => 'field_52f6d9okl931sa',
                'label' => __( 'Featured Artists', "intense" ),
                'name' => 'intense_music_featured_artists',
                'type' => 'taxonomy',
                'taxonomy' => 'intense_music_artist',
                'field_type' => 'checkbox',
                'allow_null' => 0,
                'load_save_terms' => 0,
                'return_format' => 'object',
                'multiple' => 0,
              ),
              array (
                'key' => 'field_52e6y7b2pw6y98',
                'label' => __( 'Image', "intense" ),
                'name' => 'intense_music_image',
                'type' => 'image',
                'save_format' => 'object',
                'preview_size' => 'thumbnail',
                'library' => 'all',
              ),
              array (
                'key' => 'field_52d60hop032ut',
                'label' => __( 'Music Link', 'intense' ),
                'name' => 'intense_music_link',
                'type' => 'intense_url',
                'instructions' => __( 'Link to music. Supported sites: Mixcloud, Rdio, Soundcloud, and Spotify.', "intense" ),
                'default_value' => '',
                'placeholder' => '',
                'prepend' => '',
                'append' => '',
                'formatting' => 'html',
                'maxlength' => '',
              ),
              array (
                'key' => 'field_52f6lm714nh01l',
                'label' => __( 'Audio Clip', "intense" ),
                'name' => 'intense_music_audio_clip',
                'type' => 'intense_url',
                'instructions' => __( 'Audio file url. Supported formats: mp3, ogg.', "intense" ),
                'default_value' => '',
                'placeholder' => '',
                'prepend' => '',
                'append' => '',
                'formatting' => 'html',
                'maxlength' => '',
              ),
              array (
                'key' => 'field_52f6djn6y9760',
                'label' => __( 'Video Type', "intense" ),
                'name' => 'intense_music_video_type',
                'type' => 'select',
                'choices' => array (
                  '' => __( 'Select a Video Type', "intense" ),
                  'vimeo' => __( 'Vimeo', "intense" ),
                  'youtube' => __( 'YouTube', "intense" ),
                  'vevo' => __( 'Vevo', "intense" ),
                ),
                'default_value' => '',
                'allow_null' => 0,
                'multiple' => 0,
              ),
              array (
                'key' => 'field_52d60kiq9232jg',
                'label' => __( 'Video Link', 'intense' ),
                'name' => 'intense_music_video',
                'type' => 'intense_url',
                'instructions' => __( 'Youtube or Vimeo video link.', "intense" ),
                'default_value' => '',
                'placeholder' => '',
                'prepend' => '',
                'append' => '',
                'formatting' => 'html',
                'maxlength' => '',
              ),
              array (
                'key' => 'field_52d60hhelk851k',
                'label' => __( 'Website', 'intense' ),
                'name' => 'intense_music_website',
                'type' => 'intense_url',
                'default_value' => '',
                'placeholder' => '',
                'prepend' => '',
                'append' => '',
                'formatting' => 'html',
                'maxlength' => '',
              ),
              array (
                'key' => 'field_52f6d9opkl98j',
                'label' => __( 'Release Date', "intense" ),
                'name' => 'intense_music_release_date',
                'type' => 'date_picker',
                'date_format' => 'yymmdd',
                'display_format' => 'mm/dd/yy',
                'first_day' => 0,
              ),
              array (
                'key' => 'field_52d59ffbblo98',
                'label' => __( 'Purchase Link', 'intense' ),
                'name' => 'intense_music_purchase_link',
                'type' => 'intense_url',
                'default_value' => '',
                'placeholder' => '',
                'prepend' => '',
                'append' => '',
                'formatting' => 'html',
                'maxlength' => '',
              ),
              array (
                'key' => 'field_52d90pw3blo98',
                'label' => __( 'Purchase Text', 'intense' ),
                'name' => 'intense_music_purchase_text',
                'type' => 'text',
                'default_value' => '',
                'placeholder' => '',
                'prepend' => '',
                'append' => '',
                'formatting' => 'html',
                'maxlength' => '',
              ),
              array (
                'key' => 'field_52f6c94eki9u7',
                'label' => __( 'Tracks', "intense" ),
                'name' => 'intense_music_tracks',
                'type' => 'repeater',
                'instructions' => __( 'Enter track information', "intense" ),
                'sub_fields' => array (
                  array (
                    'key' => 'field_52f6c901ju75',
                    'label' => __( 'Title', "intense" ),
                    'name' => 'intense_music_track_title',
                    'type' => 'text',
                    'default_value' => '',
                    'placeholder' => '',
                    'prepend' => '',
                    'append' => '',
                    'formatting' => 'html',
                    'maxlength' => '',
                  ),
                  array (
                    'key' => 'field_52f6c90uh71th',
                    'label' => __( 'Artist(s)', "intense" ),
                    'name' => 'intense_music_track_artists',
                    'type' => 'taxonomy',
                    'taxonomy' => 'intense_music_artist',
                    'field_type' => 'checkbox',
                    'allow_null' => 0,
                    'load_save_terms' => 0,
                    'return_format' => 'object',
                    'multiple' => 0,
                  ),
                  array (
                    'key' => 'field_52f6d9o9ij01l',
                    'label' => __( 'Audio Clip', "intense" ),
                    'name' => 'intense_music_track_audio_clip',
                    'type' => 'text',
                    'instructions' => __( 'Audio file url. Supported formats: mp3, ogg.', "intense" ),
                    'default_value' => '',
                    'placeholder' => '',
                    'prepend' => '',
                    'append' => '',
                    'formatting' => 'html',
                    'maxlength' => '',
                  ),
                  array (
                    'key' => 'field_52d6p07hn32ut',
                    'label' => __( 'Track Link', 'intense' ),
                    'name' => 'intense_music_track_link',
                    'type' => 'intense_url',
                    'instructions' => __( 'Link to track. Supported sites: Mixcloud, Rdio, Soundcloud, and Spotify.', "intense" ),
                    'default_value' => '',
                    'placeholder' => '',
                    'prepend' => '',
                    'append' => '',
                    'formatting' => 'html',
                    'maxlength' => '',
                  ),
                  array (
                    'key' => 'field_52dk98hq2lo98',
                    'label' => __( 'Track Purchase Link', 'intense' ),
                    'name' => 'intense_music_track_purchase_link',
                    'type' => 'intense_url',
                    'default_value' => '',
                    'placeholder' => '',
                    'prepend' => '',
                    'append' => '',
                    'formatting' => 'html',
                    'maxlength' => '',
                  ),
                  array (
                    'key' => 'field_52dlk61vco98',
                    'label' => __( 'Track Purchase Text', 'intense' ),
                    'name' => 'intense_music_track_purchase_text',
                    'type' => 'text',
                    'default_value' => '',
                    'placeholder' => '',
                    'prepend' => '',
                    'append' => '',
                    'formatting' => 'html',
                    'maxlength' => '',
                  ),
                  array (
                    'key' => 'field_52k9hy6f71th',
                    'label' => __( 'Album(s)', "intense" ),
                    'name' => 'intense_music_track_album',
                    'type' => 'taxonomy',
                    'taxonomy' => 'intense_music_album',
                    'field_type' => 'checkbox',
                    'allow_null' => 0,
                    'load_save_terms' => 0,
                    'return_format' => 'object',
                    'multiple' => 0,
                  ),
                  array (
                    'key' => 'field_52f6c90p5tgq5',
                    'label' => __( 'Genre(s)', "intense" ),
                    'name' => 'intense_music_track_genre',
                    'type' => 'taxonomy',
                    'taxonomy' => 'intense_music_genre',
                    'field_type' => 'checkbox',
                    'allow_null' => 0,
                    'load_save_terms' => 0,
                    'return_format' => 'object',
                    'multiple' => 1,
                  ),
                  array (
                    'key' => 'field_52f6c9ik901hz',
                    'label' => __( 'Remixer(s)', "intense" ),
                    'name' => 'intense_music_track_remixers',
                    'type' => 'taxonomy',
                    'taxonomy' => 'intense_music_remixer',
                    'field_type' => 'checkbox',
                    'allow_null' => 0,
                    'load_save_terms' => 0,
                    'return_format' => 'object',
                    'multiple' => 0,
                  ),
                  array (
                    'key' => 'field_52f6pl68uh5',
                    'label' => __( 'BPM', "intense" ),
                    'name' => 'intense_music_track_bpm',
                    'type' => 'text',
                    'default_value' => '',
                    'placeholder' => '',
                    'prepend' => '',
                    'append' => '',
                    'formatting' => 'html',
                    'maxlength' => '',
                  ),
                  array (
                    'key' => 'field_528ua5vtgq5',
                    'label' => __( 'Key', "intense" ),
                    'name' => 'intense_music_track_key',
                    'type' => 'text',
                    'column_width' => 10,
                    'default_value' => '',
                    'placeholder' => '',
                    'prepend' => '',
                    'append' => '',
                    'formatting' => 'html',
                    'maxlength' => '',
                  ),
                  array (
                    'key' => 'field_52f6c9087y6b5',
                    'label' => __( 'Time/Length', "intense" ),
                    'name' => 'intense_music_track_length',
                    'type' => 'text',
                    'column_width' => 10,
                    'default_value' => '',
                    'placeholder' => '',
                    'prepend' => '',
                    'append' => '',
                    'formatting' => 'html',
                    'maxlength' => '',
                  ),
                ),
                'row_min' => '',
                'row_limit' => '',
                'layout' => 'row',
                'button_label' => __( 'Add Track', "intense" ),
              ),
              array (
                'key' => 'field_52f6cbb6eyh876',
                'label' => __( 'Reviews', "intense" ),
                'name' => 'intense_music_reviews',
                'type' => 'repeater',
                'sub_fields' => array (
                  array (
                    'key' => 'field_52f6cc37lkm87f',
                    'label' => __( 'Reviewer', "intense" ),
                    'name' => 'intense_music_reviewer',
                    'type' => 'text',
                    'column_width' => 30,
                    'default_value' => '',
                    'placeholder' => 'Name of reviewer',
                    'prepend' => '',
                    'append' => '',
                    'formatting' => 'html',
                    'maxlength' => '',
                  ),
                  array (
                    'key' => 'field_52f6d844pok8h',
                    'label' => __( 'Review Date', "intense" ),
                    'name' => 'intense_music_review_date',
                    'type' => 'date_picker',
                    'column_width' => 15,
                    'date_format' => 'yymmdd',
                    'display_format' => 'mm/dd/yy',
                    'first_day' => 0,
                  ),
                  array (
                    'key' => 'field_52f6cd57y6gh8',
                    'label' => __( 'Rating', "intense" ),
                    'name' => 'intense_music_review_rating',
                    'type' => 'number',
                    'column_width' => 10,
                    'default_value' => '',
                    'placeholder' => '',
                    'prepend' => '',
                    'append' => '',
                    'min' => 0,
                    'max' => 5,
                    'step' => '.5',
                  ),
                  array (
                    'key' => 'field_52f6cd19nj2hx',
                    'label' => __( 'Review', "intense" ),
                    'name' => 'intense_music_review',
                    'type' => 'textarea',
                    'column_width' => 45,
                    'default_value' => '',
                    'placeholder' => '',
                    'maxlength' => '',
                    'formatting' => 'br',
                  ),
                ),
                'row_min' => '',
                'row_limit' => '',
                'layout' => 'table',
                'button_label' => __( 'Add Review', "intense" ),
              ),
      );
    }

    public function get_subtitle() {
      return get_field('intense_music_subtitle');
    }
  }
}