AP_Update_Helper::replace_old_reputation_event( string $old_event )

Description #

Return new reputation event alternative.

Parameters #

  • $old_event
    string (Required) Old event.

Source #

File: admin/update.php

	public function replace_old_reputation_event( $old_event ) {
		$events = array(
			'ask'                => [ 'new_question', 'question' ],
			'answer'             => [ 'new_answer', 'answer' ],
			'received_vote_up'   => [ 'vote_up', 'question_upvote', 'answer_upvote' ],
			'received_vote_down' => [ 'vote_down', 'question_downvote', 'answer_downvote' ],
			'given_vote_up'      => [ 'voted_up', 'question_upvoted', 'answer_upvoted' ],
			'given_vote_down'    => [ 'voted_down', 'question_downvoted', 'answer_downvoted' ],
			'selecting_answer'   => 'select_answer',
			'select_answer'      => 'best_answer',
			'comment'            => 'new_comment',
		);

		$found = false;

		foreach ( $events as $new_event => $olds ) {
			if ( is_array( $olds ) && in_array( $old_event, $olds, true ) ) {
				$found = $new_event;
				break;
			} elseif ( $old_event === $olds ) {
				$found = $new_event;
				break;
			}
		}

		if ( false !== $found ) {
			return $found;
		}

		return  $old_event;
	}

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