function dwqa_valid_captcha($type)
{
    global $dwqa_general_settings;
    if ('question' == $type && !dwqa_is_captcha_enable_in_submit_question()) {
        return true;
    }
    if ('single-question' == $type && !dwqa_is_captcha_enable_in_single_question()) {
        return true;
    }
    return apply_filters('dwqa_valid_captcha', false);
}
function dwqa_submit_answer_form()
{
    ?>
	<div id="dwqa-add-answers" class="dwqa-answer-form">
		<h3 class="dwqa-headline"><?php 
    _e('Answer this Question', 'dwqa');
    ?>
</h3>
	<?php 
    if (isset($_GET['errors'])) {
        echo '<p class="alert">';
        echo urldecode(esc_url($_GET['errors'])) . '<br>';
        echo '</p>';
    }
    ?>
	<form action="<?php 
    echo admin_url('admin-ajax.php?action=dwqa-add-answer');
    ?>
" name="dwqa-answer-question-form" id="dwqa-answer-question-form" method="post">
	<?php 
    add_filter('tiny_mce_before_init', 'dwqa_paste_srtip_disable');
    $editor = array('wpautop' => false, 'id' => 'dwqa-answer-question-editor', 'textarea_name' => 'answer-content', 'rows' => 2);
    ?>
	<?php 
    dwqa_init_tinymce_editor($editor);
    ?>
	<?php 
    do_action('dwqa_submit_answer_ui', get_the_ID());
    ?>
	
	<script type="text/javascript">
	 var RecaptchaOptions = {
		theme : 'clean'
	 };
	 </script>
	<?php 
    global $dwqa_general_settings;
    if (dwqa_is_captcha_enable_in_single_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 class="form-buttons">
			<input type="submit" name="submit-answer" id="submit-answer" value="<?php 
    _e('Add answer', 'dwqa');
    ?>
" class="dwqa-btn dwqa-btn-primary" />

			<?php 
    if (current_user_can('manage_options')) {
        ?>
			<input type="submit" name="submit-answer" id="save-draft-answer" value="<?php 
        _e('Save draft', 'dwqa');
        ?>
" class="dwqa-btn dwqa-btn-default" />
			<?php 
    }
    ?>
		</div>
		<div class="dwqa-privacy">
			<input type="hidden" name="privacy" value="publish">
			<span class="dwqa-change-privacy">
				<div class="dwqa-btn-group">
					<button type="button" class="dropdown-toggle" ><span><?php 
    echo 'private' == get_post_status() ? '<i class="fa fa-lock"></i> ' . __('Private', 'dwqa') : '<i class="fa fa-globe"></i> ' . __('Public', 'dwqa');
    ?>
</span> <i class="fa fa-caret-down"></i></button>
					<div class="dwqa-dropdown-menu">
						<div class="dwqa-dropdown-caret">
							<span class="dwqa-caret-outer"></span>
							<span class="dwqa-caret-inner"></span>
						</div>
						<ul role="menu">
							<li data-privacy="publish" class="current" title="<?php 
    _e('Everyone can see', 'dwqa');
    ?>
"><a href="#"><i class="fa fa-globe"></i> <?php 
    _e('Public', 'dwqa');
    ?>
</a></li>
							<li data-privacy="private" title="<?php 
    _e('Only Author and Administrator can see', 'dwqa');
    ?>
"><a href="#"><i class="fa fa-lock"></i> <?php 
    _e('Private', 'dwqa');
    ?>
</a></li>
						</ul>
					</div>
				</div>
			</span>
		</div>
	</form>
	</div>
	<?php 
}
Example #3
0
<script type="text/javascript">
 var RecaptchaOptions = {
	theme : 'clean'
 };
 </script>
<?php 
global $dwqa_general_settings, $dwqa_options;
if (is_singular('dwqa-question') && dwqa_is_captcha_enable_in_single_question() || isset($dwqa_options['pages']['submit-question']) && is_page($dwqa_options['pages']['submit-question']) && 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">';
    $is_ssl = is_ssl();
    echo recaptcha_get_html($public_key, null, $is_ssl);
    echo '<br></div>';
}
function dwqa_valid_captcha($type)
{
    if ('question' == $type && !dwqa_is_captcha_enable_in_submit_question()) {
        return true;
    }
    if ('single-question' == $type && !dwqa_is_captcha_enable_in_single_question()) {
        return true;
    }
    global $dwqa_general_settings;
    $private_key = isset($dwqa_general_settings['captcha-google-private-key']) ? $dwqa_general_settings['captcha-google-private-key'] : '';
    if (!isset($_POST["recaptcha_challenge_field"]) || !isset($_POST['recaptcha_response_field'])) {
        return false;
    }
    $resp = recaptcha_check_answer($private_key, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
    if ($resp->is_valid) {
        return true;
    }
    return false;
}
<?php

if ('dwqa-question' == get_post_type() && dwqa_is_captcha_enable_in_single_question() || dwqa_is_ask_form() && dwqa_is_captcha_enable_in_submit_question()) {
    ?>
<p class="dwqa-captcha">
	<?php 
    $number_1 = mt_rand(0, 20);
    $number_2 = mt_rand(0, 20);
    ?>
	<span class="dwqa-number-one"><?php 
    echo esc_attr($number_1);
    ?>
</span>
	<span class="dwqa-plus">&#43;</span>
	<span class="dwqa-number-one"><?php 
    echo esc_attr($number_2);
    ?>
</span>
	<span class="dwqa-plus">&#61;</span>
	<input type="text" name="dwqa-captcha-result" id="dwqa-captcha-result" value="" placeholder="<?php 
    _e('Enter the result', 'dwqa');
    ?>
">
	<input type="hidden" name="dwqa-captcha-number-1" id="dwqa-captcha-number-1" value="<?php 
    echo esc_attr($number_1);
    ?>
">
	<input type="hidden" name="dwqa-captcha-number-2" id="dwqa-captcha-number-2" value="<?php 
    echo esc_attr($number_2);
    ?>
">
?>
	<?php 
dwqa_init_tinymce_editor($editor);
?>
	<?php 
do_action('dwqa_submit_answer_ui', get_the_ID());
?>
	
	<script type="text/javascript">
	 var RecaptchaOptions = {
		theme : 'clean'
	 };
	 </script>
	<?php 
global $dwqa_general_settings;
if (dwqa_is_captcha_enable_in_single_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 class="form-buttons">
			<input type="submit" name="submit-answer" id="submit-answer" value="<?php 
_e('Add answer', 'dwqa');
?>
" class="dwqa-btn dwqa-btn-primary" />

			<?php 
if (current_user_can('edit_posts')) {
    ?>