ap_add_post_vote( integer $post_id, boolean|integer $user_id, string $up_vote = true )
Description #
Add post vote.
Parameters #
- $post_idinteger (Required) Post ID.
- $user_idboolean | integer (Required) ID of user casting vote.
- $up_votestring (Optional) Is up vote. Default value: true
Source #
File: includes/votes.php
function ap_add_post_vote( $post_id, $user_id = 0, $up_vote = true ) { if ( false === $user_id ) { $user_id = get_current_user_id(); } $_post = get_post( $post_id ); $rec_user_id = $_post->post_author; $value = $up_vote ? '1' : '-1'; $row = ap_vote_insert( $post_id, $user_id, 'vote', $rec_user_id, $value ); if ( false !== $row ) { // Update qameta. $counts = ap_update_votes_count( $post_id ); $vote_type = $up_vote ? 'vote_up' : 'vote_down'; /** * Action ap_[vote_type] * Action triggred after adding a vote for a post. * * @param integer $post_id Post ID. * @param array $counts All vote counts. */ do_action( 'ap_' . $vote_type, $post_id, $counts ); return $counts; } return false; }
Expand full source code Collapse full source code View on GitHub: includes/votes.php:523
Add your comment