AnsPress_Admin_Ajax::anspress_recount()

Description #

Ajax callback for performing recount actions.

Changelog #

VersionDescription
4.0.5Introduced.

Source #

File: admin/ajax.php

	public static function anspress_recount() {
		check_ajax_referer( 'recount', '__nonce' );

		// Check if user have permission to do this action.
		if ( ! current_user_can( 'manage_options' ) ) {
			wp_send_json( [
				'error' => true,
			] );
		}

		$sub_action = ap_sanitize_unslash( 'sub_action', 'r', '' );
		$current = (int) ap_sanitize_unslash( 'current', 'r', 0 );
		$offset = 50 * $current;

		$method_name = 'recount_' . $sub_action;

		if ( ! empty( $sub_action ) && method_exists( __CLASS__, $method_name ) ) {
			self::$method_name( $current, $offset );
		}

		wp_send_json( [
			'error' => true,
		] );
	}

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