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

310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
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