ap_insert_reputation_event( string $slug, string $label, string $description, int $points, int $activity, string $parent_type = '', string $icon = '' )
Description #
Insert a reputation event to database.
Parameters #
- $slugstring (Required) Reputation event unique slug.
- $labelstring (Required) Reputation event label, must be less than 100 letters.
- $descriptionstring (Required) Reputation event description.
- $pointsint (Required) Signed point value.
- $activityint (Required) Activity label.
- $parent_typestring (Optional) Parent type. Default value: ''
- $iconstring (Optional) Reputation event icon. Default value: ''
Changelog #
Source #
File: includes/reputation.php
function ap_insert_reputation_event( $slug, $label, $description, $points, $activity, $parent_type = '', $icon = '' ) { global $wpdb; $slug = sanitize_key( $slug ); $existing = ap_get_reputation_event_by_slug( $slug ); if ( $existing ) { return new WP_Error( 'already_exits' ); } $inserted = $wpdb->insert( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery $wpdb->ap_reputation_events, array( 'slug' => $slug, 'label' => $label, 'description' => $description, 'points' => $points, 'activity' => $activity, 'parent' => $parent_type, 'icon' => $icon, ), array( '%s', '%s', '%s', '%d', '%s', '%s', '%s', ) ); if ( $inserted ) { $inserted_id = $wpdb->insert_id; // Delete cache. wp_cache_delete( 'all', 'ap_get_all_reputation_events' ); /** * Hook called right after inserting a reputation event. * * @param object $event Reputation event id. * @since 4.3.0 */ do_action( 'ap_inserted_reputation_event', $inserted_id ); return $inserted_id; } return new WP_Error( 'failed_to_insert_rep_event' ); }
Expand full source code Collapse full source code View on GitHub: includes/reputation.php:350
Add your comment