ID, 'ar_woo_product_Detail', true); $count1 = count($get_model_Details); $html1 = ''; if ($count1 > 0 && is_array($get_model_Details)) { $nonce = encryptIt(preg_replace("(^https?://)", "", site_url())); $html1 .= '
'; $html1 .= '
[arwordpress id=' . $_GET['post'] . ']
     '; $html1 .= '
[URL to AR Display App]
'; $html1 .= '
webandprintdesign.arforwordpress://?api-name=' . site_url() . '/?single_product=productList&product_id=' . $_GET['post'] . '&nonce=' . $nonce . '
'; $html1 .= '
'; //echo "
";print_r($get_model_Details);   exit;      
        echo '';
        $c = 1;
        foreach ($get_model_Details as $setDetail) {
            // echo "
";print_r($setDetail);            

            $html1 .= '
'; $scaleDisable = ''; /* Selection of 2d or 3d */ $selected2d = ""; $selected2dWrapper = "display:none;"; if ($setDetail["model_type"] == "2d") { $selected2d = "checked"; $selected2dWrapper = ""; $scaleDisable = 'display:none;'; } $selected3d = ""; $selected3dWrapper = "display:none;"; if ($setDetail["model_type"] == "3d") { $selected3d = "checked"; $selected3dWrapper = ""; $scaleDisable = ''; } $html1 .= '
3D Model 2D Model
'; /* Ends */ $html1 .= ''; $html1 .= '
'; $html1 .= ''; $html1 .= '
'; if ($setDetail['dae'] != '') { $html1 .= ' '; } $html1 .= '
'; $html1 .= ''; $html1 .= ''; $html1 .= '
'; $html1 .= '
'; $html1 .= '
'; $html1 .= '
'; // Changed 18 Dec 2017 $html1 .= '
'; $html1 .= '
'; //echo count($setDetail['default_texture']); $html1 .= '
'; $html1 .= '
'; $html1 .= '
'; if (!empty($setDetail['default_texture'])) { $get_texture_images = array(); $texture_remove_id = 1; foreach ($setDetail['default_texture'] as $get_multi_images) { $html1 .= '
    '; $html1 .= '
  • '; $get_texture_images[] = $get_multi_images; $html1 .= '
'; $texture_remove_id++; //echo $get_multi_images; } $string_texture = implode(',', $get_texture_images); } $html1 .= '
'; //**********2D Photo********** /* Model Type */ $photo_width = $setDetail["2dphoto_width"]; $photo_height = $setDetail["2dphoto_height"]; $photo_depth = $setDetail["2dphoto_depth"]; $photo_format = $setDetail["2dphoto_format"]; $selectedjpgformat = ""; if ($photo_format == "jpg") { $selectedjpgformat = "selected"; } $selectedpngformat = ""; if ($photo_format == "png") { $selectedpngformat = "selected"; } /* Ends */ $daeFileExist = 'display:none'; if ($setDetail['dae'] != "") { $daeFileExist = ''; } $html1 .= '
'; $html1 .= '
'; $html1 .= 'Width (m) '; $html1 .= 'Height (m) '; $html1 .= 'Depth (m) '; $html1 .= 'Texture Format '; $html1 .= 'Create 3D Box'; $html1 .= '
'; $html1 .= ''; $html1 .= '
'; $html1 .= ''; $html1 .= '
'; //**********End 2D Photo********** $html1 .= ' '; $color_texture = sizeof($setDetail['wp_ar_multi']); if ($color_texture > 0) { $display = "display"; } else { $display = "nodisplay"; } $html1 .= '
'; // $html1 .= ' '; $html1 .= ''; $j = 1; $color_texture = sizeof($setDetail['wp_ar_multi']); $html1 .= ''; foreach ($setDetail['wp_ar_multi'] as $option) { $html1 .= ' '; // $html1 .= ' '; $html1 .= ' '; $j++; } $html1 .= ' '; $html1 .= ' '; $html1 .= '
Color Texture(s)
' . $j . '
'; $get_images = array(); $remove_id = 1; foreach ($option['bg'] as $get_multi_images) { if (!empty($get_multi_images)) { $html1 .= '
    '; $html1 .= '
  • '; $get_images[] = $get_multi_images; $html1 .= '
'; $remove_id++; } } $string_version = implode(',', $get_images); $html1 .= '
'; $html1 .= '
'; $html1 .= 'Remove Model'; $html1 .= 'Add New Color'; $html1 .= '
'; $html1 .= '
'; $html1 .= '
'; $c++; } } $html1 .= '
'; echo $html1; $add_model = ''; echo $add_model; } add_action('save_post', 'save_ar_woo_custom_meta_data'); // Saving the uploaded file details function save_ar_woo_custom_meta_data($id) { /* --- security verification --- */ //check for nonce if (!isset($_POST['ar_location_nonce_field'])) { return $id; } //verify nonce if (!wp_verify_nonce($_POST['ar_location_nonce_field'], 'ar_location_nonce')) { return $id; } if (isset($_POST['post_type'])) if ('page' == $_POST['post_type']) { if (!current_user_can('edit_page', $id)) { return $id; } // end if } else { if (!current_user_can('edit_page', $id)) { return $id; } // end if } // end if /* - end security verification - */ $getuploadData = $_POST['wp_ar_custom']; $dataget = array(); $i = 1; //echo '
'; print_r( $_POST['wp_ar_custom'] ); die();

    if (isset($_POST['wp_ar_custom']) != '') {
        foreach ($getuploadData as $data) {
            //echo "
";print_r($_FILES);exit;

            /* Model Type */
            $model_type = $data["model_type"];
            $photo_width = isset($data["2dphoto_width"]) ? $data["2dphoto_width"] : "";
            $photo_height = isset($data["2dphoto_height"]) ? $data["2dphoto_height"] : "";
            $photo_depth = isset($data["2dphoto_depth"]) ? $data["2dphoto_depth"] : "";
            $photo_format = isset($data["2dphoto_format"]) ? $data["2dphoto_format"] : "";

            $data["model_type"] = $model_type;
            $data["2dphoto_width"] = $photo_width;
            $data["2dphoto_height"] = $photo_height;
            $data["2dphoto_depth"] = $photo_depth;
            $data["2dphoto_format"] = $photo_format;
            /* Ends */


            if (!empty($_FILES['wp_ar_dae' . $i . '_custom_attachment']['name'])) {
                $upload_DAE_get = ar_woo_getReadImage($data['dae']); // get converted image file
                $upload_DAE = sanitize_text_field($upload_DAE_get);
            } else {
                $upload_DAE_get = ar_woo_getReadImage($data['dae']); // get converted image file
                $upload_DAE = sanitize_text_field($upload_DAE_get);
            }
            $data['dae'] = $upload_DAE; // Dae File Upload
            //echo "
";print_r($_FILES['default_texture'.$i]['name']);exit;
            $default_texture = array();
            foreach ($_FILES['default_texture' . $i]['name'] as $texture => $value) {
                $get_remove_images = explode(',', sanitize_text_field($_POST['remove_images' . $i]));
                if (!in_array($_FILES['default_texture' . $i]['name'][$texture], $get_remove_images)) {

                    if ($_FILES['default_texture' . $i]['name'][$texture] != '') {
                        $imagename = $_FILES['default_texture' . $i]['name'][$texture];
                        $ext = pathinfo($imagename, PATHINFO_EXTENSION);
                        $random = $id . '_' . $i . '_' . $imagename;

                        $upload_dir = wp_upload_dir();
                        unlink($upload_dir['path'] . '/' . $random); // unlink image with same name

                        $image_change_name = $random;
                        $upload_texture_get = wp_upload_bits($image_change_name, null, file_get_contents($_FILES['default_texture' . $i]['tmp_name'][$texture]));
                        $default_texture[] = $upload_texture_get['url'];
                    }
                }
            }

            if (!empty($_POST['default_texture' . $i] && $_FILES['default_texture' . $i]['name'])) {
                $string_version = explode(',', sanitize_text_field($_POST['default_texture' . $i]));
                $default_texture = array_merge($default_texture, $string_version);
            }
            //echo "
";print_r($default_texture);exit;
            $data['default_texture'] = $default_texture;  // Multiple Default Texture File Upload


            $multi_option = $_POST['wp_ar_multi' . $i]; /*             * ******** Get Bunch of Color & Texture image ********* */
            $getoption = array();
            //echo "
";print_r($_FILES['wp_ar_multi'.$i]['name']);exit;
            foreach ($multi_option as $key => $option) {
                //echo "
";print_r($_FILES['wp_ar_multi'.$i]['name'][$key]);			
                $get_upload_multi_bg = array();
                foreach ($_FILES['wp_ar_multi' . $i]['name'][$key] as $img => $value) {

                    if (!empty($_FILES['wp_ar_multi' . $i]['name'][$key][$img])) {

                        $get_remove_texture = explode(',', sanitize_text_field($_POST['remove_images_texture' . $i . '_' . $key]));

                        if (!in_array($_FILES['wp_ar_multi' . $i]['name'][$key][$img], $get_remove_texture)) {

                            $imagename = $_FILES['wp_ar_multi' . $i]['name'][$key][$img];
                            $ext = pathinfo($imagename, PATHINFO_EXTENSION);
                            $random = $id . '_' . $i . '_' . $imagename;

                            $upload_dir = wp_upload_dir();
                            unlink($upload_dir['path'] . '/' . $random); // unlink image with same name

                            $image_change_name = $random;
                            $upload_bg_get = wp_upload_bits($image_change_name, null, file_get_contents($_FILES['wp_ar_multi' . $i]['tmp_name'][$key][$img]));
                            $get_upload_multi_bg[] = $upload_bg_get['url'];
                        }
                    } else {
                        $get_the_value = $string_version = explode(',', sanitize_text_field($option['bg']));
                        $get_upload_multi_bg = $get_the_value;
                    }
                }
                if (!empty($option['bg'] && $_FILES['wp_ar_multi' . $i]['name'][$key][$img])) {
                    $string_version = explode(',', sanitize_text_field($option['bg']));
                    $get_upload_multi_bg = array_merge($get_upload_multi_bg, $string_version);
                }

                $option['bg'] = $get_upload_multi_bg; // Multiple Texture File Upload
                $getoption[] = $option;
            }
            $data['wp_ar_multi'] = $getoption;
            $dataget[] = $data;
            $i++;
        }

        // echo "
";print_r($dataget);exit;
        update_post_meta($id, 'ar_woo_product_Detail', $dataget);
    }
}

/* * ******** CUrl unlink Convert Image from servar ************* */

function ar_woo_unlink($link, $name) {
    $data = array(
        'method' => 'POST',
        'body' => array(
            'image_name' => $name,
    ));
    $response = wp_remote_post($link, $data);
}

/* * *********** End ******************** */

function ar_woo_getReadImage($link) {
    $upload_dir = wp_upload_dir();
    $imagepath = $link;
    $image_name = basename($imagepath);

    $imageString = file_get_contents($imagepath);
    $getextension = getimagesize($imagepath);
    $extension = image_type_to_extension($getextension[2]);
    file_put_contents($upload_dir['path'] . '/' . $image_name, $imageString);
    ar_woo_unlink("http://199.229.252.211:8080/upload/image_unlink.php", $image_name);
    return $upload_dir['url'] . '/' . $image_name;
}

/******** Arformobile Description *********/
function ar_wp_add_custom_meta_box() {
    
        add_meta_box(
        'app_description',              // $id
        'Product Description Mobile',   // $title
        'show_custom_meta_box',         // $callback
        'product',                      // $page
        'normal',                       // $context
        'high'                          // $priority
        );
    
}
add_action( 'add_meta_boxes', 'ar_wp_add_custom_meta_box' );

function show_custom_meta_box( $post ) 
{
    wp_nonce_field( 'app_description', 'ar_wp_add_custome_our_nonce' );

    $value = get_post_meta( $post->ID, 'app_description', true );
    // echo ' ';
    // echo '';    
    ?>