Ejemplo n.º 1
0
 public function widget($args, $instance)
 {
     global $questions;
     $title = apply_filters('widget_title', $instance['title']);
     echo $args['before_widget'];
     if (!empty($title)) {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     echo '<div class="ap-widget-inner">';
     if (!class_exists('Tags_For_AnsPress')) {
         echo 'Tags plugin must be installed for related question. Get <a href="https://wordpress.org/plugins/tags-for-anspress">Tags for AnsPress</a>';
         return;
     }
     $tags = get_the_terms(get_question_id(), 'question_tag');
     $tags_in = array();
     if ($tags) {
         foreach ($tags as $t) {
             $tags_in[] = $t->term_id;
         }
     }
     $question_args = array('tax_query' => array(array('taxonomy' => 'question_tag', 'field' => 'term_id', 'terms' => $tags_in)), 'showposts' => 5, 'post__not_in' => array(get_question_id()));
     $questions = ap_get_questions($question_args);
     include ap_get_theme_location('widget-related_questions.php');
     wp_reset_postdata();
     echo '</div>';
     echo $args['after_widget'];
 }
Ejemplo n.º 2
0
 /**
  * Initialize class
  * @param array $args Query arguments.
  * @access public
  * @since  2.0
  */
 public function __construct($args = array())
 {
     global $answers;
     $paged = get_query_var('paged') ? get_query_var('paged') : 1;
     $defaults = array('question_id' => get_question_id(), 'ap_answers_query' => true, 'showposts' => ap_opt('answers_per_page'), 'paged' => $paged, 'only_best_answer' => false, 'include_best_answer' => false);
     $args['post_status'][] = 'publish';
     $args['post_status'][] = 'closed';
     $this->args = wp_parse_args($args, $defaults);
     if (isset($this->args['question_id'])) {
         $question_id = $this->args['question_id'];
     }
     if (!empty($question_id)) {
         $this->args['post_parent'] = $question_id;
     }
     if (isset($this->args['sortby'])) {
         $this->orderby_answers();
     }
     // Check if requesting only for best Answer
     if (isset($this->args['only_best_answer']) && $this->args['only_best_answer']) {
         $this->args['meta_query'] = array(array('key' => ANSPRESS_BEST_META, 'type' => 'BOOLEAN', 'compare' => '=', 'value' => '1'));
     }
     $this->args['post_type'] = 'answer';
     $args = $this->args;
     /**
      * Initialize parent class
      */
     parent::__construct($args);
 }
Ejemplo n.º 3
0
 public function wp_head()
 {
     if (is_question()) {
         global $wp;
         echo '<link href="' . home_url(add_query_arg(array(), $wp->request)) . '" title="' . wp_title('|', false, 'right') . '" type="application/rss+xml" rel="alternate">';
         echo '<link rel="canonical" href="' . get_permalink(get_question_id()) . '"> ';
     }
 }
Ejemplo n.º 4
0
 public function insert_views($template)
 {
     //Log current time as user meta, so later we can check when user was active.
     if (is_user_logged_in()) {
         update_user_meta(get_current_user_id(), '__last_active', current_time('mysql'));
     }
     if (is_question()) {
         ap_insert_views(get_question_id(), 'question');
     }
     if (is_ap_user() && ap_get_displayed_user_id() != get_current_user_id() && ap_get_displayed_user_id()) {
         ap_insert_views(ap_get_displayed_user_id(), 'profile');
     }
 }
Ejemplo n.º 5
0
/**
 * Print all particpants of a question
 * @param  integer $avatar_size
 * @param  boolean $post_id
 * @return void
 * @since  0.4
 */
function ap_get_all_parti($avatar_size = 40, $post_id = false)
{
    if (!$post_id) {
        $post_id = get_question_id();
    }
    $parti = ap_get_parti($post_id);
    echo '<span class="ap-widget-title">' . sprintf(_n('<span>1</span> Participant', '<span>%d</span> Participants', count($parti), 'ap'), count($parti)) . '</span>';
    echo '<div class="ap-participants-list clearfix">';
    foreach ($parti as $p) {
        echo '<a title="' . ap_user_display_name($p->apmeta_userid, true) . '" href="' . ap_user_link($p->apmeta_userid) . '" class="ap-avatar">';
        echo get_avatar($p->apmeta_userid, $avatar_size);
        echo '</a>';
    }
    echo '</div>';
}
Ejemplo n.º 6
0
 /**
  * Output single question page
  * @return void
  */
 public function question_page()
 {
     global $questions;
     ap_get_question(get_question_id());
     if (ap_have_questions()) {
         while (anspress()->questions->have_posts()) {
             anspress()->questions->the_post();
             global $post;
             setup_postdata($post);
         }
         include ap_get_theme_location('question.php');
         wp_reset_postdata();
     } else {
         include ap_get_theme_location('not-found.php');
     }
 }
Ejemplo n.º 7
0
 /**
  * Output single question page
  * @return void
  */
 public function question_page()
 {
     global $questions;
     $questions = ap_get_question(get_question_id());
     if (ap_have_questions()) {
         /**
          * Set current question as global post
          * @since 2.3.3
          */
         while (ap_questions()) {
             ap_the_question();
             global $post;
             setup_postdata($post);
             include ap_get_theme_location('question.php');
         }
         wp_reset_postdata();
     } else {
         include ap_get_theme_location('not-found.php');
     }
 }
Ejemplo n.º 8
0
 public function widget($args, $instance)
 {
     $title = apply_filters('widget_title', $instance['title']);
     $avatar = $instance['avatar'];
     $show_selected = $instance['show_selected'];
     $show_activity = $instance['show_activity'];
     $show_answers = $instance['show_answers'];
     $show_vote = $instance['show_vote'];
     $show_views = $instance['show_views'];
     $show_category = $instance['show_category'];
     $show_tags = $instance['show_tags'];
     echo $args['before_widget'];
     if (!empty($title)) {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     $question_args = array('ap_query' => 'related', 'ap_title' => get_the_title(get_question_id()), 'post_type' => 'question', 'post__not_in' => array(get_question_id()), 'post_status' => 'publish', 'showposts' => ap_opt('question_per_page'));
     $question = new WP_Query($question_args);
     include ap_get_theme_location('questions-widget.php');
     echo $args['after_widget'];
     wp_reset_postdata();
 }
Ejemplo n.º 9
0
							<li class="ap-tip ap-ansslable" title="<?php 
    _e('Answer is accepted', 'ap');
    ?>
">
								<i class="ap-icon-answer"></i>
							</li>
						<?php 
}
?>
						<li class="list-meta ap-tip" title="<?php 
_e('Last activity', 'ap');
?>
">	
							<i class="ap-icon-clock ap-meta-icon"></i>
							<?php 
printf('<span class="when">%s %s ago</span>', ap_get_latest_history_html(get_the_ID()), ap_human_time(mysql2date('U', ap_last_active(get_question_id()))));
ap_user_display_name();
?>
						</li>
						<li class="ap-tip" title="<?php 
_e('Question category', 'ap');
?>
"><?php 
ap_question_categories_html(false, false);
?>
</li>
						<li class="ap-tip" title="<?php 
_e('Question tagged', 'ap');
?>
"><?php 
ap_question_tags_html(false, false);
Ejemplo n.º 10
0
function ap_post_subscribers_count($post_id)
{
    _deprecated_function('ap_post_subscribers_count', '2.2.0.1', 'ap_subscribers_count');
    $post_id = $post_id ? $post_id : get_question_id();
    return ap_meta_total_count('subscriber', $post_id);
}
Ejemplo n.º 11
0
				<div class="ap-question-side">
					<h3 class="ap-question-side-title"><?php 
            _e('Tags', 'ap');
            ?>
</h3>
					<?php 
            ap_question_tags_html(get_question_id());
            ?>
				</div>
				<?php 
        }
        ?>
				<!-- End Tags -->
				
				<!-- Start participants -->
				<div class="ap-question-side">			
					<?php 
        ap_get_all_parti(30, get_question_id());
        ?>
				</div>
				<!-- End participants -->
			</div>
		</div>
	</div>
