Reputation::register_default_events()
Description #
Register default reputation events.
Source #
File: addons/reputation/reputation.php
public function register_default_events() { $events_db = wp_cache_get( 'all', 'ap_get_all_reputation_events' ); if ( false === $events_db ) { $events_db = ap_get_all_reputation_events(); } // If already in DB return from here. if ( ! $events_db ) { $events = array( array( 'slug' => 'register', 'label' => __( 'Registration', 'anspress-question-answer' ), 'description' => __( 'Points awarded when user account is created', 'anspress-question-answer' ), 'icon' => 'apicon-question', 'activity' => __( 'Registered', 'anspress-question-answer' ), 'points' => 10, ), array( 'slug' => 'ask', 'points' => 2, 'label' => __( 'Asking', 'anspress-question-answer' ), 'description' => __( 'Points awarded when user asks a question', 'anspress-question-answer' ), 'icon' => 'apicon-question', 'activity' => __( 'Asked a question', 'anspress-question-answer' ), 'parent' => 'question', ), array( 'slug' => 'answer', 'points' => 5, 'label' => __( 'Answering', 'anspress-question-answer' ), 'description' => __( 'Points awarded when user answers a question', 'anspress-question-answer' ), 'icon' => 'apicon-answer', 'activity' => __( 'Posted an answer', 'anspress-question-answer' ), 'parent' => 'answer', ), array( 'slug' => 'comment', 'points' => 2, 'label' => __( 'Commenting', 'anspress-question-answer' ), 'description' => __( 'Points awarded when user comments on question or answer', 'anspress-question-answer' ), 'icon' => 'apicon-comments', 'activity' => __( 'Commented on a post', 'anspress-question-answer' ), 'parent' => 'comment', ), array( 'slug' => 'select_answer', 'points' => 2, 'label' => __( 'Selecting an Answer', 'anspress-question-answer' ), 'description' => __( 'Points awarded when user selects an answer for their question', 'anspress-question-answer' ), 'icon' => 'apicon-check', 'activity' => __( 'Selected an answer as best', 'anspress-question-answer' ), 'parent' => 'question', ), array( 'slug' => 'best_answer', 'points' => 10, 'label' => __( 'Answer selected as best', 'anspress-question-answer' ), 'description' => __( 'Points awarded when user\'s answer is selected as best', 'anspress-question-answer' ), 'icon' => 'apicon-check', 'activity' => __( 'Answer was selected as best', 'anspress-question-answer' ), 'parent' => 'answer', ), array( 'slug' => 'received_vote_up', 'points' => 10, 'label' => __( 'Received up vote', 'anspress-question-answer' ), 'description' => __( 'Points awarded when user receives an upvote', 'anspress-question-answer' ), 'icon' => 'apicon-thumb-up', 'activity' => __( 'Received an upvote', 'anspress-question-answer' ), ), array( 'slug' => 'received_vote_down', 'points' => -2, 'label' => __( 'Received down vote', 'anspress-question-answer' ), 'description' => __( 'Points awarded when user receives a down vote', 'anspress-question-answer' ), 'icon' => 'apicon-thumb-down', 'activity' => __( 'Received a down vote', 'anspress-question-answer' ), ), array( 'slug' => 'given_vote_up', 'points' => 0, 'label' => __( 'Gives an up vote', 'anspress-question-answer' ), 'description' => __( 'Points taken from user when they give an up vote', 'anspress-question-answer' ), 'icon' => 'apicon-thumb-up', 'activity' => __( 'Given an up vote', 'anspress-question-answer' ), ), array( 'slug' => 'given_vote_down', 'points' => 0, 'label' => __( 'Gives down vote', 'anspress-question-answer' ), 'description' => __( 'Points taken from user when they give a down vote', 'anspress-question-answer' ), 'icon' => 'apicon-thumb-down', 'activity' => __( 'Given a down vote', 'anspress-question-answer' ), ), ); $custom_points = get_option( 'anspress_reputation_events', array() ); foreach ( $events as $event ) { $points = isset( $custom_points[ $event['slug'] ] ) ? (int) $custom_points[ $event['slug'] ] : (int) $event['points']; ap_insert_reputation_event( $event['slug'], $event['label'], $event['description'], $points, ! empty( $event['activity'] ) ? $event['activity'] : '', ! empty( $event['parent'] ) ? $event['parent'] : '', $event['icon'] ); } $events_db = ap_get_all_reputation_events(); wp_cache_set( 'all', $events_db, 'ap_get_all_reputation_events' ); } if ( empty( $events_db ) ) { return; } // Fallback for register events. foreach ( $events_db as $event ) { $args = (array) $event; unset( $args['slug'] ); ap_register_reputation_event( $event->slug, $args ); } }
Expand full source code Collapse full source code View on GitHub: addons/reputation/reputation.php:125
Add your comment