<?php 
add_action( 'cmb2_admin_init', 'triptip_metaboxes' );
/**
 * Define the metabox and field configurations.
 */
function triptip_metaboxes() {
    
    // Start with an underscore to hide fields from custom fields list
    $prefix = '_triptip_';

    /**
     * Initiate the metabox
     */
    $cmb = new_cmb2_box( array(
        'id'            => 'event_options',
        'title'         => esc_html__( 'Event Data', 'triptip' ),
        'object_types'  => array( 'event' ), // Post type
        'context'       => 'normal',
        'priority'      => 'high',
        'show_names'    => true, // Show field names on the left
        
    ) );

    $cmb->add_field( array(
        'name' => esc_html__('Event Date','triptip'),
        'id'   => 'event_date',
        'type' => 'text_date',
    ) );

    $cmb->add_field( array(
        'name' => esc_html__('Time Opening','triptip'),
        'id' => 'event_open',
        'type' => 'text_time'
    ) );

    $cmb->add_field( array(
        'name' => esc_html__('Time Closed','triptip'),
        'id' => 'event_closed',
        'type' => 'text_time'
    ) );

    $cmb->add_field(
        array(
                'name'    => esc_html__( 'Phone:', 'triptip' ),
                'desc'    => esc_html__( 'Your Company Phone (optional)', 'triptip' ),
                'id'      => $prefix . 'phone',
                'type'    => 'text',
            )
    );

    $cmb->add_field(
        array(
                'name'    => esc_html__( 'E-mail:', 'triptip' ),
                'desc'    => esc_html__( 'Your Company E-mail:(optional)', 'triptip' ),
                'id'      => $prefix . 'email',
                'type'    => 'text',
            )
    );

    $cmb->add_field(
        array(
                'name'    => esc_html__( 'Website:', 'triptip' ),
                'desc'    => esc_html__( 'Your Company Website (optional)', 'triptip' ),
                'id'      => $prefix . 'website',
                'type'    => 'text',
            )
    );

    $cmb = new_cmb2_box( array(
        'id'            => 'listing_options',
        'title'         => esc_html__( 'Listing Data', 'triptip' ),
        'object_types'  => array( 'listing' ), // Post type
        'context'       => 'normal',
        'priority'      => 'high',
        'show_names'    => true, // Show field names on the left
        
    ) );

    $cmb->add_field( array(
        'name' => esc_html__('Trending Listing','triptip'),
        'desc' => esc_html__('Set as Top Trending Listing','triptip'),
        'id'   => 'trending',
        'type' => 'checkbox',
    ) );

    $cmb->add_field(
        array(
                'name'    => esc_html__( 'Phone:', 'triptip' ),
                'desc'    => esc_html__( 'Your Company Phone (optional)', 'triptip' ),
                'id'      => $prefix . 'phone',
                'type'    => 'text',
            )
    );

    $cmb->add_field(
        array(
                'name'    => esc_html__( 'Email:', 'triptip' ),
                'desc'    => esc_html__( 'Your Company Email: (optional)', 'triptip' ),
                'id'      => $prefix . 'email',
                'type'    => 'text',
            )
    );

    $cmb->add_field(
        array(
                'name'    => esc_html__( 'Website:', 'triptip' ),
                'desc'    => esc_html__( 'Your Company Website (optional)', 'triptip' ),
                'id'      => $prefix . 'website',
                'type'    => 'text',
            )
    );

    $cmb->add_field(
        array(
                'name'    => esc_html__( 'Price range:', 'triptip' ),
                'desc'    => '',
                'id'      => $prefix . 'price_range',
                'type'    => 'radio_inline',
                'options' => array(
                    1 => '$',
                    2 => '$$',
                    3 => '$$$',
                    4 => '$$$$',
                ),
                'default' => 2,
            )
    );

     $group_field_id = $cmb->add_field( array(
        'id'          => 'custom_meta',
        'type'        => 'group',
        'description' => esc_html__( 'Custom Meta Data', 'triptip' ),
        'options'     => array(
            'group_title'       => esc_html__( 'Custom data {#}', 'triptip' ), // since version 1.1.4, {#} gets replaced by row number
            'add_button'        => esc_html__( 'Add Another Meta Data', 'triptip' ),
            'remove_button'     => esc_html__( 'Remove Custom Data', 'triptip' ),
            'sortable'          => true, // beta
            'closed'         => false, // true to have the groups closed by default
        ),
        ) );

        // Id's for group's fields only need to be unique for the group. Prefix is not needed.
        $cmb->add_group_field( $group_field_id, array(
        'name' => esc_html__('Title','triptip'),
        'id'   => 'title',
        'type' => 'text',
        ) );

        $cmb->add_group_field( $group_field_id, array(
        'name' => esc_html__('Icon','triptip'),
        'id'   => 'icon',
        'type' => 'text',
        ) );

        $cmb->add_group_field( $group_field_id, array(
        'name' => esc_html__('Value','triptip'),
        'id'   => 'value',
        'type' => 'text',
        ) );

    
    $group_field_id = $cmb->add_field( array(
        'id'          => 'bussiness_hour',
        'type'        => 'group',
        'description' => esc_html__( 'Business Hours', 'triptip' ),
        'options'     => array(
            'group_title'       => esc_html__( 'Day {#}', 'triptip' ), // since version 1.1.4, {#} gets replaced by row number
            'add_button'        => esc_html__( 'Add Another Day', 'triptip' ),
            'remove_button'     => esc_html__( 'Remove Day', 'triptip' ),
            'sortable'          => true, // beta
            'closed'         => true, // true to have the groups closed by default
        ),
    ) );

    // Id's for group's fields only need to be unique for the group. Prefix is not needed.
    $cmb->add_group_field( $group_field_id, array(
        'name' => esc_html__('Day','triptip'),
        'id'   => 'day',
        'type' => 'text',
    ) );

    $cmb->add_group_field( $group_field_id, array(
        'name' => esc_html__('Closed','triptip'),
        'desc' => esc_html__('Check this box if your company not work in this Day','triptip'),
        'id'   => 'closed',
        'type' => 'checkbox',
    ) );
    
    $cmb->add_group_field( $group_field_id, array(
        'name' => esc_html__('Open Hour','triptip'),
        'description' => esc_html__('Time to open','triptip'),
        'id'   => 'open',
        'type' => 'text_time',
    ) );

    $cmb->add_group_field( $group_field_id, array(
        'name' => esc_html__('Close Hour','triptip'),
        'description' => esc_html__('Time to close','triptip'),
        'id'   => 'close',
        'type' => 'text_time',
    ) );

    $cmb = new_cmb2_box( array(
        'id'            => 'location_options',
        'title'         => esc_html__( 'Location Data', 'triptip' ),
        'object_types'  => array( 'event','listing' ), // Post type
        'context'       => 'normal',
        'priority'      => 'high',
        'show_names'    => true, // Show field names on the left
        
    ) );

    $cmb->add_field(
        array(
                'name'    => esc_html__( 'Your Address:', 'triptip' ),
                'desc'    => esc_html__( 'Your Company Address (optional)', 'triptip' ),
                'id'      => $prefix . 'address',
                'type'    => 'text',
            )
    );

    $cmb->add_field(
        array(
                'name'    => esc_html__( 'Your map latitude data:', 'triptip' ),
                'desc'    => esc_html__( 'Your Google map latitude data (Example: 51.5344894)', 'triptip' ).esc_html__('You can go here to convert your Address to Lat - Long data:','triptip').'<a target="_blank" href="https://www.latlong.net/convert-address-to-lat-long.html">https://www.latlong.net/convert-address-to-lat-long.html</a>',
                'id'      => $prefix . 'latitude',
                'type'    => 'text',
            )
    );

    $cmb->add_field(
        array(
                'name'    => esc_html__( 'Your map longitude data:', 'triptip' ),
                'desc'    => esc_html__( 'Your Google map longitude data (Example: -0.1370057)', 'triptip' ).esc_html__('You can go here to convert your Address to Lat - Long data:','triptip').'<a target="_blank" href="https://www.latlong.net/convert-address-to-lat-long.html">https://www.latlong.net/convert-address-to-lat-long.html</a>',
                'id'      => $prefix . 'longitude',
                'type'    => 'text',
            )
    );

    $cmb->add_field(
        array(
                'name'    => esc_html__( 'Your map pin Icon:', 'triptip' ),
                'desc'    => esc_html__( 'Your Google map icon class name (Example: la la-cutlery)', 'triptip' ).esc_html__('You can find more icon class here:','triptip').'<a target="_blank" href="https://icons8.com/line-awesome">https://icons8.com/line-awesome</a>',
                'id'      => $prefix . 'mapicon',
                'type'    => 'text',
            )
    );

    $cmb = new_cmb2_box( array(
        'id'            => 'listing_media',
        'title'         => esc_html__( 'Listing Media Data', 'triptip' ),
        'object_types'  => array( 'listing', 'event' ), // Post type
        'context'       => 'normal',
        'priority'      => 'high',
        'show_names'    => true, // Show field names on the left
        
    ) );

    $cmb->add_field(  array(
        'name' => esc_html__('Author Logo Brand','triptip'),
        'desc' => '',
        'id'   => $prefix . 'brand',
        'type'    => 'file',
        
    ));
    $cmb->add_field(  array(
        'name' => esc_html__('Listing Banner Image','triptip'),
        'desc' => '',
        'id'   => $prefix . 'banner',
        'type'    => 'file',
        
    ));

    $cmb->add_field(  array(
        'name' => esc_html__('Listing Gallery Images','triptip'),
        'desc' => '',
        'id'   => $prefix . 'gallery',
        'type'    => 'file_list',
        'save_id' => true,
        
    ));

    $cmb = new_cmb2_box( array(
        'id'            => 'listing_layout',
        'title'         => esc_html__( 'Single Listing Layout', 'triptip' ),
        'object_types'  => array( 'listing'), // Post type
        'context'       => 'normal',
        'priority'      => 'high',
        'show_names'    => true, // Show field names on the left
        
    ) );

    $cmb->add_field(
        array(
                'name'    => esc_html__( 'Single Layout:', 'triptip' ),
                'desc'    => '',
                'id'      => $prefix . 'single_layout',
                'type'    => 'radio_inline',
                'options' => array(
                    'default' => esc_html__('Default', 'triptip' ),
                    'largeimage' => esc_html__('Large Image', 'triptip' ),
                    'fullwidth' => esc_html__('Fullwidth', 'triptip' )
                ),
                'default' => 'default',
            )
    );


    $cmb = new_cmb2_box( array(
        'id'            => 'page_options',
        'title'         => esc_html__( 'Page Setting', 'triptip' ),
        'object_types'  => array( 'page' ), // Post type
        'context'       => 'normal',
        'priority'      => 'high',
        'show_names'    => true, // Show field names on the left
        
    ) );
    
    $cmb->add_field(  array(
        'name' => esc_html__(' Page Custom Logo Image','triptip'),
        'desc' => '',
        'id'   => $prefix . 'custom_logo',
        'type'    => 'file',
        
    ));

    $cmb->add_field(  array(
        'name' => esc_html__(' Page Banner Slider','triptip'),
        'desc' => '',
        'id'   => $prefix . 'page_banner',
        'type'    => 'text',
        
    ));
    
    $cmb->add_field(
        array(
                'name'     => esc_html__( 'Banner SubTitle', 'triptip' ),
                'desc'     => esc_html__( 'Page Banner SubTittle (optional)', 'triptip' ),
                'id'       => $prefix . 'banner_subtitle',
                'type'     => 'textarea',
                'on_front' => false,
            )
    );

    $cmb->add_field( array(
        'name'             => esc_html__( 'Page Header layout', 'triptip' ),
        'desc'             => esc_html__( 'Select your page header layout', 'triptip' ),
        'id'               => $prefix . 'header_layout',
        'type'             => 'select',
        
        'options'          => array(
            '1' => esc_html__( 'Default', 'triptip' ),
            '2' => esc_html__( 'Transparent Header', 'triptip' ),
            '3' => esc_html__( 'White Conatiner', 'triptip' ),
            '4' => esc_html__( 'Light Fullwidth', 'triptip' ),
           
        ),
    ) );

     $cmb->add_field( array(
        'name'             => esc_html__( 'Page Footer layout', 'triptip' ),
        'desc'             => esc_html__( 'Select your page footer layout', 'triptip' ),
        'id'               => $prefix . 'footer_layout',
        'type'             => 'select',
        
        'options'          => array(
            '1' => esc_html__( 'Default', 'triptip' ),
            '2' => esc_html__( 'White Background', 'triptip' ),
           
        ),
    ) );

    $cmb = new_cmb2_box( array(
        'id'            => 'post_options',
        'title'         => esc_html__( 'Post Format Intro', 'triptip' ),
        'object_types'  => array( 'post', ), // Post type
        'context'       => 'normal',
        'priority'      => 'high',
        'show_names'    => true, // Show field names on the left
        
    ) );

    // Regular text field
    $cmb->add_field(  array(
        'name' => esc_html__(' Post Banner Image','triptip'),
        'desc' => '',
        'id'   => $prefix . 'page_banner',
        'type'    => 'file',
        
    ));

    $cmb = new_cmb2_box( array(
        'id'            => 'user_edit',
        'title'         => esc_html__( 'User Meta Profile', 'triptip' ),
        'object_types'  => array( 'user', ), // Post type
        'context'       => 'normal',
        'priority'      => 'high',
        'show_names'    => true, // Show field names on the left
        
    ) );

    $cmb->add_field(
        array(
                'name'    => esc_html__( 'Avatar', 'triptip' ),
                'desc'    => esc_html__( 'field description (optional)', 'triptip' ),
                'id'      => $prefix . 'avatar',
                'type'    => 'file',
                'save_id' => true,
            )
    );

    $cmb->add_field(
        array(
                'name'     => esc_html__( 'Address', 'triptip' ),
                'desc'     => esc_html__( 'Your Address (optional)', 'triptip' ),
                'id'       => $prefix . 'user_address',
                'type'     => 'text',
                'on_front' => false,
            )
    );

    $cmb->add_field(
        array(
                'name'     => esc_html__( 'Facebook', 'triptip' ),
                'desc'     => esc_html__( 'Your Facebook Link (optional)', 'triptip' ),
                'id'       => $prefix . 'user_facebook',
                'type'     => 'text',
                'on_front' => false,
            )
    );

    $cmb->add_field(
        
        array(
                'name'     => esc_html__( 'Google', 'triptip' ),
                'desc'     => esc_html__( 'Your Google Link (optional)', 'triptip' ),
                'id'       => $prefix . 'user_google',
                'type'     => 'text',
                'on_front' => false,
            )
    );

    $cmb->add_field(
        array(
                'name'     => esc_html__( 'Twitter', 'triptip' ),
                'desc'     => esc_html__( 'Your Twitter Link (optional)', 'triptip' ),
                'id'       => $prefix . 'user_twitter',
                'type'     => 'text',
                'on_front' => false,
            )
    );
      
    $cmb->add_field(
        array(
                'name'     => esc_html__( 'Youtube', 'triptip' ),
                'desc'     => esc_html__( 'Your Youtube Link (optional)', 'triptip' ),
                'id'       => $prefix . 'user_youtube',
                'type'     => 'text',
                'on_front' => false,
            )
    );

    $cmb->add_field(
        array(
                'name'     => esc_html__( 'Linkedin', 'triptip' ),
                'desc'     => esc_html__( 'Your Linkedin Link (optional)', 'triptip' ),
                'id'       => $prefix . 'user_linkedin',
                'type'     => 'text',
                'on_front' => false,
            )
    );

    $cmb->add_field(
        array(
                'name'     => esc_html__( 'Instagram', 'triptip' ),
                'desc'     => esc_html__( 'Your Instagram Link (optional)', 'triptip' ),
                'id'       => $prefix . 'user_instagram',
                'type'     => 'text',
                'on_front' => false,
            )
    );

    $cmb->add_field(
        array(
                'name'     => esc_html__( 'Dribbble', 'triptip' ),
                'desc'     => esc_html__( 'Your Dribbble Link (optional)', 'triptip' ),
                'id'       => $prefix . 'user_dribble',
                'type'     => 'text',
                'on_front' => false,
            )
    );
    
}

?>