</div>

<?php 
    } else {
        echo '<div class="ap-pending-notice ap-icon-clock">' . __('You do not have permission to view this question.') . '</div>';
    }
}
Ejemplo n.º 12
0
<?php

$question_id = get_question_id();
$current_user = get_userdata(get_current_user_id());
$validate = ap_validate_form();
if (!empty($validate['has_error'])) {
    echo '<div class="alert alert-danger" data-dismiss="alert"><button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>' . __('Problem submitting form, please recheck form', 'ap') . '</div>';
}
?>

<div id="answer-form-c">	
	<div class="ap-avatar">
		<?php 
echo get_avatar($current_user->user_email, ap_opt('avatar_size_qquestion'));
?>
	</div>
	<?php 
ap_answer_form($question_id);
?>
</div>
Ejemplo n.º 13
0
/**
 * Output subscribe btn HTML
 * @param boolean|integer $action_id Question ID or Term ID
 * @return string
 * @since 2.0.1
 */
function ap_subscribe_btn_html($action_id = false, $type = false)
{
    global $question_category, $question_tag;
    if ($action_id === false) {
        if (is_question()) {
            $action_id = get_question_id();
        } elseif (is_question_category()) {
            $action_id = $question_category->term_id;
        } elseif (is_question_tag()) {
            $action_id = $question_tag->term_id;
        }
    }
    if ($type == false) {
        if (is_question_category()) {
            $subscribe_type = 'category';
        } elseif (is_question_tag()) {
            $subscribe_type = 'tag';
        } else {
            $subscribe_type = false;
        }
    } else {
        if ($type === 'category') {
            $subscribe_type = 'category';
        } elseif ($type === 'tag') {
            $subscribe_type = 'tag';
        } else {
            $subscribe_type = false;
        }
    }
    $subscribed = ap_is_user_subscribed($action_id, false, $subscribe_type);
    $nonce = wp_create_nonce('subscribe_' . $action_id . '_' . $subscribe_type);
    $title = !$subscribed ? __('Follow question', 'ap') : __('Unfollow question', 'ap');
    ?>

	<div class="ap-subscribe" id="<?php 
    echo 'subscribe_' . $action_id;
    ?>
">
		<a href="#" class="ap-btn-toggle<?php 
    echo $subscribed ? ' active' : '';
    ?>
" data-query="ap_ajax_action=subscribe&action_id=<?php 
    echo $action_id;
    ?>
&__nonce=<?php 
    echo $nonce;
    ?>
&type=<?php 
    echo $subscribe_type;
    ?>
" data-action="ap_subscribe" data-args="<?php 
    echo $action_id . '-' . $nonce;
    ?>
">
			<span class="apicon-toggle-on"></span>
			<span class="apicon-toggle-off"></span>
		</a>
		<b><?php 
    echo $title;
    ?>
</b>
	</div>

	<?php 
}
Ejemplo n.º 14
0
/**
 * Ohjaa kayttaja halutulle sivulle
 */
function direct_right()
{
    if (array_key_exists('question_id', $_GET)) {
        // To redirect the user back to the question where he logged in
        $question_id = get_question_id();
        header("Location: /pgCodesS/index.php?question_id=" . $question_id . "&successful_login");
    } else {
        if ($_GET['login']) {
            header("Location: /pgCodesS/index.php?" . "successful_login");
        } else {
            header("Location: /pgCodesS/index.php");
        }
    }
}
Ejemplo n.º 15
0
 /**
  * Update concal link when wpseo plugin installed
  * @return string
  */
 public function wpseo_canonical()
 {
     if (is_question()) {
         return get_permalink(get_question_id());
     }
 }
Ejemplo n.º 16
0
					<?php 
    if (ap_opt('answer_help_page') != '') {
        ?>
						<li><a href="#ap-form-help"><?php 
        _e('How to answer', 'ap');
        ?>
</a></li>
					<?php 
    }
    ?>
				</ul>				
			</div>
			<div class="ap-tab-container">
				<div id="ap-form-main" class="active ap-tab-item">
					<?php 
    ap_answer_form(get_question_id());
    ?>
				</div>
				<div id="ap-form-help" class="ap-tab-item">
					<?php 
    if (ap_opt('answer_help_page') != '') {
        ?>
						
						<?php 
        ap_how_to_answer();
        ?>
					<?php 
    }
    ?>
				</div>
			</div>
