Example #1
0
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());
?>
	
	<?php 
dwqa_load_template('captcha', 'form');
?>
		<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 
Example #2
0
    public function ajax_create_update_question_editor()
    {
        if (!isset($_POST['question'])) {
            return false;
        }
        extract($_POST);
        ob_start();
        ?>
		<form action="<?php 
        echo admin_url('admin-ajax.php?action=dwqa-update-question');
        ?>
" method="post">
			<?php 
        wp_nonce_field('_dwqa_update_question');
        ?>

			<?php 
        if ('draft' == get_post_status($question) && dwqa_current_user_can('edit_question')) {
            ?>
			<input type="hidden" name="dwqa-action-draft" value="true" >
			<?php 
        }
        ?>
 
			<input type="hidden" name="dwqa-action" value="update-question" >
			<input type="hidden" name="question" value="<?php 
        echo $question;
        ?>
">
			<?php 
        $question = get_post($question);
        ?>
			<input type="text" style="width:100%" name="dwqa-question-title" id="dwqa-question-title" value="<?php 
        echo $question->post_title;
        ?>
">
			<?php 
        $question_content = apply_filters('dwqa_prepare_edit_question_content', $question->post_content);
        add_filter('dwqa_prepare_edit_question_content', 'wpautop');
        dwqa_init_tinymce_editor(array('content' => $question_content, 'textarea_name' => 'dwqa-question-content', 'wpautop' => false));
        ?>
			<p class="dwqa-question-form-btn">
				<input type="submit" name="submit-question" class="dwqa-btn dwqa-btn-default" value="<?php 
        _e('Update', 'dwqa');
        ?>
">
				<a type="button" class="question-edit-cancel dwqa-btn dwqa-btn-link" ><?php 
        _e('Cancel', 'dwqa');
        ?>
</a>
				<?php 
        if ('draft' == get_post_status($question) && current_user_can('manage_options')) {
            ?>
				<input type="submit" name="submit-question" class="btn btn-primary btn-small" value="<?php 
            _e('Publish', 'dwqa');
            ?>
">
				<?php 
        }
        ?>
			</p>
		</form>
		<?php 
        $editor = ob_get_contents();
        ob_end_clean();
        wp_send_json_success(array('editor' => $editor));
    }
" value="<?php 
echo isset($_POST['question-title']) ? esc_html($_POST['question-title']) : '';
?>
" />
			<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('content' => isset($_POST['question-content']) ? wp_kses_data($_POST['question-content']) : '', 'id' => 'dwqa-question-content-editor', 'textarea_name' => 'question-content', 'media_buttons' => true));
?>
			</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>
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 
}
		<?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 $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']) {
    ?>
	<p>
		<label for="question-status"><?php 
    _e('Status', 'dwqa');
    ?>
</label>
		<select class="dwqa-select" id="question-status" name="question-status">
			<optgroup label="<?php 
    public function ajax_create_update_question_editor()
    {
        if (!isset($_POST['question'])) {
            return false;
        }
        extract($_POST);
        ob_start();
        ?>
		<form action="<?php 
        echo admin_url('admin-ajax.php?action=dwqa-update-question');
        ?>
" method="post">
			<?php 
        wp_nonce_field('_dwqa_update_question');
        ?>

			<?php 
        if ('draft' == get_post_status($question) && dwqa_current_user_can('edit_question')) {
            ?>
			<input type="hidden" name="dwqa-action-draft" value="true" >
			<?php 
        }
        ?>
 
			<input type="hidden" name="dwqa-action" value="update-question" >
			<input type="hidden" name="question" value="<?php 
        echo $question;
        ?>
">
			<?php 
        $question = get_post($question);
        ?>
			<input type="text" style="width:100%" name="dwqa-question-title" id="dwqa-question-title" value="<?php 
        echo $question->post_title;
        ?>
">
			<?php 
        $question_content = apply_filters('dwqa_prepare_edit_question_content', $question->post_content);
        dwqa_init_tinymce_editor(array('content' => $question_content, 'textarea_name' => 'dwqa-question-content', 'wpautop' => false));
        ?>
			<script type="text/javascript">
				var id = 'dwqa-custom-content-editor';
				var settings = tinyMCEPreInit.mceInit['dwqa-answer-question-editor'];

                    settings.elements = id;
                    settings.body_class = id + ' post-type-dwqa-question';
                    settings.editor_selector = id; // deprecated in TinyMCE 4.x
                    settings.selector = '#' + id;
                    //init tinymce
                    if( tinyMCE.get(id) ) {
                        tinymce.remove('#'+id);   
                    }
                    tinyMCE.init(settings);
			</script>
			<p class="dwqa-question-form-btn">
				<input type="submit" name="submit-question" class="dwqa-btn dwqa-btn-default" value="<?php 
        _e('Update', 'dwqa');
        ?>
">
				<a type="button" class="question-edit-cancel dwqa-btn dwqa-btn-link" ><?php 
        _e('Cancel', 'dwqa');
        ?>
</a>
				<?php 
        if ('draft' == get_post_status($question) && current_user_can('manage_options')) {
            ?>
				<input type="submit" name="submit-question" class="btn btn-primary btn-small" value="<?php 
            _e('Publish', 'dwqa');
            ?>
">
				<?php 
        }
        ?>
			</p>
		</form>
		<?php 
        $editor = apply_filters('dwqa_question_edit_content_editor', ob_get_contents(), $_POST);
        ob_end_clean();
        wp_send_json_success(array('editor' => $editor));
    }
            <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', 'edd_dwqa_categories');
?>
</label>	

                <?php 
dwqa_init_tinymce_editor(array('content' => isset($_POST['question-content']) ? stripslashes(htmlentities($_POST['question-content'])) : '', 'id' => 'dwqa-question-content-editor', 'textarea_name' => 'question-content', 'media_buttons' => true));
?>
	

            </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.', 'edd_dwqa_categories');
function dwqa_ajax_create_editor()
{
    if (!isset($_POST['answer_id']) || !isset($_POST['question'])) {
        return false;
    }
    extract($_POST);
    ob_start();
    ?>
    <form action="<?php 
    echo admin_url('admin-ajax.php?action=dwqa-add-answer');
    ?>
" method="post">
        <?php 
    wp_nonce_field('_dwqa_add_new_answer');
    ?>

        <?php 
    if ('draft' == get_post_status($answer_id) && current_user_can('manage_options')) {
        ?>
        <input type="hidden" name="dwqa-action-draft" value="true" >
        <?php 
    }
    ?>
 
        <input type="hidden" name="dwqa-action" value="update-answer" >
        <input type="hidden" name="answer-id" value="<?php 
    echo $answer_id;
    ?>
">
        <input type="hidden" name="question" value="<?php 
    echo $question;
    ?>
">
        <?php 
    $answer = get_post($answer_id);
    dwqa_init_tinymce_editor(array('content' => htmlentities($answer->post_content, ENT_COMPAT | ENT_HTML5, get_option('blog_charset')), 'textarea_name' => 'answer-content', 'wpautop' => false));
    ?>
        <p class="dwqa-answer-form-btn">
            <input type="submit" name="submit-answer" class="dwqa-btn dwqa-btn-default" value="<?php 
    _e('Update', 'dwqa');
    ?>
">
            <a type="button" class="answer-edit-cancel dwqa-btn dwqa-btn-link" ><?php 
    _e('Cancel', 'dwqa');
    ?>
</a>
            <?php 
    if ('draft' == get_post_status($answer_id) && current_user_can('manage_options')) {
        ?>
            <input type="submit" name="submit-answer" class="btn btn-primary btn-small" value="<?php 
        _e('Publish', 'dwqa');
        ?>
">
            <?php 
    }
    ?>
        </p>
        <div class="dwqa-privacy">
            <input type="hidden" name="privacy" value="publish">
            <span class="dwqa-current-privacy"><i class="fa fa-globe"></i> <?php 
    _e('Public', 'dwqa');
    ?>
</span>
            <span class="dwqa-change-privacy">
                <div class="dwqa-btn-group">
                    <button class="dropdown-toggle" type="button"><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" <?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>
    <?php 
    $editor = ob_get_contents();
    ob_end_clean();
    wp_send_json_success(array('editor' => $editor));
}
	<?php 
do_action('dwqa_before_answer_submit_form');
?>
	<div class="dwqa-answer-form-title"><?php 
_e('Your Answer', 'dwqa');
?>
</div>
	<form name="dwqa-answer-form" id="dwqa-answer-form" method="post">
		<?php 
dwqa_print_notices();
?>
		<?php 
$content = isset($_POST['answer-content']) ? $_POST['answer-content'] : '';
?>
		<?php 
dwqa_init_tinymce_editor(array('content' => $content, 'textarea_name' => 'answer-content', 'id' => 'dwqa-answer-content'));
?>
		<?php 
dwqa_load_template('captcha', 'form');
?>

		<?php 
if (dwqa_current_user_can('post_answer') && !is_user_logged_in()) {
    ?>
		<p>
			<label for="user-email"><?php 
    _e('Your Email', 'dwqa');
    ?>
</label>
			<?php 
    $email = isset($_POST['user-email']) ? $_POST['user-email'] : '';
    _e('Title', 'dwqa');
    ?>
</label>
		<input type="text" name="question_title" value="<?php 
    echo $title;
    ?>
" tabindex="1">
	</p>
	<?php 
}
?>
	<?php 
$content = call_user_func('dwqa_' . $type . '_get_edit_content', $edit_id);
?>
	<p><?php 
dwqa_init_tinymce_editor(array('content' => $content, 'textarea_name' => $type . '_content'));
?>
</p>
	<?php 
if ('dwqa-question' == get_post_type($edit_id)) {
    ?>
	<p>
		<label for="question-category"><?php 
    _e('Category', 'dwqa');
    ?>
</label>
		<?php 
    $category = wp_get_post_terms($edit_id, 'dwqa-question_category');
    ?>
		<?php 
    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($category[0]->term_id) ? $category[0]->term_id : false));
Example #11
0
    public function ajax_create_update_question_editor()
    {
        check_ajax_referer('_dwqa_edit_question', 'nonce');
        if (!isset($_POST['post'])) {
            return false;
        }
        extract($_POST);
        $title = get_the_title($post);
        $title = apply_filters('dwqa_prepare_edit_question_title', $title, $post);
        $content = get_post_field('post_content', $post);
        $content = apply_filters('dwqa_prepare_edit_question_content', $title, $post);
        $args = array('content' => $content, 'id' => 'dwqa-question-edit-form', 'textarea_name' => 'question-content-edit');
        ob_start();
        ?>
		<form method="post" class="dwqa-answer-form">
			<input name="question_title" value="<?php 
        echo $title;
        ?>
">
			<?php 
        dwqa_init_tinymce_editor($args);
        ?>
			<input type="hidden" name="question_id" value="<?php 
        echo esc_attr($post);
        ?>
">
		</form>
		<?php 
        $editor = apply_filters('dwqa_question_edit_content_editor', ob_get_contents(), $_POST);
        ob_end_clean();
        wp_send_json_success(array('editor' => $editor));
    }