<?php

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

$slect_styleanimationblog = get_post_meta($post->ID, "slect_styleanimationblog", true) ? get_post_meta($post->ID, "slect_styleanimationblog", true): ' ';

$slect_blog_erp_rw = get_post_meta($post->ID, "slect_blog_erp_rw", true) ? get_post_meta($post->ID, "slect_blog_erp_rw", true): 'col-2';
$slect_blg_butondata = get_post_meta($post->ID, "slect_blg_butondata", true) ? get_post_meta($post->ID, "slect_blg_butondata", true): ' ';
$el_fi_blog_gridbg = get_post_meta($post->ID, "el_fi_blog_gridbg", true) ? get_post_meta($post->ID, "el_fi_blog_gridbg", true): ' ';
$el_fi_blog_gridbg_2 = get_post_meta($post->ID, "el_fi_blog_gridbg_2", true) ? get_post_meta($post->ID, "el_fi_blog_gridbg_2", true): ' ';
$fancy_blogMetabtn_align = get_post_meta($post->ID, "fancy_blogMetabtn_align", true) ? get_post_meta($post->ID, "fancy_blogMetabtn_align", true): 'left';


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



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

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

$facncy_meta_post = get_terms(array (
'taxonomy'      => 'category',
'hide_empty'    => true,
'orderby'       => 'none',

));

if ($facncy_meta_post)
{

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

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

<select class="item_slct"  name="slectblog__styledata">
 <option value="st-free" ' . selected('st-free', $slectblog__styledata, false) . '>'.esc_html('Free Style', 'fancy-fiter').'</option>
 <option class="prodataver">'.esc_html('Style One (Pro)', 'fancy-fiter').'</option>
 <option class="prodataver">'.esc_html('Style Two (Pro)', 'fancy-fiter').'</option>
 <option class="prodataver">'.esc_html('Style Three (Pro)', 'fancy-fiter').'</option>
 <option class="prodataver">'.esc_html('Style Four (Pro)', 'fancy-fiter').'</option>
 <option class="prodataver">'.esc_html('Style Five (Pro)', 'fancy-fiter').'</option>
 <option class="prodataver">'.esc_html('Style Six (Pro)', 'fancy-fiter').'</option>
 <option class="prodataver">'.esc_html('Style Seven (Pro)', 'fancy-fiter').'</option>
 <option class="prodataver">'.esc_html('Style Eight (Pro)', 'fancy-fiter').'</option>
 <option class="prodataver">'.esc_html('Style Nine (Pro)', 'fancy-fiter').'</option>
 <option class="prodataver">'.esc_html('Style Ten (Pro)', 'fancy-fiter').'</option>
</select></li>
<li  class="mtfgfancy_selectsd"><label class="fancymetagrid"> Animation Effects</label><select class="item_slct" name="slect_styleanimationblog" id="id_free_method" >

<option value="fancyfilter_pro-free-item--eff1" ' . selected('fancyfilter_pro-free-item--eff1', $slect_styleanimationblog, false) . '>'.esc_html('Effect 1', 'fancy-fiter').'</option>  
<option value="fancyfilter_pro-free-item--eff2" ' . selected('fancyfilter_pro-free-item--eff2', $slect_styleanimationblog, false) . '>'.esc_html('Effect 2', 'fancy-fiter').'</option>  
<option value="fancyfilter_pro-free-item--eff3" ' . selected('fancyfilter_pro-free-item--eff3', $slect_styleanimationblog, false) . '>'.esc_html('Effect 3', 'fancy-fiter').'</option>  
<option value="fancyfilter_pro-free-item--eff4" ' . selected('fancyfilter_pro-free-item--eff4', $slect_styleanimationblog, 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_blog_gridbg" value="'.$el_fi_blog_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_blog_gridbg_2" value="'.$el_fi_blog_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_blog_erp_rw">
   <option value="col-1" ' . selected('col-1', $slect_blog_erp_rw, false) . '>'.esc_html('Two Column', 'fancy-fiter').'</option>
   <option value="col-2"  ' . selected('col-2', $slect_blog_erp_rw, false) . '>'.esc_html('Three Column', 'fancy-fiter').'</option>
   <option value="col-3"  ' . selected('col-3', $slect_blog_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_blg_butondata" id="id_application_method">
 <option value="btnsyle-no" ' . selected('btnsyle-no', $slect_blg_butondata, false) . '>'.esc_html('None', 'fancy-fiter').'</option>
 <option value="btnsyle-1" ' . selected('btnsyle-1', $slect_blg_butondata, false) . '>'.esc_html('Style 1 ', 'fancy-fiter').'</option>
 <option value="btnsyle-2" ' . selected('btnsyle-2', $slect_blg_butondata, false) . '>'.esc_html('Style 2 ', 'fancy-fiter').'</option>
 </select></li>
<li  class="mtfgfancy_selectsd">
<label class="fancymetagrid">Button Align</label>
<select  name="fancy_blogMetabtn_align"  class="item_slct" >
 <option value="left" ' . selected('left', $fancy_blogMetabtn_align, false) . '>'.esc_html('Left', 'fancy-fiter').'</option>
 <option value="center" ' . selected('center', $fancy_blogMetabtn_align, false) . '>'.esc_html('Center', 'fancy-fiter').'</option>
 <option value="right" ' . selected('right', $fancy_blogMetabtn_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_blog_metabtn_clor" value="'.$fancy_blog_metabtn_clor.'" class="fancyfilter_color" data-alpha-enabled="true">
</li>
<li   class="mtfgfancy_selectsd">
<label class="fancymetagrid">Button Background</label>
<input type="text" name="fancy_blogmetabtn_ac_bg" value="'.$fancy_blogmetabtn_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_blog_metabtn_bg" value="'.$fancy_blog_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_post))
{

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_blog id ="'.esc_attr($post->ID).'" grid_style = "'. esc_attr($slectblog__styledata).'" button="'.esc_attr($slect_blg_butondata).'" col_1="'.esc_attr($el_fi_blog_gridbg).'" col_2="'.esc_attr($el_fi_blog_gridbg_2).'" align="'.esc_attr($fancy_blogMetabtn_align).'" btn_act="'.esc_attr($fancy_blog_metabtn_bg).'" btnclr="'.esc_attr($fancy_blog_metabtn_clor).'" btnbg="'.esc_attr($fancy_blogmetabtn_ac_bg).'" layout="'.esc_attr($slect_blog_erp_rw).'" animation="'.esc_attr($slect_styleanimationblog).'"]
    </p></div>';
}

