<?php 


$slect_stylepro_data = get_post_meta($post->ID, "slect_stylepro_data", true) ? get_post_meta($post->ID, "slect_stylepro_data", true): ' ';
$slect_clm_erp_rw = get_post_meta($post->ID, "slect_clm_erp_rw", true) ? get_post_meta($post->ID, "slect_clm_erp_rw", true): 'col-2';
$slect_styleanimationcm = get_post_meta($post->ID, "slect_styleanimationcm", true) ? get_post_meta($post->ID, "slect_styleanimationcm", true): ' ';

$slect_prodct_butondata = get_post_meta($post->ID, "slect_prodct_butondata", true) ? get_post_meta($post->ID, "slect_prodct_butondata", true): ' ';
$el_fi_prodct_gridbg = get_post_meta($post->ID, "el_fi_prodct_gridbg", true) ? get_post_meta($post->ID, "el_fi_prodct_gridbg", true): ' ';
$el_fi_prodct_gridbg_2 = get_post_meta($post->ID, "el_fi_prodct_gridbg_2", true);
$fancy_proMetabtn_align = get_post_meta($post->ID, "fancy_proMetabtn_align", true) ? get_post_meta($post->ID, "fancy_proMetabtn_align", true): 'left';


$fancy_Pro_metabtn_ac_bg = get_post_meta($post->ID, "fancy_Pro_metabtn_ac_bg", true);



$fancy_Pro_metabtn_bg = get_post_meta($post->ID, "fancy_Pro_metabtn_bg", true) ? get_post_meta($post->ID, "fancy_Pro_metabtn_bg", true): '#81d742';

$fancy_metabtn_Proclor = get_post_meta($post->ID, "fancy_metabtn_Proclor", true) ? get_post_meta($post->ID, "fancy_metabtn_Proclor", true): '#2d2d2d';



$facncy_meta_product = get_terms(array (
   'taxonomy'     => 'product_cat',
   'orderby' => 'none',
   'hide_empty' => true,


));
   if ($facncy_meta_product)
   {

    $html .= '<li class="mtfgfancy ksfjdutry"><p class="metaitem_title"><label for="facncy_meta_product">Choose Product Categories: </label></p></li><li  class="mtfgfancy_select"><select id="facncy_meta_product"  name="facncy_meta_product[]" multiple="multiple" class="yoo_display_option">';
    foreach ($facncy_meta_product as $el_category)
    {
        $selected = (is_array($appended_meta_product) && in_array($el_category->term_id, $appended_meta_product)) ? ' selected="selected"' : '';
        $html .= '<option value="' . $el_category->term_id . '" ' . $selected . '>' .$el_category->name. '</option>';
    }
    $html .= '</select></li>';

    $html .= '<li  class="mtfgfancy_selectsd"><label class="fancymetagrid"> Choose Grid Style</label>

  <select value="st-free" selected>
     <option>'.esc_html('Free Style', 'fancy-fiter').'</option>
  </select></li>
 <li  class="mtfgfancy_selectsd"><label class="fancymetagrid"> Animation Effects</label><select class="item_slct" name="slect_styleanimationcm" id="id_free_method" >

  <option value="fancyfilter_pro-free-item--eff1" ' . selected('fancyfilter_pro-free-item--eff1', $slect_styleanimationcm, false) . '>'.esc_html('Effect 1', 'fancy-fiter').'</option>  
  <option value="fancyfilter_pro-free-item--eff2" ' . selected('fancyfilter_pro-free-item--eff2', $slect_styleanimationcm, false) . '>'.esc_html('Effect 2', 'fancy-fiter').'</option>  
  <option value="fancyfilter_pro-free-item--eff3" ' . selected('fancyfilter_pro-free-item--eff3', $slect_styleanimationcm, false) . '>'.esc_html('Effect 3', 'fancy-fiter').'</option>  
  <option value="fancyfilter_pro-free-item--eff4" ' . selected('fancyfilter_pro-free-item--eff4', $slect_styleanimationcm, false) . '>'.esc_html('Effect 4', 'fancy-fiter').'</option>  </select></li>
  <li   class="mtfgfancy_selectsd"><label class="fancymetagrid">Background One</label>
  <input type="text" name="el_fi_prodct_gridbg" value="'.$el_fi_prodct_gridbg.'" class="fancyfilter_color" data-alpha-enabled="true">
  </li><li  class="mtfgfancy_selectsd">
  <label class="fancymetagrid">Background Two(For Gradient)</label>
  <input type="text" name="el_fi_prodct_gridbg_2" value="'.$el_fi_prodct_gridbg_2.'" class="fancyfilter_color" data-alpha-enabled="true" >
    <div><em>Not Applicable for Grid Style 4</em></div>
  </li> ' ;


    $html .= '<li  class="mtfgfancy_selectsd"><label class="fancymetagrid"> Column Per Row</label>

  <select class="item_slct"  name="slect_clm_erp_rw">
     <option value="col-1" ' . selected('col-1', $slect_clm_erp_rw, false) . '>'.esc_html('Two Column', 'fancy-fiter').'</option>
     <option value="col-2"  ' . selected('col-2', $slect_clm_erp_rw, false) . '>'.esc_html('Three Column', 'fancy-fiter').'</option>
     <option value="col-3"  ' . selected('col-3', $slect_clm_erp_rw, false) . '>'.esc_html('Four Column', 'fancy-fiter').'</option>
  </select></li>' ;

  $html .= '<li  class="mtfgfancy_selectsd"><label class="fancymetagrid">Choose Filter Button Style</label>
  <select  name="slect_prodct_butondata" id="id_application_method">
     <option value="btnsyle-no" ' . selected('btnsyle-no', $slect_prodct_butondata, false) . '>'.esc_html('None', 'fancy-fiter').'</option>
     <option value="btnsyle-1" ' . selected('btnsyle-1', $slect_prodct_butondata, false) . '>'.esc_html('Style 1 ', 'fancy-fiter').'</option>
     <option value="btnsyle-2" ' . selected('btnsyle-2', $slect_prodct_butondata, false) . '>'.esc_html('Style 2 ', 'fancy-fiter').'</option>
  </select></li>
  <li  class="mtfgfancy_selectsd">
  <label class="fancymetagrid">Button Align</label>
  <select  name="fancy_proMetabtn_align"  class="item_slct" >
     <option value="left" ' . selected('left', $fancy_proMetabtn_align, false) . '>'.esc_html('Left', 'fancy-fiter').'</option>
     <option value="center" ' . selected('center', $fancy_proMetabtn_align, false) . '>'.esc_html('Center', 'fancy-fiter').'</option>
     <option value="right" ' . selected('right', $fancy_proMetabtn_align, false) . '>'.esc_html('Right', 'fancy-fiter').'</option>
  </select></li>

  </li><li   class="mtfgfancy_selectsd">
  <label class="fancymetagrid">Button Label Color</label>
  <input type="text" name="fancy_metabtn_Proclor" value="'.$fancy_metabtn_Proclor.'" class="fancyfilter_color" data-alpha-enabled="true">
  </li>
    <li   class="mtfgfancy_selectsd">
    <label class="fancymetagrid">Button Background</label>
    <input type="text" name="fancy_Pro_metabtn_ac_bg" value="'.$fancy_Pro_metabtn_ac_bg.'" class="fancyfilter_color" data-alpha-enabled="true" >
    <div><em>Applies only to button styles 3,4,6,8,10,13</em></div>
    </li>
  <li   class="mtfgfancy_selectsd">
  <label class="fancymetagrid">Active Color</label>
  <input type="text" name="fancy_Pro_metabtn_bg" value="'.$fancy_Pro_metabtn_bg.'" class="fancyfilter_color" data-alpha-enabled="true">
  </li>';
}
else{
    
    echo "Please create an item by attaching a category first <a href='".esc_url(admin_url('/'))."edit.php?post_type=fancyfilter'>Click here</a>";

}
   

$html .= '</ul>';

 $allowed_html = array(
    'ul' => array(
        'id'    => array(),
        'class'    => array(),
        'style'    => array(),

    ),
    'li' => array(
        'id'    => array(),
        'class'    => array(),
        'style'    => array(),
    ),
    'label' => array(
        'id'    => array(),
        'class'    => array(),
        'for'    => array(),
    ),
    'input' => array(
        'type'  => array(),
        'id'    => array(),
        'class'    => array(),
        'name'  => array(),
        'value' => array(),
        'checked'  => array(), 
     ),
    'select' => array(
        'class'    => array(),
        'id'    => array(),
        'name'  => array(),
        'multiple'  => array(),

     ),
        'option'  => array(
        'value' => array(),
        'class'    => array(),
        'id'    => array(),
        'selected'  => array(),        
        ),
        'div'  => array(
        'class'    => array(),
        'id'    => array(),
        'style'    => array(),
        ),
        'strong'  => array(
        'class'    => array(),
        'id'    => array(),
        ),
        'table'  => array(
        'class'    => array(),
        'id'    => array(),
        ),
        'tr'  => array(
        'class'    => array(),
        'id'    => array(),
        ),
        'tbody'  => array(
        'class'    => array(),
        'id'    => array(),
        ),
        'th'  => array(
        'class'    => array(),
        'id'    => array(),
        ),
        'td'  => array(
        'class'    => array(),
        'id'    => array(),
        ),
        'span' => array(
        'id'    => array(),
        'class'    => array(),
        'style'    => array(),
    ),
        'em' => array(
        'id'    => array(),
        'class'    => array(),
        'style'    => array(),
    ),
);



echo wp_kses($html,$allowed_html );

if (!empty($appended_meta_product))
{

echo '<div class="shortcode_display">
        <h4>Shortcode</h4>
        <em><p>To display the frontend, copy the code below and paste it in the desired location</p></em>
        <p class="dynashorcde">
        [fancyfilter_product id ="'.esc_attr($post->ID).'" grid_style ="st-free" button="'.esc_attr($slect_prodct_butondata).'" col_1="'.esc_attr($el_fi_prodct_gridbg).'" col_2="'.esc_attr($el_fi_prodct_gridbg_2).'" align="'.esc_attr($fancy_proMetabtn_align).'" btn_act="'.esc_attr($fancy_Pro_metabtn_bg).'" btnclr="'.esc_attr($fancy_metabtn_Proclor).'" btnbg="'.esc_attr($fancy_Pro_metabtn_ac_bg).'" layout="'.esc_attr($slect_clm_erp_rw).'" animation="'.esc_attr($slect_styleanimationcm).'"]
        </p></div>';

}

