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


PHP ap_user_can_edit_question函数代码示例

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


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

示例1: ap_load_edit_form

 public function ap_load_edit_form()
 {
     $nonce = sanitize_text_field($_POST['nonce']);
     $post_id = sanitize_text_field($_POST['id']);
     $type = sanitize_text_field($_POST['type']);
     if (wp_verify_nonce($nonce, $type . '-' . $post_id)) {
         $post = get_post($post_id);
         if (ap_user_can_edit_question($post_id) && $post->post_type == 'question') {
             ob_start();
             ap_edit_question_form($post_id);
             $html = ob_get_clean();
             $result = array('action' => true, 'type' => 'question', 'message' => __('Form loaded.', 'ap'), 'html' => $html);
         } elseif (ap_user_can_edit_answer($post_id) && $post->post_type == 'answer') {
             ob_start();
             ap_edit_answer_form($post_id);
             $html = ob_get_clean();
             $result = array('action' => true, 'type' => 'answer', 'message' => __('Form loaded.', 'ap'), 'html' => $html);
         } else {
             $result = array('action' => false, 'message' => __('You do not have permission to edit this question.', 'ap'));
         }
     } else {
         $result = array('action' => false, 'message' => __('Something went wrong, please try again.', 'ap'));
     }
     die(json_encode($result));
 }
开发者ID:jessor,项目名称:anspress,代码行数:25,代码来源:anspress-form.php

示例2: ap_post_actions_buttons

/**
 * Post actions buttons
 * @return 	string
 * @param  array $disable
 * @return void
 * @since 	2.0
 */
function ap_post_actions_buttons($disable = array())
{
    global $post;
    if (!$post->post_type == 'question' || !$post->post_type == 'answer') {
        return;
    }
    $actions = array();
    /**
     * Select answer button
     * @var string
     */
    if ($post->post_type == 'answer') {
        $actions['select_answer'] = ap_select_answer_btn_html($post->ID);
    }
    /**
     * Comment button
     */
    if (ap_user_can_comment()) {
        $actions['comment'] = ap_comment_btn_html();
    }
    $actions['status'] = ap_post_change_status_btn_html($post->ID);
    /**
     * edit question link
     */
    if (ap_user_can_edit_question($post->ID) && $post->post_type == 'question') {
        $actions['dropdown']['edit_question'] = ap_edit_post_link_html();
    }
    if (ap_user_can_edit_ans($post->ID) && $post->post_type == 'answer') {
        $actions['dropdown']['edit_answer'] = ap_edit_post_link_html();
    }
    if (is_user_logged_in()) {
        $actions['dropdown']['flag'] = ap_flag_btn_html();
    }
    if (is_super_admin() && $post->post_type == 'question') {
        $actions['dropdown']['featured'] = ap_featured_post_btn();
    }
    if (ap_user_can_delete($post->ID) && $post->post_status != 'trash') {
        $actions['dropdown']['delete'] = ap_post_delete_btn_html();
    }
    if (ap_user_can_delete($post->ID)) {
        $actions['dropdown']['permanent_delete'] = ap_post_permanent_delete_btn_html();
    }
    /**
     * FILTER: ap_post_actions_buttons
     * For filtering post actions buttons
     * @var 	string
     * @since 	2.0
     */
    $actions = apply_filters('ap_post_actions_buttons', $actions);
    if (!empty($actions) && count($actions) > 0) {
        echo '<ul id="ap_post_actions_' . $post->ID . '" class="ap-q-actions ap-ul-inline clearfix">';
        foreach ($actions as $k => $action) {
            if (!empty($action) && $k != 'dropdown' && !in_array($k, $disable)) {
                echo '<li class="ap-post-action ap-action-' . $k . '">' . $action . '</li>';
            }
        }
        if (!empty($actions['dropdown'])) {
            echo '<li class="ap-post-action dropdown">';
            echo '<div id="ap_post_action_' . $post->ID . '" class="ap-dropdown">';
            echo '<a class="apicon-ellipsis more-actions ap-tip ap-dropdown-toggle" title="' . __('More action', 'ap') . '" href="#"></a>';
            echo '<ul class="ap-dropdown-menu">';
            foreach ($actions['dropdown'] as $sk => $sub) {
                echo '<li class="ap-post-action ap-action-' . $sk . '">' . $sub . '</li>';
            }
            echo '</ul>';
            echo '</div>';
            echo '</li>';
        }
        echo '</ul>';
    }
}
开发者ID:haythameyd,项目名称:powrly,代码行数:78,代码来源:theme.php

示例3: edit_question

 /**
  * Process edit question form
  * @return void
  * @since 2.0.1
  */
 public function edit_question()
 {
     global $ap_errors, $validate;
     // return if user do not have permission to edit this question
     if (!ap_user_can_edit_question($this->fields['edit_post_id'])) {
         return;
     }
     $post = get_post($this->fields['edit_post_id']);
     $user_id = get_current_user_id();
     $status = 'publish';
     if (ap_opt('edit_question_status') == 'moderate' || ap_opt('edit_question_status') == 'point' && ap_get_points($user_id) < ap_opt('mod_answer_point')) {
         $status = 'moderate';
     }
     if (isset($this->fields['is_private']) && $this->fields['is_private']) {
         $status = 'private_post';
     }
     $question_array = array('ID' => $post->ID, 'post_author' => $post->post_author, 'post_title' => $this->fields['title'], 'post_name' => sanitize_title($this->fields['title']), 'post_content' => apply_filters('ap_form_contents_filter', $this->fields['description']), 'post_status' => $status);
     /**
      * FILTER: ap_pre_update_question
      * Can be used to modify $args before updating question
      * @var array
      * @since 2.0.1
      */
     $question_array = apply_filters('ap_pre_update_question', $question_array);
     $post_id = wp_update_post($question_array);
     if ($post_id) {
         $this->redirect = get_permalink($post_id);
         $this->result = array('action' => 'edited_question', 'message' => 'question_updated', 'do' => array('redirect' => $this->redirect));
     }
     $this->process_image_uploads($post->ID, $post->post_author);
 }
开发者ID:Byrlyne,项目名称:anspress,代码行数:36,代码来源:process-form.php

示例4: ap_edit_post_link_html

/**
 * Returns edit post button html.
 *
 * @param bool         $echo
 * @param int | object $post_id_or_object
 *
 * @return null|string
 *
 * @since 2.0.1
 */
function ap_edit_post_link_html($echo = false, $post_id_or_object = false)
{
    if (!is_object($post_id_or_object)) {
        $post_id_or_object = get_post($post_id_or_object);
    }
    $post = $post_id_or_object;
    $edit_link = ap_post_edit_link($post);
    $output = '';
    if ($post->post_type == 'question' && ap_user_can_edit_question($post->ID)) {
        $output = "<a href='{$edit_link}' data-button='ap-edit-post' title='" . __('Edit this question', 'ap') . "' class='apEditBtn'>" . __('Edit', 'ap') . '</a>';
    } elseif ($post->post_type == 'answer' && ap_user_can_edit_ans($post->ID)) {
        $output = "<a href='{$edit_link}' data-button='ap-edit-post' title='" . __('Edit this answer', 'ap') . "' class='apEditBtn'>" . __('Edit', 'ap') . '</a>';
    }
    if ($echo) {
        echo $output;
    } else {
        return $output;
    }
}
开发者ID:Krl4,项目名称:anspress,代码行数:29,代码来源:functions.php

示例5: edit_page

 /**
  * Output edit page template
  */
 public function edit_page()
 {
     $post_id = (int) sanitize_text_field(get_query_var('edit_post_id'));
     if (!ap_user_can_edit_question($post_id)) {
         echo '<p>' . esc_attr__('You don\'t have permission to access this page.', 'ap') . '</p>';
         return;
     } else {
         global $editing_post;
         $editing_post = get_post($post_id);
         // Include theme file.
         include ap_get_theme_location('edit.php');
     }
 }
开发者ID:Byrlyne,项目名称:anspress,代码行数:16,代码来源:common-pages.php

示例6: ap_edit_q_btn_html

function ap_edit_q_btn_html()
{
    $post_id = get_the_ID();
    if (ap_user_can_edit_question($post_id)) {
        $action = 'question-' . $post_id;
        $nonce = wp_create_nonce($action);
        $edit_link = add_query_arg(array('edit_q' => $post_id, 'nonce' => $nonce), get_permalink(ap_opt('base_page')));
        //$args = json_encode(array('action' => 'ap_load_edit_form', 'id'=> $post_id, 'nonce' => $nonce, 'type' => 'question'));
        echo "<a href='{$edit_link}' data-button='ap-edit-post' title='" . __('Edit this question', 'ap') . "'>" . __('Edit', 'ap') . "</a>";
    }
    return;
}
开发者ID:coollog,项目名称:theboola,代码行数:12,代码来源:anspress-functions.php


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