<?php
function pg_metabox_accommodation($meta_boxes)
{
  $accommodation_metaboxes = [
    "id" => "accommodation",
    "title" => esc_html__("Accomodation details", "Inoby"),
    "post_types" => ["accommodation"],
    "context" => "normal",
    "priority" => "default",
    "autosave" => "false",
    'tab_style' => 'left',
    "tabs" => [
      'gallery' => array(
        'label' => __('Banner', 'inoby'),
      ),
      'facilities' => array(
        'label' => __('Status & Facilities', 'inoby'),
      ),
      'important_info' => array(
        'label' => __('Important info', 'inoby'),
      ),
    ],
    "fields" => [
      array(
        'id'               => 'accommodation_banner_place',
        'name'             => __('Place', 'inoby'),
        'type'             => 'text',
        'tab'              => 'gallery',
      ),
      array(
        'type'             => 'divider',
        'tab'              => 'gallery',
      ),
      array(
        'id'               => 'accommodation_banner_img',
        'name'             => __('Banner Background', 'inoby'),
        'type'             => 'image_advanced',
        'force_delete'     => false,
        'max_file_uploads' => 1,
        'max_status'       => false,
        'image_size'       => 'thumbnail',
        'tab'              => 'gallery',
      ),
      array(
        'type'             => 'divider',
        'tab'              => 'gallery',
      ),
      array(
        'id'               => 'accommodation_gallery',
        'name'             => __('Gallery', 'inoby'),
        'type'             => 'image_advanced',
        'force_delete'     => false,
        'max_file_uploads' => 20,
        'max_status'       => false,
        'image_size'       => 'thumbnail',
        'tab'              => 'gallery',
      ),
      array(
        'type'             => 'divider',
        'tab'              => 'gallery',
      ),
      array(
        'id'               => 'accommodation_google_maps',
        'name'             => __('Google Maps - URL', 'inoby'),
        'type'             => 'url',
        'tab'              => 'gallery',
      ),

      array(
        'id'               => 'accommodation_status_heading',
        'name'             => __('Status Heading', 'inoby'),
        'type'             => 'text',
        'tab'              => 'facilities',
        'sanitize_callback' => 'none',
      ),
      array(
        'id'               => 'accommodation_status_text',
        'name'             => __('Status Text', 'inoby'),
        'type'             => 'textarea',
        'tab'              => 'facilities',
        'sanitize_callback' => 'none',
      ),
      array(
        'id'               => 'accommodation_facilities_heading',
        'name'             => __('Facilities Heading', 'inoby'),
        'type'             => 'text',
        'tab'              => 'facilities',
        'sanitize_callback' => 'none',
      ),
      array(
        'group_title'   => __('{accommodation_facilities_text}', 'inoby'),
        'id'            => 'accommodation_facilities',
        'type'          => 'group',
        'clone'         => true,
        'collapsible'   => true,
        "default_state" => "collapsed",
        "sort_clone" => true,
        'tab' => 'facilities',
        'fields' => array(
          array(
            'name'             => __('Icon', 'inoby'),
            'id'               => 'accommodation_facilities_icon',
            'type'             => 'image_advanced',
            'force_delete'     => false,
            'max_file_uploads' => 1,
          ),
          array(
            'name' => __('Text', 'inoby'),
            'id'   => 'accommodation_facilities_text',
            'type' => 'text',
          ),
          [
            'name' => __('Featured', 'inoby'),
            'id'   => 'accommodation_facilities_featured',
            'type' => 'checkbox',
            'std'  => 0,
          ],
        )
      ),
      array(
        'id'               => 'accommodation_facilities_text',
        'name'             => __('Facilities Text', 'inoby'),
        'type'             => 'textarea',
        'tab'              => 'facilities',
        'sanitize_callback' => 'none',
      ),
      array(
        'id'               => 'accommodation_label',
        'name'             => __('Label', 'inoby'),
        'type'             => 'text',
        'tab'              => 'important_info',
      ),
      array(
        'id'               => 'accommodation_default_price_before',
        'name'             => __('Text before default price', 'inoby'),
        'type'             => 'text',
        'std'             => 'From',
        'tab'              => 'important_info',
      ),
      array(
        'id'               => 'accommodation_default_price_after',
        'name'             => __('Text after default price', 'inoby'),
        'type'             => 'text',
        'std'             => '/ night',
        'tab'              => 'important_info',
      ),
      array(
        'id'               => 'accommodation_main_color',
        'name'             => __('Main color', 'inoby'),
        'type'             => 'color',
        'alpha_channel'    => true,
        'tab'              => 'important_info',
      ),
    ], 
  ];

  $meta_boxes[] = apply_filters("inoby_accommodation_metaboxes", $accommodation_metaboxes);

  return $meta_boxes;
}
add_filter("rwmb_meta_boxes", "pg_metabox_accommodation");
?>