<?php
// Do not allow direct access to the file.
if( ! defined( 'ABSPATH' ) ) {
    exit;
}
/**
 * Enqueue scripts and styles.
 */
function atmospheres_scripts_pricing_list() {
	wp_enqueue_style( 'atmospheres-pricing-list-css', get_template_directory_uri() . '/include/pricing-list/pricing-list.css' );
}
add_action( 'wp_enqueue_scripts', 'atmospheres_scripts_pricing_list' );

function atmospheres_pricing_list() {
	if( get_theme_mod('atmospheres_priceing_activate') ) {
?>
<div class="price-html">
    <div class="section-plans" id="section-plans">
      <div class="u-center-text u-margin-bottom-big">
        <h2 class="heading-secondary">
            <?php if ( get_theme_mod('atmospheres_pricing_title','All PLANS')) { echo esc_html(get_theme_mod('atmospheres_pricing_title', 'All PLANS')); } ?>
        </h2>
      </div>

	  <?php if(!get_theme_mod('atmospheres_priceing_deactivate_1')) { ?>
        <div class="col-1-of-3">
          <div class="card">
            <div class="card__side card__side--front-1">
              <div class="card__title card__title--1">
                <i class="fa fa-paper-plane"></i>
				<?php if ( get_theme_mod('atmospheres_pricing_plan_1_','BASIC')) { ?>
                <h4 class="card__heading"><?php echo esc_html(get_theme_mod('atmospheres_pricing_plan_1_', 'BASIC')); ?></h4>
				<?php } ?>
              </div>

              <div class="card__details">
                <ul>
				<?php for($a=1;$a<=9;$a++) { 
				if ( get_theme_mod('atmospheres_pricing_text_1_'.$a, 'Description')) { ?>
					<li><?php echo esc_html(get_theme_mod('atmospheres_pricing_text_1_'.$a, 'Description')); ?></li>
				<?php } } ?>
                </ul>
              </div>
            </div>
            <div class="card__side card__side--back card__side--back-1">
              <div class="card__cta">
                <div class="card__price-box">
				<?php if ( get_theme_mod('atmospheres_pricing_price1','$2.90/mo')) { ?>
                  <p class="card__price-value"><?php echo esc_html(get_theme_mod('atmospheres_pricing_price1','$2.90/mo')); ?></p>
				<?php } ?>
                </div>
				<?php if ( get_theme_mod('atmospheres_select_button_title1','SELECT')) { ?>
                <a href="<?php echo esc_url(get_theme_mod('atmospheres_pricing_button_url_1')); ?>" class="btn btn--green"><?php echo esc_html(get_theme_mod('atmospheres_select_button_title1','SELECT')); ?></a>
				<?php } ?>
              </div>
            </div>
          </div>
        </div>
		<?php } ?>
		<?php if(!get_theme_mod('atmospheres_priceing_deactivate_2')) { ?>
        <div class="col-1-of-3">
          <div class="card">
            <div class="card__side card__side--front-2">
              <div class="card__title card__title--2">
                <i class="fa fa-plane"></i>
				<?php if ( get_theme_mod('atmospheres_pricing_plan_2_','PLUS')) { ?>
                <h4 class="card__heading"><?php echo esc_html(get_theme_mod('atmospheres_pricing_plan_2_', 'PLUS')); ?></h4>
				<?php } ?>
              </div>

              <div class="card__details">
                <ul>
				<?php for($a=1;$a<=9;$a++) { 
				if ( get_theme_mod('atmospheres_pricing_text_2_'.$a, 'Description')) { ?>
					<li><?php echo esc_html(get_theme_mod('atmospheres_pricing_text_2_'.$a, 'Description')); ?></li>
				<?php } } ?>
                </ul>
              </div>
            </div>
            <div class="card__side card__side--back card__side--back-2">
              <div class="card__cta">
                <div class="card__price-box">
				<?php if ( get_theme_mod('atmospheres_pricing_price2','$4.90/mo')) { ?>
                  <p class="card__price-value"><?php echo esc_html(get_theme_mod('atmospheres_pricing_price2','$4.90/mo')); ?></p>
				<?php } ?>
                </div>
				<?php if ( get_theme_mod('atmospheres_select_button_title2','SELECT')) { ?>
                <a href="<?php echo esc_url(get_theme_mod('atmospheres_pricing_button_url_2')); ?>" class="btn btn--green"><?php echo esc_html(get_theme_mod('atmospheres_select_button_title2','SELECT')); ?></a>
				<?php } ?>
              </div>
            </div>
          </div>
        </div>
        <?php } ?>
		<?php if(!get_theme_mod('atmospheres_priceing_deactivate_3')) { ?>
        <div class="col-1-of-3">
          <div class="card">
            <div class="card__side card__side--front-3">
              <div class="card__title card__title--3">
                <i class="fa fa-rocket"></i>
				<?php if ( get_theme_mod('atmospheres_pricing_plan_3_','PRO')) { ?>
                <h4 class="card__heading"><?php echo esc_html(get_theme_mod('atmospheres_pricing_plan_3_', 'PRO')); ?></h4>
				<?php } ?>
              </div>

              <div class="card__details">
                <ul>
				<?php for($a=1;$a<=9;$a++) { 
				if ( get_theme_mod('atmospheres_pricing_text_3_'.$a, 'Description')) { ?>
					<li><?php echo esc_html(get_theme_mod('atmospheres_pricing_text_3_'.$a, 'Description')); ?></li>
				<?php } } ?>
                </ul>
              </div>
            </div>
            <div class="card__side card__side--back card__side--back-3">
              <div class="card__cta">
                <div class="card__price-box">
				<?php if ( get_theme_mod('3','$22.90/mo')) { ?>
                  <p class="card__price-value"><?php echo esc_html(get_theme_mod('atmospheres_pricing_price3','$22.90/mo')); ?></p>
				<?php } ?>
                </div>
				<?php if ( get_theme_mod('atmospheres_select_button_title3','SELECT')) { ?>
                <a href="<?php echo esc_url(get_theme_mod('atmospheres_pricing_button_url_3')); ?>" class="btn btn--green"><?php echo esc_html(get_theme_mod('atmospheres_select_button_title3','SELECT')); ?></a>
				<?php } ?>
              </div>
            </div>
          </div>
        </div>
		<?php } ?>
      
	  <div class="u-center-text u-margin-top-huge">
		<?php if ( get_theme_mod('atmospheres_pricing_button_title','GET STARTED')) { ?>
			<a href="<?php echo esc_url(get_theme_mod('atmospheres_pricing_button_url')); ?>" class="btn btn--green"><?php echo esc_html(get_theme_mod('atmospheres_pricing_button_title', 'GET STARTED')); ?></a>
		<?php } ?>
	   </div>
    </div>
  </div>
<?php }
}

