• 1.
    <?php
  • 2.
    /**
  • 3.
     * The template for displaying single answers
  • 4.
     *
  • 5.
     * @package DW Question & Answer
  • 6.
     * @since DW Question & Answer 1.0.1
  • 7.
     */
  • 8.
    	global $dwqa_shortcode_atts;
  • 9.
     
  • 10.
    	if ( isset( $dwqa_shortcode_atts['category'] ) && $dwqa_shortcode_atts['category'] !='') {
  • 11.
    		$dwqa_category = get_term_by('slug', $dwqa_shortcode_atts['category'], 'dwqa-question_category');
  • 12.
    	}
  • 13.
    ?>
  • 14.
     
  • 15.
    <?php do_action( 'dwqa_before_question_submit_form' ); ?>
  • 16.
    <?php if ( dwqa_current_user_can( 'post_question' ) ) : ?>
  • 17.
    	<form method="post" class="dwqa-content-ask-form" enctype="multipart/form-data">
  • 18.
    		<p class="dwqa-search">
  • 19.
    			<label for="question_title"><?php _e( 'Title', 'dwqa' ) ?></label>
  • 20.
    			<?php $title = isset( $_POST['question-title'] ) ? $_POST['question-title'] : ''; ?>
  • 21.
    			<input type="text" data-nonce="<?php echo wp_create_nonce( '_dwqa_filter_nonce' ) ?>" id="question-title" name="question-title" value="<?php echo esc_attr( $title ) ?>" tabindex="1">
  • 22.
    		</p>
  • 23.
    		<?php $content = isset( $_POST['question-content'] ) ? $_POST['question-content'] : ''; ?>
  • 24.
    		<p><?php dwqa_init_tinymce_editor( array( 'content' => $content, 'textarea_name' => 'question-content', 'id' => 'question-content' ) ) ?></p>
  • 25.
    		<?php global $dwqa_general_settings; ?>
  • 26.
    		<?php if ( isset( $dwqa_general_settings['enable-private-question'] ) && $dwqa_general_settings['enable-private-question'] && is_user_logged_in() ) : ?>
  • 27.
    		<p>
  • 28.
    			<label for="question-status"><?php _e( 'Status', 'dwqa' ) ?></label>
  • 29.
    			<select class="dwqa-select" id="question-status" name="question-status">
  • 30.
    				<optgroup label="<?php _e( 'Who can see this?', 'dwqa' ) ?>">
  • 31.
    					<!-- <option value="publish"><?php _e( 'Public', 'dwqa' ) ?></option> -->
  • 32.
    					<option value="private"><?php _e( 'Only Me &amp; Admin', 'dwqa' ) ?></option>
  • 33.
    				</optgroup>
  • 34.
    			</select>
  • 35.
    		</p>
  • 36.
    		<?php endif; ?>
  • 37.
    		<p>
  • 38.
    			<label for="question-category"><?php _e( 'Category', 'dwqa' ) ?></label>
  • 39.
    			<?php
  • 40.
     
  • 41.
    				if(isset($dwqa_category) && isset($dwqa_category->term_id) && $dwqa_category->term_id>0){
  • 42.
    					echo '<span>'. $dwqa_category->name .'</span>';
  • 43.
    					echo '<input type="hidden" name="question-category" value="'. $dwqa_category->term_id .'">';
  • 44.
    				}else{
  • 45.
    					wp_dropdown_categories( array(
  • 46.
    						'name'          => 'question-category',
  • 47.
    						'id'            => 'question-category',
  • 48.
    						'taxonomy'      => 'dwqa-question_category',
  • 49.
    						// 'show_option_none' => __( 'Select question category', 'dwqa' ),
  • 50.
    						'hide_empty'    => 0,
  • 51.
    						'quicktags'     => array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' ),
  • 52.
    						'selected'      => isset( $_POST['question-category'] ) ? esc_attr( $_POST['question-category'] ) : false,
  • 53.
    					) );
  • 54.
    				}
  • 55.
    			?>
  • 56.
    		</p>
  • 57.
    		<p>
  • 58.
    			<label for="question-tag"><?php _e( 'Tag', 'dwqa' ) ?></label>
  • 59.
    			<?php $tags = isset( $_POST['question-tag'] ) ? $_POST['question-tag'] : ''; ?>
  • 60.
    			<input type="text" class="dwqa-question-tags" name="question-tag" value="<?php echo esc_attr( $tags ) ?>" >
  • 61.
    		</p>
  • 62.
    		<?php if ( dwqa_current_user_can( 'post_question' ) && !is_user_logged_in() ) : ?>
  • 63.
    		<p class="dwqa_hidden_feild" style="display: none;">
  • 64.
    			<label for="_dwqa_anonymous_email"><?php _e( 'Your Email', 'dwqa' ) ?></label>
  • 65.
    			<?php $email = isset( $_POST['_dwqa_anonymous_email'] ) ? $_POST['_dwqa_anonymous_email'] : ''; ?>
  • 66.
    			<input type="email" class="dwqa-question-anonymous-email" name="_dwqa_anonymous_email" value="anonymous@gmail.com" readonly>
  • 67.
    		</p>
  • 68.
    		<p class="dwqa_hidden_feild" style="display: none;">
  • 69.
    			<label for="_dwqa_anonymous_name"><?php _e( 'Your Name', 'dwqa' ) ?></label>
  • 70.
    			<?php $name = isset( $_POST['_dwqa_anonymous_name'] ) ? $_POST['_dwqa_anonymous_name'] : ''; ?>
  • 71.
    			<input type="text" class="dwqa-question-anonymous-name" name="_dwqa_anonymous_name" value="Anonymous" readonly>
  • 72.
    		</p>
  • 73.
    		<?php endif; ?>
  • 74.
    		<?php do_action( 'dwqa_before_question_submit_button' ) ?>
  • 75.
    		<?php wp_nonce_field( '_dwqa_submit_question' ) ?>
  • 76.
    		<?php dwqa_load_template( 'captcha', 'form' ); ?>
  • 77.
    		<?php do_action('dwqa_show_captcha_question')?>
  • 78.
    		<input type="submit" name="dwqa-question-submit" class="dwqa-btn dwqa-btn-primary" value="<?php _e( 'Submit', 'dwqa' ) ?>" >
  • 79.
    		<?php do_action( 'dwqa_after_question_submit_button' ) ?>
  • 80.
    	</form>
  • 81.
    <?php else : ?>
  • 82.
    	<?php if ( is_user_logged_in() ) : ?>
  • 83.
    		<div><?php _e( "You doesn't have permission to post a question", 'dwqa' ) ?></div>
  • 84.
    	<?php else : ?>
  • 85.
    		<?php dwqa_load_template( 'login', 'form' ) ?>
  • 86.
    	<?php endif; ?>
  • 87.
    <?php endif; ?>
  • 88.
    <?php do_action( 'dwqa_after_question_submit_form' ); ?>
