<?php
/**
 * The Popup Settings Meta-box configurations.
 *
 * @package Smart_Post_Show_Pro
 * @subpackage admin
 */

if ( ! defined( 'ABSPATH' ) ) {
	die; } // Cannot access pages directly.

/**
 * The Popup settings class.
 */
class SPSP_DetailSettings {

	/**
	 * Popup settings section metabox.
	 *
	 * @param string $prefix The metabox key.
	 * @return void
	 */
	public static function section( $prefix ) {
		SP_PCP::createSection(
			$prefix,
			array(
				'title'  => __( 'Detail page Settings', 'smart-post-show-pro' ),
				'icon'   => 'sps-icon-detail-page',
				'fields' => array(
					array(
						'id'       => 'pcp_page_link_type',
						'type'     => 'radio',
						'title'    => __( 'Detail Page Link Type', 'smart-post-show-pro' ),
						'subtitle' => __( 'Choose a link type for the (item) detail page.', 'smart-post-show-pro' ),
						'options'  => array(
							'popup'       => __( 'Popup', 'smart-post-show-pro' ),
							'single_page' => __( 'Single Page', 'smart-post-show-pro' ),
							'none'        => __( 'None (no link action)', 'smart-post-show-pro' ),
						),
						'default'  => 'single_page',
					),
					array(
						'id'         => 'pcp_link_target',
						'type'       => 'select',
						'title'      => __( 'Target', 'smart-post-show-pro' ),
						'subtitle'   => __( 'Open post (item) in.', 'smart-post-show-pro' ),
						'options'    => array(
							'_self'   => __( 'Current Tab', 'smart-post-show-pro' ),
							'_blank'  => __( 'New Tab', 'smart-post-show-pro' ),
							'_parent' => __( 'Parent', 'smart-post-show-pro' ),
							'_top'    => __( 'Top', 'smart-post-show-pro' ),
						),
						'default'    => '_self',
						'dependency' => array( 'pcp_page_link_type', '==', 'single_page' ),
					),
					array(
						'id'      => 'pcp_link_rel',
						'type'    => 'checkbox',
						'title'   => __( 'Add rel="nofollow" to item links', 'smart-post-show-pro' ),
						'default' => 'false',
					),
					array(
						'id'         => 'pcp_popup_type',
						'type'       => 'layout_preset',
						'class'      => 'hide-active-sign',
						'title'      => __( 'Popup Type', 'smart-post-show-pro' ),
						'subtitle'   => __( 'Choose a popup type.', 'smart-post-show-pro' ),
						'options'    => array(
							'single_popup' => array(
								'image' => SP_PCP_URL . 'admin/img/popup-type/single_popup.svg',
								'text'  => __( 'Single Popup', 'smart-post-show-pro' ),
							),
							'multi_popup'  => array(
								'image' => SP_PCP_URL . 'admin/img/popup-type/multi_popup.svg',
								'text'  => __( 'Multi Popup', 'smart-post-show-pro' ),
							),
						),
						'default'    => 'single_popup',
						'dependency' => array( 'pcp_page_link_type', '==', 'popup' ),
					),
					array(
						'id'         => 'popup_post_content_sorter',
						'type'       => 'sortable',
						'title'      => __( 'Popup Fields', 'smart-post-show-pro' ),
						'subtitle'   => __( 'Show/Hide content fields in the popup. These fields are also sortable.', 'smart-post-show-pro' ),
						'class'      => 'post_content_sorter_sortable',
						'default'    => array(
							'popup_show_post_thumb'     => true,
							'popup_show_post_title'     => true,
							'popup_show_post_meta'      => true,
							'popup_show_post_content'   => true,
							'popup_show_social_share'   => true,
							'popup_show_custom_fields'  => false,
							'popup_show_product_rating' => false,
							'popup_show_product_price'  => false,
							'popup_show_product_cart'   => false,
						),
						'fields'     => array(
							array(
								'id'         => 'popup_show_post_thumb',
								'type'       => 'switcher',
								'title'      => __( 'Thumbnail', 'smart-post-show-pro' ),
								'text_on'    => __( 'Show', 'smart-post-show-pro' ),
								'text_off'   => __( 'Hide', 'smart-post-show-pro' ),
								'text_width' => 80,
							),
							array(
								'id'         => 'popup_show_post_title',
								'type'       => 'switcher',
								'title'      => __( 'Title', 'smart-post-show-pro' ),
								'text_on'    => __( 'Show', 'smart-post-show-pro' ),
								'text_off'   => __( 'Hide', 'smart-post-show-pro' ),
								'text_width' => 80,
							),
							array(
								'id'         => 'popup_show_post_meta',
								'class'      => 'sp-pcp-popup-show-post-meta sp-product-not-fields',
								'type'       => 'switcher',
								'title'      => __( 'Meta Fields', 'smart-post-show-pro' ),
								'text_on'    => __( 'Show', 'smart-post-show-pro' ),
								'text_off'   => __( 'Hide', 'smart-post-show-pro' ),
								'text_width' => 80,
							),
							array(
								'id'         => 'popup_show_post_content',
								'type'       => 'switcher',
								'title'      => __( 'Content', 'smart-post-show-pro' ),
								'text_on'    => __( 'Show', 'smart-post-show-pro' ),
								'text_off'   => __( 'Hide', 'smart-post-show-pro' ),
								'text_width' => 80,
							),
							array(
								'id'         => 'popup_show_social_share',
								'class'      => 'sp-pcp-popup-show-social-share sp-product-not-fields',
								'type'       => 'switcher',
								'title'      => __( 'Social Share', 'smart-post-show-pro' ),
								'text_on'    => __( 'Show', 'smart-post-show-pro' ),
								'text_off'   => __( 'Hide', 'smart-post-show-pro' ),
								'text_width' => 80,
							),
							array(
								'id'         => 'popup_show_custom_fields',
								'type'       => 'switcher',
								'title'      => __( 'Custom Fields', 'smart-post-show-pro' ),
								'text_on'    => __( 'Show', 'smart-post-show-pro' ),
								'text_off'   => __( 'Hide', 'smart-post-show-pro' ),
								'text_width' => 80,
							),
							array(
								'id'         => 'popup_show_product_rating',
								'class'      => 'sp-pcp-popup-show-product-rating sp-product-fields',
								'type'       => 'switcher',
								'title'      => __( 'Rating', 'smart-post-show-pro' ),
								'text_on'    => __( 'Show', 'smart-post-show-pro' ),
								'text_off'   => __( 'Hide', 'smart-post-show-pro' ),
								'text_width' => 80,
							),
							array(
								'id'         => 'popup_show_product_price',
								'class'      => 'sp-pcp-popup-show-product-price sp-product-fields',
								'type'       => 'switcher',
								'title'      => __( 'Price', 'smart-post-show-pro' ),
								'text_on'    => __( 'Show', 'smart-post-show-pro' ),
								'text_off'   => __( 'Hide', 'smart-post-show-pro' ),
								'text_width' => 80,
							),
							array(
								'id'         => 'popup_show_product_cart',
								'class'      => 'sp-pcp-popup-show-product-cart sp-product-fields',
								'type'       => 'switcher',
								'title'      => __( 'Add To Cart', 'smart-post-show-pro' ),
								'text_on'    => __( 'Show', 'smart-post-show-pro' ),
								'text_off'   => __( 'Hide', 'smart-post-show-pro' ),
								'text_width' => 80,
							),
						),
						'dependency' => array( 'pcp_page_link_type', '==', 'popup' ),
					),
					array(
						'id'         => 'popup_content_color',
						'type'       => 'color_group',
						'title'      => __( 'Content Color', 'smart-post-show-pro' ),
						'subtitle'   => __( 'Set the popup content color.', 'smart-post-show-pro' ),
						'options'    => array(
							'post-title'    => __( 'Post Title', 'smart-post-show-pro' ),
							'post-meta'     => __( 'Post Meta', 'smart-post-show-pro' ),
							'post-content'  => __( 'Post Content', 'smart-post-show-pro' ),
							'custom-fields' => __( 'Custom Fields', 'smart-post-show-pro' ),
						),
						'default'    => array(
							'post-title'    => '#111',
							'post-meta'     => '#888',
							'post-content'  => '#444',
							'custom-fields' => '#888',
						),
						'dependency' => array( 'pcp_page_link_type', '==', 'popup' ),
					),
					array(
						'id'         => 'popup_bg_color',
						'type'       => 'color',
						'title'      => __( 'Background Color', 'smart-post-show-pro' ),
						'subtitle'   => __( 'Change the popup background color.', 'smart-post-show-pro' ),
						'default'    => '#fff',
						'dependency' => array( 'pcp_page_link_type', '==', 'popup' ),
					),
					array(
						'id'         => 'popup_overlay_color',
						'type'       => 'color',
						'title'      => __( 'Overlay Color', 'smart-post-show-pro' ),
						'subtitle'   => __( 'Change the popup overlay color.', 'smart-post-show-pro' ),
						'default'    => 'rgba(11,11,11,0.8)',
						'dependency' => array( 'pcp_page_link_type', '==', 'popup' ),
					),
					array(
						'id'         => 'popup_close_button',
						'type'       => 'switcher',
						'title'      => __( 'Close Button', 'smart-post-show-pro' ),
						'subtitle'   => __( 'Enable/Disable popup close button.', 'smart-post-show-pro' ),
						'text_on'    => __( 'Enabled', 'smart-post-show-pro' ),
						'text_off'   => __( 'Disabled', 'smart-post-show-pro' ),
						'text_width' => 100,
						'default'    => true,
						'dependency' => array( 'pcp_page_link_type', '==', 'popup' ),
					),
					array(
						'id'         => 'popup_close_btn_size',
						'type'       => 'spacing',
						'title'      => __( 'Close Button Size', 'smart-post-show-pro' ),
						'subtitle'   => __( 'Set close button icon size.', 'smart-post-show-pro' ),
						'sanitize'   => 'pcp_sanitize_number_array_field',
						'all'        => true,
						'min'        => 30,
						'max'        => 100,
						'units'      => array( 'px' ),
						'default'    => array(
							'all'  => '30',
							'unit' => 'px',
						),
						'dependency' => array( 'pcp_page_link_type|popup_close_button', '==|==', 'popup|true' ),
					),
					array(
						'id'         => 'popup_close_button_color',
						'type'       => 'color_group',
						'title'      => __( 'Close Button Color', 'smart-post-show-pro' ),
						'subtitle'   => __( 'Change the popup close button color.', 'smart-post-show-pro' ),
						'options'    => array(
							'color'       => __( 'Color', 'smart-post-show-pro' ),
							'hover-color' => __( 'Hover Color', 'smart-post-show-pro' ),
						),
						'default'    => array(
							'color'       => '#fc0c0c',
							'hover-color' => '#e1624b',
						),
						'dependency' => array( 'pcp_page_link_type|popup_close_button', '==|==', 'popup|true' ),
					),
					array(
						'id'         => 'popup_nav_color',
						'type'       => 'color_group',
						'title'      => __( 'Navigation Color', 'smart-post-show-pro' ),
						'subtitle'   => __( 'Change the popup navigation color.', 'smart-post-show-pro' ),
						'options'    => array(
							'color'       => __( 'Color', 'smart-post-show-pro' ),
							'hover-color' => __( 'Hover Color', 'smart-post-show-pro' ),
							'bg'          => __( 'Background', 'smart-post-show-pro' ),
							'hover-bg'    => __( 'Hover Background', 'smart-post-show-pro' ),
						),
						'default'    => array(
							'color'       => '#aaa',
							'hover-color' => '#fff',
							'bg'          => 'rgba(0,0,0,0.5)',
							'hover-bg'    => '#e1624b',
						),
						'dependency' => array( 'pcp_page_link_type|pcp_popup_type', '==|==', 'popup|multi_popup' ),
					),
					array(
						'id'         => 'pcp_popup_img_sizes',
						'type'       => 'image_sizes',
						'title'      => __( 'Thumbnail Image Dimensions', 'smart-post-show-pro' ),
						'subtitle'   => __( 'Change the popup image dimensions.', 'smart-post-show-pro' ),
						'default'    => 'full',
						'dependency' => array( 'popup_show_post_thumb|pcp_page_link_type', '==', 'true|popup' ),
					),
					array(
						'id'                => 'pcp_popup_image_crop_size',
						'type'              => 'dimensions_advanced',
						'title'             => __( 'Custom Dimensions', 'smart-post-show-pro' ),
						'subtitle'          => __( 'Set custom size for the popup image.', 'smart-post-show-pro' ),
						'chosen'            => true,
						'bottom'            => false,
						'left'              => false,
						'color'             => false,
						'top_icon'          => '<i class="fa fa-arrows-h"></i>',
						'right_icon'        => '<i class="fa fa-arrows-v"></i>',
						'top_placeholder'   => 'width',
						'right_placeholder' => 'height',
						'styles'            => array(
							'Soft-crop',
							'Hard-crop',
						),
						'default'           => array(
							'top'   => '600',
							'right' => '400',
							'style' => 'Soft-crop',
							'unit'  => 'px',
						),
						'attributes'        => array(
							'min' => 0,
						),
						'dependency'        => array( 'popup_show_post_thumb|pcp_popup_img_sizes|pcp_page_link_type', '==|==', 'true|custom|popup' ),
					),
					array(
						'id'         => 'pcp_popup_width',
						'type'       => 'spacing',
						'class'      => 'pcp-popup-width',
						'title'      => __( 'Maximum Width', 'smart-post-show-pro' ),
						'subtitle'   => __( 'Set maximum popup width.', 'smart-post-show-pro' ),
						'sanitize'   => 'pcp_sanitize_number_array_field',
						'all'        => true,
						'min'        => 0,
						'max'        => 3000,
						'all_icon'   => '<i class="fa fa-arrows-h"></i>',
						'units'      => array( 'px', '%' ),
						'default'    => array(
							'all' => '1050',
						),
						'dependency' => array( 'pcp_page_link_type', '==', 'popup' ),
					),
					array(
						'id'         => 'pcp_popup_height',
						'type'       => 'spacing',
						'class'      => 'pcp-popup-height',
						'title'      => __( 'Maximum Height', 'smart-post-show-pro' ),
						'subtitle'   => __( 'Set maximum popup height.', 'smart-post-show-pro' ),
						'sanitize'   => 'pcp_sanitize_number_array_field',
						'all'        => true,
						'min'        => 0,
						'max'        => 3000,
						'all_icon'   => '<i class="fa fa-arrows-v"></i>',
						'units'      => array( 'vh', 'px', '%' ),
						'default'    => array(
							'all' => '700',
						),
						'dependency' => array( 'pcp_page_link_type', '==', 'popup' ),
					),
				), // End of fields array.
			)
		); // Display settings section end.
	}
}