add_action('price_list_3', 'atmospheres_pricing_list');
function atmospheres_price_customize_register( $wp_customize ) {
			$faq1 = '<div class="seos-help"><img class="seos-img" src="'. SEOS_THEME_URI .'/images/faq.gif" /><img class="hidden-help" src="'. SEOS_THEME_URI .'/images/5_help.webp" /></div>';
			$wp_customize->add_section( 'atmospheres_price_' , array(
				'title'       => __( 'Price List', 'atmospheres' ),
				'priority'   => 4,
			) );
			
			$wp_customize->add_setting( 'atmospheres_priceing_activate', array (
				'sanitize_callback' => 'atmospheres__sanitize_checkbox',
				'default' => false
			) );
			
			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'atmospheres_priceing_activate', array(
				'label'    => __( 'Activate on: Homepage, Blog Page', 'atmospheres' ),
				'section'  => 'atmospheres_price_',
				'type' => 'checkbox',
			) ) );

			$wp_customize->add_setting( 'atmospheres_pricing_title', array (
				'sanitize_callback' => 'sanitize_text_field',
				'default' => 'All PLANS',
			) );
			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'atmospheres_pricing_title', array(
			    'label'    => __( 'Section Title ', 'atmospheres' ),
				'description'   => sprintf( '%s', $faq1 ),	
				'section'  => 'atmospheres_price_',
				'type' => 'text',
			) ) );

			$wp_customize->add_setting( 'atmospheres_pricing_button_title', array (
				'sanitize_callback' => 'sanitize_text_field',
				'default' => 'GET STARTED',
			) );
			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'atmospheres_pricing_button_title', array(
			    'label'    => __( 'Button Title ', 'atmospheres' ),
				'section'  => 'atmospheres_price_',
				'type' => 'text',
			) ) );
			
			$wp_customize->add_setting( 'atmospheres_pricing_button_url', array (
				'sanitize_callback' => 'esc_url_raw',
			) );
			
			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'atmospheres_pricing_button_url', array(
				'label'    => __( 'Enter Button url', 'atmospheres' ),		
				'section'  => 'atmospheres_price_',
			) ) );	

			$wp_customize->add_setting( 'xmlf_pr3_color', array (
				'sanitize_callback' => 'sanitize_hex_color',
				'default' => '#AD3903'	
			) );
				
			$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'xmlf_pr3_color', array(
				'label'    => __( 'Background Color', 'atmospheres' ),
				'section'  => 'atmospheres_price_',
			) ) );
			
			$wp_customize->add_setting( 'xmlf_pr3_icons_color', array (
				'sanitize_callback' => 'sanitize_hex_color',
				'default' => '#eaeaea'	
			) );
				
			$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'xmlf_pr3_icons_color', array(
				'label'    => __( 'Icons Color', 'atmospheres' ),
				'section'  => 'atmospheres_price_',
			) ) );
			
			$wp_customize->add_setting( 'xmlf_pr3_border_color', array (
				'sanitize_callback' => 'sanitize_hex_color',
				'default' => '#AD3903'	
			) );
				
			$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'xmlf_pr3_border_color', array(
				'label'    => __( 'Borders Color', 'atmospheres' ),
				'section'  => 'atmospheres_price_',
			) ) );
			
/************************************ Plan 1 ************************************/
			
			$wp_customize->add_setting( 'atmospheres_priceing_deactivate_1', array (
				'sanitize_callback' => 'atmospheres__sanitize_checkbox',
			) );
			
			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'atmospheres_priceing_deactivate_1', array(
				'label'    => __( 'Deactivate Plan 1 ', 'atmospheres' ),
				'section'  => 'atmospheres_price_',
				'type' => 'checkbox',
			) ) );
			
			$wp_customize->add_setting( 'atmospheres_pricing_plan_1_', array (
				'sanitize_callback' => 'sanitize_text_field',
				'default' => 'BASIC',
			) );
			
			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'atmospheres_pricing_plan_1_', array(
				'label'    => __( 'Add Plan 1', 'atmospheres' ),
				'section'  => 'atmospheres_price_',
				'type' => 'text',
			) ) );
				
			$wp_customize->add_setting( 'atmospheres_pricing_price1', array (
				'sanitize_callback' => 'sanitize_text_field',
				'default' => '$2.90/mo',
			) );
			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'atmospheres_pricing_price1', array(
			    'label'    => __( 'Plan Price ', 'atmospheres' ),
				'section'  => 'atmospheres_price_',
				'type' => 'text',
			) ) );
			
			$wp_customize->add_setting( 'atmospheres_select_button_title1', array (
				'sanitize_callback' => 'sanitize_text_field',
				'default' => 'SELECT',
			) );
			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'atmospheres_select_button_title1', array(
			    'label'    => __( 'Button Title ', 'atmospheres' ),
				'section'  => 'atmospheres_price_',
				'type' => 'text',
			) ) );
			
			$wp_customize->add_setting( 'atmospheres_pricing_button_url_1', array (
				'sanitize_callback' => 'esc_url_raw',
			) );
			
			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'atmospheres_pricing_button_url_1', array(
				'label'    => __( 'Enter Button url', 'atmospheres' ),		
				'section'  => 'atmospheres_price_',
			) ) );
			
			for($a=1;$a<=9;$a++) {
				$wp_customize->add_setting( 'atmospheres_pricing_text_1_'.$a, array (
					'sanitize_callback' => 'sanitize_text_field',
					'default' => 'Description',
				) );
				
				$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'atmospheres_pricing_text_1_'.$a, array(
					'label'    => __( 'Option ', 'atmospheres' ),
					'description'    => __( 'Recommended 30 characters max ', 'atmospheres' ),
					'section'  => 'atmospheres_price_',
					'type' => 'text',
				) ) );
			}

/************************************ Plan 2 ************************************/		
	
			$wp_customize->add_setting( 'atmospheres_priceing_deactivate_2', array (
				'sanitize_callback' => 'atmospheres__sanitize_checkbox',
			) );
			
			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'atmospheres_priceing_deactivate_2', array(
				'label'    => __( 'Deactivate Plan 2 ', 'atmospheres' ),
				'section'  => 'atmospheres_price_',
				'type' => 'checkbox',
			) ) );
			
			$wp_customize->add_setting( 'atmospheres_pricing_plan_2_', array (
				'sanitize_callback' => 'sanitize_text_field',
				'default' => 'PLUS',
			) );
			
			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'atmospheres_pricing_plan_2_', array(
				'label'    => __( 'Add Plan 2', 'atmospheres' ),
				'section'  => 'atmospheres_price_',
				'type' => 'text',
			) ) );
			
			$wp_customize->add_setting( 'atmospheres_pricing_price2', array (
				'sanitize_callback' => 'sanitize_text_field',
				'default' => '$4.90/mo',
			) );
			
			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'atmospheres_pricing_price2', array(
			    'label'    => __( 'Plan Price ', 'atmospheres' ),
				'section'  => 'atmospheres_price_',
				'type' => 'text',
			) ) );
			
			$wp_customize->add_setting( 'atmospheres_select_button_title2', array (
				'sanitize_callback' => 'sanitize_text_field',
				'default' => 'SELECT',
			) );
			
			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'atmospheres_select_button_title2', array(
			    'label'    => __( 'Button Title ', 'atmospheres' ),
				'section'  => 'atmospheres_price_',
				'type' => 'text',
			) ) );
			
			$wp_customize->add_setting( 'atmospheres_pricing_button_url_2', array (
				'sanitize_callback' => 'esc_url_raw',
			) );
			
			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'atmospheres_pricing_button_url_2', array(
				'label'    => __( 'Enter Button url', 'atmospheres' ),		
				'section'  => 'atmospheres_price_',
			) ) );
			
			for($a=1;$a<=9;$a++) {
				$wp_customize->add_setting( 'atmospheres_pricing_text_2_'.$a, array (
					'sanitize_callback' => 'sanitize_text_field',
					'default' => 'Description',
				) );
				
				$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'atmospheres_pricing_text_2_'.$a, array(
					'label'    => __( 'Option', 'atmospheres' ),
					'description'    => __( 'Recommended 30 characters max ', 'atmospheres' ),
					'section'  => 'atmospheres_price_',
					'type' => 'text',
				) ) );
			}
			
/************************************ Plan 3 ************************************/		
	
			$wp_customize->add_setting( 'atmospheres_priceing_deactivate_3', array (
				'sanitize_callback' => 'atmospheres__sanitize_checkbox',
			) );
			
			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'atmospheres_priceing_deactivate_3', array(
				'label'    => __( 'Deactivate Plan 3 ', 'atmospheres' ),
				'section'  => 'atmospheres_price_',
				'type' => 'checkbox',
			) ) );
			
			$wp_customize->add_setting( 'atmospheres_pricing_plan_3_', array (
				'sanitize_callback' => 'sanitize_text_field',
				'default' => 'PRO',
			) );
			
			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'atmospheres_pricing_plan_3_', array(
				'label'    => __( 'Add Plan 3', 'atmospheres' ),
				'section'  => 'atmospheres_price_',
				'type' => 'text',
			) ) );
				
			$wp_customize->add_setting( 'atmospheres_pricing_price3', array (
				'sanitize_callback' => 'sanitize_text_field',
				'default' => '$22.90/mo',
			) );
			
			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'atmospheres_pricing_price3', array(
			    'label'    => __( 'Plan Price ', 'atmospheres' ),
				'section'  => 'atmospheres_price_',
				'type' => 'text',
			) ) );
			
			$wp_customize->add_setting( 'atmospheres_select_button_title3', array (
				'sanitize_callback' => 'sanitize_text_field',
				'default' => 'SELECT',
			) );
			
			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'atmospheres_select_button_title3', array(
			    'label'    => __( 'Button Title ', 'atmospheres' ),
				'section'  => 'atmospheres_price_',
				'type' => 'text',
			) ) );
			
			$wp_customize->add_setting( 'atmospheres_pricing_button_url_3', array (
				'sanitize_callback' => 'esc_url_raw',
			) );
			
			$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'atmospheres_pricing_button_url_3', array(
				'label'    => __( 'Enter Button url', 'atmospheres' ),		
				'section'  => 'atmospheres_price_',
			) ) );
			
			for($a=1;$a<=9;$a++) {
				$wp_customize->add_setting( 'atmospheres_pricing_text_3_'.$a, array (
					'sanitize_callback' => 'sanitize_text_field',
					'default' => 'Description',
				) );
				
				$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'atmospheres_pricing_text_3_'.$a, array(
					'label'    => __( 'Option', 'atmospheres' ),
					'description'    => __( 'Recommended 30 characters max ', 'atmospheres' ),
					'section'  => 'atmospheres_price_',
					'type' => 'text',
				) ) );
			}			
}
		add_action( 'customize_register', 'atmospheres_price_customize_register' );

		// Hide Inputs in Customize Panel //
		function  atmospheres_hide_pricing_customize_styles( $input ) { ?>
			<style type="text/css">
				#_customize-input-include_pricing_ {
					display: none;
				}
			</style>
		<?php }

		add_action( 'customize_controls_print_styles', 'atmospheres_hide_pricing_customize_styles');
		
	
	function atmospheres_price_3_styles() {
        $xmlf_pr3_color = esc_attr( get_theme_mod( 'xmlf_pr3_color', '#AD3903' ) );
        $xmlf_pr3_border_color = esc_attr( get_theme_mod( 'xmlf_pr3_border_color', '#AD3903' ) );
        $xmlf_pr3_icons_color = esc_attr( get_theme_mod( 'xmlf_pr3_icons_color','#eaeaea' ) );
## Colors Styles
		if( $xmlf_pr3_color) { $style1 = "body .btn--green, body .card__side--back-1, body .card__side--back-2, body .card__side--back-3, body .card__side--front-1, body .card__side--front-2, body .card__side--front-3 { background: linear-gradient(-45deg, #000, {$xmlf_pr3_color});}";} else { $style1 =""; }
		if( $xmlf_pr3_border_color) { $style2 = "body .card__details ul li:not(:first-child) { border-top: 1px solid {$xmlf_pr3_border_color};}";} else { $style2 =""; }
		if( $xmlf_pr3_icons_color) { $style3 = "body .col-1-of-3 .fa { color: {$xmlf_pr3_icons_color};}";} else { $style3 =""; }
       
	   wp_add_inline_style( 'custom-style-css', 
		$style1.$style2.$style3
		);
}
add_action( 'wp_enqueue_scripts', 'atmospheres_price_3_styles' );