Ejemplo n.º 17
0
function ap_get_breadcrumbs()
{
    $current_page = get_query_var('ap_page');
    $title = ap_page_title();
    $a = array();
    $a['base'] = array('title' => ap_opt('base_page_title'), 'link' => ap_base_page_link(), 'order' => 0);
    if (is_question_tag()) {
        $a['tag'] = array('title' => __('Tags', 'ap'), 'link' => '', 'order' => 10);
    } elseif (is_question()) {
        $a['page'] = array('title' => substr($title, 0, 30) . (strlen($title) > 30 ? __('..', 'ap') : ''), 'link' => get_permalink(get_question_id()), 'order' => 10);
    } elseif ($current_page != 'base' && $current_page != '') {
        if ($current_page == 'user') {
            $a['page'] = array('title' => __('User', 'ap'), 'link' => ap_user_link(ap_get_displayed_user_id()), 'order' => 10);
            $a['user_page'] = array('title' => substr($title, 0, 30) . (strlen($title) > 30 ? __('..', 'ap') : ''), 'link' => ap_user_link(ap_get_displayed_user_id(), get_query_var('user_page')), 'order' => 10);
        } else {
            $a['page'] = array('title' => substr($title, 0, 30) . (strlen($title) > 30 ? __('..', 'ap') : ''), 'link' => ap_get_link_to($current_page), 'order' => 10);
        }
    }
    $a = apply_filters('ap_breadcrumbs', $a);
    return ap_sort_array_by_order($a);
}
Ejemplo n.º 18
0
/**
 * Ota uusi kysymys tietokantaan
 */
function receive_new_question()
{
    /* $question_id integer
     * $title string
     * $body string
     * $tags string
     */
    $body = pg_escape_string($_POST['question']['body']);
    $title = pg_escape_string($_POST['question']['title']);
    $tags = $_POST['question']['tags'];
    /** 
     * Tarkasta sisaankirjaus
     */
    if (check_user_status()) {
        echo "User status pelaa";
        if (validate_input($title, $body, $tags)) {
            echo "User input pelaa";
            $title = $_POST['question']['title'];
            set_question();
            set_tags();
            $question_id = get_question_id();
            // question must be set before
            header("Location: /pgCodesS/index.php?" . "question_sent" . "&" . "question_id=" . $question_id . "&" . $title);
        } else {
            header("Location: /pgCodesS/index.php?" . "ask_question" . "&unsuccessful_new_question");
        }
    } else {
        header("Location: /pgCodesS/index.php" . "ask_question" . "&unsuccessful_new_question");
    }
}
Ejemplo n.º 19
0
 /**
  * Output single question page
  * @return void
  */
 public function question_page()
 {
     // Set Header as 404 if question id is not set.
     if (false === get_question_id()) {
         $this->set_404();
         return;
     }
     global $questions;
     $questions = ap_get_question(get_question_id());
     if (ap_have_questions()) {
         /**
          * Set current question as global post
          * @since 2.3.3
          */
         while (ap_questions()) {
             ap_the_question();
             global $post;
             setup_postdata($post);
         }
         include ap_get_theme_location('question.php');
         wp_reset_postdata();
     } else {
         $this->set_404();
     }
 }
Ejemplo n.º 20
0
function ap_question_subscribers($action_id = false, $type = '', $avatar_size = 30)
{
    global $question_category, $question_tag;
    if (false === $action_id) {
        if (is_question()) {
            $action_id = get_question_id();
        } elseif (is_question_category()) {
            $action_id = $question_category->term_id;
        } elseif (is_question_tag()) {
            $action_id = $question_tag->term_id;
        }
    }
    if ($type == '') {
        $type = is_question() ? 'q_all' : 'tax_new_q';
    }
    $subscribers = ap_get_subscribers($action_id, $type);
    if ($subscribers) {
        echo '<div class="ap-question-subscribers clearfix">';
        echo '<div class="ap-question-subscribers-inner">';
        foreach ($subscribers as $subscriber) {
            echo '<a href="' . ap_user_link($subscriber->subs_user_id) . '"';
            ap_hover_card_attributes($subscriber->subs_user_id);
            echo '>' . get_avatar($subscriber->subs_user_id, $avatar_size) . '</a>';
        }
        echo '</div>';
        echo '</div>';
    }
}
Ejemplo n.º 21
0
 /**
  * Get the real ID from plugins.
  *
  * Only works on front-end as there's no need to check for inconsistent
  * functions for the current ID in the admin.
  *
  * @since 2.5.0
  *
  * @return int|empty the ID.
  */
 public function check_the_real_ID()
 {
     if (null !== ($cache = $this->get_query_cache(__METHOD__))) {
         return $cache;
     }
     $id = '';
     if ($this->is_wc_shop()) {
         //* WooCommerce Shop
         $id = get_option('woocommerce_shop_page_id');
     } elseif (function_exists('get_question_id') && did_action('template_redirect')) {
         //* AnsPress
         $id = get_question_id();
     }
     /**
      * Applies filters the_seo_framework_real_id : The Real ID for plugins on front-end.
      * @since 2.5.0
      * @TODO add to Filters API.
      */
     $this->set_query_cache(__METHOD__, $id = (int) apply_filters('the_seo_framework_real_id', $id));
     return $id;
 }
