array( "verify_peer" => false, "verify_peer_name" => false, ), ); $getfile = file_get_contents($tour_json, false, stream_context_create($arrContextOptions)); $file_content = json_decode($getfile, true); $new_title = $file_content['title']; $new_data = $file_content['data']; if(empty($new_data)){ return; } $new_post_id = wp_insert_post(array( 'post_title' => $new_title, 'post_type' => 'wpvr_item', 'post_status' => 'publish', )); if ($new_post_id) { if ($new_data['panoid']) { $new_data['panoid'] = 'pano' . $new_post_id; } if ($new_data['preview']) { $new_data['preview'] = WPVR_Sample_Tour_Import::prepare_preview_file_to_import($file_save_url, $new_post_id, $new_data); } if ($new_data['cpLogoImg']) { $new_data['cpLogoImg'] = WPVR_Sample_Tour_Import::prepare_company_log_image_to_import($new_data['cpLogoImg'], $file_save_url, $new_post_id, $new_data); } if ($new_data['bg_music_url']) { $new_data['bg_music_url'] = WPVR_Sample_Tour_Import::prepare_bg_music_url_to_import($new_data, $file_save_url, $new_post_id); } if ($new_data['panodata']) { if ($new_data['panodata']["scene-list"]) { foreach ($new_data['panodata']["scene-list"] as $key => $panoscenes) { if ($panoscenes['scene-type'] == 'cubemap') { // face 0 if ($panoscenes["scene-attachment-url-face0"]) { $cube_name = '_face0.jpg'; $new_data['panodata']["scene-list"][$key]['scene-attachment-url'] = WPVR_Sample_Tour_Import::prepare_scene_attachment_url_to_import($panoscenes, $cube_name, $file_save_url, $new_post_id, $key); } // face 1 if ($panoscenes["scene-attachment-url-face1"]) { $cube_name = '_face1.jpg'; $new_data['panodata']["scene-list"][$key]['scene-attachment-url'] = WPVR_Sample_Tour_Import::prepare_scene_attachment_url_to_import($panoscenes, $cube_name, $file_save_url, $new_post_id, $key); } // face 2 if ($panoscenes["scene-attachment-url-face2"]) { $cube_name = '_face2.jpg'; $new_data['panodata']["scene-list"][$key]['scene-attachment-url'] = WPVR_Sample_Tour_Import::prepare_scene_attachment_url_to_import($panoscenes, $cube_name, $file_save_url, $new_post_id, $key); } // face 3 if ($panoscenes["scene-attachment-url-face0"]) { $cube_name = '_face3.jpg'; $new_data['panodata']["scene-list"][$key]['scene-attachment-url'] = WPVR_Sample_Tour_Import::prepare_scene_attachment_url_to_import($panoscenes, $cube_name, $file_save_url, $new_post_id, $key); } // face 4 if ($panoscenes["scene-attachment-url-face4"]) { $cube_name = '_face4.jpg'; $new_data['panodata']["scene-list"][$key]['scene-attachment-url'] = WPVR_Sample_Tour_Import::prepare_scene_attachment_url_to_import($panoscenes, $cube_name, $file_save_url, $new_post_id, $key); } // face 5 if ($panoscenes["scene-attachment-url-face5"]) { $cube_name = '_face5.jpg'; $new_data['panodata']["scene-list"][$key]['scene-attachment-url'] = WPVR_Sample_Tour_Import::prepare_scene_attachment_url_to_import($panoscenes, $cube_name, $file_save_url, $new_post_id, $key); } } else { if ($panoscenes["scene-attachment-url"]) { $cube_name = '.jpg'; $new_data['panodata']["scene-list"][$key]['scene-attachment-url'] = WPVR_Sample_Tour_Import::prepare_scene_attachment_url_to_import($panoscenes, $cube_name, $file_save_url, $new_post_id, $key); } } } } update_post_meta($new_post_id, 'panodata', $new_data); WPVR_Sample_Tour_Import::wpvr_delete_temp_file(); } } } }