AnsPress_Hooks::transition_post_status( string $new_status, string $old_status, WP_Post $post )
Description #
Trigger activity update hook on question and answer status transition.
Parameters #
- $new_statusstring (Required) New post status.
- $old_statusstring (Required) Old post status.
- $postWP_Post (Required) WordPress post object.
Source #
File: includes/hooks.php
public static function transition_post_status( $new_status, $old_status, $post ) { if ( 'new' === $old_status || ! in_array( $post->post_type, [ 'answer', 'question' ], true ) ) { return; } $question_id = 'answer' === $post->post_type ? $post->post_parent : $post->ID; $answer_id = 'answer' === $post->post_type ? $post->ID : 0; // Log to db. ap_activity_add( array( 'q_id' => $question_id, 'a_id' => $answer_id, 'action' => 'status_' . $new_status, ) ); }
Expand full source code Collapse full source code View on GitHub: includes/hooks.php:814
Add your comment