AnsPress_Admin_Ajax::ap_admin_vote()
Description #
Handle ajax vote in wp-admin post edit screen.
Cast vote as guest user with ID 0, so that when this vote never get rest if user vote.
Source #
File: admin/ajax.php
public static function ap_admin_vote() {
$args = ap_sanitize_unslash( 'args', 'p' );
if ( current_user_can( 'manage_options' ) && anspress_verify_nonce( 'admin_vote' ) ) {
$post = ap_get_post( $args[0] );
if ( $post ) {
$value = 'up' === $args[1] ? true : false;
$counts = ap_add_post_vote( $post->ID, 0, $value );
echo esc_attr( $counts['votes_net'] );
}
}
wp_die();
}
Expand full source code Collapse full source code View on GitHub: admin/ajax.php:80
Add your comment