public function submit_question_form_shortcode() { global $dwqa, $dwqa_sript_vars, $script_version; ob_start(); $dwqa->template->remove_all_filters('the_content'); echo '<div class="dwqa-container" >'; dwqa_load_template('question', 'submit-form'); echo '</div>'; $html = ob_get_contents(); $dwqa->template->restore_all_filters('the_content'); ob_end_clean(); wp_enqueue_script('dwqa-submit-question', DWQA_URI . 'inc/templates/default/assets/js/dwqa-submit-question.js', array('jquery'), $script_version, true); wp_localize_script('dwqa-submit-question', 'dwqa', $dwqa_sript_vars); return $this->sanitize_output($html); }
public function submit_question_form_shortcode() { global $dwqa_sript_vars, $script_version, $dwqa_template_compat; ob_start(); $dwqa_template_compat->remove_all_filters('the_content'); echo '<div class="dwqa-container" >'; if (dwqa_current_user_can('post_question')) { dwqa_load_template('question', 'submit-form'); } else { echo '<p class="alert alert-error">' . __('You do not have permission to submit question.', 'dwqa') . '</p>'; } echo '</div>'; $html = ob_get_contents(); $dwqa_template_compat->restore_all_filters('the_content'); ob_end_clean(); wp_enqueue_script('dwqa-submit-question', DWQA_URI . 'inc/templates/default/assets/js/dwqa-submit-question.js', array('jquery'), $script_version, true); wp_localize_script('dwqa-submit-question', 'dwqa', $dwqa_sript_vars); return $this->sanitize_output($html); }
function dwqa_submit_question_form() { _deprecated_function(__FUNCTION__, '1.2.6', 'dwqa_load_template( "submit-question", "form" )'); dwqa_load_template('submit-question', 'form'); }
</div> <?php } ?> <!-- Question Tags --> <?php do_action('dwqa-question-content-footer'); ?> <!-- Question footer --> <div class="dwqa-comments"> <?php comments_template(); ?> </div> </div><!-- end question --> <div id="dwqa-answers"> <?php dwqa_load_template('answers'); ?> </div><!-- end dwqa-add-answers --> </div><!-- end dwqa-single-question --> <?php } // end of the loop. ?> <?php }
/** * AJAX: To make filter questions for plugins * @return string JSON */ public function filter_question() { if (!isset($_POST['nonce'])) { wp_die(0); } if (!check_ajax_referer('_dwqa_filter_nonce', 'nonce', false)) { wp_die(0); } if (!isset($_POST['type'])) { wp_die(0); } // Make an query for global $wpdb; if (!defined('DWQA_FILTERING')) { define('DWQA_FILTERING', true); } $this->filter = wp_parse_args($_POST, $this->filter); //query post filter add_filter('posts_join', array($this, 'join_postmeta_count_answers')); add_filter('posts_orderby', array($this, 'edit_posts_orderby')); add_filter('posts_where', array($this, 'posts_where')); $questions = $this->get_questions(); //remove query post filter remove_filter('posts_join', array($this, 'join_postmeta_count_answers')); remove_filter('posts_orderby', array($this, 'edit_posts_orderby')); remove_filter('posts_where', array($this, 'posts_where')); // Print content of questions if ($questions->have_posts()) { global $post; $pages_total = $questions->found_posts; $pages_number = ceil($pages_total / (int) $this->filter['posts_per_page']); $start_page = isset($this->filter['paged']) && $this->filter['paged'] > 2 ? $this->filter['paged'] - 2 : 1; if ($pages_number > 1) { $link = get_post_type_archive_link('dwqa-question'); ob_start(); echo '<ul data-pages="' . $pages_number . '" >'; echo '<li class="prev' . ($this->filter['paged'] == 1 ? ' dwqa-hide' : '') . '"><a href="javascript:void( 0 );">Prev</a></li>'; if ($start_page > 1) { echo '<li><a href="' . esc_url(add_query_arg('paged', 1, $link)) . '">1</a></li><li class="dot"><span>...</span></li>'; } for ($i = $start_page; $i < $start_page + 5; $i++) { if ($pages_number < $i) { break; } if ($i == $this->filter['paged']) { echo '<li class="active"><a href="' . $link . '">' . $i . '</a></li>'; } else { echo '<li><a href="' . esc_url(add_query_arg('paged', $i, $link)) . '">' . $i . '</a></li>'; } } if ($i - 1 < $pages_number) { echo '<li class="dot"><span>...</span></li><li><a href="' . esc_url(add_query_arg('paged', $pages_number, $link)) . '"> ' . $pages_number . '</a></li>'; } echo '<li class="next' . ($this->filter['paged'] == $pages_number ? ' dwqa-hide' : '') . '"><a href="javascript:void( 0 );">' . __('Next', 'dwqa') . '</a></li>'; echo '</ul>'; $pagenavigation = ob_get_contents(); ob_end_clean(); } ob_start(); while ($questions->have_posts()) { $questions->the_post(); dwqa_load_template('content', 'question'); } $results = ob_get_contents(); ob_end_clean(); } else { // Notthing found ob_start(); if (!dwqa_current_user_can('read_question')) { echo '<div class="alert">' . __('You do not have permission to view questions', 'dwqa') . '</div>'; } echo '<p class="not-found">'; _e('Sorry, but nothing matched your filter. ', 'dwqa'); if (is_user_logged_in()) { global $dwqa_options; if (isset($dwqa_options['pages']['submit-question'])) { $submit_link = get_permalink($dwqa_options['pages']['submit-question']); if ($submit_link) { printf('%s <a href="%s">%s</a>', __('You can ask question', 'dwqa'), $submit_link, __('here', 'dwqa')); } } } else { printf('%s <a href="%s">%s</a>', __('Please', 'dwqa'), wp_login_url(get_post_type_archive_link('dwqa-question')), __('Login', 'dwqa')); $register_link = wp_register('', '', false); if (!empty($register_link) && $register_link) { echo __(' or', 'dwqa') . ' ' . $register_link; } _e(' to submit question.', 'dwqa'); } echo '</p>'; $results = ob_get_contents(); ob_end_clean(); } wp_send_json_success(array('results' => $results, 'pagenavi' => isset($pagenavigation) ? $pagenavigation : '')); wp_die(); }
function dwqa_content_end_wrapper() { echo '</div>'; dwqa_load_template('content', 'end-wrapper'); wp_reset_query(); }
public function question_content($template) { global $dwqa_options; $template_folder = trailingslashit(get_template_directory()); if (is_singular('dwqa-question')) { ob_start(); remove_filter('comments_open', array($this, 'close_default_comment')); echo '<div class="dwqa-container" >'; dwqa_load_template('single', 'question'); echo '</div>'; $content = ob_get_contents(); add_filter('comments_open', array($this, 'close_default_comment')); ob_end_clean(); // Reset post global $post, $current_user; $this->reset_content(array('ID' => $post->ID, 'post_title' => $post->post_title, 'post_author' => 0, 'post_date' => $post->post_date, 'post_content' => $content, 'post_type' => 'dwqa-question', 'post_status' => $post->post_status, 'is_single' => true)); $single_template = isset($dwqa_options['single-template']) ? $dwqa_options['single-template'] : false; $this->remove_all_filters('the_content'); if ($single_template && file_exists($template_folder . $single_template)) { return $template_folder . $single_template; } else { return dwqa_get_template('single.php'); } } if (is_tax('dwqa-question_category') || is_tax('dwqa-question_tag') || is_post_type_archive('dwqa-question') || is_post_type_archive('dwqa-answer')) { ob_start(); echo '<div class="dwqa-container" >'; dwqa_load_template('question', 'list'); echo '</div>'; $content = ob_get_contents(); ob_end_clean(); $post_id = isset($dwqa_options['pages']['archive-question']) ? $dwqa_options['pages']['archive-question'] : 0; if ($post_id) { $post = get_post($post_id); $this->reset_content(array('ID' => $post_id, 'post_title' => $post->post_title, 'post_author' => 0, 'post_date' => $post->post_date, 'post_content' => $content, 'post_type' => 'dwqa-question', 'post_status' => $post->post_status, 'is_archive' => true, 'comment_status' => 'closed')); $this->remove_all_filters('the_content'); return dwqa_get_template('page.php'); } } return $template; }
<?php /** * Template use for display list of question * * @since DW Question Answer 1.0 */ get_header('dwqa'); ?> <?php do_action('dwqa_before_page'); ?> <?php dwqa_load_template('question', 'list'); ?> <?php do_action('dwqa_after_page'); ?> <?php get_footer('dwqa');
function dwqa_archive_question() { global $script_version, $dwqa_sript_vars; ob_start(); ?> <div class="dwqa-container" > <div id="archive-question" class="dw-question"> <div class="dwqa-list-question"> <div class="loading"></div> <div class="dwqa-search"> <form action="" class="dwqa-search-form"> <input class="dwqa-search-input" placeholder="<?php _e('Search', 'dwqa'); ?> "> <span class="dwqa-search-submit fa fa-search show"></span> <span class="dwqa-search-loading dwqa-hide"></span> <span class="dwqa-search-clear fa fa-times dwqa-hide"></span> </form> </div> <div class="filter-bar"> <?php wp_nonce_field('_dwqa_filter_nonce', '_filter_wpnonce', false); ?> <?php global $dwqa_options; $submit_question_link = get_permalink($dwqa_options['pages']['submit-question']); ?> <?php if ($dwqa_options['pages']['submit-question'] && $submit_question_link) { ?> <a href="<?php echo $submit_question_link; ?> " class="dwqa-btn dwqa-btn-success"><?php _e('Ask a question', 'dwqa'); ?> </a> <?php } ?> <div class="filter"> <li class="status"> <?php $selected = isset($_GET['status']) ? $_GET['status'] : 'all'; ?> <ul> <li><?php _e('Status:'); ?> </li> <li class="<?php echo $selected == 'all' ? 'active' : ''; ?> status-all" data-type="all"> <a href="#"><?php _e('All', 'dwqa'); ?> </a> </li> <li class="<?php echo $selected == 'open' ? 'active' : ''; ?> status-open" data-type="open"> <a href="#"><?php echo current_user_can('edit_posts') ? __('Need Answer', 'dwqa') : __('Open', 'dwqa'); ?> </a> </li> <li class="<?php echo $selected == 'replied' ? 'active' : ''; ?> status-replied" data-type="replied"> <a href="#"><?php _e('Answered', 'dwqa'); ?> </a> </li> <li class="<?php echo $selected == 'resolved' ? 'active' : ''; ?> status-resolved" data-type="resolved"> <a href="#"><?php _e('Resolved', 'dwqa'); ?> </a> </li> <li class="<?php echo $selected == 'closed' ? 'active' : ''; ?> status-closed" data-type="closed"> <a href="#"><?php _e('Closed', 'dwqa'); ?> </a> </li> <?php if (dwqa_current_user_can('edit_question')) { ?> <li class="<?php echo $selected == 'overdue' ? 'active' : ''; ?> status-overdue" data-type="overdue"><a href="#"><?php _e('Overdue', 'dwqa'); ?> </a></li> <li class="<?php echo $selected == 'pending-review' ? 'active' : ''; ?> status-pending-review" data-type="pending-review"><a href="#"><?php _e('Queue', 'dwqa'); ?> </a></li> <?php } ?> </ul> </li> </div> <div class="filter sort-by"> <div class="filter-by-category select"> <?php $selected = false; $taxonomy = get_query_var('taxonomy'); if ($taxonomy && 'dwqa-question_category' == $taxonomy) { $term_name = get_query_var($taxonomy); $term = get_term_by('slug', $term, $taxonomy); $selected = $term->term_id; } else { $question_category_rewrite = get_option('dwqa-question-category-rewrite', 'question-category'); $question_category_rewrite = $question_category_rewrite ? $question_category_rewrite : 'question-category'; $selected = isset($_GET[$question_category_rewrite]) ? $_GET[$question_category_rewrite] : 'all'; } $selected_label = __('Select a category', 'dwqa'); if ($selected && $selected != 'all') { $selected_term = get_term_by('id', $selected, 'dwqa-question_category'); $selected_label = $selected_term->name; } ?> <span class="current-select"><?php echo $selected_label; ?> </span> <ul id="dwqa-filter-by-category" class="category-list" data-selected="<?php echo $selected; ?> "> <?php wp_list_categories(array('show_option_all' => __('All', 'dwqa'), 'show_option_none' => __('Empty', 'dwqa'), 'taxonomy' => 'dwqa-question_category', 'hide_empty' => 0, 'show_count' => 0, 'title_li' => '', 'walker' => new Walker_Category_DWQA())); ?> </ul> </div> <?php $tag_field = ''; if ($taxonomy == 'dwqa-question_tag') { $selected = false; if ($taxonomy) { $term_name = get_query_var($taxonomy); $term = get_term_by('slug', $term_name, $taxonomy); $selected = $term->term_id; } elseif ('dwqa-question_category' == $taxonomy) { $question_tag_rewrite = get_option('dwqa-question-tag-rewrite', 'question-tag'); $question_tag_rewrite = $question_tag_rewrite ? $question_tag_rewrite : 'question-tag'; $selected = isset($_GET[$question_tag_rewrite]) ? $_GET[$question_tag_rewrite] : 'all'; } if (isset($selected) && $selected != 'all') { $tag_field = '<input type="hidden" name="dwqa-filter-by-tags" id="dwqa-filter-by-tags" value="' . $selected . '" >'; } } $tag_field = apply_filters('dwqa_filter_bar', $tag_field); echo $tag_field; ?> <ul class="order"> <li class="most-reads <?php echo isset($_GET['orderby']) && $_GET['orderby'] == 'views' ? 'active' : ''; ?> " data-type="views" > <span><?php _e('View', 'dwqa'); ?> </span> <i class="fa fa-sort <?php echo isset($_GET['orderby']) && $_GET['orderby'] == 'views' ? 'icon-sort-up' : ''; ?> "></i> </li> <li class="most-answers <?php echo isset($_GET['orderby']) && $_GET['orderby'] == 'answers' ? 'active' : ''; ?> " data-type="answers" > <span href="#"><?php _e('Answer', 'dwqa'); ?> </span> <i class="fa fa-sort <?php echo isset($_GET['orderby']) && $_GET['orderby'] == 'answers' ? 'fa-sort-up' : ''; ?> "></i> </li> <li class="most-votes <?php echo isset($_GET['orderby']) && $_GET['orderby'] == 'votes' ? 'active' : ''; ?> " data-type="votes" > <span><?php _e('Vote', 'dwqa'); ?> </span> <i class="fa fa-sort <?php echo isset($_GET['orderby']) && $_GET['orderby'] == 'votes' ? 'fa-sort-up' : ''; ?> "></i> </li> </ul> <?php global $dwqa_general_settings; $posts_per_page = isset($dwqa_general_settings['posts-per-page']) ? $dwqa_general_settings['posts-per-page'] : get_query_var('posts_per_page'); ?> <input type="hidden" id="dwqa_filter_posts_per_page" name="posts_per_page" value="<?php echo $posts_per_page; ?> "> </div> </div> <?php do_action('dwqa-before-question-list'); ?> <?php do_action('dwqa-prepare-archive-posts'); ?> <?php if (have_posts()) { ?> <div class="questions-list"> <?php while (have_posts()) { the_post(); ?> <?php dwqa_load_template('content', 'question'); ?> <?php } ?> </div> <div class="archive-question-footer"> <?php if ($taxonomy == 'dwqa-question_category') { $args = array('post_type' => 'dwqa-question', 'posts_per_page' => -1, 'tax_query' => array(array('taxonomy' => $taxonomy, 'field' => 'slug', 'terms' => $term_name))); $query = new WP_Query($args); $total = $query->post_count; } else { if ('dwqa-question_tag' == $taxonomy) { $args = array('post_type' => 'dwqa-question', 'posts_per_page' => -1, 'tax_query' => array(array('taxonomy' => $taxonomy, 'field' => 'slug', 'terms' => $term_name))); $query = new WP_Query($args); $total = $query->post_count; } else { $total = wp_count_posts('dwqa-question'); $total = $total->publish; } } $number_questions = $total; $number = get_query_var('posts_per_page'); $pages = ceil($number_questions / $number); if ($pages > 1) { ?> <div class="pagination"> <ul data-pages="<?php echo $pages; ?> " > <?php $paged = get_query_var('paged') ? get_query_var('paged') : 1; $i = 0; echo '<li class="prev'; if ($i == 0) { echo ' dwqa-hide'; } echo '"><a href="javascript:void()">' . __('Prev', 'dwqa') . '</a></li>'; $link = get_post_type_archive_link('dwqa-question'); $start = $paged - 2; $end = $paged + 2; if ($end > $pages) { $end = $pages; $start = $pages - 5; } if ($start < 1) { $start = 1; $end = 5; if ($end > $pages) { $end = $pages; } } if ($start > 1) { echo '<li><a href="' . add_query_arg('paged', 1, $link) . '">1</a></li><li class="dot"><span>...</span></li>'; } for ($i = $start; $i <= $end; $i++) { $current = $i == $paged ? 'class="active"' : ''; if ($i == 1) { echo '<li ' . $current . '><a href="' . $link . '">' . $i . '</a></li>'; } else { echo '<li ' . $current . '><a href="' . add_query_arg('paged', $i, $link) . '">' . $i . '</a></li>'; } } if ($i - 1 < $pages) { echo '<li class="dot"><span>...</span></li><li><a href="' . add_query_arg('paged', $pages, $link) . '">' . $pages . '</a></li>'; } echo '<li class="next'; if ($paged == $pages) { echo ' dwqa-hide'; } echo '"><a href="javascript:void()">' . __('Next', 'dwqa') . '</a></li>'; ?> </ul> </div> <?php } ?> <?php if ($dwqa_options['pages']['submit-question'] && $submit_question_link) { ?> <a href="<?php echo $submit_question_link; ?> " class="dwqa-btn dwqa-btn-success"><?php _e('Ask a question', 'dwqa'); ?> </a> <?php } ?> </div> <?php } else { ?> <?php if (!dwqa_current_user_can('read_question')) { echo '<div class="alert">' . __('You do not have permission to view questions', 'dwqa') . '</div>'; } echo '<p class="not-found">'; _e('Sorry, but nothing matched your filter.', 'dwqa'); if (is_user_logged_in()) { global $dwqa_options; if (isset($dwqa_options['pages']['submit-question'])) { $submit_link = get_permalink($dwqa_options['pages']['submit-question']); if ($submit_link) { _e('You can ask question <a href="' . $submit_link . '">here</a>', 'dwqa'); } } } else { _e('Please <a href="' . wp_login_url(get_post_type_archive_link('dwqa-question')) . '">Login</a>', 'dwqa'); $register_link = wp_register('', '', false); if (!empty($register_link) && $register_link) { echo __(' or', 'dwqa') . ' ' . $register_link; } _e(' to submit question.', 'dwqa'); wp_login_form(); } echo '</p>'; ?> <?php } ?> <?php do_action('dwqa-after-archive-posts'); ?> </div> </div> </div> <?php $html = ob_get_contents(); ob_end_clean(); wp_enqueue_script('dwqa-questions-list', DWQA_URI . 'inc/templates/default/assets/js/dwqa-questions-list.js', array('jquery'), $script_version, true); wp_localize_script('dwqa-questions-list', 'dwqa', $dwqa_sript_vars); return $html; }
if ($answers->max_num_pages > 1) { $question_url = get_permalink($question_id); echo '<h3 class="dwqa-answers-page-navigation-head">' . sprintf(__('Answer page %d', 'dwqa'), $ans_cur_page) . '</h3>'; echo '<ul class="dwqa-answers-page-navigation">'; for ($i = 1; $i <= $answers->max_num_pages; $i++) { echo '<li class="' . ($ans_cur_page == $i ? 'active' : '') . '"><a href="' . esc_url(add_query_arg('ans-page', $i, $question_url)) . '">' . $i . '</a></li>'; } echo '</ul>'; } //Create answer form if (dwqa_is_closed($question_id)) { echo '<p class="alert">' . __('This question is now closed', 'dwqa') . '</p>'; return false; } if (dwqa_current_user_can('post_answer')) { dwqa_load_template('answer', 'submit-form'); } else { ?> <?php if (is_user_logged_in()) { ?> <div class="alert"><?php _e('You do not have permission to submit answer.', 'dwqa'); ?> </div> <?php } else { ?> <h3 class="dwqa-title"> <?php printf('%1$s <a href="%2$s" title="%3$s">%3$s</a> %4$s', __('Please login or', 'dwqa'), wp_registration_url(), __('Register', 'dwqa'), __('to Submit Answer', 'dwqa'));
function dwqa_display_sticky_questions() { $sticky_questions = get_option('dwqa_sticky_questions', array()); if (!empty($sticky_questions)) { $query = array('post_type' => 'dwqa-question', 'post__in' => $sticky_questions, 'posts_per_page' => 40); $sticky_questions = new WP_Query($query); ?> <div class="sticky-questions"> <?php while ($sticky_questions->have_posts()) { $sticky_questions->the_post(); ?> <?php dwqa_load_template('content', 'question'); ?> <?php } ?> </div> <?php wp_reset_postdata(); } }
public function single_question() { global $post, $current_user; $post_id = get_the_ID(); ?> <div class="dwqa-single-question"> <!-- dwqa-status-private --> <article id="question-<?php echo $post_id; ?> " <?php post_class('dwqa-question'); ?> > <header class="dwqa-header"> <h1 class="dwqa-title"><?php the_title(); ?> </h1> <div class="dwqa-meta"> <span class="dwqa-vote" data-type="question" data-nonce="<?php echo wp_create_nonce('_dwqa_question_vote_nonce'); ?> " data-question="<?php echo $post_id; ?> " > <a class="dwqa-vote-dwqa-btn dwqa-vote-up" data-vote="up" href="#" title="<?php _e('Vote Up', 'dwqa'); ?> "><?php _e('Vote Up', 'dwqa'); ?> </a> <div class="dwqa-vote-count"><?php $point = dwqa_vote_count(); echo $point > 0 ? '+' . $point : $point; ?> </div> <a class="dwqa-vote-dwqa-btn dwqa-vote-down" data-vote="down" href="#" title="<?php _e('Vote Down', 'dwqa'); ?> "><?php _e('Vote Down', 'dwqa'); ?> </a> </span> <?php if (is_user_logged_in()) { ?> <span data-post="<?php echo $post_id; ?> " data-nonce="<?php echo wp_create_nonce('_dwqa_follow_question'); ?> " class="dwqa-favourite <?php echo dwqa_is_followed($post_id) ? 'active' : ''; ?> " title="<?php echo dwqa_is_followed($post_id) ? __('Unfollow This Question', 'dwqa') : __('Follow This Question', 'dwqa'); ?> "><!-- add class 'active' --> <i class="fa fa-star"></i> </span> <?php } ?> </div> </header> <div class="dwqa-content"> <?php the_content(); ?> </div> <?php $tags = get_the_term_list($post_id, 'dwqa-question_tag', '<span class="dwqa-tag">', '</span><span class="dwqa-tag">', '</span>'); if (!empty($tags)) { ?> <div class="dwqa-tags"><?php echo $tags; ?> </div> <?php } ?> <!-- Question Tags --> <footer class="dwqa-footer"> <div class="dwqa-author"> <?php echo get_avatar($post->post_author, 32, false); ?> <span class="author"> <?php printf('<a href="%1$s" title="%2$s %3$s">%3$s</a>', get_author_posts_url(get_the_author_meta('ID')), __('Posts by', 'dwqa'), get_the_author_meta('display_name')); ?> </span><!-- Author Info --> <span class="dwqa-date"> <?php printf('<a href="%s" title="%s #%d">%s %s</a>', get_permalink(), __('Link to', 'dwqa'), $post_id, __('asked', 'dwqa'), get_the_date()); ?> </span> <!-- Question Date --> <div data-post="<?php echo $post_id; ?> " data-nonce="<?php echo wp_create_nonce('_dwqa_update_privacy_nonce'); ?> " data-type="question" class="dwqa-privacy"> <input type="hidden" name="privacy" value="<?php get_post_status(); ?> "> <span class="dwqa-current-privacy"> <?php echo 'private' == get_post_status() ? '<i class="fa fa-lock"></i> ' . __('Private', 'dwqa') : '<i class="fa fa-globe"></i> ' . __('Public', 'dwqa'); ?> </span> <?php if (dwqa_current_user_can('edit_question') || dwqa_current_user_can('edit_answer') || $post->post_author == $current_user->ID) { ?> <span class="dwqa-change-privacy"> <div class="dwqa-btn-group"> <button type="button" class="dropdown-toggle" ><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 title="<?php _e('Everyone can see', 'dwqa'); ?> " data-privacy="publish" <?php echo 'publish' == get_post_status() ? 'class="current"' : ''; ?> ><a href="#"><i class="fa fa-globe"></i> <?php _e('Public', 'dwqa'); ?> </a></li> <li title="<?php _e('Only Author and Administrator can see', 'dwqa'); ?> " data-privacy="private" <?php echo 'private' == get_post_status() ? 'class="current"' : ''; ?> ><a href="#" ><i class="fa fa-lock"></i> <?php _e('Private', 'dwqa'); ?> </a></li> </ul> </div> </div> </span> <?php } ?> </div><!-- post status --> </div> <?php $categories = wp_get_post_terms($post_id, 'dwqa-question_category'); if (!empty($categories)) { $cat = $categories[0]; ?> <div class="dwqa-category"> <span class="dwqa-category-title"><?php _e('Category', 'dwqa'); ?> </span> <a class="dwqa-category-name" href="<?php echo get_term_link($cat); ?> " title="<?php _e('All questions from', 'dwqa'); ?> <?php echo $cat->name; ?> "><?php echo $cat->name; ?> </a> </div> <?php } ?> <!-- Question Categories --> <?php $meta = get_post_meta($post_id, '_dwqa_status', true); if (!$meta) { $meta = 'open'; } ?> <div class="dwqa-current-status"> <span class="dwqa-status-title"><?php _e('Status', 'dwqa'); ?> </span> <span class="dwqa-status-name"><?php echo $meta; ?> </span> <?php if (dwqa_current_user_can('edit_question') || dwqa_current_user_can('edit_answer') || $current_user->ID == $post->post_author) { ?> <span class="dwqa-change-status"> <div class="dwqa-btn-group"> <button type="button" class="dropdown-toggle" ><i class="fa fa-caret-down"></i></button> <div class="dwqa-dropdown-menu" data-nonce="<?php echo wp_create_nonce('_dwqa_update_question_status_nonce'); ?> " data-question="<?php the_ID(); ?> " > <div class="dwqa-dropdown-caret"> <span class="dwqa-caret-outer"></span> <span class="dwqa-caret-inner"></span> </div> <ul role="menu" data-nonce="<?php echo wp_create_nonce('_dwqa_update_question_status_nonce'); ?> " data-question="<?php the_ID(); ?> "> <?php if ('resolved' == $meta || 'pending' == $meta || 'closed' == $meta) { ?> <li class="dwqa-re-open" data-status="re-open"> <a href="#"><i class="fa fa-reply"></i> <?php _e('Re-Open', 'dwqa'); ?> </a> </li> <?php } ?> <?php if ('closed' != $meta) { ?> <li class="dwqa-closed" data-status="closed"> <a href="#"><i class="fa fa-lock"></i> <?php _e('Closed', 'dwqa'); ?> </a> </li> <?php } ?> <?php if ('pending' != $meta && 'closed' != $meta && current_user_can('edit_posts', $post_id)) { ?> <li class="dwqa-pending" data-status="pending"> <a href="#"><i class="fa fa-question-circle"></i> <?php _e('Pending', 'dwqa'); ?> </a> </li> <?php } ?> <?php if ('resolved' != $meta && 'closed' != $meta) { ?> <li class="dwqa-resolved" data-status="resolved"> <a href="#"><i class="fa fa-check-circle-o"></i> <?php _e('Resolved', 'dwqa'); ?> </a> </li> <?php } ?> </ul> </div> </div> </span> <?php } ?> <!-- Change Question Status --> </div> </footer> <div class="dwqa-comments"> <?php comments_template(); ?> </div> </article><!-- end question --> <div id="dwqa-answers"> <?php dwqa_load_template('answers'); ?> </div><!-- end dwqa-add-answers --> </div><!-- end dwqa-single-question --> <?php }
<?php get_header('dwqa'); ?> <?php do_action('dwqa_before_page'); ?> <?php dwqa_load_template('question', 'submit-form'); ?> <?php do_action('dwqa_after_page'); ?> <?php get_footer('dwqa');
if (('private' == get_post_status() || 'pending' == get_post_status()) && (dwqa_current_user_can('edit_answer') || dwqa_current_user_can('edit_question', $question_id)) || 'publish' == get_post_status()) { ?> <?php dwqa_load_template('content', 'question'); ?> <?php } ?> <?php } ?> <?php } else { ?> <?php dwqa_load_template('content', 'none'); ?> <?php } ?> <?php do_action('dwqa_after_questions_list'); ?> </div> <div class="dwqa-questions-footer"> <?php dwqa_question_paginate_link(); ?> <?php if (dwqa_current_user_can('post_question')) { ?>
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 if (current_user_can('edit_posts')) { ?> <input type="submit" name="submit-answer" id="save-draft-answer" value="<?php _e('Save draft', 'dwqa'); ?> " class="dwqa-btn dwqa-btn-default" /> <?php
<?php do_action('dwqa_before_single_question'); ?> <?php while (have_posts()) { the_post(); ?> <?php if (!dwqa_is_edit()) { ?> <?php dwqa_load_template('content', 'single-question'); ?> <?php } else { ?> <?php dwqa_load_template('content', 'edit'); ?> <?php } ?> <?php } ?> <?php do_action('dwqa_after_single_question'); } ?> </div>
} ?> </div> <div class="archive-question-footer"> <?php dwqa_load_template('navigation', 'archive'); ?> <?php dwqa_get_ask_question_link(); ?> </div> <?php } else { ?> <?php dwqa_load_template('archive', 'question-notfound'); ?> <?php } ?> <?php do_action('dwqa-after-archive-posts'); ?> </div> </div> <?php do_action('dwqa_after_page'); get_footer('dwqa');
if (is_user_logged_in() && (dwqa_current_user_can('edit_answer') || $current_user->ID == $answer->post_author || $current_user->ID == $question->post_author)) { dwqa_load_template('content', 'answer'); } } else { dwqa_load_template('content', 'answer'); } $position++; } unset($position); //Drafts if (current_user_can('edit_posts')) { global $post; if (!empty($drafts)) { foreach ($drafts as $post) { setup_postdata($post); dwqa_load_template('content', 'answer'); } } } ?> </div> <?php } else { if (!dwqa_current_user_can('read_answer')) { echo '<div class="alert">' . __('You do not have permission to view answers', 'dwqa') . '</div>'; } } wp_reset_query(); //Create answer form global $dwqa_options;