<?php /** * The template for displaying single answers * * @package DW Question & Answer * @since DW Question & Answer 1.0.1 */ global $dwqa_shortcode_atts; if ( isset( $dwqa_shortcode_atts['category'] ) && $dwqa_shortcode_atts['category'] !='') { $dwqa_category = get_term_by('slug', $dwqa_shortcode_atts['category'], 'dwqa-question_category'); } ?> <?php do_action( 'dwqa_before_question_submit_form' ); ?> <?php if ( dwqa_current_user_can( 'post_question' ) ) : ?> <form method="post" class="dwqa-content-ask-form" enctype="multipart/form-data"> <p class="dwqa-search"> <label for="question_title"><?php _e( 'Title', 'dwqa' ) ?></label> <?php $title = isset( $_POST['question-title'] ) ? $_POST['question-title'] : ''; ?> <input type="text" data-nonce="<?php echo wp_create_nonce( '_dwqa_filter_nonce' ) ?>" id="question-title" name="question-title" value="<?php echo esc_attr( $title ) ?>" tabindex="1"> </p> <?php $content = isset( $_POST['question-content'] ) ? $_POST['question-content'] : ''; ?> <p><?php dwqa_init_tinymce_editor( array( 'content' => $content, 'textarea_name' => 'question-content', 'id' => 'question-content' ) ) ?></p> <?php global $dwqa_general_settings; ?> <?php if ( isset( $dwqa_general_settings['enable-private-question'] ) && $dwqa_general_settings['enable-private-question'] && is_user_logged_in() ) : ?> <p> <label for="question-status"><?php _e( 'Status', 'dwqa' ) ?></label> <select class="dwqa-select" id="question-status" name="question-status"> <optgroup label="<?php _e( 'Who can see this?', 'dwqa' ) ?>"> <!-- <option value="publish"><?php _e( 'Public', 'dwqa' ) ?></option> --> <option value="private"><?php _e( 'Only Me &amp; Admin', 'dwqa' ) ?></option> </optgroup> </select> </p> <?php endif; ?> <p> <label for="question-category"><?php _e( 'Category', 'dwqa' ) ?></label> <?php if(isset($dwqa_category) && isset($dwqa_category->term_id) && $dwqa_category->term_id>0){ echo '<span>'. $dwqa_category->name .'</span>'; echo '<input type="hidden" name="question-category" value="'. $dwqa_category->term_id .'">'; }else{ wp_dropdown_categories( array( 'name' => 'question-category', 'id' => 'question-category', 'taxonomy' => 'dwqa-question_category', // 'show_option_none' => __( 'Select question category', 'dwqa' ), 'hide_empty' => 0, 'quicktags' => array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' ), 'selected' => isset( $_POST['question-category'] ) ? esc_attr( $_POST['question-category'] ) : false, ) ); } ?> </p> <p> <label for="question-tag"><?php _e( 'Tag', 'dwqa' ) ?></label> <?php $tags = isset( $_POST['question-tag'] ) ? $_POST['question-tag'] : ''; ?> <input type="text" class="dwqa-question-tags" name="question-tag" value="<?php echo esc_attr( $tags ) ?>" > </p> <?php if ( dwqa_current_user_can( 'post_question' ) && !is_user_logged_in() ) : ?> <p class="dwqa_hidden_feild" style="display: none;"> <label for="_dwqa_anonymous_email"><?php _e( 'Your Email', 'dwqa' ) ?></label> <?php $email = isset( $_POST['_dwqa_anonymous_email'] ) ? $_POST['_dwqa_anonymous_email'] : ''; ?> <input type="email" class="dwqa-question-anonymous-email" name="_dwqa_anonymous_email" value="anonymous@gmail.com" readonly> </p> <p class="dwqa_hidden_feild" style="display: none;"> <label for="_dwqa_anonymous_name"><?php _e( 'Your Name', 'dwqa' ) ?></label> <?php $name = isset( $_POST['_dwqa_anonymous_name'] ) ? $_POST['_dwqa_anonymous_name'] : ''; ?> <input type="text" class="dwqa-question-anonymous-name" name="_dwqa_anonymous_name" value="Anonymous" readonly> </p> <?php endif; ?> <?php do_action( 'dwqa_before_question_submit_button' ) ?> <?php wp_nonce_field( '_dwqa_submit_question' ) ?> <?php dwqa_load_template( 'captcha', 'form' ); ?> <?php do_action('dwqa_show_captcha_question')?> <input type="submit" name="dwqa-question-submit" class="dwqa-btn dwqa-btn-primary" value="<?php _e( 'Submit', 'dwqa' ) ?>" > <?php do_action( 'dwqa_after_question_submit_button' ) ?> </form> <?php else : ?> <?php if ( is_user_logged_in() ) : ?> <div><?php _e( "You doesn't have permission to post a question", 'dwqa' ) ?></div> <?php else : ?> <?php dwqa_load_template( 'login', 'form' ) ?> <?php endif; ?> <?php endif; ?> <?php do_action( 'dwqa_after_question_submit_form' ); ?>

Copy Code to Clipboard Raw

Sign-in or Create a Free Account.

Snippi uses Twitter or Facebook to register and create accounts. Registration will enable you to keep track of your snippets. We never spam your timeline or wall. Ever.

Sign-in with Facebook Sign-in with Twitter