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


PHP ap_get_answers函数代码示例

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


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

示例1: answers_page

 /**
  * Output for user answers page
  * @since 2.0.1
  */
 public function answers_page()
 {
     global $answers;
     $answers = ap_get_answers(array('author' => ap_get_displayed_user_id()));
     include ap_get_theme_location('user/user-answers.php');
     wp_reset_postdata();
 }
开发者ID:alaershov,项目名称:anspress,代码行数:11,代码来源:class-user.php

示例2: process_answer_form

 /**
  * Process answer form
  */
 public function process_answer_form()
 {
     global $ap_errors, $validate;
     if (ap_show_captcha_to_user() && !$this->check_recaptcha()) {
         $this->result = array('form' => $_POST['ap_form_action'], 'message' => 'captcha_error', 'errors' => array('captcha' => __('Bot verification failed.', 'ap')));
         return;
     }
     $question = get_post((int) $_POST['form_question_id']);
     $args = array('description' => array('sanitize' => array('remove_more', 'encode_pre_code', 'wp_kses'), 'validate' => array('required' => true, 'length_check' => ap_opt('minimum_question_length'))), 'is_private' => array('sanitize' => array('only_boolean')), 'name' => array('sanitize' => array('strip_tags', 'sanitize_text_field')), 'form_question_id' => array('sanitize' => array('only_int')), 'edit_post_id' => array('sanitize' => array('only_int')));
     /**
      * FILTER: ap_answer_fields_validation
      * Filter can be used to modify answer form fields.
      * @var void
      * @since 2.0.1
      */
     $args = apply_filters('ap_answer_fields_validation', $args);
     $validate = new AnsPress_Validation($args);
     $ap_errors = $validate->get_errors();
     // if error in form then return
     if ($validate->have_error()) {
         $this->result = array('form' => $_POST['ap_form_action'], 'message_type' => 'error', 'message' => __('Check missing fields and then re-submit.', 'ap'), 'errors' => $ap_errors);
         return;
     }
     $fields = $validate->get_sanitized_fields();
     $this->fields = $fields;
     if (!empty($fields['edit_post_id'])) {
         $this->edit_answer($question);
         return;
     }
     // Do security check, if fails then return
     if (!ap_user_can_answer($question->ID) || !isset($_POST['__nonce']) || !wp_verify_nonce($_POST['__nonce'], 'nonce_answer_' . $question->ID)) {
         $this->result = ap_ajax_responce('no_permission');
         return;
     }
     $user_id = get_current_user_id();
     $status = 'publish';
     if (ap_opt('new_answer_status') == 'moderate' || ap_opt('new_answer_status') == 'point' && ap_get_points($user_id) < ap_opt('new_answer_status')) {
         $status = 'moderate';
     }
     if (isset($this->fields['is_private']) && $this->fields['is_private']) {
         $status = 'private_post';
     }
     $answer_array = array('post_title' => $question->post_title, 'post_author' => $user_id, 'post_content' => apply_filters('ap_form_contents_filter', $fields['description']), 'post_parent' => $question->ID, 'post_type' => 'answer', 'post_status' => $status, 'comment_status' => 'open');
     /**
      * FILTER: ap_pre_insert_answer
      * Can be used to modify args before inserting answer
      * @var array
      * @since 2.0.1
      */
     $answer_array = apply_filters('ap_pre_insert_answer', $answer_array);
     $post_id = wp_insert_post($answer_array);
     if ($post_id) {
         // get existing answer count
         $current_ans = ap_count_published_answers($question->ID);
         if (!is_user_logged_in() && ap_opt('allow_anonymous') && isset($fields['name'])) {
             update_post_meta($post_id, 'anonymous_name', $fields['name']);
         }
         if ($this->is_ajax) {
             if ($current_ans == 1) {
                 global $post;
                 $post = $question;
                 setup_postdata($post);
             } else {
                 global $post;
                 $post = get_post($post_id);
                 setup_postdata($post);
             }
             ob_start();
             global $answers;
             if ($current_ans == 1) {
                 $answers = ap_get_answers(array('question_id' => $question->ID));
                 ap_get_template_part('answers');
             } else {
                 $answers = ap_get_answers(array('p' => $post_id));
                 while (ap_have_answers()) {
                     ap_the_answer();
                     ap_get_template_part('answer');
                 }
             }
             $html = ob_get_clean();
             $count_label = sprintf(_n('1 Answer', '%d Answers', $current_ans, 'ap'), $current_ans);
             $result = array('postid' => $post_id, 'action' => 'new_answer', 'div_id' => '#answer_' . get_the_ID(), 'can_answer' => ap_user_can_answer($post->ID), 'html' => $html, 'message' => 'answer_submitted', 'do' => 'clearForm', 'view' => array('answer_count' => $current_ans, 'answer_count_label' => $count_label));
             $this->result = $result;
         }
     }
     $this->process_image_uploads($post_id, $user_id);
 }
