<?php $post_id = get_the_ID(); ?> <article id="question-<?php echo $post_id; ?> " class="dwqa-question <?php echo dwqa_is_sticky($post_id) ? 'dwqa-sticky-question' : ''; ?> "> <header class="dwqa-header"> <?php if (current_user_can('edit_posts')) { ?> <?php if (dwqa_is_pending($post_id)) { ?> <span class="dwqa-label"><?php _e('Pending', 'dwqa'); ?> </span> <?php } ?> <?php } ?> <a class="dwqa-title" href="<?php the_permalink(); ?> " title="<?php
function dwqa_question_meta_button($post_id = false) { if (!$post_id) { $post_id = get_the_ID(); } ?> <div class="dwqa-meta"> <div 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> </div> <?php dwqa_question_status_button($post_id); ?> <?php dwqa_question_privacy_button($post_id); ?> <?php $categories = wp_get_post_terms($post_id, 'dwqa-question_category'); ?> <?php if (!empty($categories)) { ?> <?php $cat = $categories[0]; ?> <div class="dwqa-category"> <a class="dwqa-category-name" href="<?php echo get_term_link($cat); ?> " title="<?php _e('All questions from', 'dwqa'); ?> <?php echo $cat->name; ?> "><i class="fa fa-folder-open"></i> <?php echo $cat->name; ?> </a> </div> <?php } ?> <!-- Question Categories --> <?php dwqa_question_action_buttons($post_id); ?> <?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' --> <span class="dwpa_follow"><?php _e('follow', 'dwqa'); ?> </span> <span class="dwpa_following"><?php _e('following', 'dwqa'); ?> </span> <span class="dwpa_unfollow"><?php _e('unfollow', 'dwqa'); ?> </span> </span> <?php } ?> <?php if (dwqa_current_user_can('edit_question')) { ?> <span data-post="<?php echo $post_id; ?> " data-nonce="<?php echo wp_create_nonce('_dwqa_stick_question'); ?> " class="dwqa-stick-question <?php echo dwqa_is_sticky($post_id) ? 'active' : ''; ?> " title="<?php echo dwqa_is_sticky($post_id) ? __('Unpin this Question from the top', 'dwqa') : __('Pin this Question to top', 'dwqa'); ?> "><i class="fa fa-bookmark"></i></span> <?php } ?> </div> <?php }
<?php /** * The template for displaying question content * * @package DW Question & Answer * @since DW Question & Answer 1.4.0 */ ?> <div class="dwqa-question-item <?php echo dwqa_is_sticky() ? 'dwqa-sticky' : ''; ?> "> <header class="dwqa-question-title"><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></header> <div class="dwqa-question-meta"> <?php dwqa_question_print_status(); ?> <?php global $post; $user_id = get_post_field('post_author', get_the_ID()) ? get_post_field('post_author', get_the_ID()) : false; $time = human_time_diff(get_post_time('U')); $text = __('asked', 'dwqa'); $latest_answer = dwqa_get_latest_answer(); if ($latest_answer) {
public function stick_question() { check_ajax_referer('_dwqa_stick_question', 'nonce'); if (!isset($_POST['post'])) { wp_send_json_error(array('message' => __('Invalid Post', 'dwqa'))); } $question = get_post(intval($_POST['post'])); if (is_user_logged_in()) { global $current_user; $sticky_questions = get_option('dwqa_sticky_questions', array()); if (!dwqa_is_sticky($question->ID)) { $sticky_questions[] = $question->ID; update_option('dwqa_sticky_questions', $sticky_questions); wp_send_json_success(array('code' => 'stickied')); } else { foreach ($sticky_questions as $key => $q) { if ($q == $question->ID) { unset($sticky_questions[$key]); } } update_option('dwqa_sticky_questions', $sticky_questions); wp_send_json_success(array('code' => 'Unstick')); } } else { wp_send_json_error(array('code' => 'not-logged-in')); } }
} ?> <?php if (dwqa_current_user_can('edit_question')) { ?> <span data-post="<?php echo $post_id; ?> " data-nonce="<?php echo wp_create_nonce('_dwqa_stick_question'); ?> " class="dwqa-stick-question <?php echo dwqa_is_sticky($post_id) ? 'active' : ''; ?> " title="<?php echo dwqa_is_sticky($post_id) ? __('Stick this Question to the front page', 'dwqa') : __('Unstick this Question to the front page', 'dwqa'); ?> "><i class="fa fa-bookmark"></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)) {
?> <?php if (dwqa_is_pending($post_id)) { ?> <span class="dwqa-label"><?php _e('Pending', 'dwqa'); ?> </span> <?php } ?> <?php } ?> <?php if (dwqa_is_sticky($post_id)) { echo '<i class="fa fa-bookmark"></i>'; } ?> <a class="dwqa-title" href="<?php the_permalink(); ?> " title="<?php echo esc_attr(sprintf(__('Permalink to %s', 'dwqa'), the_title_attribute('echo=0'))); ?> " rel="bookmark"><?php the_title(); ?> </a> <div class="dwqa-meta"> <?php
function dwqa_question_states($states, $post) { if (dwqa_is_sticky($post->ID) && 'dwqa-question' == get_post_type($post->ID)) { $states[] = __('Sticky Question', 'dwqa'); } return $states; }