Ejemplo n.º 22
0
/**
 * Return question id with solved prefix if answer is accepted.
 *
 * @param bool|int $question_id
 *
 * @return string
 *
 * @since  	2.3 [@see ap_page_title]
 */
function ap_question_title_with_solved_prefix($question_id = false)
{
    if ($question_id === false) {
        $question_id = get_question_id();
    }
    $solved = ap_question_best_answer_selected($question_id);
    if (ap_opt('show_solved_prefix')) {
        return ($solved ? __('[Solved] ', 'ap') : '') . get_the_title($question_id);
    }
    return get_the_title($question_id);
}
Ejemplo n.º 23
0
/** Laita kysymys tietokantaan
 * @param $question_id integer
 */
function put_question_to_db($question_id)
{
    /* $title string
     * $body string
     * $tags string
     */
    if (check_user_status()) {
        echo "User status pelaa";
        $body = pg_escape_string($_POST['question']['body']);
        $title = pg_escape_string($_POST['question']['title']);
        $tags = $_POST['question']['tags'];
        if (validate_input($title, $body, $tags)) {
            echo "User input pelaa";
            $title = $_POST['question']['title'];
            set_question($question_id);
            set_tags($question_id);
            header("Location: /pgCodesS/index.php?" . "question_updated" . "&" . "question_id=" . $question_id . "&" . $title);
        } else {
            header("Location: /pgCodesS/index.php?" . "&unsuccessful_new_question");
        }
    } else {
        header("Location: /pgCodesS/index.php" . "&unsuccessful_new_question");
    }
}
// Let's fire!
// Laita kysymystietokantaan
put_question_to_db(get_question_id());
ob_end_flush();
Ejemplo n.º 24
0
function ap_page_title()
{
    if (is_question()) {
        $new_title = get_the_title(get_question_id());
    } elseif (is_ask()) {
        $new_title = ap_opt('ask_page_title');
    } elseif (is_question_categories()) {
        $new_title = ap_opt('categories_page_title');
    } elseif (is_question_tags()) {
        $new_title = ap_opt('tags_page_title');
    } elseif (is_question_tag()) {
        $tag = get_term_by('slug', get_query_var('question_tags'), 'question_tags');
        $new_title = sprintf(__('Question tag: %s', 'ap'), $tag->name);
    } elseif (is_question_cat()) {
        $category = get_term_by('slug', get_query_var('question_category'), 'question_category');
        $new_title = sprintf(__('Question category: %s', 'ap'), $category->name);
    } elseif (is_question_edit()) {
        $new_title = __('Edit question ', 'ap') . get_the_title(get_question_id());
    } elseif (is_answer_edit()) {
        $new_title = __('Edit answer', 'ap');
    } elseif (is_ap_users()) {
        $new_title = ap_opt('users_page_title');
    } elseif (is_ap_user()) {
        $new_title = ap_user_page_title();
    } elseif (is_ap_search()) {
        $new_title = sprintf(ap_opt('search_page_title'), get_query_var('ap_s'));
    } else {
        $new_title = ap_opt('base_page_title');
    }
    $new_title = apply_filters('ap_page_title', $new_title);
    return $new_title;
}
Ejemplo n.º 25
0
function ap_change_label_html($post_id)
{
    if (ap_user_can_change_label()) {
        ?>
	<div class="ap-change-label-from ap-dropdown pull-right">
		<a class="ap-icon ap-icon-cog ap-dropdown-toggle" data-action="ap-change-status"></a>
		<div class="ap-dropdown-menu">
			<?php 
        $labels = get_terms('question_label', array('orderby' => 'name', 'hide_empty' => false));
        $taxo = get_the_terms($post_id, 'question_label');
        $taxo_array = array();
        if ($taxo) {
            foreach ($taxo as $t) {
                $taxo_array[] = $t->slug;
            }
        }
        if ($labels) {
            echo '<ul id="ap-label-select" data-action="ap-label-select">';
            echo '<li class="ap-select-header">' . __('Label', 'ap') . '</li>';
            foreach ($labels as $l) {
                $color = ap_get_label_color($l->term_id);
                echo '<li data-args="' . $l->term_id . '" class="ap-select-item ' . ap_icon('checked') . ' ' . (in_array($l->slug, $taxo_array) ? ' selected' : '') . '" data-color="' . $color . '"><span class="question-label-color" style="background:' . $color . ';"></span>' . $l->name . '<span class="unselect ap-icon-cross"></span></li>';
            }
            $nonce = wp_create_nonce('label-' . get_question_id());
            echo '<li class="ap-select-footer"><a href="#" data-button="ap-save-label" data-id="' . get_question_id() . '" data-nonce="' . $nonce . '" class="ap-btn ap-small">' . __('Done', 'ap') . '</a>';
            echo '<a href="#" class="ap-btn ap-small" data-toggle="ap-dropdown">' . __('Close', 'ap') . '</a>';
            echo '</li></ul>';
        }
        ?>
			
		</div>
	</div>
	<?php 
    }
}
Ejemplo n.º 26
0
    public function ap_base_page_sc($atts, $content = "")
    {
        if (!is_question()) {
            $order = get_query_var('sort');
            $label = sanitize_text_field(get_query_var('label'));
            if (empty($order)) {
                $order = 'active';
            }
            //ap_opt('answers_sort');
            if (empty($label)) {
                $label = '';
            }
            $paged = get_query_var('paged') ? get_query_var('paged') : 1;
            $question_args = array('ap_query' => 'main_questions', 'post_type' => 'question', 'post_status' => 'publish', 'showposts' => ap_opt('question_per_page'), 'paged' => $paged);
            if ($order == 'active') {
                $question_args['ap_query'] = 'main_questions_active';
                $question_args['orderby'] = 'meta_value';
                $question_args['meta_key'] = ANSPRESS_UPDATED_META;
                $question_args['meta_query'] = array('relation' => 'OR', array('key' => ANSPRESS_UPDATED_META, 'compare' => 'NOT EXISTS'));
            } elseif ($order == 'voted') {
                $question_args['orderby'] = 'meta_value_num';
                $question_args['meta_key'] = ANSPRESS_VOTE_META;
            } elseif ($order == 'answers') {
                $question_args['orderby'] = 'meta_value_num';
                $question_args['meta_key'] = ANSPRESS_ANS_META;
            } elseif ($order == 'unanswered') {
                $question_args['orderby'] = 'meta_value';
                $question_args['meta_key'] = ANSPRESS_ANS_META;
                $question_args['meta_value'] = '0';
            } elseif ($order == 'oldest') {
                $question_args['orderby'] = 'date';
                $question_args['order'] = 'ASC';
            }
            if ($label != '') {
                $question_args['tax_query'] = array(array('taxonomy' => 'question_label', 'field' => 'slug', 'terms' => $label));
            }
            $question_args = apply_filters('ap_main_query_args', $question_args);
        }
        if (is_question()) {
            $args = array('p' => get_question_id(), 'post_type' => 'question', 'post_status' => array('moderate', 'publish'));
            $question = new WP_Query($args);
        } elseif (is_question_tag()) {
            $question_args['tax_query'] = array(array('taxonomy' => 'question_tags', 'field' => 'id', 'terms' => array(get_question_tag_id())));
            $question = new WP_Query($question_args);
            $tag = $question->get_queried_object();
        } elseif (is_question_cat()) {
            $question_args['tax_query'] = array(array('taxonomy' => 'question_category', 'field' => 'id', 'terms' => array(get_question_cat_id())));
            $question = new WP_Query($question_args);
            $category = $question->get_queried_object();
        } elseif (is_question_tags()) {
            $paged = get_query_var('paged') ? get_query_var('paged') : 1;
            $per_page = ap_opt('tags_per_page');
            $total_terms = wp_count_terms('question_tags');
            $offset = $per_page * ($paged - 1);
            $args = array('number' => $per_page, 'offset' => $offset, 'hide_empty' => false, 'orderby' => 'count', 'order' => 'DESC');
            $tags = get_terms('question_tags', $args);
        } elseif (is_question_categories()) {
            $paged = get_query_var('paged') ? get_query_var('paged') : 1;
            $per_page = ap_opt('categories_per_page');
            $total_terms = wp_count_terms('question_category');
            $offset = $per_page * ($paged - 1);
            $cat_args = array('parent' => 0, 'number' => $per_page, 'offset' => $offset, 'hide_empty' => false, 'orderby' => 'count', 'order' => 'DESC');
            $categories = get_terms('question_category', $cat_args);
        } elseif (is_ap_users()) {
            global $current_user_meta;
            $count_args = array('fields' => 'all_with_meta', 'number' => 999999);
            $user_count_query = new WP_User_Query($count_args);
            $user_count = $user_count_query->get_results();
            // count the number of users found in the query
            $total_users = $user_count ? count($user_count) : 1;
            // how many users to show per page
            $per_page = ap_opt('users_per_page');
            // grab the current page number and set to 1 if no page number is set
            $paged = get_query_var('paged') ? get_query_var('paged') : 1;
            // calculate the total number of pages.
            $total_pages = 1;
            $offset = $per_page * ($paged - 1);
            $total_pages = ceil($total_users / $per_page);
            $order = get_query_var('sort');
            if (empty($order)) {
                $order = 'points';
            }
            $args = array('number' => $per_page, 'offset' => $offset);
            if ($order == 'points') {
                $args['ap_query'] = 'sort_points';
                $args['meta_key'] = 'ap_points';
                $args['orderby'] = 'meta_value';
                $args['order'] = 'DESC';
            } elseif ($order == 'newest') {
                $args['orderby'] = 'date';
                $args['order'] = 'DESC';
            }
            // The Query
            $users = new WP_User_Query($args);
        } elseif (is_ap_user()) {
            global $current_user_meta;
            global $user;
            $user = get_userdata(ap_get_user_page_user());
            if ($user === FALSE) {
                echo '<div class="user-not-found">' . __('User not found', 'ap') . '</div>';
                return;
            }
            $userid = $user->data->ID;
            $display_name = $user->data->display_name;
            $username = $user->data->user_login;
            $current_user_meta = array_map('ap_meta_array_map', get_user_meta($userid));
        } elseif (is_ap_search()) {
            $question_args['s'] = sanitize_text_field(get_query_var('ap_s'));
            $question = new WP_Query($question_args);
        } else {
            $question = new WP_Query($question_args);
        }
        echo '<div class="ap-container">';
        do_action('ap_page_top');
        echo '<div class="ap-dtable">';
        echo '<div class="ap-cl">';
        include ap_get_theme_location(ap_get_current_page_template());
        if (is_ap_users()) {
            $base = ap_get_link_to('users') . '/%_%';
            ap_pagi($base, ceil($total_users / $per_page), $paged);
        }
        if (is_question_tags()) {
            ap_pagi(ap_get_link_to('tags') . '/%_%', ceil($total_terms / $per_page), $paged);
        }
        if (is_question_categories()) {
            ap_pagi(ap_get_link_to('categories') . '/%_%', ceil($total_terms / $per_page), $paged);
        }
        echo '</div>';
        if (!is_question() && is_active_sidebar('ap-sidebar')) {
            echo '<div class="ap-sidebar">';
            dynamic_sidebar('ap-sidebar');
            echo '</div>';
        }
        echo '</div>';
        if (!ap_opt('author_credits')) {
            ?>
				<div class="ap-footer">
					<p class="ap-author-credit">AnsPress Version <?php 
            echo AP_VERSION;
            ?>
</p>
				</div>
			<?php 
        }
        wp_reset_postdata();
        echo '</div>';
    }