AnsPress_Hooks::question_answer_hooks( integer $post_id, object $post, boolean $updated )
Description #
Trigger AnsPress posts hooks right after inserting question/answer
Parameters #
- $post_idinteger (Required) Post ID.
- $postobject (Required) Post Object
- $updatedboolean (Required) Is updating post
Source #
File: includes/hooks.php
public static function question_answer_hooks( $post_id, $post, $updated ) {
if ( wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) ) {
return;
}
// check if post type is question or answer.
if ( ! in_array( $post->post_type, [ 'question', 'answer' ] ) ) {
return;
}
if ( $updated ) {
if ( 'answer' === $post->post_type ) {
// Update answer count.
ap_update_answers_count( $post->post_parent );
}
/**
* Action triggered right after updating question/answer.
*
* @param integer $post_id Inserted post ID.
* @param object $post Inserted post object.
* @since 0.9
*/
do_action( 'ap_processed_update_' . $post->post_type, $post_id, $post );
} else {
/**
* Action triggered right after inserting new question/answer.
*
* @param integer $post_id Inserted post ID.
* @param object $post Inserted post object.
* @since 0.9
*/
do_action( 'ap_processed_new_' . $post->post_type, $post_id, $post );
}
if ( 'question' === $post->post_type ) {
// Update qameta terms.
ap_update_qameta_terms( $post_id );
}
}
Expand full source code Collapse full source code View on GitHub: includes/hooks.php:571
Add your comment