_x( 'Virtual Tours', 'Post Type General Name', 'cf' ), 'singular_name' => _x( 'Virtual Tour', 'Post Type Singular Name', 'cf' ), 'menu_name' => __( 'Virtual Tours', 'cf' ), 'name_admin_bar' => __( 'Virtual Tours', 'cf' ), 'archives' => __( 'Item Archives', 'cf' ), 'parent_item_colon' => __( 'Parent Item:', 'cf' ), 'all_items' => __( 'Manage Virtual Tours', 'cf' ), 'add_new_item' => __( 'Add New VT', 'cf' ), 'add_new' => __( 'Add Virtual Tour', 'cf' ), 'new_item' => __( 'New VT', 'cf' ), 'edit_item' => __( 'Edit VT', 'cf' ), 'update_item' => __( 'Update VT', 'cf' ), 'view_item' => __( 'View VT', 'cf' ), 'search_items' => __( 'Search Virtual Tours', 'cf' ), 'not_found' => __( 'Not found', 'cf' ), 'not_found_in_trash' => __( 'Not found in Trash', 'cf' ), 'featured_image' => __( 'Featured Image', 'cf' ), 'set_featured_image' => __( 'Set featured image', 'cf' ), 'remove_featured_image' => __( 'Remove featured image', 'cf' ), 'use_featured_image' => __( 'Use as featured image', 'cf' ), 'insert_into_item' => __( 'Insert into item', 'cf' ), 'uploaded_to_this_item' => __( 'Uploaded to this item', 'cf' ), 'items_list' => __( 'Items list', 'cf' ), 'items_list_navigation' => __( 'Items list navigation', 'cf' ), 'filter_items_list' => __( 'Filter items list', 'cf' ), ); $args = array( 'label' => __( 'Virtual Tour', 'cf' ), 'description' => __( 'Virtual Tours', 'cf' ), 'labels' => $labels, 'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields', ), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_icon' => ABR_PLUGIN_DIR_URL.'img/vr.png', 'show_in_admin_bar' => true, 'show_in_nav_menus' => true, 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => true, 'publicly_queryable' => true, 'capability_type' => 'post', ); register_post_type( 'virtualtour', $args ); } public static function virtual_tours_add_meta_box() { add_meta_box('virtual_tours-virtual-tours',__('Virtual Tours','virtual_tours'),array($this,'abr_virtual_tours_html'),'virtualtour','normal','default'); } public static function abr_get_image_id($image_url) { global $wpdb; $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid='%s';", $image_url)); if(isset($attachment[0])){ return $attachment[0]; } } public static function ar_virtual_tour_unzip_ajax(){ if(isset($_REQUEST)){ WP_Filesystem(); $zipurl = $_REQUEST['zipurl']; $zipbasename = basename($zipurl); $zipID = AR_Virtual_Tours::abr_get_image_id($zipurl); $zipLoc = get_attached_file($zipID); $destination = wp_upload_dir(); $destination_path = $destination['path']; $unzipfile = unzip_file($zipLoc, $destination_path); if($unzipfile==1){echo 'Successfully unzipped the file!';} else {echo 'There was an error unzipping the file.';} } die(); } public static function abr_virtual_tours_html($post){ global $post; global $wpdb; // Noncename needed to verify where the data originated echo ''; $strFile = get_post_meta($post -> ID, $key = 'podcast_file', true); $media_file = get_post_meta($post -> ID, $key = '_wp_attached_file', true); if(!empty($media_file)){ $strFile = $media_file; } ?>
ID; } if (!current_user_can('edit_post', $post -> ID)) return $post -> ID; $podcasts_meta['podcast_file'] = $_POST['podcast_file']; foreach($podcasts_meta as $key => $value) { if ($post -> post_type == 'revision') return; $value = implode(',', (array) $value); if(get_post_meta($post -> ID, $key, FALSE)) { // If the custom field already has a value it will update update_post_meta($post -> ID, $key, $value); } else { // If the custom field doesn't have a value it will add add_post_meta($post -> ID, $key, $value); } if (!$value) delete_post_meta($post -> ID, $key); // Delete if blank value } } function abr_virtual_tour_admin_scripts() { wp_enqueue_script('media-upload'); wp_enqueue_script('thickbox'); } function abr_virtual_tour_admin_styles(){ wp_enqueue_style('thickbox'); } } add_action('plugins_loaded',array('AR_Virtual_Tours','init'));