当前位置: 首页>>代码示例>>PHP>>正文


PHP ap_count_answer_meta函数代码示例

本文整理汇总了PHP中ap_count_answer_meta函数的典型用法代码示例。如果您正苦于以下问题:PHP ap_count_answer_meta函数的具体用法?PHP ap_count_answer_meta怎么用?PHP ap_count_answer_meta使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ap_count_answer_meta函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: suggest_similar_questions

 /**
  * Show similar questions when asking a question.
  *
  * @since 2.0.1
  */
 public function suggest_similar_questions()
 {
     if (empty($_POST['value']) || !ap_verify_default_nonce() && !current_user_can('manage_options')) {
         wp_die('false');
     }
     $keyword = sanitize_text_field(wp_unslash($_POST['value']));
     $is_admin = (bool) $_POST['is_admin'];
     $questions = get_posts(array('post_type' => 'question', 'showposts' => 10, 's' => $keyword));
     if ($questions) {
         $items = '<div class="ap-similar-questions-head">';
         $items .= '<h3>' . ap_icon('check', true) . sprintf(__('%d similar questions found', 'anspress-question-answer'), count($questions)) . '</h3>';
         $items .= '<p>' . __('We\'ve found similar questions that have already been asked, click to read them.', 'anspress-question-answer') . '</p>';
         $items .= '</div>';
         $items .= '<div class="ap-similar-questions">';
         foreach ($questions as $p) {
             $count = ap_count_answer_meta($p->ID);
             $p->post_title = ap_highlight_words($p->post_title, $keyword);
             if ($is_admin) {
                 $items .= '<div class="ap-q-suggestion-item clearfix"><a class="select-question-button button button-primary button-small" href="' . add_query_arg(array('post_type' => 'answer', 'post_parent' => $p->ID), admin_url('post-new.php')) . '">' . __('Select', 'anspress-question-answer') . '</a><span class="question-title">' . $p->post_title . '</span><span class="acount">' . sprintf(_n('1 Answer', '%d Answers', $count, 'anspress-question-answer'), $count) . '</span></div>';
             } else {
                 $items .= '<a class="ap-sqitem clearfix" target="_blank" href="' . get_permalink($p->ID) . '"><span class="acount">' . sprintf(_n('1 Answer', '%d Answers', $count, 'anspress-question-answer'), $count) . '</span><span class="ap-title">' . $p->post_title . '</span></a>';
             }
         }
         $items .= '</div>';
         $result = array('status' => true, 'html' => $items);
     } else {
         $result = array('status' => false, 'message' => __('No related questions found', 'anspress-question-answer'));
     }
     $this->send($result);
 }
开发者ID:alaershov,项目名称:anspress,代码行数:35,代码来源:ajax.php

示例2: suggest_similar_questions

 /**
  * Show similar questions when asking a question
  * @return void
  * @since 2.0.1
  */
 public function suggest_similar_questions()
 {
     if (empty($_POST['value'])) {
         return;
     }
     $keyword = sanitize_text_field($_POST['value']);
     $questions = get_posts(array('post_type' => 'question', 'showposts' => 10, 's' => $keyword));
     if ($questions) {
         $items = '<div class="ap-similar-questions-head">';
         $items .= '<h3>' . ap_icon('check', true) . sprintf(__('%d similar questions found', 'ap'), count($questions)) . '</h3>';
         $items .= '<p>' . __('We found similar questions that have already been asked, click to read them. Avoid creating duplicate questions, it will be deleted.') . '</p>';
         $items .= '</div>';
         $items .= '<div class="ap-similar-questions">';
         foreach ($questions as $p) {
             $count = ap_count_answer_meta($p->ID);
             $p->post_title = ap_highlight_words($p->post_title, $keyword);
             if (!isset($_POST['is_admin'])) {
                 $items .= '<a class="ap-sqitem clearfix" href="' . get_permalink($p->ID) . '"><span class="acount">' . sprintf(_n('1 Answer', '%d Answers', $count, 'ap'), $count) . '</span><span class="ap-title">' . $p->post_title . '</span></a>';
             } else {
                 $items .= '<div class="ap-q-suggestion-item clearfix"><a class="select-question-button button button-primary button-small" href="' . add_query_arg(array('post_type' => 'answer', 'post_parent' => $p->ID), admin_url('post-new.php')) . '">' . __('Select', 'ap') . '</a><span class="question-title">' . $p->post_title . '</span><span class="acount">' . sprintf(_n('1 Answer', '%d Answers', $count, 'ap'), $count) . '</span></div>';
             }
         }
         $items .= '</div>';
         $result = array('status' => true, 'html' => $items);
     } else {
         $result = array('status' => false, 'message' => __('No related questions found', 'ap'));
     }
     ap_send_json($result);
 }
