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


PHP ap_question_best_answer_selected函数代码示例

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


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

示例1: 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

示例2: ap_display_question_metas

/**
 * Question meta to display
 * @param  false|integer $question_id
 * @return string
 * @since 2.0.1
 */
function ap_display_question_metas($question_id = false)
{
    if (false === $question_id) {
        $question_id = get_the_ID();
    }
    $metas = array();
    if (!is_question()) {
        if (ap_question_best_answer_selected()) {
            $metas['solved'] = '<span class="ap-best-answer-label ap-tip" title="' . __('answer accepted', 'ap') . '">' . __('Solved', 'ap') . '</span>';
        }
        $view_count = ap_get_qa_views();
        $metas['views'] = sprintf(__('<i>%d views</i>', 'ap'), $view_count);
        $metas['history'] = ap_get_latest_history_html($question_id, true);
    }
    /**
     * FILTER: ap_display_question_meta
     * Used to filter question display meta
     */
    $metas = apply_filters('ap_display_question_metas', $metas, $question_id);
    $output = '';
    if (!empty($metas) && is_array($metas)) {
        foreach ($metas as $meta => $display) {
            $output .= "<span class='ap-display-meta-item {$meta}'>{$display}</span>";
        }
    }
    return $output;
}
开发者ID:haythameyd,项目名称:powrly,代码行数:33,代码来源:theme.php

示例3: select_best_answer

 /**
  * Ajax action for selecting a best answer.
  *
  * @since 2.0.0
  */
 public function select_best_answer()
 {
     $answer_id = (int) $_POST['answer_id'];
     if (!is_user_logged_in()) {
         ap_send_json(ap_ajax_responce('no_permission'));
         return;
     }
     if (!wp_verify_nonce($_POST['__nonce'], 'answer-' . $answer_id)) {
         $this->something_wrong();
     }
     $post = get_post($answer_id);
     if (ap_question_best_answer_selected($post->post_parent)) {
         do_action('ap_unselect_answer', $post->post_author, $post->post_parent, $post->ID);
         update_post_meta($post->ID, ANSPRESS_BEST_META, 0);
         update_post_meta($post->post_parent, ANSPRESS_SELECTED_META, false);
         update_post_meta($post->post_parent, ANSPRESS_UPDATED_META, current_time('mysql'));
         if (ap_opt('close_after_selecting')) {
             wp_update_post(array('ID' => $post->post_parent, 'post_status' => 'publish'));
         }
         ap_update_user_best_answers_count_meta($post->post_author);
         ap_update_user_solved_answers_count_meta($post->post_author);
         $this->send(array('message' => 'unselected_the_answer', 'action' => 'unselected_answer', 'do' => 'reload'));
     } else {
         do_action('ap_select_answer', $post->post_author, $post->post_parent, $post->ID);
         update_post_meta($post->ID, ANSPRESS_BEST_META, 1);
         update_post_meta($post->post_parent, ANSPRESS_SELECTED_META, $post->ID);
         update_post_meta($post->post_parent, ANSPRESS_UPDATED_META, current_time('mysql'));
         if (ap_opt('close_after_selecting')) {
             wp_update_post(array('ID' => $post->post_parent, 'post_status' => 'closed'));
         }
         ap_update_user_best_answers_count_meta($post->post_author);
         ap_update_user_solved_answers_count_meta($post->post_author);
         $html = ap_select_answer_btn_html($answer_id);
         $this->send(array('message' => 'selected_the_answer', 'action' => 'selected_answer', 'do' => 'reload', 'html' => $html));
     }
 }
开发者ID:alaershov,项目名称:anspress,代码行数:41,代码来源:ajax.php

示例4: ap_get_questions

?>
</h3>
				<?php 
$questions = ap_get_questions(array('sortby' => 'newest'));
if (ap_have_questions()) {
    ?>

				<div class="ap-user-posts">
					<?php 
    while (ap_questions()) {
        ap_the_question();
        ?>

						<div class="ap-user-posts-item clearfix">
							<a class="ap-user-posts-vcount ap-tip<?php 
        echo ap_question_best_answer_selected() ? ' answer-selected' : '';
        ?>
" href="<?php 
        ap_question_the_permalink();
        ?>
" title="<?php 
        _e('Answers');
        ?>
"><?php 
        echo ap_icon('answer', true);
        echo ap_question_get_the_answer_count();
        ?>
</a>
							<span class="ap-user-posts-active"><?php 
        ap_question_the_active_ago();
        ?>
开发者ID:VLabsInc,项目名称:WordPressPlatforms,代码行数:31,代码来源:dashboard.php

示例5: ap_question_title_with_solved_prefix

/**
 * 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);
}
开发者ID:Krl4,项目名称:anspress,代码行数:20,代码来源:functions.php


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