AnsPress_Upgrader::replace_old_reputation_event( string $old_event )

Description #

Return new reputation event alternative.

Parameters #

  • $old_event
    string (Required) Old event.

Source #

File: lib/class-anspress-upgrader.php

	public function replace_old_reputation_event( $old_event ) {
		$events = array(
			'ask'                => array( 'new_question', 'question' ),
			'answer'             => array( 'new_answer', 'answer' ),
			'received_vote_up'   => array( 'vote_up', 'question_upvote', 'answer_upvote' ),
			'received_vote_down' => array( 'vote_down', 'question_downvote', 'answer_downvote' ),
			'given_vote_up'      => array( 'voted_up', 'question_upvoted', 'answer_upvoted' ),
			'given_vote_down'    => array( '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