<?php
if ( ! defined( 'ABSPATH' ) ) exit;

/*-----------------------------------------------------------------------------------*/
/* This file hooks the metaboxes to Metabox system powered by TT FW plugin.
/*-----------------------------------------------------------------------------------*/

// remove metaoptions for CPT from the plugin.
remove_filter( 'cs_metabox_options', 'tt_temptt_team_metas_opt', 20 ); // remove the plugin team opts, if exists.
remove_filter( 'cs_metabox_options', 'tt_temptt_portfolio_metas_opt', 20 ); // remove the plugin team opts, if exists.

/*-----------------------------------------------------------------------------------*/
/* CS meta boxes override                                                            */
/*-----------------------------------------------------------------------------------*/
// framework options filter example
if( !function_exists( 'tt_temptt_metas_opt' )) {
	function tt_temptt_metas_opt( $options ) {


// Lets create metas for team CPTs
	$tt_temptt_team2_meta =  array(
		// begin: a section
		array(
			'name'   => 'section_1',
			'title'  => 'General Settings',
			'icon'   => 'fa fa-cog',
			// begin: fields
			'fields' => array(
				array(
				  'type'    => 'notice',
				  'class'   => 'info',
				  'content' => 'Please add related information about this item. Please note that image can be added from Featured image box on right sidebar.',
				),
				array(
				  'id'      => '_single_team_facebook', // another unique id
				  'type'    => 'text',
				  'title'   => 'Link Facebook',
				  'desc'    => 'This link appears on facebook icon on this item.',
				),
				array(
				  'id'      => '_single_team_twitter', // another unique id
				  'type'    => 'text',
				  'title'   => 'Link Twitter',
				  'desc'    => 'This link appears on twitter icon on this item.',
				),
				array(
				  'id'      => '_single_team_google', // another unique id
				  'type'    => 'text',
				  'title'   => 'Link Google +',
				  'desc'    => 'This link appears on google icon on this item.',
				),
				array(
				  'id'      => '_single_team_linkedin', // another unique id
				  'type'    => 'text',
				  'title'   => 'Link Linkedin',
				  'desc'    => 'This link appears on linkedin icon on this item.',
				),
				array(
				  'id'      => '_single_team_email', // another unique id
				  'type'    => 'text',
				  'title'   => 'Email',
				  'desc'    => 'This link appears on Contact me button.',
				),
				), // end: fields
		) // end: a section
	);



// Lets create metas for team CPTs
	$tt_temptt_testimonial2_meta =  array(
		// begin: a section
		array(
			'name'   => 'section_1',
			'title'  => 'General Settings',
			'icon'   => 'fa fa-cog',
			// begin: fields
			'fields' => array(
				array(
				  'type'    => 'notice',
				  'class'   => 'info',
				  'content' => 'Please add related information about this item. Please note that image can be added from Featured image box on right sidebar.',
				),
				array(
				  'id'      => '_single_testimonial_author', // another unique id
				  'type'    => 'text',
				  'title'   => 'Author name',
				),
				array(
					'id'    => '_single_testimonial_signature',
					'type'  => 'upload',
					'title' => esc_html__( 'Author Signature', 'logiscargo' ),
					'desc'  => esc_html__( 'Upload signature image of the author (optional)' ),
				),

				), // end: fields
		) // end: a section
	);



// Lets create metas for service CPTs
	$tt_temptt_service2_meta =  array(
		// begin: a section
		array(
			'name'   => 'section_1',
			'title'  => 'General Settings',
			'icon'   => 'fa fa-cog',
			// begin: fields
			'fields' => array(
					array(
					  'type'    => 'notice',
					  'class'   => 'info',
					  'content' => 'Please add short description about this item. Please note that image can be added from Featured image box on right sidebar.',
					),
					array(
					  'id'      => '_single_service_desc', // another unique id
					  'type'    => 'textarea',
					  'title'   => 'Service Description',
					  'desc'    => 'This short text appears on the service block.',
					),
					array(
					  'id'      => '_single_service_icon', // another unique id
					  'type'    => 'text',
					  'title'   => 'Service icon',
					  'desc'    => 'Enter icon for this service, you can put any icon from this page https://fortawesome.github.io/Font-Awesome/cheatsheet/ eg: fa fa-home. leave blank to show default Globe icon.',
					),
						array(
							'id'      => '_single_enable_headline',
							'type'    => 'switcher',
							'title'   => esc_html__( 'Enable Hero section on this page', 'logiscargo' ),
							'label'   => esc_html__( 'Hero section appears after header and before content area. Note: Hero section is full liquid width. If you want boxed Hero section, use visual composer Hero Component to build it please. Note: Visual composer must be active for Hero section to work.', 'logiscargo' ),
							'default' => true
						),
						array(
							'id'         => '_single_headline_title',
							'type'       => 'text',
							'title'      => esc_html__( 'Main Title.', 'logiscargo' ),
							'desc'      => esc_html__( 'Appears as highlight text in Hero section. If left blank, it displays default page title.', 'logiscargo' ),
							'dependency' => array( '_single_enable_headline', '==', 'true' ),
						),
						array(
							'id'    => '_single_page_img',
							'type'  => 'upload',
							'title' => esc_html__( 'Hero area background', 'logiscargo' ),
							'desc'  => esc_html__( 'This image appears in background of hero section above. As the text is light, dark image is suggested. Recommended image size is 1300x400 px.', 'logiscargo' ),
							'dependency' => array( '_single_enable_headline', '==', 'true' ),
						),
						array(
						  'id'      => '_single_page_color',
						  'type'    => 'color_picker',
						  'title'   => esc_html__( 'Background color.', 'logiscargo' ),
						  'desc'    => esc_html__( 'You can choose to have background color, also, if you make this color transparent, it will work as overlay color on the image chosen above.', 'logiscargo' ),
						  'default' => '',
						  'rgba'    => true,
						  'dependency' => array( '_single_enable_headline', '==', 'true' ),
						),

						array(
						  'id'       => '_single_text_apprnce',
						  'type'     => 'select',
						  'title' => esc_html__( 'Text Appearance.', 'logiscargo' ),
						  'desc' => esc_html__( 'Based on the color of background image, you might need to make text color Light or Dark.', 'logiscargo' ),
						  'options'  => array(
						    'light'  => esc_html__( 'Light', 'logiscargo' ),
						    'dark'  => esc_html__( 'Dark', 'logiscargo' ),
						  ),
							'dependency' => array( '_single_enable_headline', '==', 'true' ),
						  'default'  => 'light',
						),
						array(
						  'id'    => '_single_hero_breadcrumbs',
						  'type'  => 'switcher',
						  'title' => esc_html__( 'Insert breadcrumbs in Hero section.', 'logiscargo' ),
						  'label'  => esc_html__( 'Insert breadcrumb in this area. Note: Yoast SEO plugin must be active, and Breadcrumb enabled in SEO/Advanced in wp-admin.', 'logiscargo' ),
						  'default' => true,
						  'dependency' => array( '_single_enable_headline', '==', 'true' ),
						),
						array(
							'id'      => '_single_enable_tpadding',
							'type'    => 'switcher',
							'title'   => esc_html__( 'Enable Top padding', 'logiscargo' ),
							'label'   => esc_html__( 'When enabled, the page has some white space on the top. Recommended to disable if you want page builder to cover from top of this page.', 'logiscargo' ),
							'default' => true
						),
						array(
							'id'      => '_single_enable_bpadding',
							'type'    => 'switcher',
							'title'   => esc_html__( 'Enable bottom padding', 'logiscargo' ),
							'label'   => esc_html__( 'When enabled, the page has some space on the bottom before footer starts. Recommended to disable if you want page builder to cover till last of this page.', 'logiscargo' ),
							'default' => true
						),
				), // end: fields
		) // end: a section
	);


// Lets create options that we will use mostly, in page, product, pages
	$tt_temptt_default_meta =  array(

				// begin: a section
				array(
					'name'   => 'section_1',
					'title'  => 'General Settings',
					'icon'   => 'fa fa-cog',
					// begin: fields
					'fields' => array(

						array(
							'id'      => '_single_enable_headline',
							'type'    => 'switcher',
							'title'   => esc_html__( 'Enable Hero section on this page', 'logiscargo' ),
							'label'   => esc_html__( 'Hero section appears after header and before content area. Note: Hero section is full liquid width. If you want boxed Hero section, use visual composer Hero Component to build it please. Note: Visual composer must be active for Hero section to work.', 'logiscargo' ),
							'default' => true
						),
						array(
							'id'         => '_single_headline_title',
							'type'       => 'text',
							'title'      => esc_html__( 'Main Title.', 'logiscargo' ),
							'desc'      => esc_html__( 'Appears as highlight text in Hero section. If left blank, it displays default page title.', 'logiscargo' ),
							'dependency' => array( '_single_enable_headline', '==', 'true' ),
						),
						array(
							'id'    => '_single_page_img',
							'type'  => 'upload',
							'title' => esc_html__( 'Hero area background', 'logiscargo' ),
							'desc'  => esc_html__( 'This image appears in background of hero section above. As the text is light, dark image is suggested. Recommended image size is 1300x400 px.', 'logiscargo' ),
							'dependency' => array( '_single_enable_headline', '==', 'true' ),
						),
						array(
						  'id'      => '_single_page_color',
						  'type'    => 'color_picker',
						  'title'   => esc_html__( 'Background color.', 'logiscargo' ),
						  'desc'    => esc_html__( 'You can choose to have background color, also, if you make this color transparent, it will work as overlay color on the image chosen above.', 'logiscargo' ),
						  'default' => '',
						  'rgba'    => true,
						  'dependency' => array( '_single_enable_headline', '==', 'true' ),
						),

						array(
						  'id'       => '_single_text_apprnce',
						  'type'     => 'select',
						  'title' => esc_html__( 'Text Appearance.', 'logiscargo' ),
						  'desc' => esc_html__( 'Based on the color of background image, you might need to make text color Light or Dark.', 'logiscargo' ),
						  'options'  => array(
						    'light'  => esc_html__( 'Light', 'logiscargo' ),
						    'dark'  => esc_html__( 'Dark', 'logiscargo' ),
						  ),
							'dependency' => array( '_single_enable_headline', '==', 'true' ),
						  'default'  => 'light',
						),
						array(
						  'id'    => '_single_hero_breadcrumbs',
						  'type'  => 'switcher',
						  'title' => esc_html__( 'Insert breadcrumbs in Hero section.', 'logiscargo' ),
						  'label'  => esc_html__( 'Insert breadcrumb in this area. Note: Yoast SEO plugin must be active, and Breadcrumb enabled in SEO/Advanced in wp-admin.', 'logiscargo' ),
						  'default' => true,
						  'dependency' => array( '_single_enable_headline', '==', 'true' ),
						),
						array(
							'id'      => '_single_enable_tpadding',
							'type'    => 'switcher',
							'title'   => esc_html__( 'Enable Top padding', 'logiscargo' ),
							'label'   => esc_html__( 'When enabled, the page has some white space on the top. Recommended to disable if you want page builder to cover from top of this page.', 'logiscargo' ),
							'default' => true
						),
						array(
							'id'      => '_single_enable_bpadding',
							'type'    => 'switcher',
							'title'   => esc_html__( 'Enable bottom padding', 'logiscargo' ),
							'label'   => esc_html__( 'When enabled, the page has some space on the bottom before footer starts. Recommended to disable if you want page builder to cover till last of this page.', 'logiscargo' ),
							'default' => true
						),
					), // end: fields
				), // end: a section

);


/* Start creating meta options. */

$options = array(); // remove old options

// -----------------------------------------
// Page Metabox Options                    -
// -----------------------------------------

		$options[] = array(
			'id'        => '_tt_meta_page_opt',
			'title'     => 'Page Options',
			'post_type' => 'page',
			'context'   => 'normal',
			'priority'  => 'default',
			'sections'  => $tt_temptt_default_meta

		);
		$options[] = array(
			'id'        => '_tt_meta_page_opt',
			'title'     => 'Posts Options',
			'post_type' => 'post',
			'context'   => 'normal',
			'priority'  => 'default',
			'sections'  => $tt_temptt_default_meta

		);

		$options[] = array(
		   'id'        => '_tt_meta_page_opt',
		   'title'     => 'Team Options',
		   'post_type' => 'tt-team',
		   'context'   => 'normal',
		   'priority'  => 'default',
		   'sections'  => $tt_temptt_team2_meta

		);

		$options[] = array(
		   'id'        => '_tt_meta_page_opt',
		   'title'     => 'Service Options',
		   'post_type' => 'tt-service',
		   'context'   => 'normal',
		   'priority'  => 'default',
		   'sections'  => $tt_temptt_service2_meta

		);

		$options[] = array(
		   'id'        => '_tt_meta_page_opt',
		   'title'     => 'Testimonials Options',
		   'post_type' => 'tt-testimonial',
		   'context'   => 'normal',
		   'priority'  => 'default',
		   'sections'  => $tt_temptt_testimonial2_meta

		);

		// Note : Meta options for CPTs are triggered from templatation-framework plugin as needed by this theme.

		return $options;

	}

	add_filter( 'cs_metabox_options', 'tt_temptt_metas_opt' );

}