开发者ID:VLabsInc,项目名称:WordPressPlatforms,代码行数:34,代码来源:ajax.php

示例3: question_answer_post_class

 /**
  * Add answer-seleted class in post_class
  * @param  array $classes Post class attribute.
  * @return array
  * @since 2.0.1
  */
 public function question_answer_post_class($classes)
 {
     global $post;
     if ('question' == $post->post_type) {
         if (ap_question_best_answer_selected($post->ID)) {
             $classes[] = 'answer-selected';
         }
         if (ap_is_featured_question($post->ID)) {
             $classes[] = 'featured-question';
         }
         $classes[] = 'answer-count-' . ap_count_answer_meta();
     } elseif ('answer' == $post->post_type) {
         if (ap_answer_is_best($post->ID)) {
             $classes[] = 'best-answer';
         }
     }
     return $classes;
 }
开发者ID:Byrlyne,项目名称:anspress,代码行数:24,代码来源:class-theme.php

示例4: question_meta_box_content

    public function question_meta_box_content($post)
    {
        $ans_count = ap_count_answer_meta($post->ID);
        $vote_count = get_post_meta($post->ID, ANSPRESS_VOTE_META, true);
        ?>
			<ul>
				<li> <?php 
        printf(_n('<strong>1</strong> Answer', '<strong>%d</strong> Answers', $ans_count, 'ap'), $ans_count);
        ?>
 </li>
				<li> <?php 
        printf(_n('<strong>1</strong> Vote', '<strong>%d</strong> Votes', $vote_count, 'ap'), $vote_count);
        ?>
 </li>
			</ul>
		<?php 
    }
开发者ID:haythameyd,项目名称:powrly,代码行数:17,代码来源:meta_box.php

示例5: ap_count_other_answer

/**
 * Count all answers excluding best answer.
 *
 * @return int
 */
function ap_count_other_answer($question_id = false)
{
    if (!$question_id) {
        $question_id = get_question_id();
    }
    $count = ap_count_answer_meta($question_id);
    if (ap_question_best_answer_selected($question_id)) {
        return (int) ($count - 1);
    }
    return (int) $count;
}
开发者ID:Krl4,项目名称:anspress,代码行数:16,代码来源:functions.php

示例6: ap_question_get_the_answer_count

/**
 * Return active question answer count
 * @return integer
 * @since 2.1
 */
function ap_question_get_the_answer_count()
{
    return ap_count_answer_meta(ap_question_get_the_ID());
}
开发者ID:haythameyd,项目名称:powrly,代码行数:9,代码来源:question-loop.php

