Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //above here it's theme's code
- add_action('init', 'coupon_register');
- function coupon_register() {
- $labels = array(
- 'name' => _x('Coupons', 'post type general name'),
- 'singular_name' => _x('Coupon', 'post type singular name'),
- 'add_new' => _x('Add New', 'coupon item'),
- 'add_new_item' => __('Add New Coupon Item'),
- 'edit_item' => __('Edit Coupon Item'),
- 'new_item' => __('New Coupon Item'),
- 'view_item' => __('View Coupon Item'),
- 'search_items' => __('Search Coupon'),
- '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() . '/cuponeria.png',
- 'rewrite' => true,
- 'capability_type' => 'post',
- 'hierarchical' => false,
- 'menu_position' => null,
- 'supports' => array('title','editor','thumbnail')
- );
- register_post_type( 'coupon' , $args );
- flush_rewrite_rules();
- }
- register_taxonomy("coupon_category", array("coupon"), array("hierarchical" => true, "label" => "Coupon_categories", "singular_label" => "Coupon_category", "rewrite" => true));
- register_taxonomy("stores", array("coupon"), array("hierarchical" => true, "label" => "Stores", "singular_label" => "Store", "rewrite" => true));
- add_action("admin_init", "admin_init");
- function admin_init(){
- add_meta_box("basic_info", "Basic info about coupon", "basic_info", "coupon", "normal", "low");
- }
- function basic_info() {
- global $post;
- $custom = get_post_custom($post->ID);
- $discount_percentage = $custom["discount_percentage"][0];
- $expire_date = $custom["expire_date"][0];
- ?>
- <p><label>Discount percentage: </label><br />
- <input cols="50" name="discount_percentage" value = "<?php echo $discount_percentage; ?>"></p>
- <p><label>Expire at: </label><br />
- <input cols="50" name="expire_date" value = "<?php echo $expire_date; ?>"></p>
- <?php
- }
- add_action('save_post', 'save_details');
- function save_details(){
- global $post;
- update_post_meta($post->ID, "discount_percentage", $_POST["discount_percentage"]);
- update_post_meta($post->ID, "expire_date", $_POST["expire_date"]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement