<?php
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

add_filter( 'rwmb_meta_boxes', 'kktfwp_meta_boxes');

function kktfwp_meta_boxes( $meta_boxes )
{
	/**
	 * Prefix of meta keys (optional)
	 * Use underscore (_) at the beginning to make keys hidden
	 * Alt.: You also can make prefix empty to disable it
	 */
	// Better has an underscore as last sign
	$prefix = 'kk_';
	$bgMeta = array( 
		array(
			'name'             => esc_html__( 'Background type', 'toppic' ),
			'id'               => "_custom_bg_type_value",
			'type'             => 'select',
			'tab'  			   => 'background',
			'options'          => array (
								'Default' => esc_html__( 'Default', 'toppic' ),
								'Custom Slideshow' => esc_html__( 'Custom Slideshow', 'toppic' ),
								'Video' => esc_html__( 'Video', 'toppic' ),
								'Image' => esc_html__( 'Image', 'toppic' ),
							),
			
			'std'              => 'default',
			'hidden'  =>  array( 'page_template', 'template-homepage-grid.php' )
		),
		array(
			'name'             => esc_html__( 'Images/Slides', 'toppic' ),
			'id'               => "{$prefix}homegrid",
			'type'             => 'image_advanced',
			'tab'  			   => 'background',
			'max_file_uploads' => 0,
			'visible' 		   => array('_custom_bg_type_value', 'Custom Slideshow'),
		),
		array(
			'name'             => esc_html__( 'Background video', 'toppic' ),
			'desc'             => esc_html__( 'Enter an URL to the background video file for this page. Supports: local video (mp4), YouTube. If you prefer to use YouTube, simply add an URL to the YouTube page where your video is.', 'toppic' ),
			'id'               => "_bg_video_value",
			'tab'  			   => 'background',
			'type'             => 'file_input',
			'visible' 		   => array('_custom_bg_type_value', 'Video'),
		),
		array(
			'name'             => esc_html__( 'Mute video', 'toppic' ),
			'desc'             => esc_html__( 'Muted autoplay is always allowed. Autoplay with sound is allowed if the user has interacted with the domain (click, tap, etc.) otherwise the sound will be muted automatically.', 'toppic' ),
			'id' 			   => "{$prefix}muteVid",
			'tab'  			   => 'background',
			'type' 			   => 'switch',
			'std'			   => true,
			'visible' 		   => array('_custom_bg_type_value', 'Video' ),
		),
		array(
			'name'             => esc_html__( 'Video poster image', 'toppic' ),
			'desc'             => esc_html__( 'This image will be displayed before starting video playback and if video playback fails. Recommended to use a screenshot of the first frame from the video.', 'toppic' ),
			'id'               => "_bg_image_fallback_value",
			'tab'  			   => 'background',
			'type'             => 'file_input',
			'visible' 		   => array('_custom_bg_type_value', 'Video' ),
		),
		array(
			'name'             => esc_html__( 'Background image', 'toppic' ),
			'id'               => "_bg_image_value",
			'tab'  			   => 'background',
			'type'             => 'file_input',
			'visible' 		   => array('_custom_bg_type_value', 'Image' ),
		),		
	);
	
	$pageMeta = array(
		array(
			'name'             => esc_html__( 'Image proportions', 'toppic' ),
			'id'               => "_kk_homepage_layout_value",
			'type'             => 'select',
			'tab'			   => 'page',
			'options' => array(
							'Random'			=>	esc_html__( 'Original', 'toppic' ),	
							'Square'			=>  esc_html__( 'Square', 'toppic' ),
							'Landscape'			=>	esc_html__( 'Landscape', 'toppic' ),
							'Portrait'			=>	esc_html__( 'Portrait', 'toppic' ),		
						),
			'std' 			=> 'Random',
			'hidden'  		=>  array( 'page_template', '!=', 'template-homepage-grid.php' )
		),
		array(
			'name'             => esc_html__( 'Images', 'toppic' ),
			'id'               => "{$prefix}grid",
			'type'             => 'image_advanced',
			'tab'			   => 'page',
			'max_file_uploads' => 0,
			'hidden'  		=>  array( 'page_template', '!=', 'template-homepage-grid.php' )
		),
		array(
			'name'             => esc_html__( 'Album columns', 'toppic' ),
			'id'               => "_album_layout_value",
			'type'             => 'select',
			'tab'			   => 'page',
			'options' => array(
							'2-column' 		   => esc_html__( '2 columns', 'toppic' ),
							'2-column (wide)'  => esc_html__( '2 columns (wide)', 'toppic' ),
							'3-column' 		   => esc_html__( '3 columns', 'toppic' ),
							'3-column (wide)'  => esc_html__( '3 columns (wide)', 'toppic' ),
							'4-column'  	   => esc_html__( '4 columns', 'toppic' ),
							'4-column (wide)'  => esc_html__( '4 columns (wide)', 'toppic' ),
						),
			'std' 			=> '3-column',
			'hidden'  		=>  array( 'page_template', '!=', 'template-gallery.php' )
		),
		array(
			'name'             => esc_html__( 'Portfolio columns', 'toppic' ),
			'id'               => "_portfolio_layout_value",
			'type'             => 'select',
			'tab'			   => 'page',
			'options' => array(
							'2-column' 		   => esc_html__( '2 columns', 'toppic' ),
							'2-column (wide)'  => esc_html__( '2 columns (wide)', 'toppic' ),
							'3-column' 		   => esc_html__( '3 columns', 'toppic' ),
							'3-column (wide)'  => esc_html__( '3 columns (wide)', 'toppic' ),
							'4-column'  	   => esc_html__( '4 columns', 'toppic' ),
							'4-column (wide)'  => esc_html__( '4 columns (wide)', 'toppic' ),
						),
			'std' 			=> '3-column',
			'hidden'  		=>  array( 'page_template', '!=', 'template-portfolio.php' )
		),
		array(
			'name'             => esc_html__( 'Filter', 'toppic' ),
			'id'               => "_{$prefix}enbale_filter",
			'type'             => 'button_group',
			'tab'			   => 'page',
			'options' => array(
						'false' => esc_html__( 'Disable', 'toppic' ),						
						'true'  => esc_html__( 'Enable', 'toppic' )
						),
			'std' 			=> 'false',
			'visible'  		=>  array( 'page_template', 'in', array( 'template-portfolio.php', 'template-gallery.php' ) )
		),
		array(
			'name'             => esc_html__( 'Projects to display', 'toppic' ),
			'id'               => "_{$prefix}posts_to_display",
			'type'             => 'button_group',
			'tab'			   => 'page',
			'options' => array(
						'all'  => esc_html__( 'All', 'toppic' ),
						'category' => esc_html__( 'By category', 'toppic' ),						
						'custom' => esc_html__( 'User defined', 'toppic' )						
						),
			'std' 			=> 'all',
			'visible'  		=>  array( 'page_template', 'in', array( 'template-portfolio.php', 'template-gallery.php' ) )
		),
		array(
			'name' 			=> esc_html__( 'Select categories', 'toppic' ),
			'id' 			=> "{$prefix}filter-portfolio",
			'type'			=> 'taxonomy',
			'tab'			=> 'page',
			'taxonomy' 		=> 'portfolio-type',
			'field_type' 	=> 'checkbox_list',
			'visible'  		=>  array (
									array( 'page_template', 'template-portfolio.php' ),
									array( 'posts_to_display', 'category' ),
								)
		),
		array(
			'name' 			=> esc_html__( 'Select categories', 'toppic' ),
			'id' 			=> "{$prefix}filter",
			'type' 			=> 'taxonomy',
			'tab'			=> 'page',
			'taxonomy' 		=> 'gallery-type',
			'field_type' 	=> 'checkbox_list',
			'visible'  		=>  array(
									array( 'page_template', 'template-gallery.php' ),
									array( 'posts_to_display', 'category' ),
								)
		),
		array(
			'name' 			=> esc_html__( 'Select galleries', 'toppic' ),
			'id' 			=> "_{$prefix}defined_galleries",
			'type' 			=> 'post',
			'tab'			=> 'page',
			'post_type' 	=> 'gallery',
			'field_type' 	=> 'checkbox_list',
			'visible'  		=>  array(
									array( 'page_template', 'template-gallery.php' ),
									array( 'posts_to_display', 'custom' ),
								)
		),
		array(
			'name' 			=> esc_html__( 'Select projects', 'toppic' ),
			'id' 			=> "_{$prefix}defined_projects",
			'type' 			=> 'post',
			'tab'			=> 'page',
			'post_type' 	=> 'portfolio',
			'field_type' 	=> 'checkbox_list',
			'visible'  		=>  array(
									array( 'page_template', 'template-portfolio.php' ),
									array( 'posts_to_display', 'custom' ),
								)
		),
		
	);
	
	$parallax = array(
			array(
				'name'             => esc_html__( 'Title type', 'toppic' ),
				'id'               => "{$prefix}title_type",
				'type'             => 'button_group',
				'tab'			   => 'page',
				'options' => array(
							'default'  => esc_html__( 'Default', 'toppic' ),
							'parallax' => esc_html__( 'Parallax', 'toppic' ),			
							'disabled' => esc_html__( 'No title', 'toppic' ),				
							),
				'std' => 'default',
				'hidden'  =>  array( 'page_template', 'in', array( 'template-homepage-slider.php', 'template-homepage-grid.php' ) )
			),
			array(
				'name'             => esc_html__( 'Use custom title', 'toppic' ),
				'id' 			   => $prefix .'customTitle',
				'tab'  			   => 'page',
				'type' 			   => 'switch',
				'desc' 			   => esc_html__( 'Use custom text for title.', 'toppic' ),
				'std'			   => false,
				'visible' 		   => array('kk_title_type', 'parallax' ),
			),
			array(
				'name'             => esc_html__( 'Custom Title & Description', 'benue' ),
				'id'               => $prefix .'customdescription',
				'type'             => 'wysiwyg',
				'tab'  			   => 'page',
				'options'          => array (
										'media_buttons' => true,
										'textarea_rows' => 12,	
									),
				'visible' => array('kk_customTitle', true),
			),			
			array(
				'name'             => esc_html__( 'Parallax height', 'toppic' ),
				'id'               => "{$prefix}title_size",
				'type'             => 'button_group',
				'tab'			   => 'page',
				'options' => array(
							'standard'  => esc_html__( 'Standard', 'toppic' ),
							'full'  	=> esc_html__( 'Full height', 'toppic' ),			
							),
				'std' 			   => 'standard',
				'visible' 		   => array('kk_title_type', 'parallax' ),
			),					
			array(
				'name'             => esc_html__( 'Parallax image', 'toppic' ),
				'desc'      	   => esc_html__( 'Recommended image size: min width - 1920px', 'toppic' ),
				'id'               => "{$prefix}title_bg",
				'type'             => 'image_advanced',
				'tab'			   => 'page',
				'max_file_uploads' => 1,
				'visible' 		   => array('kk_title_type', 'parallax' ),
			),
			array(
				'name'             => esc_html__( 'Parallax video', 'toppic' ),
				'desc'             => esc_html__( 'Optional. Video requires a fallback for devices that doesn\'t support a video as background. Possibly a video screenshot ("Parallax image" field above). Supported video formats:: MP4, WEBM, OGG', 'toppic' ),
				'id'               => "{$prefix}herovid",
				'tab'  			   => 'page',
				'type' 			   => 'file_advanced',
				'mime_type'		   => array( 'video/mp4', 'video/webm', 'video/ogg' ),
				'max_file_uploads' => 1,
				'max_status'  	   => false,
				'visible' 		   => array('kk_title_type', 'parallax' ),
			),
			array(
				'name'             => esc_html__( 'Pause on scroll', 'toppic' ),
				'id' 			   => $prefix .'pauseVid',
				'tab'  			   => 'page',
				'type' 			   => 'switch',
				'desc' 			   => esc_html__( 'Pause parallax video if is not in viewport', 'toppic' ),
				'std'			   => true,
				'visible' 		   => array('kk_title_type', 'parallax' ),
			),
			array(
				'name'             => esc_html__( 'Mute video', 'toppic' ),
				'id' 			   => $prefix .'muteVidP',
				'tab'  			   => 'page',
				'type' 			   => 'switch',
				'desc' 			   => esc_html__( 'Play video without audio', 'toppic' ),
				'std'			   => true,
				'visible' 		   => array('kk_title_type', 'parallax' ),
			),			
		);
	
	if ( get_theme_mod( 'kktfwp_menu_style', 'kk-menu-default' ) !== 'kk-menu-left-boxed' && get_theme_mod( 'kktfwp_content_width', 'kk-boxed' ) === 'kk-full' ) {
		
		$pageMeta = array_merge(
			$pageMeta, $parallax
		
		);		
	}

	
	// PAGE META
	
	$meta_boxes[] = array(
		'title' => esc_html__( 'Page Attributes', 'toppic' ),
		'post_types'  => array ( 'page' ),
		'id' => 'kktfwp-page-settings',
		'context' => 'normal',
		'priority' => 'high',
		'toggle_type' => 'slide',
		
		'tabs'      => array(
			'page' => array(
				'label'      => esc_html__( 'Page', 'toppic' ),
				'icon'  => 'dashicons-admin-page', // Dashicon
			),
			'background' => array(
				'label'      => esc_html__( 'Background', 'toppic' ),
				'icon'  => 'dashicons-welcome-view-site', // Dashicon
			),		
		),
		
		// Tab style: 'default', 'box' or 'left'. Optional
		'tab_style' => 'left',

		'fields' => array_merge(			
			$bgMeta, $pageMeta
			)		
	);
	
	
	// PRODUCT META
	
	$meta_boxes[] = array(
		'title' => esc_html__( 'Page Attributes', 'toppic' ),
		'post_types'  => array ( 'product' ),
		'id' => 'kktfwp-page-settings',
		'context' => 'normal',
		'priority' => 'high',
		'toggle_type' => 'slide',
		
		'tabs'      => array(
			'background' => array(
				'label'      => esc_html__( 'Background', 'toppic' ),
				'icon'  => 'dashicons-welcome-view-site', // Dashicon
			),		
		),
		
		// Tab style: 'default', 'box' or 'left'. Optional
		'tab_style' => 'left',

		'fields' => array_merge(			
			$bgMeta
			)		
	);
	
	
	// PORTFOLIO META
	
	$meta_boxes[] = array(
		'title' => esc_html__( 'Page Attributes', 'toppic' ),
		'post_types'  => array ( 'portfolio' ),
		'id' => 'kktfwp-page-settings',
		'context' => 'normal',
		'priority' => 'high',
		'toggle_type' => 'slide',
		
		'tabs'      => array(
			'page' => array(
				'label'      => esc_html__( 'Project', 'toppic' ),
				'icon'  => 'dashicons-format-image', // Dashicon
			),	
			'background' => array(
				'label'      => esc_html__( 'Background', 'toppic' ),
				'icon'  => 'dashicons-welcome-view-site', // Dashicon
			),		
		),
		
		// Tab style: 'default', 'box' or 'left'. Optional
		'tab_style' => 'left',

		'fields' => array_merge(			
			$bgMeta, $parallax,
			
			array(
				array(
					'name'             => esc_html__( 'Link to', 'toppic' ),
					'id'               => "_{$prefix}linkTo",
					'type'             => 'button_group',
					'tab'			   => 'page',
					'options' => array(
								'default'	=>	esc_html__( 'Default', 'toppic' ),						
								'page'		=>	esc_html__( 'Custom page', 'toppic' ),						
								'custom'	=>  esc_html__( 'Custom URL', 'toppic' ),
							),
					'std' 			  => 'default'
				),
				array(
					'name'             => ' ',
					'id'               => "_{$prefix}linkToPage",
					'type'             => 'post',
					'post_type'		   => array( 'post', 'page', 'gallery', 'portfolio' ),
					'tab'			   => 'page',
					'field_type'	   => 'select_advanced',
					'placeholder' 	   => esc_html__( 'Select a page', 'toppic' ),
					'query_args'  => array(
								'post_status'    => 'publish',
								'posts_per_page' => - 1,
							),
					'visible' 	 => array( '_kk_linkTo', 'page' )
					
				),
				array(
					'name' 			   => ' ',
					'placeholder'	   => esc_html__( 'Enter an URL', 'toppic' ),
					'desc'	   		   => esc_html__( 'Must starts with http(s)', 'toppic' ),
					'tab'			   => 'page',
					'id'   			   => "_{$prefix}customUrl",
					'type'             => 'url',
					'visible' 		   => array( '_kk_linkTo', 'custom' )
				),
				array(
					'name' 			   => ' ',
					'desc'			   => esc_html__( 'Open in new tab', 'toppic' ),
					'tab'			   => 'page',
					'id'   			   => "_{$prefix}newTab",
					'type'             => 'checkbox',
					'std'              => 0,
					'visible' 	 => array( '_kk_linkTo', 'in', array( 'page', 'custom' ) )
				),
				array(
				'name'             => esc_html__( 'Sidebar', 'toppic' ),
				'id'               => "{$prefix}project_layout",
				'type'             => 'button_group',
				'tab'			   => 'page',
				'options' => array(
							'sidebar_off' => esc_html__( 'Disable', 'toppic' ),
							'sidebar_on'  => esc_html__( 'Enable', 'toppic' ),
							),
				'std' => 'sidebar_off'
				),
				array(
					'name'             => esc_html__( 'Project Type', 'toppic' ),
					'id'               => "{$prefix}project_type",
					'type'             => 'button_group',
					'tab'			   => 'page',
					'options' => array(
								'image'  => esc_html__( 'Image(s)', 'toppic' ),
								'slideshow' => esc_html__( 'Slider', 'toppic' ),
								'video' => esc_html__( 'Video', 'toppic' ),
								),
					'std' => 'image'
				),
				array(
					'name'             => esc_html__( 'Slider Autostart', 'toppic' ),
					'id'               => "{$prefix}slider_auto",
					'class'			   => 'slider-auto-wrapper',
					'type'             => 'button_group',
					'tab'			   => 'page',
					'options' => array(
								'yes'  => esc_html__( 'Yes', 'toppic' ),
								'no' => esc_html__( 'No', 'toppic' ),
								),
					'std' => 'no',
					'visible' 		   => array('kk_project_type', 'slideshow' ),
				),
				array(
					'id' 				=> "{$prefix}sliderDelay",
					'class'				=> 'slider-auto-wrapper',
					'type' 				=> 'number',
					'tab'			    => 'page',
					'name'				=> esc_html__( 'Delay between transitions (ms)', 'toppic' ),
					'std' 				=> '3000',
					'min' 				=> '1',
					'step' 				=> '1',
					'visible' 		   => array('kk_project_type', 'slideshow' ),
				),
				
				array(
					'name'             => esc_html__( 'Upload project images', 'toppic' ),
					'id'               => "{$prefix}projimg",
					'class'			   => 'projimg_wrapper',
					'type'             => 'image_advanced',
					'tab'			   => 'page',
					'max_file_uploads' => 0,
					'hidden' 		   => array('kk_project_type', 'video' ),
				),
				
				array(
					'name'             => esc_html__( 'Paste your embedded video code', 'toppic' ),
					'id'               => "{$prefix}projvid",
					'class'			   => 'projvid_wrapper',
					'type'             => 'textarea',
					'tab'			   => 'page',
					'sanitize_callback' => 'none',
					'clone'            => false,
					'visible' 		   => array('kk_project_type', 'video' ),
				),				
			)
		)			
					
	);
	
	
	// GALLERY META
	
	$meta_boxes[] = array(
		'title' => esc_html__( 'Page Attributes', 'toppic' ),
		'post_types'  => array ( 'gallery' ),
		'id' => 'kktfwp-page-settings',
		'context' => 'normal',
		'priority' => 'high',
		'toggle_type' => 'slide',
		
		'tabs'      => array(
			'page' => array(
				'label'      => esc_html__( 'Gallery', 'toppic' ),
				'icon'  => 'dashicons-format-gallery', // Dashicon
			),	
			'background' => array(
				'label'      => esc_html__( 'Background', 'toppic' ),
				'icon'  => 'dashicons-welcome-view-site', // Dashicon
			),		
		),
		
		// Tab style: 'default', 'box' or 'left'. Optional
		'tab_style' => 'left',

		'fields' => array_merge(			
			$bgMeta, $parallax,
			
			array(
				array(
					'name'             => esc_html__( 'Link to', 'toppic' ),
					'id'               => "_{$prefix}linkTo",
					'type'             => 'button_group',
					'tab'			   => 'page',
					'options' => array(
								'default'	=>	esc_html__( 'Default', 'toppic' ),						
								'page'		=>	esc_html__( 'Custom page', 'toppic' ),						
								'custom'	=>  esc_html__( 'Custom URL', 'toppic' ),
							),
					'std' 			  => 'default'
				),
				array(
					'name'             => ' ',
					'id'               => "_{$prefix}linkToPage",
					'type'             => 'post',
					'post_type'		   => array( 'post', 'page', 'gallery', 'portfolio' ),
					'tab'			   => 'page',
					'field_type'	   => 'select_advanced',
					'placeholder' 	   => esc_html__( 'Select a page', 'toppic' ),
					'query_args'  => array(
								'post_status'    => 'publish',
								'posts_per_page' => - 1,
							),
					'visible' 	 => array( '_kk_linkTo', 'page' )
					
				),
				array(
					'name' 			   => ' ',
					'placeholder'	   => esc_html__( 'Enter an URL', 'toppic' ),
					'desc'	   		   => esc_html__( 'Must starts with http(s)', 'toppic' ),
					'tab'			   => 'page',
					'id'   			   => "_{$prefix}customUrl",
					'type'             => 'url',
					'visible' 		   => array( '_kk_linkTo', 'custom' )
				),
				array(
					'name' 			   => ' ',
					'desc'			   => esc_html__( 'Open in new tab', 'toppic' ),
					'tab'			   => 'page',
					'id'   			   => "_{$prefix}newTab",
					'type'             => 'checkbox',
					'std'              => 0,
					'visible' 	 => array( '_kk_linkTo', 'in', array( 'page', 'custom' ) )
				),
				array(
					'name'             => esc_html__( 'Gallery layout', 'toppic' ),
					'id'               => '_gallery_layout_value',
					'type'             => 'select',
					'tab'			   => 'page',
					'options' => array(
								'2-column'			=>  esc_html__( '2 Columns', 'toppic' ),
								'3-column'			=>	esc_html__( '3 Columns', 'toppic' ),
								'4-column'			=>	esc_html__( '4 Columns', 'toppic' ),
								'Thumbnails'		=>	esc_html__( 'Thumbnails', 'toppic' ),
								'Fullscreen-Grid'	=>	esc_html__( 'Grid (fullscreen)', 'toppic' ),
								'Fullscreen'		=>	esc_html__( 'Fullscreen', 'toppic' ),							
							),
					'std' => '2-column',
				),
				array(
					'name'             => esc_html__( 'Gallery type', 'toppic' ),
					'id'               => "{$prefix}proof",
					'type'             => 'select',
					'tab'			   => 'page',
					'class'			   => 'kk-proofing-gallery',
					'options' => array(
								'normal' => esc_html__( 'Normal', 'toppic' ),
								'proofing' => esc_html__( 'Photo proofing', 'toppic' )							
								),
					'std' 		 => 'normal',
					'hidden' 	 => array( '_gallery_layout_value', 'Fullscreen' )
				),
				array(
					'name'             => esc_html__( 'Crop images', 'toppic' ),
					'desc'			   => esc_html__( 'Thumbnails are cropped to align', 'toppic' ),
					'id'               => '_is_masonry_value',
					'type'             => 'button_group',
					'tab'			   => 'page',
					'options' => array(
								'No'	=>	esc_html__( 'Yes', 'toppic' ),						
								'Yes'	=>  esc_html__( 'No', 'toppic' ),
							),
					'std' 			  => 'No',
					'hidden' 		  => array( '_gallery_layout_value', 'in', array( 'Fullscreen-Grid', 'Fullscreen' ) )
				),
				array(
					'name'             => esc_html__( 'Image proportions', 'toppic' ),
					'id'               => '_grid_type_value',
					'type'             => 'select',
					'tab'			   => 'page',
					'options' => array(
								'Random'			=>	esc_html__( 'Original', 'toppic' ),	
								'Square'			=>  esc_html__( 'Square', 'toppic' ),
								'Landscape'			=>	esc_html__( 'Landscape', 'toppic' ),
								'Portrait'			=>	esc_html__( 'Portrait', 'toppic' ),														
							),
					'std' 		=> 'Random',
					'visible' 	 => array( '_gallery_layout_value', 'Fullscreen-Grid' )
				),
				array(
					'name'             => esc_html__( 'Transition effect', 'toppic' ),
					'id'               => '_full_style_value',
					'type'             => 'select',
					'tab'			   => 'page',
					'options' => array(
								'Default'		=>	esc_html__( 'Default', 'toppic' ),	
								'Fade'			=>  esc_html__( 'Fade', 'toppic' ),
								'Move'			=>	esc_html__( 'Move', 'toppic' )													
							),
					'std' 		=> 'Default',
					'visible' 	 => array( '_gallery_layout_value', 'Fullscreen' )
				),
				array(
					'name'             => esc_html__( 'Image scaling', 'toppic' ),
					'id'               => '_scale_mode_value',
					'type'             => 'button_group',
					'tab'			   => 'page',
					'options' => array(
								'Fill'		=>	esc_html__( 'Fill', 'toppic' ),	
								'Fit'			=>  esc_html__( 'Fit', 'toppic' )												
							),
					'std' 		=> 'Fill',
					'visible' 	 => array( '_gallery_layout_value', 'Fullscreen' )
				),
				array(
					'name'             => esc_html__( 'Display nearby images', 'toppic' ),
					'id'               => '_near_by_value',
					'type'             => 'button_group',
					'tab'			   => 'page',
					'options' => array(
								'Yes'		=>	esc_html__( 'Yes', 'toppic' ),	
								'No'		=>  esc_html__( 'No', 'toppic' )												
							),
					'std' 		=> 'No',
					'visible' => array(
						'when' => array(
							 array( '_gallery_layout_value', 'Fullscreen' ),
							 array( '_scale_mode_value', 'Fit' )
						 ),
						 'relation' => 'and'
					)
				),
				array(
					'name'             => esc_html__( 'Gallery images', 'toppic' ),
					'desc'			   => esc_html__( 'Select or upload images. Use drag and drop if you need to reorder images. ', 'toppic' ),
					'id'               => "{$prefix}imgadv",
					'type'             => 'image_advanced',
					'tab'			   => 'page',
					'max_file_uploads' => 0,
				),
			)
		)			
					
	);
	
	
	// POST META
	
	$meta_boxes[] = array(
		'title' => esc_html__( 'Page Attributes', 'toppic' ),
		'post_types'  => array ( 'post' ),
		'id' => 'kktfwp-page-settings',
		'context' => 'normal',
		'priority' => 'high',
		'toggle_type' => 'slide',
		
		'tabs'      => array(			
			'page' => array(
				'label' => esc_html__( 'Post Settings', 'toppic' ),
				'icon'  => 'dashicons-welcome-write-blog', // Dashicon
			),	
			'background' => array(
				'label'      => esc_html__( 'Background', 'toppic' ),
				'icon'  => 'dashicons-welcome-view-site', // Dashicon
			),			
		),
		
		// Tab style: 'default', 'box' or 'left'. Optional
		'tab_style' => 'left',

		'fields' => array_merge(
			
			$bgMeta,	
			
			array(
				array(
					'name'             => esc_html__( 'Gallery images', 'toppic' ),
					'id'               => "{$prefix}imgpost",
					'tab'  			   => 'page',
					'type'             => 'image_advanced',
					'max_file_uploads' => 0,
					'visible' => array( 'post_format', 'gallery' )
				),
				array(
					'name' 			   => esc_html__( 'Link URL', 'toppic' ),
					'desc' 			   => esc_html__( 'Enter the link URL (e.g. http://***.com or http://www.***.com)', 'toppic' ),
					'id' 			   => '_post_link_value',
					'type' 			   => 'url',
					'tab'  			   => 'page',
					'visible' => array( 'post_format', 'link' )				
				),
				array(
					'name' 			   => esc_html__( 'Quote', 'toppic' ),
					'desc' 			   => esc_html__( 'Write your quote here', 'toppic' ),
					'id' 			   => '_post_quote_value',
					'type' 			   => 'textarea',
					'tab'  			   => 'page',
					'visible' => array( 'post_format', 'quote' )				
				),
				array(
					'name' 			   => esc_html__( 'Quote source', 'toppic' ),
					'desc' 			   => esc_html__( 'Write quote source or leave this field blank. HTML tags are allowed.', 'toppic' ),
					'id' 			   => '_post_quote_source_value',
					'type' 			   => 'text',
					'tab'  			   => 'page',
					'visible' => array( 'post_format', 'quote' )				
				),
				array(
					'name' 			   => esc_html__( 'oEmbed video', 'toppic' ),
					'desc' 			   => esc_html__( 'Paste here your oEmbeded code', 'toppic' ),
					'id' 			   => '_post_video_value',
					'type' 			   => 'textarea',
					'tab'  			   => 'page',
					'sanitize_callback' => 'none',
					'visible' => array( 'post_format', 'video' )				
				)
			), $parallax			
		)			
	);

	return $meta_boxes;
}