示例7: custom_columns_value

 public function custom_columns_value($column)
 {
     global $post;
     if (!($post->post_type != 'question' || $post->post_type != 'answer')) {
         return $column;
     }
     if ('asker' == $column || 'answerer' == $column) {
         echo get_avatar(get_the_author_meta('user_email'), 40);
     } elseif ('status' == $column) {
         echo '<span class="post-status">';
         if ('private_post' == $post->post_status) {
             echo __('Private', 'ap');
         } elseif ('closed' == $post->post_status) {
             echo __('Closed', 'ap');
         } elseif ('moderate' == $post->post_status) {
             echo __('Moderate', 'ap');
         } elseif ('private' == $post->post_status) {
             echo __('Private', 'ap');
         } elseif ('darft' == $post->post_status) {
             echo __('Draft', 'ap');
         } elseif ('pending' == $post->post_status) {
             echo __('Pending', 'ap');
         } elseif ('trash' == $post->post_status) {
             echo __('Trash', 'ap');
         } else {
             echo __('Open', 'ap');
         }
         echo '</span>';
     } elseif ('question_category' == $column && taxonomy_exists('question_category')) {
         $category = get_the_terms($post->ID, 'question_category');
         if (!empty($category)) {
             $out = array();
             foreach ($category as $cat) {
                 $out[] = edit_term_link($cat->name, '', '', $cat, false);
             }
             echo join(', ', $out);
         } else {
             _e('--');
         }
     } elseif ('question_tag' == $column && taxonomy_exists('question_tag')) {
         $terms = get_the_terms($post->ID, 'question_tag');
         if (!empty($terms)) {
             $out = array();
             foreach ($terms as $term) {
                 $out[] = sprintf('<a href="%s">%s</a>', esc_url(add_query_arg(array('post_type' => $post->post_type, 'question_tag' => $term->slug), 'edit.php')), esc_html(sanitize_term_field('name', $term->name, $term->term_id, 'question_tag', 'display')));
             }
             echo join(', ', $out);
         } else {
             _e('--', 'ap');
         }
     } elseif ('answers' == $column) {
         $a_count = ap_count_answer_meta();
         /* If terms were found. */
         if (!empty($a_count)) {
             echo '<a class="ans-count" title="' . $a_count . __('answers', 'ap') . '" href="' . esc_url(add_query_arg(array('post_type' => 'answer', 'post_parent' => $post->ID), 'edit.php')) . '">' . $a_count . '</a>';
         } else {
             echo '<a class="ans-count" title="0' . __('answers', 'ap') . '">0</a>';
         }
     } elseif ('parent_question' == $column) {
         echo '<a class="parent_question" href="' . esc_url(add_query_arg(array('post' => $post->post_parent, 'action' => 'edit'), 'post.php')) . '"><strong>' . get_the_title($post->post_parent) . '</strong></a>';
     } elseif ('vote' == $column) {
         $vote = get_post_meta($post->ID, ANSPRESS_VOTE_META, true);
         echo '<span class="vote-count' . ($vote ? ' zero' : '') . '">' . $vote . '</span>';
     } elseif ('flag' == $column) {
         $total_flag = ap_post_flag_count();
         echo '<span class="flag-count' . ($total_flag ? ' flagged' : '') . '">' . $total_flag . '</span>';
     }
 }
开发者ID:haythameyd,项目名称:powrly,代码行数:68,代码来源:post_types.php

示例8: question_meta_box_content

    public function question_meta_box_content($post)
    {
        $ans_count = ap_count_answer_meta($post->ID);
        $vote_count = get_post_meta($post->ID, ANSPRESS_VOTE_META, true);
        ?>
            <ul class="ap-meta-list">
            	<?php 
        if ('answer' == $post->post_type) {
            ?>
					<li>
						<i class="apicon-answer"></i>
						<?php 
            printf(_n('<strong>1</strong> Answer', '<strong>%d</strong> Answers', $ans_count, 'anspress-question-answer'), $ans_count);
            ?>
						<a href="#" class="add-answer"><?php 
            _e('Add an answer', 'anspress-question-answer');
            ?>
</a>
					</li>
				<?php 
        }
        ?>
				
				<li>
					<i class="apicon-thumb-up"></i>
					<?php 
        printf(_n('<strong>1</strong> Vote', '<strong>%d</strong> Votes', $vote_count, 'anspress-question-answer'), $vote_count);
        ?>
					
					<a id="ap-vote-down" href="#" class="vote button button-small"><?php 
        _e('-', 'anspress-question-answer');
        ?>
</a>
					<a id="ap-vote-up" href="#" class="vote button button-small"><?php 
        _e('+', 'anspress-question-answer');
        ?>
</a>
				</li>
				<li><?php 
        $this->flag_meta_box($post);
        ?>
 </li>
            </ul>
		<?php 
    }
开发者ID:erashu212,项目名称:anspress,代码行数:45,代码来源:meta_box.php


注:本文中的ap_count_answer_meta函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。