SelectAnswer()

Description #

Run async tasks for hook ap_select_answer.

Changelog #

VersionDescription
4.1.8Introduced.

Source #

File: includes/class-async-tasks.php

class SelectAnswer extends \WP_Async_Task { // phpcs:ignore

	/**
	 * The hook name.
	 *
	 * @var string
	 */
	protected $action = 'ap_select_answer';

	/**
	 * Prepare data for the asynchronous request
	 *
	 * @param array $data Arguments.
	 * @return array
	 * @since 4.1.8
	 */
	protected function prepare_data( $data ) {
		return array( 'post_id' => $data[0]->ID );
	}

	/**
	 * Run action.
	 *
	 * @return void
	 * @since 4.1.8
	 */
	protected function run_action() {
		$post_id = ap_sanitize_unslash( 'post_id', 'g' );
		$post    = ap_get_post( $post_id );

		if ( $post ) {
			do_action( "wp_async_$this->action", $post );
		}
	}
}

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