AnsPress_Upgrader::answer_tasks( integer $answer_id )

Description #

Process answers tasks.

Parameters #

  • $answer_id
    integer (Required) Answer ID.

Source #

File: lib/class-anspress-upgrader.php

	private function answer_tasks( $answer_id ) {
		$answer      = get_post( $answer_id );
		$last_active = get_post_meta( $answer_id, '_ap_updated', true );
		$best_answer = get_post_meta( $answer_id, '_ap_best_answer', true );
		$flags       = (int) get_post_meta( $answer_id, '_ap_flag', true );

		$args = array(
			'flags'        => $flags,
			'last_updated' => empty( $last_active ) ? $answer->post_date : $last_active,
		);

		if ( '1' === $best_answer ) {
			$args['selected'] = 1;
		}

		ap_insert_qameta( $answer_id, $args );
		$this->migrate_votes( $answer_id );

		delete_post_meta( $answer_id, '_ap_updated' );
		delete_post_meta( $answer_id, '_ap_best_answer' );
		delete_post_meta( $answer_id, '_ap_subscriber' );
		delete_post_meta( $answer_id, '_ap_participants' );
		delete_post_meta( $answer_id, '_ap_close' );
		delete_post_meta( $answer_id, '_ap_vote' );
		delete_post_meta( $answer_id, '_ap_flag' );
		delete_post_meta( $answer_id, '_ap_selected' );

		$this->restore_last_activity( $answer_id );
	}

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