<?php
/**
 * The core plugin class.
 *
 * This is used to define internationalization, admin-specific hooks, and
 * public-facing site hooks.
 *
 * Also maintains the unique identifier of this plugin as well as the current
 * version of the plugin.
 *
 * @since      1.1.4
 * @package    Yoo_Bar
 * @subpackage Yoo_Bar/includes
 * @author     Sharabindu <info@sharabindu.com>
 */
class FancyProductMetaDataLite
{

    public function __construct()
    {

        add_action('admin_menu', array(
            $this,
            'fancyfilter_posttype_metas'
        ));
        add_action('save_post', array(
            $this,
            'fancyfilter_posttype_save_metas'
        ) , 10, 2);
    }

    public function fancyfilter_posttype_metas()
    {

        add_meta_box('fancy_product_type', 'Blog Post', array(
            $this,
            'fancyfilter_posttype_select_metas'
        ) , 'morefilter', 'advanced', 'default');
    }

    public function fancyfilter_posttype_select_metas($post)
    {

 

        $html = ' <ul class="fancydescrip_metainfo">';


        $appended_meta_post = get_post_meta($post->ID, 'facncy_meta_post', true);

        include FANCYFILTER_PATH .'metaData/FancyMetaExtra/BlogData.php';

    }

    public function fancyfilter_posttype_save_metas($post_id, $post)
    {

    $nonce = wp_create_nonce( 'fancyblog-nonce' );
    if ( ! wp_verify_nonce( $nonce, 'fancyblog-nonce' ) ) return;


        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return $post_id;

        if ($post->post_type == 'morefilter')
        {
            if (isset($_POST['facncy_meta_post'])) update_post_meta($post_id, 'facncy_meta_post', sanitize_mime_type(wp_unslash($_POST['facncy_meta_post'])));
            else delete_post_meta($post_id, 'facncy_meta_post');

            if (isset($_POST['slect_blg_butondata']))
            {update_post_meta($post_id, 'slect_blg_butondata', sanitize_text_field(wp_unslash($_POST['slect_blg_butondata'])));
            }else{delete_post_meta($post_id, 'slect_blg_butondata');}
            if (isset($_POST['el_fi_blog_gridbg']))
            {update_post_meta($post_id, 'el_fi_blog_gridbg', sanitize_text_field(wp_unslash($_POST['el_fi_blog_gridbg'])));
            }else{delete_post_meta($post_id, 'el_fi_blog_gridbg');}
            if (isset($_POST['el_fi_blog_gridbg_2']))
            {update_post_meta($post_id, 'el_fi_blog_gridbg_2', sanitize_text_field(wp_unslash($_POST['el_fi_blog_gridbg_2'])));
            }else{delete_post_meta($post_id, 'el_fi_blog_gridbg_2');}
            if (isset($_POST['fancy_blogMetabtn_align']))
            {update_post_meta($post_id, 'fancy_blogMetabtn_align', sanitize_text_field(wp_unslash($_POST['fancy_blogMetabtn_align'])));}else{delete_post_meta($post_id, 'fancy_blogMetabtn_align');}
            if (isset($_POST['fancy_blog_metabtn_bg']))
            {update_post_meta($post_id, 'fancy_blog_metabtn_bg', sanitize_text_field(wp_unslash($_POST['fancy_blog_metabtn_bg'])));}else{delete_post_meta($post_id, 'fancy_blog_metabtn_bg');}
            if (isset($_POST['fancy_blogmetabtn_ac_bg']))
            {update_post_meta($post_id, 'fancy_blogmetabtn_ac_bg', sanitize_text_field(wp_unslash($_POST['fancy_blogmetabtn_ac_bg'])));}else{delete_post_meta($post_id, 'fancy_blogmetabtn_ac_bg');}
            if (isset($_POST['fancy_blog_metabtn_clor']))
            {update_post_meta($post_id, 'fancy_blog_metabtn_clor', sanitize_text_field(wp_unslash($_POST['fancy_blog_metabtn_clor'])));}else{delete_post_meta($post_id, 'fancy_blog_metabtn_clor');}

            if (isset($_POST['slectblog__styledata']))
            {update_post_meta($post_id, 'slectblog__styledata', sanitize_text_field(wp_unslash($_POST['slectblog__styledata'])));}else{delete_post_meta($post_id, 'slectblog__styledata');}
            if (isset($_POST['slect_blog_erp_rw']))
            {update_post_meta($post_id, 'slect_blog_erp_rw', sanitize_text_field(wp_unslash($_POST['slect_blog_erp_rw'])));}else{delete_post_meta($post_id, 'slect_blog_erp_rw');}
            if (isset($_POST['slect_styleanimationblog']))
            {update_post_meta($post_id, 'slect_styleanimationblog', sanitize_text_field(wp_unslash($_POST['slect_styleanimationblog'])));}else{delete_post_meta($post_id, 'slect_styleanimationblog');}

            return $post_id;
        }
    }

}

if (class_exists('FancyProductMetaDataLite'))
{
    new FancyProductMetaDataLite;
};

