Created
March 18, 2014 10:04
-
-
Save rambuvn/9617066 to your computer and use it in GitHub Desktop.
The shortcode for show question of one category
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function dwqa_submit_question_form_varius_category_shortcode($atts){ | |
global $dwqa_sript_vars, $script_version; | |
extract( shortcode_atts( array( | |
'category' => 0 | |
), $atts ) ); | |
if( ! $category ) { | |
return false; | |
} | |
$term = get_term( $category, 'dwqa-question_category' ); | |
if( is_wp_error($term) ) { | |
return false; | |
} | |
ob_start(); | |
echo '<div class="dwqa-container" >'; | |
?> | |
<div id="submit-question" class="dwqa-submit-question"> | |
<?php | |
global $dwqa_options, $dwqa_current_error; | |
if( is_wp_error( $dwqa_current_error ) ) { | |
$error_messages = $dwqa_current_error->get_error_messages(); | |
if( !empty($error_messages) ) { | |
echo '<div class="alert alert-error">'; | |
foreach ($error_messages as $message) { | |
echo $message; | |
} | |
echo '</div>'; | |
} | |
} | |
?> | |
<form action="" name="dwqa-submit-question-form" id="dwqa-submit-question-form" method="post"> | |
<div class="question-advance"> | |
<div class="question-meta"> | |
<div class="select-category"> | |
<label for="question-category"><?php _e('Question Category','dwqa') ?></label><input type="hidden" name="question-category" id="question-category" value="<?php echo $term->term_id ?>"> | |
<input style="width:100%" type="text" name="question-category-name" id="question-category-name" value="<?php echo $term->name ?>" disabled="disabled"> | |
</div> | |
<div class="input-tag"> | |
<label for="question-tag"><?php _e('Question Tags','dwqa') ?></label> | |
<input type="text" name="question-tag" id="question-tag" placeholder="<?php _e('tag 1, tag 2,...','dwqa') ?>" /> | |
</div> | |
</div> | |
</div> | |
<div class="input-title"> | |
<label for="question-title"><?php _e('Your question','dwqa') ?> *</label> | |
<input type="text" name="question-title" id="question-title" placeholder="<?php _e('How to...','dwqa') ?>" autocomplete="off" data-nonce="<?php echo wp_create_nonce( '_dwqa_filter_nonce' ) ?>" /> | |
<span class="dwqa-search-loading dwqa-hide"></span> | |
<span class="dwqa-search-clear fa fa-times dwqa-hide"></span> | |
</div> | |
<div class="question-advance"> | |
<div class="input-content"> | |
<label for="question-content"><?php _e('Question details','dwqa') ?></label> | |
<?php dwqa_init_tinymce_editor( array( 'id' => 'dwqa-question-content-editor', 'textarea_name' => 'question-content' ) ); ?> | |
</div> | |
<?php if( isset($dwqa_options['enable-private-question']) && $dwqa_options['enable-private-question'] ) : ?> | |
<div class="checkbox-private"> | |
<label for="private-message"><input type="checkbox" name="private-message" id="private-message" value="true"> <?php _e('Post this Question as Private.','dwqa') ?> <i class="fa fa-question-circle" title="<?php _e('Only you as Author and Admin can see the question', 'dwqa') ?>"></i></label> | |
</div> | |
<?php endif; ?> | |
<div class="question-signin"> | |
<?php do_action( 'dwqa_submit_question_ui' ); ?> | |
</div> | |
<script type="text/javascript"> | |
var RecaptchaOptions = { | |
theme : 'clean' | |
}; | |
</script> | |
<?php | |
global $dwqa_general_settings; | |
if( dwqa_is_captcha_enable_in_submit_question() ) { | |
$public_key = isset($dwqa_general_settings['captcha-google-public-key']) ? $dwqa_general_settings['captcha-google-public-key'] : ''; | |
echo '<div class="google-recaptcha">'; | |
echo recaptcha_get_html($public_key); | |
echo '<br></div>'; | |
} | |
?> | |
</div> | |
<div class="form-submit"> | |
<input type="submit" value="<?php _e('Ask Question','dwqa') ?>" class="dwqa-btn dwqa-btn-success btn-submit-question" /> | |
</div> | |
</form> | |
</div> | |
<?php | |
echo '</div>'; | |
$html = ob_get_contents(); | |
ob_end_clean(); | |
wp_enqueue_script( 'dwqa-submit-question', DWQA_URI . 'assets/js/dwqa-submit-question.js', array( 'jquery' ), $script_version, true ); | |
wp_localize_script( 'dwqa-submit-question', 'dwqa', $dwqa_sript_vars ); | |
return str_replace("\n", '', $html ); | |
} | |
add_shortcode( 'dwqa-submit-question-form-2', 'dwqa_submit_question_form_varius_category_shortcode' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment