<?php
wp_register_style('select2.min.css', WOO2APP_CSS_URL . 'select2.min.css');
wp_enqueue_style('select2.min.css'.WOO2APP_FILES_VER);
$current_url = admin_url().'admin.php?page=woo2app/woo2app_design/woo2app_show_design.php&tab=chideman&sub_page=banner';
if (isset($_POST['woo2app-admin']) && wp_verify_nonce($_POST['woo2app-admin'], 'woo2app-admin')) {
	if($_REQUEST["action1"] && $_REQUEST["action2"] && $_REQUEST["action3"]  && $_REQUEST["pic1"]  && $_REQUEST["pic2"]  && $_REQUEST["pic3"] ) {
		$title = __('3rd Banner - Right', 'woo2app');
		$type     = "";
		$pic      = "";
		$showtype = 6;
		if(isset($_REQUEST["type"])  && $_REQUEST["type"] == 'on'){
			$showtype = 66;
			$title = __('3rd Banner - side by side else', 'woo2app');
		}
		$value1   = "";
		$value2   = "";
		$value3   = "";
		$value4   = "";
		if ( $_REQUEST["action1"] == 1 ) {
			$value1 = ($_REQUEST["product1"]);
		}
		if ( $_REQUEST["action1"] == 2 ) {
			$value1 = ($_REQUEST["cat1"]);
		}
		if ( $_REQUEST["action1"] == 3 ) {
			$value1 = ($_REQUEST["link1"]);
		}
		if ( $_REQUEST["action1"] == 4 ) {
			$value1 = ($_REQUEST["post1"]);
		}
		if ( $_REQUEST["action1"] == 5 ) {
			$value1 = ($_REQUEST["post_cat1"]);
		}
		if ($_REQUEST["action1"] == 8) {
			$value1 = ($_REQUEST["tags1"]);
		}
		if ($_REQUEST["action1"] == 9) {
			$value1 = explode(',', ($_REQUEST["CustomList1"]));
		}
		if ( $_REQUEST["action2"] == 1 ) {
			$value2 = ($_REQUEST["product2"]);
		}
		if ( $_REQUEST["action2"] == 2 ) {
			$value2 = ($_REQUEST["cat2"]);
		}
		if ( $_REQUEST["action2"] == 3 ) {
			$value2 = ($_REQUEST["link2"]);
		}
		if ( $_REQUEST["action2"] == 4 ) {
			$value2 = ($_REQUEST["post2"]);
		}
		if ( $_REQUEST["action2"] == 5 ) {
			$value2 = ($_REQUEST["post_cat2"]);
		}
		if ($_REQUEST["action2"] == 8) {
			$value2 = ($_REQUEST["tags2"]);
		}
		if ($_REQUEST["action2"] == 9) {
			$value2 = explode(',', ($_REQUEST["CustomList2"]));
		}
		if ( $_REQUEST["action3"] == 1 ) {
			$value3 = ($_REQUEST["product3"]);
		}
		if ( $_REQUEST["action3"] == 2 ) {
			$value3 = ($_REQUEST["cat3"]);
		}
		if ( $_REQUEST["action3"] == 3 ) {
			$value3 = ($_REQUEST["link3"]);
		}
		if ( $_REQUEST["action3"] == 4 ) {
			$value3 = ($_REQUEST["post3"]);
		}
		if ( $_REQUEST["action3"] == 5 ) {
			$value3 = ($_REQUEST["post_cat3"]);
		}
		if ($_REQUEST["action3"] == 8) {
			$value3 = ($_REQUEST["tags3"]);
		}
		if ($_REQUEST["action3"] == 9) {
			$value3 = explode(',', ($_REQUEST["CustomList3"]));
		}
		$arr['banner4']             = array();
		$arr['height'] = ($_REQUEST["height"]);
		$arr['banner4'][0]['title'] = ($_REQUEST["title1"]);
		$arr['banner4'][0]['type']  = (isset($_REQUEST["sub_category_1"]) && $_REQUEST["sub_category_1"] == 'on') ? '7' : $_REQUEST["action1"];
		$arr['banner4'][0]['value'] = $value1;
		if(isset($_REQUEST["sub_category_1"]) && $_REQUEST["sub_category_1"] == 'on'){
			$x = get_term_by('slug', $value1, 'product_cat');
			if($x){
				$arr['banner4'][0]['value'] = $x->term_id;
			}
		}
		$arr['banner4'][0]['pic'] = esc_url_raw($_REQUEST["pic1"]);

		$arr['banner4'][1]['title'] = ($_REQUEST["title2"]);
		$arr['banner4'][1]['type']  = (isset($_REQUEST["sub_category_2"]) && $_REQUEST["sub_category_2"] == 'on') ? '7' : $_REQUEST["action2"];
		$arr['banner4'][1]['value'] = $value2;
		if(isset($_REQUEST["sub_category_2"]) && $_REQUEST["sub_category_2"] == 'on'){
			$x = get_term_by('slug', $value2, 'product_cat');
			if($x){
				$arr['banner4'][1]['value'] = $x->term_id;
			}
		}
		$arr['banner4'][1]['pic'] = esc_url_raw($_REQUEST["pic2"]);

		$arr['banner4'][2]['title'] = ($_REQUEST["title3"]);
		$arr['banner4'][2]['type']  = (isset($_REQUEST["sub_category_3"]) && $_REQUEST["sub_category_3"] == 'on') ? '7' : $_REQUEST["action3"];
		$arr['banner4'][2]['value'] = $value3;
		if(isset($_REQUEST["sub_category_3"]) && $_REQUEST["sub_category_3"] == 'on'){
			$x = get_term_by('slug', $value3, 'product_cat');
			if($x){
				$arr['banner4'][2]['value'] = $x->term_id;
			}
		}
		$arr['banner4'][2]['pic'] = esc_url_raw($_REQUEST["pic3"]);
		$value = ( json_encode( $arr ) );
		global $wpdb;
		$table_name = $wpdb->prefix . "woo2app_mainpage";
		$res        = $wpdb->get_results( "select MAX(mp_order) AS max_order from $table_name" );
		if ( ! is_null( $res[0]->max_order ) ) {
			foreach ( $res as $key ) {
				$max = $key->max_order + 1;
			}
		} else {
			$max = 1;
		}
		$r = $wpdb->query( $wpdb->prepare( "INSERT INTO $table_name 
		( mp_title , mp_type , mp_value , mp_showtype , mp_pic , mp_order ,mp_sort) 
		VALUES ( %s, %d, %s, %d, %s, %d, %s )", $title, $type, $value, $showtype, $pic, $max, 100 ) );
		if ( $r ) {
			echo "<p class='green'>" . _e('The banner has been saved. Sort the order.', 'woo2app') . '</p>';
		}
	}
}
$args = array(
	'hide_empty' => 0 ,
	'taxonomy' => 'product_cat'
);
$cats = get_categories($args);
$args = array(
	'hide_empty' => 0 ,
	'taxonomy' => 'category'
);
$post_cats = get_categories($args);
?>
<form action="" method="post">
	<?php wp_nonce_field('woo2app-admin', 'woo2app-admin'); ?>
    <table class="form-table <?= get_locale() == 'fa_IR' ? 'float-right' : 'float-left' ?>">
        <tbody>
        <tr>
            <th> Preview </th>
            <td >
                <div id="div_type1" style="width: 300px" >
                    <div class="img-banner3-right" >
                        <img id="p_banner2" class="p_banner2 banner3-right float-right"
                             src="<?= WOO2APP_URL . "files/img/512x512&text=1x1.png" ?>">
                        <img id="p_banner3" class="p_banner3 banner3-right-b float-right"
                             src="<?= WOO2APP_URL . "files/img/512x512&text=1x1.png" ?>">
                    </div>
                    <div class="img-banner3-right">
                        <img id="p_banner1" class="p_banner1 banner3-right-r float-right"
                             src="<?= WOO2APP_URL . "files/img/512x1024&text=1x2.png" ?>">
                    </div>
                </div>
                <div id="div_type2" class="hide">
                    <div class="" >
                        <br>
                        <br>
                        <img id="p_banner2" class="p_banner2 banner3-right float-right"
                             src="<?= WOO2APP_URL . "files/img/512x512&text=1x1.png" ?>">
                        <img id="p_banner3" class="p_banner3 banner3-right float-right"
                             src="<?= WOO2APP_URL . "files/img/512x512&text=1x1.png" ?>">
                        <img id="p_banner1" class="p_banner1 banner3-right float-right"
                             src="<?= WOO2APP_URL . "files/img/512x512&text=1x1.png" ?>">
                    </div>
                </div>
            </td>
        </tr>
        <tr valign="top" class="">
            <th scope="row">
                <label> <?php _e('Type', 'woo2app'); ?> </label>
            </th>
            <td class="forminp">
                <input type="checkbox" id="chk_type" class="regular-text" name="type" >
	            <?php _e('Show image, side by side ', 'woo2app'); ?>
            </td>
        </tr>
        <tr valign="top" class="">
            <th scope="row" class="titledesc">
                <label> <?php _e('Height', 'woo2app'); ?> </label>
            </th>
            <td class="forminp">
                <input type="text" class="regular-text" name="height" value=""
                       placeholder="<?php _e('Height(%)', 'woo2app'); ?>">
                <p>
		            <?php _e('Image Height (Percentage of display)', 'woo2app'); ?>
                </p>
            </td>
        </tr>
        <tr valign="top" class="">
            <th scope="row" class="titledesc">
                <label> <?php _e('Title', 'woo2app'); ?> </label>
            </th>
            <td class="forminp">
                <input type="text" class="regular-text" name="title1" value=""
                       placeholder="<?php _e('Title', 'woo2app'); ?>">
            </td>
        </tr>
        <tr valign="top" class="">
            <th scope="row" class="titledesc">
                <label> <?php _e('Action', 'woo2app'); ?>  </label>
            </th>
            <td class="forminp">
                <select class="regular-text action" id="action1" name="action1" required="required">
                    <option value=""><?php _e('Please Select ...', 'woo2app'); ?></option>
                    <option value="1"><?php _e('Product', 'woo2app'); ?></option>
                    <option value="2"> <?php _e('Product Category ', 'woo2app'); ?></option>
                    <option value="8"><?php _e('Product Tag', 'woo2app'); ?> </option>
                    <option value="3"><?php _e('Link', 'woo2app'); ?></option>
                    <option value="4"><?php _e('Post', 'woo2app'); ?></option>
                    <option value="5">  <?php _e('Post Categories', 'woo2app'); ?></option>
                    <option value="9"> <?php _e('Custom List', 'woo2app'); ?></option>
                    <option value="6"> <?php _e('No Action', 'woo2app'); ?> </option>
                </select>
            </td>
        </tr>
        <tr valign="top" class="el_type_action1 display-none" id="action1_product">
            <th scope="row" class="titledesc">
                <label> <?php _e('Product', 'woo2app'); ?> </label>
            </th>
            <td class="forminp">
                <select name="product1" data-id="product"    class="js-data-example-ajax regular-text">

                </select>
            </td>
        </tr>
        <tr valign="top" class="el_type_action1 display-none" id="action1_CustomList">
            <th scope="row" class="titledesc">
                <label> <?php _e('Custom list', 'woo2app'); ?> </label>
            </th>
            <td class="forminp">
                <select name="CustomList1" id="value_custom_list" class="regular-text"
                        data-live-search="true" title="<?php _e('Please Select ...', 'woo2app'); ?>">
					<?php
					$results =  get_option('mr2app_custom_product_list');
					foreach ($results as $key) {
						?>
                        <option value='<?= implode(',',$key['list_product'])?>'> <?= $key['title'];?></option>
						<?php
					}
					?>
                </select>
                <div class="clear"></div>
                <p>
                    <a href="<?= $current_url . '&sub_page=product_list'?>" class="thickbox">
						<?php _e('Create Custom List', 'woo2app'); ?>
                    </a>
                </p>
            </td>
        </tr>
        <tr valign="top" class="el_type_action1 display-none" id="action1_cat">
            <th scope="row" class="titledesc">
                <label><?php _e('Product Category', 'woo2app'); ?> </label>
            </th>
            <td class="forminp">
                <select class="regular-text" name="cat1" id="">
					<?php
					foreach ($cats as $cat) {
						?>
                        <option value="<?= $cat->slug; ?>"><?= $cat->name; ?></option>
						<?php
					}
					?>
                </select>
                <input type="checkbox" name="sub_category_1"/>
                <small><?php _e('Open Sub Category', 'woo2app'); ?></small>
            </td>
        </tr>
        <tr valign="top" class="el_type_action1 display-none" id="action1_link">
            <th scope="row" class="titledesc">
                <label> <?php _e('Link', 'woo2app'); ?> </label>
            </th>
            <td class="forminp">
                <input type="text" class="regular-text" name="link1" id="" value=""
                       placeholder="<?php _e('Link (example : https://my-site.com)', 'woo2app'); ?>">
            </td>
        </tr>
        <tr valign="top" class="el_type_action1 display-none" id="action1_post">
            <th scope="row" class="titledesc">
                <label> <?php _e('Post', 'woo2app'); ?> </label>
            </th>
            <td class="forminp">
                <select name="post1"  id="value_post_notif"  class="regular-text js-data-example-ajax"></select>
            </td>
        </tr>
        <tr valign="top" class="el_type_action1 display-none" id="action1_tags">
            <th scope="row" class="titledesc">
                <label> <?php _e('Product Tag', 'woo2app'); ?> </label>
            </th>
            <td class="forminp">
                <select name="tags1" data-id="tags"   class="js-data-example-ajax regular-text">

                </select>
            </td>
        </tr>
        <tr valign="top" class="el_type_action1 display-none" id="action1_post_cats">
            <th scope="row" class="titledesc">
                <label> <?php _e('Post Category', 'woo2app'); ?></label>
            </th>
            <td class="forminp">
                <select class="regular-text" name="post_cat1" id="post_cat">
					<?php
					foreach ($post_cats as $cat) {
						?>
                        <option value="<?= $cat->term_id; ?>"><?= $cat->name; ?></option>
						<?php
					}
					?>
                </select>
            </td>
        </tr>
        <tr class="border-bottom-1px-solid-ccc">
            <th scope="row" class="titledesc">
                <label><?php _e('Select Image', 'woo2app'); ?></label>
            </th>
            <td class="forminp">
                <input type="hidden" id="banner1_val" name="pic1">
                <img id="banner1" class="banner banner3-right-r"
                     src="<?= WOO2APP_URL . "files/img/512x1024&text=1x2.png" ?>" />
                <p>
                <hr>
	            <?php _e('Best scale', 'woo2app'); ?> : 1x2
                <hr>
	            <?php _e('Recommended Resolution', 'woo2app'); ?> : 512x1024
                <hr>
	            <?php _e('Max Size', 'woo2app'); ?> : 150KB
                <hr>
	            <?php _e('Format', 'woo2app'); ?> : PNG - JPG - JPEG - GIF
                </p>
            </td>
        </tr>
        <tr valign="top" class="">
            <th scope="row" class="titledesc">
                <label> <?php _e('Title', 'woo2app'); ?> </label>
            </th>
            <td class="forminp">
                <input type="text" class="regular-text" name="title2" value=""
                       placeholder="<?php _e('Title', 'woo2app'); ?>">
            </td>
        </tr>
        <tr valign="top" class="">
            <th scope="row" class="titledesc">
                <label> <?php _e('Action', 'woo2app'); ?>  </label>
            </th>
            <td class="forminp">
                <select class="regular-text action" id="action2" name="action2" required="required">
                    <option value=""><?php _e('Please Select ...', 'woo2app'); ?></option>
                    <option value="1"><?php _e('Product', 'woo2app'); ?></option>
                    <option value="2"> <?php _e('Product Category ', 'woo2app'); ?></option>
                    <option value="8"><?php _e('Product Tag', 'woo2app'); ?> </option>
                    <option value="3"><?php _e('Link', 'woo2app'); ?></option>
                    <option value="4"><?php _e('Post', 'woo2app'); ?></option>
                    <option value="5">  <?php _e('Post Categories', 'woo2app'); ?></option>
                    <option value="9"> <?php _e('Custom List', 'woo2app'); ?></option>
                    <option value="6"> <?php _e('No Action', 'woo2app'); ?> </option>
                </select>
            </td>
        </tr>
        <tr valign="top" class="el_type_action2 display-none" id="action2_product">
            <th scope="row" class="titledesc">
                <label> <?php _e('Product', 'woo2app'); ?> </label>
            </th>
            <td class="forminp">
                <select name="product2" data-id="product"    class="js-data-example-ajax regular-text">

                </select>
            </td>
        </tr>
        <tr valign="top" class="el_type_action2 display-none" id="action2_CustomList">
            <th scope="row" class="titledesc">
                <label> <?php _e('Custom List', 'woo2app'); ?> </label>
            </th>
            <td class="forminp">
                <select name="CustomList2" id="value_custom_list" class="regular-text"
                        data-live-search="true" title="<?php _e('Select ...', 'woo2app'); ?>">
					<?php
					$results =  get_option('mr2app_custom_product_list');
					foreach ($results as $key) {
						?>
                        <option value='<?= implode(',',$key['list_product'])?>' > <?= $key['title'];?></option>
						<?php
					}
					?>
                </select>
                <div class="clear"></div>
                <p>
                    <a href="<?= $current_url . '&sub_page=product_list'?>" class="thickbox">
						<?php _e('Create Custom List', 'woo2app'); ?>
                    </a>
                </p>
            </td>
        </tr>
        <tr valign="top" class="el_type_action2 display-none" id="action2_cat">
            <th scope="row" class="titledesc">
                <label> <?php _e('Category', 'woo2app'); ?> </label>
            </th>
            <td class="forminp">
                <select class="regular-text" name="cat2" id="">
					<?php
					foreach ($cats as $cat) {
						?>
                        <option value="<?= $cat->slug; ?>"><?= $cat->name; ?></option>
						<?php
					}
					?>
                </select>
                <input type="checkbox" name="sub_category_2"/>
                <small><?php _e('Open Sub Category', 'woo2app'); ?></small>
            </td>
        </tr>
        <tr valign="top" class="el_type_action2 display-none" id="action2_link">
            <th scope="row" class="titledesc">
                <label><?php _e('Link', 'woo2app'); ?> </label>
            </th>
            <td class="forminp">
                <input type="text" class="regular-text" name="link2" id="" value=""
                       placeholder="<?php _e('Link (example : https://my-site.com)', 'woo2app'); ?>">
            </td>
        </tr>
        <tr valign="top" class="el_type_action2 display-none" id="action2_tags">
            <th scope="row" class="titledesc">
                <label><?php _e('Product Tag', 'woo2app'); ?> </label>
            </th>
            <td class="forminp">
                <select name="tags2" data-id="tags"    class="js-data-example-ajax regular-text">

                </select>
            </td>
        </tr>
        <tr valign="top" class="el_type_action2 display-none" id="action2_post">
            <th scope="row" class="titledesc">
                <label> <?php _e('Post', 'woo2app'); ?></label>
            </th>
            <td class="forminp">
                <select name="post2"  id="value_post_notif1"   class="regular-text js-data-example-ajax"></select>
            </td>
        </tr>
        <tr valign="top" class="el_type_action2 display-none" id="action2_post_cats">
            <th scope="row" class="titledesc">
                <label><?php _e('Post Category', 'woo2app'); ?></label>
            </th>
            <td class="forminp">
                <select class="regular-text" name="post_cat2" id="post_cat">
					<?php
					foreach ($post_cats as $cat) {
						?>
                        <option value="<?= $cat->term_id; ?>"><?= $cat->name; ?></option>
						<?php
					}
					?>
                </select>
            </td>
        </tr>
        <tr class="border-bottom-1px-solid-ccc">
            <th scope="row" class="titledesc">
                <label><?php _e('Select Image', 'woo2app'); ?></label>
            </th>
            <td class="forminp">
                <input type="hidden" id="banner2_val" name="pic2">
                <img id="banner2" class="banner banner3-right-b"
                     src="<?= WOO2APP_URL . "files/img/512x512&text=1x1.png" ?>">
                <p>
                <hr>
	            <?php _e('Best scale', 'woo2app'); ?> : 1x1
                <hr>
	            <?php _e('Recommended Resolution', 'woo2app'); ?> : 512x512
                <hr>
	            <?php _e('Max Size', 'woo2app'); ?> : 100KB
                <hr>
	            <?php _e('Format', 'woo2app'); ?> : PNG - JPG - JPEG - GIF
                </p>
            </td>
        </tr>
        <tr valign="top" class="">
            <th scope="row" class="titledesc">
                <label> <?php _e('Title', 'woo2app'); ?> </label>
            </th>
            <td class="forminp">
                <input type="text" class="regular-text" name="title3" value=""
                       placeholder="<?php _e('Title', 'woo2app'); ?>">
            </td>
        </tr>
        <tr valign="top" class="">
            <th scope="row" class="titledesc">
                <label> <?php _e('Action', 'woo2app'); ?>  </label>
            </th>
            <td class="forminp">
                <select class="regular-text action" id="action3" name="action3" required="required">
                    <option value=""><?php _e('Please Select ...', 'woo2app'); ?></option>
                    <option value="1"><?php _e('Product', 'woo2app'); ?></option>
                    <option value="2"> <?php _e('Product Category ', 'woo2app'); ?></option>
                    <option value="8"><?php _e('Product Tag', 'woo2app'); ?> </option>
                    <option value="3"><?php _e('Link', 'woo2app'); ?></option>
                    <option value="4"><?php _e('Post', 'woo2app'); ?></option>
                    <option value="5">  <?php _e('Post Categories', 'woo2app'); ?></option>
                    <option value="9"> <?php _e('Custom List', 'woo2app'); ?></option>
                    <option value="6"> <?php _e('No Action', 'woo2app'); ?> </option>
                </select>
            </td>
        </tr>
        <tr valign="top" class="el_type_action3 display-none" id="action3_product">
            <th scope="row" class="titledesc">
                <label> <?php _e('Product', 'woo2app'); ?></label>
            </th>
            <td class="forminp">
                <select name="product3" data-id="product"   class="js-data-example-ajax regular-text">

                </select>
            </td>
        </tr>
        <tr valign="top" class="el_type_action3 display-none" id="action3_CustomList">
            <th scope="row" class="titledesc">
                <label> <?php _e('Custom List', 'woo2app'); ?></label>
            </th>
            <td class="forminp">
                <select name="CustomList3" id="value_custom_list" class="regular-text"
                        data-live-search="true" title="<?php _e('Please Select ...', 'woo2app'); ?>">
					<?php
					$results =  get_option('mr2app_custom_product_list');
					foreach ($results as $key) {
						?>
                        <option value='<?= implode(',',$key['list_product'])?>'> <?= $key['title'];?></option>
						<?php
					}
					?>
                </select>
                <div class="clear"></div>
                <p>
                    <a href="<?= $current_url . '&sub_page=product_list'?>" class="thickbox">
						<?php _e('Create Custom List', 'woo2app'); ?>
                    </a>
                </p>
            </td>
        </tr>
        <tr valign="top" class="el_type_action3 display-none" id="action3_cat">
            <th scope="row" class="titledesc">
                <label> <?php _e('Product Category', 'woo2app'); ?> </label>
            </th>
            <td class="forminp">
                <select class="regular-text" name="cat3" id="">
					<?php
					foreach ($cats as $cat) {
						?>
                        <option value="<?= $cat->slug; ?>"><?= $cat->name; ?></option>
						<?php
					}
					?>
                </select>
                <input type="checkbox"  name="sub_category_3"/>
                <small><?php _e('Open Sub Category', 'woo2app'); ?></small>
            </td>
        </tr>
        <tr valign="top" class="el_type_action3 display-none" id="action3_tags">
            <th scope="row" class="titledesc">
                <label> <?php _e('Product Tag', 'woo2app'); ?> </label>
            </th>
            <td class="forminp">
                <select name="tags3" data-id="tags"   class="js-data-example-ajax regular-text">

                </select>
            </td>
        </tr>
        <tr valign="top" class="el_type_action3 display-none" id="action3_link">
            <th scope="row" class="titledesc">
                <label> <?php _e('Link', 'woo2app'); ?> </label>
            </th>
            <td class="forminp">
                <input type="text" class="regular-text" name="link3" id="" value=""
                       placeholder="<?php _e('Link (example : https://my-site.com)', 'woo2app'); ?>">
            </td>
        </tr>
        <tr valign="top" class="el_type_action3 display-none" id="action3_post">
            <th scope="row" class="titledesc">
                <label> <?php _e('Post', 'woo2app'); ?> </label>
            </th>
            <td class="forminp">
                <select name="post3"  id="value_post_notif3"  class="regular-text js-data-example-ajax"></select>
            </td>
        </tr>
        <tr valign="top" class="el_type_action3 display-none" id="action3_post_cats">
            <th scope="row" class="titledesc">
                <label> <?php _e('Post Category', 'woo2app'); ?> </label>
            </th>
            <td class="forminp">
                <select class="regular-text" name="post_cat3" id="post_cat">
					<?php
					foreach ($post_cats as $cat) {
						?>
                        <option value="<?= $cat->term_id; ?>"><?= $cat->name; ?></option>
						<?php
					}
					?>
                </select>
            </td>
        </tr>
        <tr class="border-bottom-1px-solid-ccc">
            <th scope="row" class="titledesc">
                <label><?php _e('Select Image', 'woo2app'); ?></label>
            </th>
            <td class="forminp">
                <input type="hidden" id="banner3_val" name="pic3">
                <img id="banner3" class="banner banner3-right-b"
                     src="<?= WOO2APP_URL . "files/img/512x512&text=1x1.png" ?>">
                <p>
                <hr>
	            <?php _e('Best scale', 'woo2app'); ?> : 1X1
                <hr>
	            <?php _e('Recommended Resolution', 'woo2app'); ?> : 512x512
                <hr>
	            <?php _e('Max Size', 'woo2app'); ?> : 100KB
                <hr>
	            <?php _e('Format', 'woo2app'); ?> : PNG - JPG - JPEG - GIF
                </p>
            </td>
        </tr>
        <tr >
            <th scope="row" class="titledesc">
            </th>
            <td class="forminp">
                <input type="submit" class="button button-primary" value="<?php _e('+ Add To Page', 'woo2app'); ?>"
                       name="submit_banner">
            </td>
        </tbody>
    </table>
</form>
<?php
wp_enqueue_media();
wp_enqueue_script( 'loadajax.js'.WOO2APP_FILES_VER , WOO2APP_JS_URL.'loadAjaxPosts.js', array('jquery'));
wp_enqueue_script('select2.min.js'.WOO2APP_FILES_VER, WOO2APP_JS_URL . 'select2.min.js');
?>
<script>
    jQuery('#chk_type').change(function () {
        if(this.checked){
            jQuery("#div_type1").addClass('hide')
            jQuery("#div_type2").removeClass('hide')
            jQuery("#banner1").attr('src' , '<?= WOO2APP_URL . "files/img/512x512&text=1x1.png" ?>')
            jQuery("#banner1").removeClass('banner3-right-r')
            jQuery("#banner1").addClass('banner3-right')
        }
        else{
            jQuery("#div_type1").removeClass('hide')
            jQuery("#div_type2").addClass('hide');
            jQuery("#banner1").attr('src' , '<?= WOO2APP_URL . "files/img/512x1024&text=1x2.png" ?>');
            jQuery("#banner1").addClass('banner3-right-r')
            jQuery("#banner1").removeClass('banner3-right')
        }
    });
    jQuery('.action').on('change', function() {
        var type_val = (jQuery(this).val());
        var action = (jQuery(this).attr('id'))
        jQuery('.el_type_' + action).css('display','none');
        if(type_val == 1){
            jQuery('#'+ action +'_product').css('display','table-row');
        }
        else if(type_val == 2){
            jQuery('#'+ action +'_cat').css('display','table-row');
        }
        else if(type_val == 3){
            jQuery('#'+ action +'_link').css('display','table-row');
        }
        else if(type_val == 4){
            jQuery('#'+ action +'_post').css('display','table-row');
        }
        else if(type_val == 5){
            jQuery('#'+ action +'_post_cats').css('display','table-row');
        }
        else if(type_val == 8){
            jQuery('#'+ action +'_tags').css('display','table-row');
        }
        else if(type_val == 9){
            jQuery('#'+ action + '_CustomList').css('display','table-row');
        }
    });
    var custom_uploader_hami;
    jQuery('.banner').click(function (e) {
        var b_id = jQuery(this).attr('id');
        e.preventDefault();
        custom_uploader_hami = wp.media.frames.custom_uploader_hami = wp.media({
            title: '<?php _e('Select Image', 'woo2app'); ?>',
            library: {type: 'image'},
            button: {text: '<?php _e('Select', 'woo2app'); ?>'},
            multiple: false
        });
        custom_uploader_hami.on('select', function() {
            attachment = custom_uploader_hami.state().get('selection').first().toJSON();
            jQuery('#' + b_id + '_val').val(attachment.url);
            url_image = attachment.url;
            jQuery('#' + b_id ).attr("src",url_image);
            jQuery('.p_' + b_id ).attr("src",url_image);
        });
        custom_uploader_hami.open();
    })
    jQuery('.search_product_banner').keyup(function(){
        var id = jQuery(this).attr('data-id');
        //alert(id);
        var  v = jQuery(this).val();
        if(v.length >= 3){
            jQuery("#img_load"+id).attr("style",'display:block');
            jQuery.ajax({
                url: ajaxurl,
                data: {
                    action: "load_all_product",
                    search_product : v
                },
                success:function(data) {
                    jQuery("#img_load"+id).attr("style",'display:none');
                    jQuery("#value_post_items_menu"+id).html(data);
                }
            });
        }
    });
</script>