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.

Changelog #

VersionDescription
2.5Introduced.

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();
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment