Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('init', 'tours_register');
- function tours_register() {
- $labels = array(
- 'name' => _x('Tours', 'post type general name'),
- 'singular_name' => _x('New Tour', 'post type singular name'),
- 'add_new' => _x('Add New', 'tour'),
- 'add_new_item' => __('Add New Tour'),
- 'edit_item' => __('Edit Tour'),
- 'new_item' => __('New Tour'),
- 'view_item' => __('View Tour'),
- 'search_items' => __('Search Tours'),
- 'not_found' => __('Nothing found'),
- 'not_found_in_trash' => __('Nothing found in Trash'),
- 'parent_item_colon' => ''
- );
- $args = array(
- 'labels' => $labels,
- 'public' => true,
- 'publicly_queryable' => true,
- 'show_ui' => true,
- 'query_var' => true,
- 'menu_icon' => get_stylesheet_directory_uri() . '/images/divasicon.png',
- 'rewrite' => true,
- 'capability_type' => 'post',
- 'hierarchical' => false,
- 'menu_position' => null,
- 'supports' => array('title', 'editor', 'thumbnail')
- );
- register_post_type( 'tours' , $args );
- }
- add_action("admin_init", "admin_init");
- function admin_init(){
- add_meta_box("tour_info", "Tour Information", "tour_info", "tours", "normal", "low");
- }
- function tour_info(){
- global $post;
- $custom = get_post_custom($post->ID);
- $tour_when = $custom["tour_when"][0];
- $tour_duration = $custom["tour_duration"][0];
- $tour_where = $custom["tour_where"][0];
- $tour_google = $custom["tour_google"][0];
- $tour_walking = $custom["tour_walking"][0];
- $tour_price = $custom["tour_price"][0];
- $tour_home = $custom["tour_home"][0];
- $tour_link = $custom["tour_link"][0];
- ?>
- <style type="text/css">
- .tour label{float:left; line-height:30px; width:200px;}
- .tour input{width:300px;}
- </style>
- <p class="tour"><label>When:</label>
- <input name="tour_when" value="<?php echo $tour_when; ?>" /></p>
- <p class="tour"><label>Duration:</label>
- <input name="tour_duration" value="<?php echo $tour_duration; ?>" /></p>
- <p class="tour"><label>Where:</label>
- <input name="tour_where" value="<?php echo $tour_where; ?>" /></p>
- <p class="tour"><label>Google Maps URL:</label>
- <input name="tour_google" value="<?php echo $tour_google; ?>" /></p>
- <p class="tour"><label>Walking Time:</label>
- <input name="tour_walking" value="<?php echo $tour_walking; ?>" /></p>
- <p class="tour"><label>Ticket Price:</label>
- <input name="tour_price" value="<?php echo $tour_price; ?>" /><br />
- Enter only the ticket price, leave off the $ sign.</p>
- <p class="tour"><label>Sidebar text:</label>
- <input name="tour_home" value="<?php echo $tour_home; ?>" /></p>
- <p class="tour"><label>Link URL to buy tickets:</label>
- <input name="tour_link" value="<?php echo $tour_link; ?>" /></p>
- <?php
- }
- add_action('save_post', 'save_tour_details');
- function save_tour_details(){
- global $post;
- if (defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE) {
- return $post->ID;
- } else {
- update_post_meta($post->ID, "tour_when", $_POST["tour_when"]);
- update_post_meta($post->ID, "tour_duration", $_POST["tour_duration"]);
- update_post_meta($post->ID, "tour_where", $_POST["tour_where"]);
- update_post_meta($post->ID, "tour_google", $_POST["tour_google"]);
- update_post_meta($post->ID, "tour_walking", $_POST["tour_walking"]);
- update_post_meta($post->ID, "tour_price", $_POST["tour_price"]);
- update_post_meta($post->ID, "tour_home", $_POST["tour_home"]);
- update_post_meta($post->ID, "tour_link", $_POST["tour_link"]);
- }
- }
- function save_tours_details(){
- global $post;
- if (defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE) {
- return $post->ID;
- } else {
- update_post_meta($post->ID, "tour_when", $_POST["tour_when"]);
- update_post_meta($post->ID, "tour_duration", $_POST["tour_duration"]);
- update_post_meta($post->ID, "tour_where", $_POST["tour_where"]);
- update_post_meta($post->ID, "tour_google", $_POST["tour_google"]);
- update_post_meta($post->ID, "tour_walking", $_POST["tour_walking"]);
- update_post_meta($post->ID, "tour_price", $_POST["tour_price"]);
- update_post_meta($post->ID, "tour_home", $_POST["tour_home"]);
- update_post_meta($post->ID, "tour_link", $_POST["tour_link"]);
- }
- }
- function save_tours(){
- global $post;
- if(!isset($_POST["tour_when"])):
- return $post;
- endif;
- update_post_meta($post->ID, "tour_when", $_POST["tour_when"]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement