Advertisement
Viruthagiri

stackoverflow

Jul 26th, 2011
510
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         <!-- language: lang-php -->
  2.             <?php
  3.             function the_question_form() {
  4.         global $wp_query;
  5.    
  6.         if ( is_qa_page( 'edit' ) ) {
  7.             $question = $wp_query->posts[0];
  8.    
  9.             if ( !current_user_can( 'edit_question', $question->ID ) )
  10.                 return;
  11.    
  12.             $question->tags = wp_get_object_terms( $question->ID, 'question_tag', array( 'fields' => 'names' ) );
  13.            
  14.             $cats = wp_get_object_terms( $question->ID, 'question_category', array( 'fields' => 'ids' ) );
  15.             $question->cat = empty( $cats ) ? false : reset( $cats );
  16.         } else {
  17.             $question = (object) array(
  18.                 'ID' => '',
  19.                 'post_content' => '',
  20.                 'post_title' => '',
  21.                 'tags' => array(),
  22.                 'cat' => false
  23.             );
  24.         }
  25.    
  26.     ?>
  27.     <form id="question-form" method="post" enctype="multipart/form-data" action="<?php echo qa_get_url( 'archive' ); ?>">
  28.         <?php wp_nonce_field( 'qa_edit' ); ?>
  29.    
  30.         <input type="hidden" name="qa_action" value="edit_question" />
  31.         <input type="hidden" name="question_id" value="<?php echo esc_attr( $question->ID ); ?>" />
  32.    
  33.         <table>
  34.             <tr>
  35.                 <td id="question-title-label">
  36.                     <label for="question-title"><?php _e('Title:', QA_TEXTDOMAIN); ?></label>
  37.                 </td>
  38.                 <td id="question-title-td">
  39.                     <input type="text" id="question-title" name="question_title" value="<?php echo esc_attr( $question->post_title ); ?>" />
  40.                 </td>
  41.             </tr>
  42.         </table>
  43.    
  44.         <textarea name="question_content"><?php echo esc_textarea( $question->post_content ); ?></textarea>
  45.     <!-- My custom fields starts here -->
  46.    
  47.     <table>
  48.             <tr>
  49.                 <td id="image-upload-label">
  50.                     <label for="image-upload"><?php _e('Select your image:', QA_TEXTDOMAIN); ?></label>
  51.                 </td>
  52.                 <td id="image-upload-td">
  53.                     <input type="file" name="images[]" class="imagebutton" />
  54.                 </td>
  55.             </tr>
  56.         </table>
  57.    
  58.     <textarea name="image_description"></textarea>
  59.    
  60.     <!-- My custom fields ends here -->
  61.         <table id="question-taxonomies">
  62.             <tr>
  63.                 <td id="question-category-td">
  64.                 <?php wp_dropdown_categories( array(
  65.                     'taxonomy' => 'question_category',
  66.                     'selected' => $question->cat,
  67.                     'hide_empty' => false,
  68.                     'hierarchical' => true,
  69.                     'name' => 'question_cat',
  70.                     'class' => '',
  71.                     'show_option_none' => __( 'Select category...', QA_TEXTDOMAIN )
  72.                 ) ); ?>
  73.                 </td>
  74.                 <td id="question-tags-label">
  75.                     <label for="question-tags"><?php _e('Tags:', QA_TEXTDOMAIN); ?></label>
  76.                 </td>
  77.                 <td id="question-tags-td">
  78.                     <input type="text" id="question-tags" name="question_tags" value="<?php echo implode( ', ', $question->tags ); ?>" />
  79.                 </td>
  80.             </tr>
  81.         </table>
  82.    
  83.         <?php the_qa_submit_button(); ?>
  84.     </form>
  85.     <?php
  86.     }
  87.    
  88.         ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement