Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function mbro1_upload_image( $file )
- {
- $saved_path = '';
- if( file_exists( $file['tmp_name'] ) )
- {
- $saved_path = wp_upload_bits( time() . '_' . $file['name'], null, file_get_contents( $file['tmp_name'] ) );
- }
- return ( !$saved_path['error'] ? $saved_path['url'] : '');
- }
- add_action( 'save_post', 'mbro1_post_type_save');
- function mbro1_post_type_save( $post_id )
- {
- $unique = true;
- if (isset($_POST['mbro1_field_nonce']) && wp_verify_nonce( $_POST['mbro1_field_nonce'], plugin_basename(__FILE__) )) {
- if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
- return $post_id;
- if (isset($_POST['post_type']) && 'page' == $_POST['post_type'] ) {
- if ( !current_user_can( 'edit_page', $post_id ) )
- return $post_id;
- } else {
- if ( !current_user_can( 'edit_post', $post_id ) )
- return $post_id;
- }
- $post = get_post($post_id);
- add_post_meta($post_id, '_mbro1_subscribe_to_newsletter', $_POST['subscribe'], $unique);
- if( $_POST['principal_design'] != '')
- wp_set_object_terms( $post_id, array(intval($_POST['principal_design'])), 'principal-design' );
- if( $_POST['aiding_design'] != '')
- wp_set_object_terms( $post_id, array(intval($_POST['aiding_design'])), 'aiding-design' );
- if( $_POST['state'] != '')
- wp_set_object_terms( $post_id, array(intval($_POST['state'])), 'state' );
- if( $_POST['flag'] != '')
- wp_set_object_terms( $post_id, array(intval($_POST['flag'])), 'flag' );
- if( $_POST['eagle'] != '')
- wp_set_object_terms( $post_id, array(intval($_POST['eagle'])), 'eagle' );
- if( $_POST['presidential_portraits'] != '')
- wp_set_object_terms( $post_id, array(intval($_POST['presidential_portraits'])), 'president' );
- if( $_POST['animal_character'] != '')
- wp_set_object_terms( $post_id, array(intval($_POST['animal_character'])), 'animal-characters' );
- if( $_POST['non_animal_character'] != '')
- wp_set_object_terms( $post_id, array(intval($_POST['non_animal_character'])), 'non-animal-characters' );
- if( $_POST['military_items'] != '')
- wp_set_object_terms( $post_id, array(intval($_POST['military_items'])), 'military-item' );
- add_post_meta($post_id, '_mbro1_reference_number_type', $_POST['reference_number_type'], $unique);
- add_post_meta($post_id, '_mbro1_reference_number', $_POST['reference_number'], $unique);
- add_post_meta($post_id, '_mbro1_search_keyword', $_POST['search_keyword'], $unique);
- add_post_meta($post_id, '_mbro1_pre_printed_wording', $_POST['pre_printed_wording'], $unique);
- add_post_meta($post_id, '_mbro1_visible_dates', $_POST['visible_dates'], $unique);
- add_post_meta($post_id, '_mbro1_color_of_cover', $_POST['color_of_cover'], $unique);
- add_post_meta($post_id, '_mbro1_origin_address', $_POST['origin_address'], $unique);
- add_post_meta($post_id, '_mbro1_destination_address', $_POST['destination_address'], $unique);
- add_post_meta($post_id, '_mbro1_condition', $_POST['condition'], $unique);
- add_post_meta($post_id, '_mbro1_will_you_sell', $_POST['will_you_sell'], $unique);
- add_post_meta($post_id, '_mbro1_sell_price', $_POST['sell_price'], $unique);
- }
- return $post_id;
- }
- add_action( 'init', 'mbro1_create_post_type' );
- function mbro1_create_post_type() {
- register_post_type( 'cover',
- array(
- 'labels' => array(
- 'name' => __( 'Covers' ),
- 'singular_name' => __( 'Cover' )
- ),
- 'public' => true,
- 'has_archive' => true,
- 'supports' => array(
- 'author',
- ),
- )
- );
- register_taxonomy(
- 'principal-design',
- 'cover',
- array(
- 'label' => __('Principal Design'),
- 'hierarchical' => false,
- 'show_ui' => true,
- 'sort' => true,
- 'args' => array('orderby' => 'term_order'),
- 'rewrite' => array('slug' => 'pdesign')
- )
- );
- register_taxonomy(
- 'aiding-design',
- 'cover',
- array(
- 'label' => __('Aiding Design'),
- 'hierarchical' => false,
- 'show_ui' => true,
- 'sort' => true,
- 'args' => array('orderby' => 'term_order'),
- 'rewrite' => array('slug' => 'adesign')
- )
- );
- register_taxonomy(
- 'state',
- 'cover',
- array(
- 'label' => __('State'),
- 'hierarchical' => false,
- 'show_ui' => true,
- 'sort' => true,
- 'args' => array('orderby' => 'term_order'),
- 'rewrite' => array('slug' => 'state')
- )
- );
- register_taxonomy(
- 'flag',
- 'cover',
- array(
- 'label' => __('Flag'),
- 'hierarchical' => false,
- 'show_ui' => true,
- 'sort' => true,
- 'args' => array('orderby' => 'term_order'),
- 'rewrite' => array('slug' => 'flag')
- )
- );
- register_taxonomy(
- 'eagle',
- 'cover',
- array(
- 'label' => __('Eagles'),
- 'hierarchical' => false,
- 'show_ui' => true,
- 'sort' => true,
- 'args' => array('orderby' => 'term_order'),
- 'rewrite' => array('slug' => 'eagle')
- )
- );
- register_taxonomy(
- 'president',
- 'cover',
- array(
- 'label' => __('President'),
- 'hierarchical' => false,
- 'show_ui' => true,
- 'sort' => true,
- 'args' => array('orderby' => 'term_order'),
- 'rewrite' => array('slug' => 'president')
- )
- );
- register_taxonomy(
- 'animal-characters',
- 'cover',
- array(
- 'label' => __('Animal Characters/Cartoons'),
- 'hierarchical' => false,
- 'show_ui' => true,
- 'sort' => true,
- 'args' => array('orderby' => 'term_order'),
- 'rewrite' => array('slug' => 'animal-character')
- )
- );
- register_taxonomy(
- 'non-animal-characters',
- 'cover',
- array(
- 'label' => __('Non-Animal Characters/Cartoons'),
- 'hierarchical' => false,
- 'show_ui' => true,
- 'sort' => true,
- 'args' => array('orderby' => 'term_order'),
- 'rewrite' => array('slug' => 'non-animal-characters')
- )
- );
- register_taxonomy(
- 'military-item',
- 'cover',
- array(
- 'label' => __('Military Items'),
- 'hierarchical' => false,
- 'show_ui' => true,
- 'sort' => true,
- 'args' => array('orderby' => 'term_order'),
- 'rewrite' => array('slug' => 'military-item')
- )
- );
- }
- add_action( 'admin_menu', 'mbro1_meta_boxes');
- function mbro1_meta_boxes(){
- $taxonomies = array(
- 'principal-design',
- 'aiding-design',
- 'state',
- 'flag',
- 'eagle',
- 'animal-characters',
- 'non-animal-characters',
- 'military-item',
- );
- foreach ($taxonomies as $taxonomy )
- {
- remove_meta_box('tagsdiv-'.$taxonomy,'cover','core');
- }
- add_meta_box('mbro1_over_meta_box', 'Cover Informations', 'mbro1_meta_box_handler', 'cover', 'normal', 'low');
- }
- function mbro1_meta_box_handler( $post )
- {
- wp_nonce_field( plugin_basename(__FILE__), 'mbro1_field_nonce' );
- ?>
- <table border="1" width="80%" id="table3">
- <tr>
- <td width="266" bgcolor="#FFFFFF">Subscribe to our periodic Newsletter?</td>
- <td bgcolor="#FFFFFF">
- <?php
- $subscribe = get_post_meta($post->ID, '_mbro1_subscribe_to_newsletter', true);
- ?>
- <input type="radio" <?php echo (!in_array($subscribe, array('0', '')) ? "checked='checked'" : ''); ?> value='1' name="subscribe"> YES
- <input type="radio" <?php echo (in_array($subscribe, array('0', '')) ? "checked='checked'" : ''); ?> name="subscribe" value='0'> NO</td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF" colspan="2"> </td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF" colspan="2">
- <p align="center"><b>Upload Scan/Image:</b></td>
- </tr>
- <tr>
- <td width="266" bgcolor="#FFFFFF">
- <p align="center">Front: <input type="text" name="T7" size="30"></td>
- <td bgcolor="#FFFFFF">
- <input type="button" value="Browse" name="B7">
- <input type="button" value="Upload" name="B8"></td>
- </tr>
- <tr>
- <td width="266" bgcolor="#FFFFFF">
- <p align="center" style="margin-top: 0; margin-bottom: 0">Back:
- <input type="text" name="T15" size="30"><p align="center" style="margin-top: 0; margin-bottom: 0">
- <font size="1">Only upload Back if NOT blank</font></td>
- <td bgcolor="#FFFFFF">
- <p style="margin-top: 0; margin-bottom: 0">
- <input type="button" value="Browse" name="B9">
- <input type="button" value="Upload" name="B10"></td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF" colspan="2"> </td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF" colspan="2">
- <p align="center"><b>Classification:</b></td>
- </tr>
- </table>
- <table border="1" width="80%" id="table2">
- <tr>
- <td width="266" bgcolor="#FFFFFF">Does the Principal Design
- include:</td>
- <td bgcolor="#FFFFFF"><select size="1" name="principal_design">
- <option value="">Unknown</option>
- <?php
- $oTerms = wp_get_object_terms( $post->ID, 'principal-design' );
- $selectedTerm = isset($oTerms[0]) ? $oTerms[0]->term_id : '';
- $terms = get_terms( 'principal-design', array('hide_empty' => '0') );
- foreach( $terms as $term)
- {
- ?><option<?php echo ($selectedTerm == $term->term_id) ? " selected='selected'" : ''; ?> value='<?php echo $term->term_id; ?>'><?php echo $term->name; ?></option><?php
- }
- ?>
- </select></td>
- </tr>
- <tr>
- <td width="266" bgcolor="#FFFFFF">Does the Aiding Design
- include:</td>
- <td bgcolor="#FFFFFF"><select size="1" name="aiding_design">
- <option value="">Unknown</option>
- <?php
- $oTerms = wp_get_object_terms( $post->ID, 'aiding-design' );
- $selectedTerm = isset($oTerms[0]) ? $oTerms[0]->term_id : '';
- $terms = get_terms( 'aiding-design', array('hide_empty' => '0') );
- foreach( $terms as $term)
- {
- ?><option<?php echo ($selectedTerm == $term->term_id) ? " selected='selected'" : ''; ?> value='<?php echo $term->term_id; ?>'><?php echo $term->name; ?></option><?php
- }
- ?>
- </select></td>
- </tr>
- <tr>
- <td width="266" bgcolor="#FFFFFF">State specified on cover?</td>
- <td bgcolor="#FFFFFF"><select size="1" name="state">
- <option value="">Unknown</option>
- <?php
- $oTerms = wp_get_object_terms( $post->ID, 'state' );
- $selectedTerm = isset($oTerms[0]) ? $oTerms[0]->term_id : '';
- $terms = get_terms( 'state', array('hide_empty' => '0') );
- foreach( $terms as $term)
- {
- ?><option<?php echo ($selectedTerm == $term->term_id) ? " selected='selected'" : ''; ?> value='<?php echo $term->term_id; ?>'><?php echo $term->name; ?></option><?php
- }
- ?>
- </select></td>
- </tr>
- <tr>
- <td width="266" bgcolor="#FFFFFF">Are there any Flags?</td>
- <td bgcolor="#FFFFFF"><select size="1" name="flag">
- <option value="">No</option>
- <?php
- $oTerms = wp_get_object_terms( $post->ID, 'flag' );
- $selectedTerm = isset($oTerms[0]) ? $oTerms[0]->term_id : '';
- $terms = get_terms( 'flag', array('hide_empty' => '0') );
- foreach( $terms as $term)
- {
- ?><option<?php echo ($selectedTerm == $term->term_id) ? " selected='selected'" : ''; ?> value='<?php echo $term->term_id; ?>'><?php echo $term->name; ?></option><?php
- }
- ?>
- </select></td>
- </tr>
- <tr>
- <td width="266" bgcolor="#FFFFFF">Are there any Eagles?</td>
- <td bgcolor="#FFFFFF"><select size="1" name="eagle">
- <option value="">No</option>
- <?php
- $oTerms = wp_get_object_terms( $post->ID, 'eagle' );
- $selectedTerm = isset($oTerms[0]) ? $oTerms[0]->term_id : '';
- $terms = get_terms( 'eagle', array('hide_empty' => '0') );
- foreach( $terms as $term)
- {
- ?><option<?php echo ($selectedTerm == $term->term_id) ? " selected='selected'" : ''; ?> value='<?php echo $term->term_id; ?>'><?php echo $term->name; ?></option><?php
- }
- ?>
- </select></td>
- </tr>
- <tr>
- <td width="266" bgcolor="#FFFFFF">Are there any Presidential Portraits?</td>
- <td bgcolor="#FFFFFF"><select size="1" name="presidential_portraits">
- <option value="">No</option>
- <?php
- $oTerms = wp_get_object_terms( $post->ID, 'president' );
- $selectedTerm = isset($oTerms[0]) ? $oTerms[0]->term_id : '';
- $terms = get_terms( 'president', array('hide_empty' => '0') );
- foreach( $terms as $term)
- {
- ?><option<?php echo ($selectedTerm == $term->term_id) ? " selected='selected'" : ''; ?> value='<?php echo $term->term_id; ?>'><?php echo $term->name; ?></option><?php
- }
- ?>
- </select></td>
- </tr>
- <tr>
- <td width="266" bgcolor="#FFFFFF">Are there any Animal Characters/Cartoons?</td>
- <td bgcolor="#FFFFFF"><select size="1" name="animal_character">
- <option value="">No</option>
- <?php
- $oTerms = wp_get_object_terms( $post->ID, 'animal-characters' );
- $selectedTerm = isset($oTerms[0]) ? $oTerms[0]->term_id : '';
- $terms = get_terms( 'animal-characters', array('hide_empty' => '0') );
- foreach( $terms as $term)
- {
- ?><option<?php echo ($selectedTerm == $term->term_id) ? " selected='selected'" : ''; ?> value='<?php echo $term->term_id; ?>'><?php echo $term->name; ?></option><?php
- }
- ?>
- </select></td>
- </tr>
- <tr>
- <td width="266" bgcolor="#FFFFFF">Are there any Non-Animal Characters/Cartoons?</td>
- <td bgcolor="#FFFFFF"><select size="1" name="non_animal_character">
- <option value="">No</option>
- <?php
- $oTerms = wp_get_object_terms( $post->ID, 'non-animal-characters' );
- $selectedTerm = isset($oTerms[0]) ? $oTerms[0]->term_id : '';
- $terms = get_terms( 'non-animal-characters', array('hide_empty' => '0') );
- foreach( $terms as $term)
- {
- ?><option<?php echo ($selectedTerm == $term->term_id) ? " selected='selected'" : ''; ?> value='<?php echo $term->term_id; ?>'><?php echo $term->name; ?></option><?php
- }
- ?>
- </select></td>
- </tr>
- <tr>
- <td width="266" bgcolor="#FFFFFF">Are there any Military Items?</td>
- <td bgcolor="#FFFFFF"><select size="1" name="military_items">
- <option value="">No</option>
- <?php
- $oTerms = wp_get_object_terms( $post->ID, 'military-item' );
- $selectedTerm = isset($oTerms[0]) ? $oTerms[0]->term_id : '';
- $terms = get_terms( 'military-item', array('hide_empty' => '0') );
- foreach( $terms as $term)
- {
- ?><option<?php echo ($selectedTerm == $term->term_id) ? " selected='selected'" : ''; ?> value='<?php echo $term->term_id; ?>'><?php echo $term->name; ?></option><?php
- }
- ?>
- </select></td>
- </tr>
- <tr>
- <td colspan="2" bgcolor="#FFFFFF">
- <p align="center"><div align="center">Search Option #1</div></p>
- </td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF">Do you know the Reference Number?</td>
- <td bgcolor="#FFFFFF"><select size="1" name="reference_number_type">
- <?php
- $_mbro1_reference_number_type = get_post_meta($post->ID, '_mbro1_reference_number_type', true);
- ?>
- <option<?php echo ($_mbro1_reference_number_type == '') ? " selected='selected'" : ''; ?> value=''>No</option>
- <option<?php echo ($_mbro1_reference_number_type == 'Weiss #') ? " selected='selected'" : ''; ?> value='Weiss #'>Weiss #</option>
- <option<?php echo ($_mbro1_reference_number_type == 'Bishel/Nutmeg #') ? " selected='selected'" : ''; ?> value='Bishel/Nutmeg #'>Bishel/Nutmeg #</option>
- </select> <input type="text" name="reference_number" value="<?php echo get_post_meta($post->ID, '_mbro1_reference_number', true); ?>" /></td>
- </tr>
- <tr>
- <td colspan="2" bgcolor="#FFFFFF">
- <p align="center"><div align="center">Search Option #2</div></p></td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF">Keyword Search (any word on the Cover)</td>
- <td bgcolor="#FFFFFF"><input type="text" name="search_keyword" size="20" value="<?php echo get_post_meta($post->ID, '_mbro1_search_keyword', true); ?>"></td>
- </tr>
- <tr>
- <td colspan="2" bgcolor="#FFFFFF">
- <p align="center"><b>Additional Information:</b></td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF">Pre-printed wording on cover</td>
- <td bgcolor="#FFFFFF"><input type="text" name="pre_printed_wording" size="20" value="<?php echo get_post_meta($post->ID, '_mbro1_pre_printed_wording', true); ?>"></td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF">Are there any visible dates?</td>
- <td bgcolor="#FFFFFF"><input type="text" name="visible_dates" size="20" value="<?php echo get_post_meta($post->ID, '_mbro1_visible_dates', true); ?>"></td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF">Color of cover</td>
- <td bgcolor="#FFFFFF"><input type="text" name="color_of_cover" size="20" value="<?php echo get_post_meta($post->ID, '_mbro1_color_of_cover', true); ?>"></td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF">Any Origin Address?</td>
- <td bgcolor="#FFFFFF"><input type="text" name="origin_address" size="20" value="<?php echo get_post_meta($post->ID, '_mbro1_origin_address', true); ?>"></td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF">Any Destination Address?</td>
- <td bgcolor="#FFFFFF"><input type="text" name="destination_address" size="20" value="<?php echo get_post_meta($post->ID, '_mbro1_destination_address', true); ?>"></td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF">Condition:</td>
- <?php
- $condition = get_post_meta($post->ID, '_mbro1_condition', true);
- ?>
- <td bgcolor="#FFFFFF"><input type="radio" name="condition" value="new" <?php echo ($condition == 'new') ? 'checked="checked"' : ''; ?>/> New /
- <input type="radio" name="condition" value="used" <?php echo ($condition == 'used') ? 'checked="checked"' : ''; ?>/> Used</td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF"> </td>
- <td bgcolor="#FFFFFF"> </td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF" colspan="2">
- <p align="center"><b>Sales Information:</b></td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF">
- <p style="margin-top: 0; margin-bottom: 0">Would you be interested in selling this
- item</td>
- <td bgcolor="#FFFFFF">
- <p style="margin-top: 0; margin-bottom: 0" align="center"><select size="1" name="will_you_sell">
- <?php
- $will_you_sell = get_post_meta($post->ID, '_mbro1_will_you_sell', true);
- ?>
- <option <?php echo ($will_you_sell == '') ? 'selected="selected"' : ''; ?> value=''>No</option>
- <option <?php echo ($will_you_sell == 'Maybe') ? 'selected="selected"' : ''; ?> value='Maybe'>Maybe</option>
- <option <?php echo ($will_you_sell == 'Yes - Specify Price') ? 'selected="selected"' : ''; ?> value='Yes - Specify Price'>Yes - Specify Price</option>
- <option>Yes - Make Offer</option>
- </select></p>
- <p style="margin-top: 0; margin-bottom: 0" align="center">Price
- USD <input type="text" name="sell_price" size="10" value="<?php echo get_post_meta($post->ID, '_mbro1_sell_price', true); ?>"></td>
- </tr>
- <tr>
- <td colspan="2" bgcolor="#FFFFFF">
- <p align="center">For information, recent sales have been in the
- range of USD XXXX</td>
- </tr>
- <tr>
- <td colspan="2" bgcolor="#FFFFFF"> </td>
- </tr>
- </table><?php
- }
- /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
- /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
- /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
- /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
- add_shortcode( 'mbro1-data-input-form', 'mbro1_form_display_shortcode_handler' );
- function mbro1_form_display_shortcode_handler( $atts, $content=bull, $code="" )
- {
- global $current_user;
- get_currentuserinfo();
- $unique = true;
- $content = "";
- if ( !is_user_logged_in() ) {
- $content = 'You have to logged in first!';
- } else {
- $query = new WP_Query( 'author=' . $current_user->ID . '&post_type=cover' );
- //echo "<!-- " . print_r( $query, true ) . " -->";
- $user_form = $query->posts;
- //echo "<!-- " . count($user_form) . " -->";
- $post_id = $user_form[0]->ID;
- @ob_start();
- ?>
- <form name="myform" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>" enctype="multipart/form-data">
- <!--<form method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>" enctype="multipart/form-data">-->
- <table border="1" width="80%" id="table3">
- <tr>
- <td width="266" bgcolor="#FFFFFF">Subscribe to our periodic Newsletter?</td>
- <td bgcolor="#FFFFFF">
- <?php
- $subscribe = get_post_meta($post_id, '_mbro1_subscribe_to_newsletter', true);
- ?>
- <input type="radio" <?php echo (!in_array($subscribe, array('0', '')) ? "checked='checked'" : ''); ?> value='1' name="subscribe"> YES
- <input type="radio" <?php echo (in_array($subscribe, array('0', '')) ? "checked='checked'" : ''); ?> name="subscribe" value='0'> NO</td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF" colspan="2"> </td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF" colspan="2">
- <p align="center"><b>Upload Scan/Image:</b></td>
- </tr>
- <tr>
- <td width="266" bgcolor="#FFFFFF" colspan="2">
- <p align="center">Front: <input type="file" name="cover_front" size="30"></td>
- </tr>
- <tr>
- <td width="266" bgcolor="#FFFFFF" colspan="2">
- <p align="center" style="margin-top: 0; margin-bottom: 0">Back:
- <input type="file" name="cover_back" size="30"><p align="center" style="margin-top: 0; margin-bottom: 0">
- <font size="1">Only upload Back if NOT blank</font></td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF" colspan="2"> </td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF" colspan="2">
- <p align="center"><b>Classification:</b></td>
- </tr>
- </table>
- <table border="1" width="80%" id="table2">
- <tr>
- <td width="266" bgcolor="#FFFFFF">Does the Principal Design
- include:</td>
- <td bgcolor="#FFFFFF"><select size="1" name="principal_design">
- <option value="">Unknown</option>
- <?php
- $oTerms = wp_get_object_terms( $post_id, 'principal-design' );
- $selectedTerm = isset($oTerms[0]) ? $oTerms[0]->term_id : '';
- $terms = get_terms( 'principal-design', array('hide_empty' => '0') );
- foreach( $terms as $term)
- {
- ?><option<?php echo ($selectedTerm == $term->term_id) ? " selected='selected'" : ''; ?> value='<?php echo $term->term_id; ?>'><?php echo $term->name; ?></option><?php
- }
- ?>
- </select></td>
- </tr>
- <tr>
- <td width="266" bgcolor="#FFFFFF">Does the Aiding Design
- include:</td>
- <td bgcolor="#FFFFFF"><select size="1" name="aiding_design">
- <option value="">Unknown</option>
- <?php
- $oTerms = wp_get_object_terms( $post_id, 'aiding-design' );
- $selectedTerm = isset($oTerms[0]) ? $oTerms[0]->term_id : '';
- $terms = get_terms( 'aiding-design', array('hide_empty' => '0') );
- foreach( $terms as $term)
- {
- ?><option<?php echo ($selectedTerm == $term->term_id) ? " selected='selected'" : ''; ?> value='<?php echo $term->term_id; ?>'><?php echo $term->name; ?></option><?php
- }
- ?>
- </select></td>
- </tr>
- <tr>
- <td width="266" bgcolor="#FFFFFF">State specified on cover?</td>
- <td bgcolor="#FFFFFF"><select size="1" name="state">
- <option value="">Unknown</option>
- <?php
- $oTerms = wp_get_object_terms( $post_id, 'state' );
- $selectedTerm = isset($oTerms[0]) ? $oTerms[0]->term_id : '';
- $terms = get_terms( 'state', array('hide_empty' => '0') );
- foreach( $terms as $term)
- {
- ?><option<?php echo ($selectedTerm == $term->term_id) ? " selected='selected'" : ''; ?> value='<?php echo $term->term_id; ?>'><?php echo $term->name; ?></option><?php
- }
- ?>
- </select></td>
- </tr>
- <tr>
- <td width="266" bgcolor="#FFFFFF">Are there any Flags?</td>
- <td bgcolor="#FFFFFF"><select size="1" name="flag">
- <option value="">No</option>
- <?php
- $oTerms = wp_get_object_terms( $post_id, 'flag' );
- $selectedTerm = isset($oTerms[0]) ? $oTerms[0]->term_id : '';
- $terms = get_terms( 'flag', array('hide_empty' => '0') );
- foreach( $terms as $term)
- {
- ?><option<?php echo ($selectedTerm == $term->term_id) ? " selected='selected'" : ''; ?> value='<?php echo $term->term_id; ?>'><?php echo $term->name; ?></option><?php
- }
- ?>
- </select></td>
- </tr>
- <tr>
- <td width="266" bgcolor="#FFFFFF">Are there any Eagles?</td>
- <td bgcolor="#FFFFFF"><select size="1" name="eagle">
- <option value="">No</option>
- <?php
- $oTerms = wp_get_object_terms( $post_id, 'eagle' );
- $selectedTerm = isset($oTerms[0]) ? $oTerms[0]->term_id : '';
- $terms = get_terms( 'eagle', array('hide_empty' => '0') );
- foreach( $terms as $term)
- {
- ?><option<?php echo ($selectedTerm == $term->term_id) ? " selected='selected'" : ''; ?> value='<?php echo $term->term_id; ?>'><?php echo $term->name; ?></option><?php
- }
- ?>
- </select></td>
- </tr>
- <tr>
- <td width="266" bgcolor="#FFFFFF">Are there any Presidential Portraits?</td>
- <td bgcolor="#FFFFFF"><select size="1" name="presidential_portraits">
- <option value="">No</option>
- <?php
- $oTerms = wp_get_object_terms( $post_id, 'president' );
- $selectedTerm = isset($oTerms[0]) ? $oTerms[0]->term_id : '';
- $terms = get_terms( 'president', array('hide_empty' => '0') );
- foreach( $terms as $term)
- {
- ?><option<?php echo ($selectedTerm == $term->term_id) ? " selected='selected'" : ''; ?> value='<?php echo $term->term_id; ?>'><?php echo $term->name; ?></option><?php
- }
- ?>
- </select></td>
- </tr>
- <tr>
- <td width="266" bgcolor="#FFFFFF">Are there any Animal Characters/Cartoons?</td>
- <td bgcolor="#FFFFFF"><select size="1" name="animal_character">
- <option value="">No</option>
- <?php
- $oTerms = wp_get_object_terms( $post_id, 'animal-characters' );
- $selectedTerm = isset($oTerms[0]) ? $oTerms[0]->term_id : '';
- $terms = get_terms( 'animal-characters', array('hide_empty' => '0') );
- foreach( $terms as $term)
- {
- ?><option<?php echo ($selectedTerm == $term->term_id) ? " selected='selected'" : ''; ?> value='<?php echo $term->term_id; ?>'><?php echo $term->name; ?></option><?php
- }
- ?>
- </select></td>
- </tr>
- <tr>
- <td width="266" bgcolor="#FFFFFF">Are there any Non-Animal Characters/Cartoons?</td>
- <td bgcolor="#FFFFFF"><select size="1" name="non_animal_character">
- <option value="">No</option>
- <?php
- $oTerms = wp_get_object_terms( $post_id, 'non-animal-characters' );
- $selectedTerm = isset($oTerms[0]) ? $oTerms[0]->term_id : '';
- $terms = get_terms( 'non-animal-characters', array('hide_empty' => '0') );
- foreach( $terms as $term)
- {
- ?><option<?php echo ($selectedTerm == $term->term_id) ? " selected='selected'" : ''; ?> value='<?php echo $term->term_id; ?>'><?php echo $term->name; ?></option><?php
- }
- ?>
- </select></td>
- </tr>
- <tr>
- <td width="266" bgcolor="#FFFFFF">Are there any Military Items?</td>
- <td bgcolor="#FFFFFF"><select size="1" name="military_items">
- <option value="">No</option>
- <?php
- $oTerms = wp_get_object_terms( $post_id, 'military-item' );
- $selectedTerm = isset($oTerms[0]) ? $oTerms[0]->term_id : '';
- $terms = get_terms( 'military-item', array('hide_empty' => '0') );
- foreach( $terms as $term)
- {
- ?><option<?php echo ($selectedTerm == $term->term_id) ? " selected='selected'" : ''; ?> value='<?php echo $term->term_id; ?>'><?php echo $term->name; ?></option><?php
- }
- ?>
- </select></td>
- </tr>
- <tr>
- <td colspan="2" bgcolor="#FFFFFF">
- <p align="center"><div align="center">Search Option #1</div></p>
- </td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF">Do you know the Reference Number?</td>
- <td bgcolor="#FFFFFF"><select size="1" name="reference_number_type">
- <?php
- $_mbro1_reference_number_type = get_post_meta($post_id, '_mbro1_reference_number_type', true);
- ?>
- <option<?php echo ($_mbro1_reference_number_type == '') ? " selected='selected'" : ''; ?> value=''>No</option>
- <option<?php echo ($_mbro1_reference_number_type == 'Weiss #') ? " selected='selected'" : ''; ?> value='Weiss #'>Weiss #</option>
- <option<?php echo ($_mbro1_reference_number_type == 'Bishel/Nutmeg #') ? " selected='selected'" : ''; ?> value='Bishel/Nutmeg #'>Bishel/Nutmeg #</option>
- </select> <input type="text" name="reference_number" value="<?php echo get_post_meta($post_id, '_mbro1_reference_number', true); ?>" /></td>
- </tr>
- <tr>
- <td colspan="2" bgcolor="#FFFFFF">
- <p align="center"><div align="center">Search Option #2</div></p></td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF">Keyword Search (any word on the Cover)</td>
- <td bgcolor="#FFFFFF"><input type="text" name="search_keyword" size="20" value="<?php echo get_post_meta($post_id, '_mbro1_search_keyword', true); ?>"></td>
- </tr>
- <tr>
- <td colspan="2" bgcolor="#FFFFFF">
- <p align="center"><b>Additional Information:</b></td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF">Pre-printed wording on cover</td>
- <td bgcolor="#FFFFFF"><input type="text" name="pre_printed_wording" size="20" value="<?php echo get_post_meta($post_id, '_mbro1_pre_printed_wording', true); ?>"></td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF">Are there any visible dates?</td>
- <td bgcolor="#FFFFFF"><input type="text" name="visible_dates" size="20" value="<?php echo get_post_meta($post_id, '_mbro1_visible_dates', true); ?>"></td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF">Color of cover</td>
- <td bgcolor="#FFFFFF"><input type="text" name="color_of_cover" size="20" value="<?php echo get_post_meta($post_id, '_mbro1_color_of_cover', true); ?>"></td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF">Any Origin Address?</td>
- <td bgcolor="#FFFFFF"><input type="text" name="origin_address" size="20" value="<?php echo get_post_meta($post_id, '_mbro1_origin_address', true); ?>"></td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF">Any Destination Address?</td>
- <td bgcolor="#FFFFFF"><input type="text" name="destination_address" size="20" value="<?php echo get_post_meta($post_id, '_mbro1_destination_address', true); ?>"></td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF">Condition:</td>
- <?php
- $condition = get_post_meta($post_id, '_mbro1_condition', true);
- ?>
- <td bgcolor="#FFFFFF"><input type="radio" name="condition" value="new" <?php echo ($condition == 'new') ? 'checked="checked"' : ''; ?>/> New /
- <input type="radio" name="condition" value="used" <?php echo ($condition == 'used') ? 'checked="checked"' : ''; ?>/> Used</td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF"> </td>
- <td bgcolor="#FFFFFF"> </td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF" colspan="2">
- <p align="center"><b>Sales Information:</b></td>
- </tr>
- <tr>
- <td bgcolor="#FFFFFF">
- <p style="margin-top: 0; margin-bottom: 0">Would you be interested in selling this
- item</td>
- <td bgcolor="#FFFFFF">
- <p style="margin-top: 0; margin-bottom: 0" align="center"><select size="1" name="will_you_sell">
- <?php
- $will_you_sell = get_post_meta($post_id, '_mbro1_will_you_sell', true);
- ?>
- <option <?php echo ($will_you_sell == '') ? 'selected="selected"' : ''; ?> value=''>No</option>
- <option <?php echo ($will_you_sell == 'Maybe') ? 'selected="selected"' : ''; ?> value='Maybe'>Maybe</option>
- <option <?php echo ($will_you_sell == 'Yes - Specify Price') ? 'selected="selected"' : ''; ?> value='Yes - Specify Price'>Yes - Specify Price</option>
- <option>Yes - Make Offer</option>
- </select></p>
- <p style="margin-top: 0; margin-bottom: 0" align="center">Price
- USD <input type="text" name="sell_price" size="10" value="<?php echo get_post_meta($post_id, '_mbro1_sell_price', true); ?>"></td>
- </tr>
- <tr>
- <td colspan="2" bgcolor="#FFFFFF">
- <p align="center">For information, recent sales have been in the
- range of USD XXXX</td>
- </tr>
- <tr>
- <td colspan="2" bgcolor="#FFFFFF"><input type="submit" name="submit" value="Submit" />
- <input type="hidden" name="action_code" value="mbro_intercept_form_input" />
- </td>
- </tr>
- </table>
- </form><?php
- $content .= @ob_get_contents();
- @ob_end_clean();
- };
- return $content;
- }
- add_action('init', 'mbro1_intercept_form_input');
- function mbro1_intercept_form_input()
- {
- global $current_user;
- get_currentuserinfo();
- if( !(isset($_POST['action_code']) && $_POST['action_code'] == 'mbro_intercept_form_input') )
- return "";
- //die("THIS CODE WORK!");
- $query = new WP_Query( 'author=' . $current_user->ID . '&post_type=cover' );
- //echo "<!-- " . print_r( $query, true ) . " -->";
- $user_form = $query->posts;
- $post_id = $user_form[0]->ID;
- if( isset( $_POST['submit'] ) )
- {
- $my_post = array(
- 'ID' => 'cover',
- 'post_type' => 'cover',
- 'post_title' => $current_user->user_login . " form data",
- 'post_content' => 'no content',
- 'post_status' => 'publish',
- 'post_author' => $current_user->ID,
- );
- // Insert the post into the database
- $post_id = wp_insert_post( $my_post );
- add_post_meta($post_id, '_mbro1_subscribe_to_newsletter', $_POST['subscribe'], $unique);
- if( $_POST['principal_design'] != '')
- wp_set_object_terms( $post_id, array(intval($_POST['principal_design'])), 'principal-design' );
- if( $_POST['aiding_design'] != '')
- wp_set_object_terms( $post_id, array(intval($_POST['aiding_design'])), 'aiding-design' );
- if( $_POST['state'] != '')
- wp_set_object_terms( $post_id, array(intval($_POST['state'])), 'state' );
- if( $_POST['flag'] != '')
- wp_set_object_terms( $post_id, array(intval($_POST['flag'])), 'flag' );
- if( $_POST['eagle'] != '')
- wp_set_object_terms( $post_id, array(intval($_POST['eagle'])), 'eagle' );
- if( $_POST['presidential_portraits'] != '')
- wp_set_object_terms( $post_id, array(intval($_POST['presidential_portraits'])), 'president' );
- if( $_POST['animal_character'] != '')
- wp_set_object_terms( $post_id, array(intval($_POST['animal_character'])), 'animal-characters' );
- if( $_POST['non_animal_character'] != '')
- wp_set_object_terms( $post_id, array(intval($_POST['non_animal_character'])), 'non-animal-characters' );
- if( $_POST['military_items'] != '')
- wp_set_object_terms( $post_id, array(intval($_POST['military_items'])), 'military-item' );
- $cover_front = mbro1_upload_image($_FILES['cover_front']);
- $cover_back = mbro1_upload_image($_FILES['cover_back']);
- add_post_meta($post_id, '_mbro1_cover_front', $cover_front, $unique);
- add_post_meta($post_id, '_mbro1_cover_back', $cover_back, $unique);
- add_post_meta($post_id, '_mbro1_reference_number_type', $_POST['reference_number_type'], $unique);
- add_post_meta($post_id, '_mbro1_reference_number', $_POST['reference_number'], $unique);
- add_post_meta($post_id, '_mbro1_search_keyword', $_POST['search_keyword'], $unique);
- add_post_meta($post_id, '_mbro1_pre_printed_wording', $_POST['pre_printed_wording'], $unique);
- add_post_meta($post_id, '_mbro1_visible_dates', $_POST['visible_dates'], $unique);
- add_post_meta($post_id, '_mbro1_color_of_cover', $_POST['color_of_cover'], $unique);
- add_post_meta($post_id, '_mbro1_origin_address', $_POST['origin_address'], $unique);
- add_post_meta($post_id, '_mbro1_destination_address', $_POST['destination_address'], $unique);
- add_post_meta($post_id, '_mbro1_condition', $_POST['condition'], $unique);
- add_post_meta($post_id, '_mbro1_will_you_sell', $_POST['will_you_sell'], $unique);
- add_post_meta($post_id, '_mbro1_sell_price', $_POST['sell_price'], $unique);
- wp_redirect( get_permalink(35) );//page that has form
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement