
<?php
 if ( ! defined( 'ABSPATH' ) ) exit;
require_once( 'legalPages.php' );
global $wpdb;
$lpObj = new legalPages();
$lpObj->lp_enqueue_editor();

$post_id = $object->ID;

if(!empty($_POST) && isset($_POST['lp-submit'])){



	if(isset($_POST['lp_eu_status'])){
	 update_option('lp_eu_cookie_enable',sanitize_text_field($_POST['lp_eu_status']));	
	} else {
	 update_option('lp_eu_cookie_enable','off');	
	}
	
	if(isset($_POST['lp-is_adult_page'])){
		
	 update_option('lp_eu_adult_enable_'.$post_id,sanitize_text_field($_POST['lp-is_adult_page']));	
	} else {
	 update_option('lp_eu_adult_enable_'.$post_id,'off');	
	}
	

	if(isset($_POST['lp_eu_theme_css'])) {
		update_option('lp_eu_theme_css', sanitize_text_field($_POST['lp_eu_theme_css']));
	} else {
		update_option('lp_eu_theme_css','0');
	}

	update_option('lp_eu_cookie_title',addslashes(sanitize_text_field($_POST['lp_eu_title'])));
	update_option('lp_eu_cookie_message',htmlentities(sanitize_text_field($_POST['lp_eu_message'])));
	update_option('lp_eu_box_color',sanitize_text_field($_POST['lp_eu_box_color']));
	update_option('lp_eu_button_color',sanitize_text_field($_POST['lp_eu_button_color']));
	update_option('lp_eu_button_text_color',sanitize_text_field($_POST['lp_eu_button_text_color']));
	update_option('lp_eu_text_color',sanitize_text_field($_POST['lp_eu_text_color']));

	update_option('lp_eu_button_text',sanitize_text_field($_POST['lp_eu_button_text']));
	update_option('lp_eu_link_text',sanitize_text_field($_POST['lp_eu_link_text']));
	update_option('lp_eu_link_url',sanitize_text_field($_POST['lp_eu_link_url']));
	update_option('lp_eu_text_size',sanitize_text_field($_POST['lp_eu_text_size']));
	update_option('lp_eu_link_color',sanitize_text_field($_POST['lp_eu_link_color']));
}





$field_value = ""; 
//get cookies enable fron postid
$lp_eu_get_visibility_post_id   = get_option('lp_eu_cookie_enable_' . $post_id);
//first check if cookies is enabled for post 
if (trim($lp_eu_get_visibility_post_id) != "" ) {
// if it's setup on or off will be coming from here only.
    if($lp_eu_get_visibility_post_id=='ON'){
        $field_value = " checked ";
    }	

} else {
   //else global value will take over always
   $lp_eu_get_visibility   = get_option('lp_eu_cookie_enable');
   
    if(trim($lp_eu_get_visibility) == "ON" ){
        $field_value = " checked ";
    }
}



$adult_value = "";
$lp_eu_get_adult_post_value   = get_option('lp_eu_adult_page_enable_' . $post_id);
//if post id present only post id will be implemented
if (trim($lp_eu_get_adult_post_value) != "" ) {
     if(trim($lp_eu_get_adult_post_value) == "ON" ){
        $adult_value = " checked ";
    }    
} else {
    $general = get_option('lp_general'); 
   if(isset($general['is_adult']) && $general['is_adult']=='1'){
        $adult_value = " checked ";
    }
}

wp_enqueue_script( 'jquery-minicolor',  plugin_dir_url( __FILE__ ) . 'js/jquery.miniColors.min.js', array('jquery') );
wp_enqueue_style('jquery-miniColor', plugin_dir_url( __FILE__ ) . 'css/minicolor/jquery.miniColors.css');

//Form validation library file
wp_enqueue_script('jquery-validation-plugin', plugin_dir_url( __FILE__ ) .'js/jquery.validate.min.js', array('jquery'));

?>


    <div class="wrap">
        <div class="postbox all_pad cooki">
            <form id="lp_eu_cookies_form" enctype="multipart/form-data" method="post" action="" name="terms">
                <div class="row">
                    <div class="col-md-9">
                        <label class="field_title"> 
                        
                             <?php _e('Cookie Bar','wplegalpages');?> : </label>
                        <label class="switch cookie_switch">

                            <input type="checkbox" <?php echo $field_value; ?> name="lp_eu_status" value="ON" >
                            <div class="slider round"></div>

                        </label>
                        <span id ='cookie_loader' class="dashicons"></span>
                       <input id="post_eid" type="hidden" value="<?php echo $post_id; ?>" name="post_eid" />
                      
                    </div>
                    <a href="#" data-toggle="tooltip" data-placement="left" title="If you would like to 'FORCE' any visitor to engage your COOKIE MESSAGE on this page even if previously viewed, please turn cookie bar option to (off) position; Then turn back to (on) position in order to reset">
                  <span class="glyphicon glyphicon-info-sign" style="z-index: 9999999;"></span> </a>
                </div>                 
            </form>
        </div>
    </div>
 <!-- --------------------------------------Adult Content Site code start------------------------ -->
  <div class="wrap">
        <div class="postbox all_pad cooki adult-info">
              <div class="row">
                    <div class="col-md-9">
                        <label class="field_title">
                        
                             <?php _e('Adult Bar','wplegalpages');?> : </label>
                        <label class="switch adult_switch">

                            <input type="checkbox" <?php echo $adult_value; ?> name="lp-is_adult_page" value="ON" >
                            <div class="slider round"></div>
                        </label>
                        <span id ='adult_loader' class="dashicons"></span>
                       <input id="post_aid" type="hidden" value="<?php echo $post_id; ?>" name="post_aid" />
                      
                    </div>
                    <a href="#" data-toggle="tooltip" data-placement="left" title="If you would like to 'FORCE' any visitor to engage your ADULT AGE VERIFICATION message on this page even if previously viewed, please turn adult bar option to (off) position; Then turn back
                   to (on) position in order to reset"> 
                    <span class="glyphicon glyphicon-info-sign" style="z-index: 9999999;"></span> </a>
                </div>

            </div>
        </div>