开发者ID:Byrlyne,项目名称:anspress,代码行数:90,代码来源:process-form.php

示例3: ap_icon

		</div><!-- close .ap-about-block-c -->

	</div><!-- close .ap-about-block -->

	<div class="ap-about-block top-answers">
		<h3><?php 
echo ap_icon('answer', true);
?>
 <?php 
_e('Top Answers', 'ap');
?>
</h3>
		<div class="ap-about-block-c">
			<?php 
ap_get_answers(array('author' => ap_get_displayed_user_id(), 'showposts' => 5, 'sortby' => 'voted'));
?>
			<?php 
if (ap_have_answers()) {
    ?>
				<?php 
    while (ap_answers()) {
        ap_the_answer();
        ?>
					<?php 
        ap_get_template_part('user/list-answer');
        ?>
				<?php 
    }
    ?>
				<div class="ap-user-posts-footer">
开发者ID:kevinfodness,项目名称:anspress,代码行数:30,代码来源:about.php

示例4: ap_question_the_answers

/**
 * Output answer of active question.
 * @return void
 * @since 2.1
 */
function ap_question_the_answers()
{
    include ap_get_theme_location('best_answer.php');
    ap_get_answers();
    include ap_get_theme_location('answers.php');
    wp_reset_postdata();
}
开发者ID:haythameyd,项目名称:powrly,代码行数:12,代码来源:question-loop.php

示例5: ap_question_the_answers

/**
 * Output answer of active question.
 * @return void
 * @since 2.1
 */
function ap_question_the_answers()
{
    global $answers;
    $answers = ap_get_best_answer();
    include ap_get_theme_location('best_answer.php');
    $answers = ap_get_answers();
    include ap_get_theme_location('answers.php');
    wp_reset_postdata();
}
开发者ID:Byrlyne,项目名称:anspress,代码行数:14,代码来源:question-loop.php

示例6: answers_meta_box_content

    /**
     * Render Meta Box content.
     */
    public function answers_meta_box_content()
    {
        global $answers;
        $answers = ap_get_answers(array('question_id' => get_the_ID()));
        if (ap_have_answers()) {
            while (ap_have_answers()) {
                ap_the_answer();
                ?>
            <div id="answer_<?php 
                the_ID();
                ?>
" data-id="<?php 
                the_ID();
                ?>
" class="ap-ansm clearfix">
                <div class="author">
					<a class="ap-ansm-avatar" href="<?php 
                ap_answer_the_author_link();
                ?>
"<?php 
                ap_hover_card_attributes(ap_answer_get_author_id());
                ?>
>
						<?php 
                ap_answer_the_author_avatar();
                ?>
					</a>
					<strong class="ap-ansm-name"><?php 
                echo ap_user_display_name(ap_answer_get_author_id());
                ?>
</strong>
                </div>

                <div class="ap-ansm-inner">
                    
                    <div class="ap-ansm-meta">
						<?php 
                ap_answer_the_active_time();
                ?>
					</div>
					
					<div class="ap-ansm-content"><?php 
                the_content();
                ?>
</div>
					
					<div class="answer-actions">

						<span><a href="<?php 
                echo get_edit_post_link(get_the_ID());
                ?>
"><?php 
                _e('Edit', 'ap');
                ?>
</a></span>
						<span class="delete vim-d vim-destructive"> | <a href="<?php 
                echo get_delete_post_link(get_the_ID());
                ?>
"><?php 
                _e('Trash', 'ap');
                ?>
</a></span>
					</div>

				</div>
			</div>
			<?php 
            }
        } else {
            ?>
            <div class="inside">
				<a href="#addanswerbtn" class="button"><?php 
            _e('Add answer', 'ap');
            ?>
</a>
				<?php 
            _e('No answers yet', 'ap');
            ?>
            </div>
            
			<?php 
        }
        wp_reset_postdata();
    }
开发者ID:Byrlyne,项目名称:anspress,代码行数:87,代码来源:meta_box.php


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