?> </div> <?php /** * ACTION: ap_after_question_content * @since 2.0.0-alpha2 */ do_action('ap_after_question_content'); ?> <?php ap_question_the_active_time(); ?> <?php ap_post_status_description(ap_question_get_the_ID()); ?> <?php /** * ACTION: ap_after_question_actions * @since 2.0 */ do_action('ap_after_question_actions'); ?> </div> </div> </div> <a class="ap-eq-view-ans" href="<?php echo get_the_permalink();
?> <?php ap_answer_the_time(); ?> </div> <div class="ap-q-inner"> <div class="ap-answer-content ap-q-content" itemprop="text"> aid=<?php echo get_the_ID(); ?> .<?php the_content(); ?> </div> <?php ap_answer_the_active_time(); ?> <?php ap_post_status_description(ap_answer_get_the_answer_id()); ?> <?php ap_post_actions_buttons(); ?> </div> <?php ap_answer_the_comments(); ?> </div> </div> </div>
/** * Handle change post status request. * @since 2.1 */ public function change_post_status() { $post_id = (int) $_POST['post_id']; $status = sanitize_text_field(wp_unslash($_POST['status'])); if (!is_user_logged_in() || !ap_verify_nonce('change_post_status_' . $post_id) || !ap_user_can_change_status($post_id)) { $this->send('no_permission'); } else { $post = get_post($post_id); if (($post->post_type == 'question' || $post->post_type == 'answer') && $post->post_status != $status) { $update_data = array(); if ('publish' == $status) { $update_data['post_status'] = 'publish'; } elseif ('moderate' == $status) { $update_data['post_status'] = 'moderate'; } elseif ('private_post' == $status) { $update_data['post_status'] = 'private_post'; } elseif ('closed' == $status) { $update_data['post_status'] = 'closed'; } // Unregister history action for edit. remove_action('ap_after_new_answer', array('AP_History', 'new_answer')); remove_action('ap_after_new_question', array('AP_History', 'new_question')); $update_data['ID'] = $post->ID; wp_update_post($update_data); ap_add_history(get_current_user_id(), $post_id, '', 'status_updated'); add_action('ap_post_status_updated', $post->ID); ob_start(); ap_post_status_description($post->ID); $html = ob_get_clean(); $this->send(array('action' => 'status_updated', 'message' => 'status_updated', 'do' => array('remove_if_exists' => '#ap_post_status_desc_' . $post->ID, 'toggle_active_class' => array('#ap_post_status_toggle_' . $post->ID, '.' . $status), 'append_before' => '#ap_post_actions_' . $post->ID), 'html' => $html)); } } $this->something_wrong(); }
/** * Handle change post status request * @return void * @since 2.1 */ public function change_post_status() { $post_id = (int) $_POST['post_id']; $status = $_POST['status']; if (!is_user_logged_in() || !wp_verify_nonce($_POST['__nonce'], 'change_post_status_' . $post_id) || !ap_user_can_change_status($post_id)) { ap_send_json(ap_ajax_responce('no_permission')); die; } else { $post = get_post($post_id); if (($post->post_type == 'question' || $post->post_type == 'answer') && $post->post_status != $status) { $update_data = array(); if ($status == 'publish') { $update_data['post_status'] = 'publish'; } elseif ($status == 'moderate') { $update_data['post_status'] = 'moderate'; } elseif ($status == 'private_post') { $update_data['post_status'] = 'private_post'; } elseif ($status == 'closed') { $update_data['post_status'] = 'closed'; } // unregister history action for edit remove_action('ap_after_new_answer', array('AP_History', 'new_answer')); remove_action('ap_after_new_question', array('AP_History', 'new_question')); $update_data['ID'] = $post->ID; wp_update_post($update_data); ap_add_history(get_current_user_id(), $post_id, '', 'status_updated'); add_action('ap_post_status_updated', $post->ID); ob_start(); ap_post_status_description($post->ID); $html = ob_get_clean(); ap_send_json(ap_ajax_responce(array('action' => 'status_updated', 'message' => 'status_updated', 'do' => array('remove_if_exists', 'toggle_active_class', 'append_before'), 'append_before_container' => '#ap_post_actions_' . $post->ID, 'toggle_active_class_container' => '#ap_post_status_toggle_' . $post->ID, 'remove_if_exists_container' => '#ap_post_status_desc_' . $post->ID, 'active' => '.' . $status, 'html' => $html))); die; } } ap_send_json(ap_ajax_responce('something_wrong')); die; }