Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- language: lang-php -->
- <?php
- function the_question_form() {
- global $wp_query;
- if ( is_qa_page( 'edit' ) ) {
- $question = $wp_query->posts[0];
- if ( !current_user_can( 'edit_question', $question->ID ) )
- return;
- $question->tags = wp_get_object_terms( $question->ID, 'question_tag', array( 'fields' => 'names' ) );
- $cats = wp_get_object_terms( $question->ID, 'question_category', array( 'fields' => 'ids' ) );
- $question->cat = empty( $cats ) ? false : reset( $cats );
- } else {
- $question = (object) array(
- 'ID' => '',
- 'post_content' => '',
- 'post_title' => '',
- 'tags' => array(),
- 'cat' => false
- );
- }
- ?>
- <form id="question-form" method="post" enctype="multipart/form-data" action="<?php echo qa_get_url( 'archive' ); ?>">
- <?php wp_nonce_field( 'qa_edit' ); ?>
- <input type="hidden" name="qa_action" value="edit_question" />
- <input type="hidden" name="question_id" value="<?php echo esc_attr( $question->ID ); ?>" />
- <table>
- <tr>
- <td id="question-title-label">
- <label for="question-title"><?php _e('Title:', QA_TEXTDOMAIN); ?></label>
- </td>
- <td id="question-title-td">
- <input type="text" id="question-title" name="question_title" value="<?php echo esc_attr( $question->post_title ); ?>" />
- </td>
- </tr>
- </table>
- <textarea name="question_content"><?php echo esc_textarea( $question->post_content ); ?></textarea>
- <!-- My custom fields starts here -->
- <table>
- <tr>
- <td id="image-upload-label">
- <label for="image-upload"><?php _e('Select your image:', QA_TEXTDOMAIN); ?></label>
- </td>
- <td id="image-upload-td">
- <input type="file" name="images[]" class="imagebutton" />
- </td>
- </tr>
- </table>
- <textarea name="image_description"></textarea>
- <!-- My custom fields ends here -->
- <table id="question-taxonomies">
- <tr>
- <td id="question-category-td">
- <?php wp_dropdown_categories( array(
- 'taxonomy' => 'question_category',
- 'selected' => $question->cat,
- 'hide_empty' => false,
- 'hierarchical' => true,
- 'name' => 'question_cat',
- 'class' => '',
- 'show_option_none' => __( 'Select category...', QA_TEXTDOMAIN )
- ) ); ?>
- </td>
- <td id="question-tags-label">
- <label for="question-tags"><?php _e('Tags:', QA_TEXTDOMAIN); ?></label>
- </td>
- <td id="question-tags-td">
- <input type="text" id="question-tags" name="question_tags" value="<?php echo implode( ', ', $question->tags ); ?>" />
- </td>
- </tr>
- </table>
- <?php the_qa_submit_button(); ?>
- </form>
- <?php
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement