ap_get_vote( integer $post_id, integer $user_id, string|array $type, string $value = '' )
Description #
Get a single vote from database.
Parameters #
- $post_idinteger (Required) Post ID.
- $user_idinteger (Required) User ID.
- $typestring | array (Required) Vote type.
- $valuestring (Optional) Vote value. Default value: ''
Source #
File: includes/votes.php
function ap_get_vote( $post_id, $user_id, $type, $value = '' ) { global $wpdb; $where = "SELECT * FROM {$wpdb->ap_votes} WHERE 1=1 "; if ( ! empty( $type ) ) { if ( is_array( $type ) ) { $where .= ' AND vote_type IN (' . sanitize_comma_delimited( $type, 'str' ) . ')'; } else { $where .= " AND vote_type = '" . sanitize_text_field( $type ) . "'"; } } if ( ! empty( $value ) ) { if ( is_array( $value ) ) { $where .= ' AND vote_value IN (' . sanitize_comma_delimited( $value, 'str' ) . ')'; } else { $where .= " AND vote_value = '" . sanitize_text_field( $value ) . "'"; } } $vote = $wpdb->get_row( $where . $wpdb->prepare( ' AND vote_post_id = %d AND vote_user_id = %d LIMIT 1', $post_id, $user_id ) ); // phpcs:ignore WordPress.DB if ( ! empty( $vote ) ) { return $vote; } return false; }
Expand full source code Collapse full source code View on GitHub: includes/votes.php:386
Add your comment