Пример #1
0
 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));
 }
Пример #2
0
<?php

/**
 * Edit page
 *
 * @link http://anspress.io
 * @since 2.0.1
 * @license GPL 2+
 * @package AnsPress
 */
if ($editing_post->post_type == 'question') {
    ap_edit_question_form();
} elseif ($editing_post->post_type == 'answer') {
    ap_edit_answer_form($editing_post->post_parent);
}