本文整理汇总了PHP中is_question函数的典型用法代码示例。如果您正苦于以下问题:PHP is_question函数的具体用法?PHP is_question怎么用?PHP is_question使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_question函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: widget
public function widget($args, $instance)
{
$title = apply_filters('widget_title', @$instance['title']);
echo $args['before_widget'];
if (!empty($title)) {
echo $args['before_title'] . $title . $args['after_title'];
}
$ans_count = ap_question_get_the_answer_count();
$last_active = ap_question_get_the_active_ago();
$total_subs = ap_question_get_the_subscriber_count();
$view_count = ap_question_get_the_view_count();
echo '<div class="ap-widget-inner">';
if (is_question()) {
echo '<ul class="ap-stats-widget">';
echo '<li><span class="stat-label apicon-pulse">' . __('Active', 'ap') . '</span><span class="stat-value"><time class="published updated" itemprop="dateModified" datetime="' . mysql2date('c', $last_active) . '">' . ap_human_time(mysql2date('U', $last_active)) . '</time></span></li>';
echo '<li><span class="stat-label apicon-eye">' . __('Views', 'ap') . '</span><span class="stat-value">' . sprintf(_n('One time', '%d times', $view_count, 'ap'), $view_count) . '</span></li>';
echo '<li><span class="stat-label apicon-answer">' . __('Answers', 'ap') . '</span><span class="stat-value">' . sprintf(_n('%2$s1%3$s answer', '%2$s%1$d%3$s answers', $ans_count, 'ap'), $ans_count, '<span data-view="answer_count">', '</span>') . '</span></li>';
echo '<li><span class="stat-label apicon-mail">' . __('Followers', 'ap') . '</span><span class="stat-value">' . sprintf(_n('1 follower', '%d followers', $total_subs, 'ap'), $total_subs) . '</span></li>';
echo '</ul>';
} else {
_e('This widget can only be used in single question page', 'ap');
}
echo '</div>';
echo $args['after_widget'];
}
示例2: ap_append_vote_count
function ap_append_vote_count($post)
{
if (!is_question() && ($post->post_type == 'question' || $post->post_type == 'answer')) {
$post->net_vote = ap_net_vote_meta($post->ID);
$post->selected = get_post_meta($post->ID, ANSPRESS_SELECTED_META, true);
$post->closed = get_post_meta($post->ID, ANSPRESS_CLOSE_META, true);
} elseif ($post->post_type == 'question' || $post->post_type == 'answer') {
//voted up count
if (is_object($post)) {
$votes = ap_post_votes($post->ID);
// net vote
$post->voted_up = $votes['voted_up'];
$post->voted_down = $votes['voted_down'];
$post->net_vote = $votes['voted_up'] - $votes['voted_down'];
//closed count
$post->closed = get_post_meta($post->ID, ANSPRESS_CLOSE_META, true);
$post->selected = get_post_meta($post->ID, ANSPRESS_SELECTED_META, true);
//flagged count
$post->flag = get_post_meta($post->ID, ANSPRESS_FLAG_META, true);
//favorite count
$post->favorite = get_post_meta($post->ID, ANSPRESS_FAV_META, true);
$post->voted_closed = ap_is_user_voted_closed();
$post->flagged = ap_is_user_flagged();
//if current logged in user voted
if (is_user_logged_in()) {
$post->favorited = ap_is_user_favorite($post->ID);
$userid = get_current_user_id();
$post->user_voted_up = ap_is_user_voted($post->ID, 'vote_up', $userid);
$post->user_voted_down = ap_is_user_voted($post->ID, 'vote_down', $userid);
}
}
}
}
示例3: wp_head
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">';
}
}
示例4: insert_views
public function insert_views($post)
{
if (is_question() && $post->post_type == 'question') {
if (!ap_is_already_viewed(get_current_user_id(), $post->ID)) {
ap_insert_views($post->ID, $post->post_type);
}
}
}
示例5: insert_views
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');
}
}
示例6: ap_get_breadcrumbs
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);
}
示例7: ap_subscribe_btn_html
/**
* 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
}
示例8: get_question_id
function get_question_id()
{
if (is_question() && get_query_var('question_id')) {
return (int) get_query_var('question_id');
} elseif (is_question() && get_query_var('question')) {
return get_query_var('question');
} elseif (is_question() && get_query_var('question_name')) {
$post = get_page_by_path(get_query_var('question_name'), OBJECT, 'question');
return $post->ID;
} elseif (get_query_var('edit_q')) {
return get_query_var('edit_q');
} elseif (ap_answer_the_object()) {
return ap_answer_get_the_question_id();
}
return false;
}
示例9: wpseo_canonical
/**
* Update concal link when wpseo plugin installed
* @return string
*/
public function wpseo_canonical()
{
if (is_question()) {
return get_permalink(get_question_id());
}
}
示例10: ap_base_page_sc
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>';
//.........这里部分代码省略.........
示例11: ap_current_page_is
function ap_current_page_is()
{
if (is_anspress()) {
if (is_question()) {
$template = 'question';
} elseif (is_ask()) {
$template = 'ask';
} elseif (is_question_categories()) {
$template = 'categories';
} elseif (is_question_tags()) {
$template = 'tags';
} elseif (is_question_tag()) {
$template = 'tag';
} elseif (is_question_cat()) {
$template = 'category';
} elseif (is_question_edit()) {
$template = 'edit-question';
} elseif (is_answer_edit()) {
$template = 'edit-answer';
} elseif (is_ap_users()) {
$template = 'users';
} elseif (is_ap_user()) {
$template = 'user';
} elseif (is_ap_search()) {
$template = 'search';
} elseif (is_ap_revision()) {
$template = 'revision';
} elseif (get_query_var('ap_page') == '') {
$template = 'base';
} else {
$template = 'not-found';
}
return apply_filters('ap_current_page_is', $template);
}
return false;
}
示例12: ap_question_subscribers
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>';
}
}
示例13: ap_current_page
/**
* Return current AnsPress page
* @return string
*/
function ap_current_page()
{
$query_var = get_query_var('ap_page');
if (is_question()) {
$query_var = 'question';
} elseif ('' == $query_var) {
$query_var = 'base';
}
return apply_filters('ap_current_page', esc_attr($query_var));
}
示例14: ap_answers_list
function ap_answers_list($question_id, $order = 'voted')
{
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
if (is_question()) {
$order = get_query_var('sort');
if (empty($order)) {
$order = ap_opt('answers_sort');
}
}
if ($order == 'voted') {
$ans_args = array('ap_query' => 'answer_sort_voted', 'post_type' => 'answer', 'post_status' => 'publish', 'post_parent' => get_the_ID(), 'showposts' => ap_opt('answers_per_page'), 'paged' => $paged, 'orderby' => 'meta_value_num', 'meta_key' => ANSPRESS_VOTE_META, 'meta_query' => array('relation' => 'OR', array('key' => ANSPRESS_BEST_META, 'compare' => '=', 'value' => '1'), array('key' => ANSPRESS_BEST_META, 'compare' => 'NOT EXISTS')));
} elseif ($order == 'oldest') {
$ans_args = array('ap_query' => 'answer_sort_newest', 'post_type' => 'answer', 'post_status' => 'publish', 'post_parent' => get_the_ID(), 'showposts' => ap_opt('answers_per_page'), 'paged' => $paged, 'orderby' => 'meta_value date', 'meta_key' => ANSPRESS_BEST_META, 'order' => 'ASC', 'meta_query' => array('relation' => 'OR', array('key' => ANSPRESS_BEST_META, 'compare' => 'NOT EXISTS')));
} else {
$ans_args = array('ap_query' => 'answer_sort_newest', 'post_type' => 'answer', 'post_status' => 'publish', 'post_parent' => get_the_ID(), 'showposts' => ap_opt('answers_per_page'), 'paged' => $paged, 'orderby' => 'meta_value date', 'meta_key' => ANSPRESS_BEST_META, 'order' => 'DESC', 'meta_query' => array('relation' => 'OR', array('key' => ANSPRESS_BEST_META, 'compare' => 'NOT EXISTS')));
}
$ans_args = apply_filters('ap_answers_query_args', $ans_args);
$ans = new WP_Query($ans_args);
// get answer sorting tab
echo '<div id="answers-c">';
ap_ans_tab();
echo '<div id="answers">';
while ($ans->have_posts()) {
$ans->the_post();
include ap_get_theme_location('answer.php');
}
echo '</div>';
ap_pagination('', 2, $paged, $ans);
echo '</div>';
wp_reset_query();
}