ap_delete_reputation_event_by_slug( string $slug )

Description #

Delete a reputation event by slug.

Parameters #

  • $slug
    string (Required) Event slug.

Changelog #

VersionDescription
4.3.0Introduced.

Source #

File: includes/reputation.php

function ap_delete_reputation_event_by_slug( $slug ) {
	global $wpdb;

	$event = ap_get_reputation_event_by_slug( $slug );

	if ( ! $event ) {
		return new WP_Error( 'rep_event_not_exits' );
	}

	$rows = $wpdb->delete( // phpcs:ignore WordPress.DB
		$wpdb->ap_reputation_events,
		array( 'slug' => $slug ),
		array( '%s' )
	);

	if ( $rows ) {
		/**
		 * Hook called right after deleting a reputation event.
		 *
		 * @param object $event Reputation event object.
		 * @since 4.3.0
		 */
		do_action( 'ap_deleted_reputation_event', $event );

		// Delete cache.
		wp_cache_delete( 'all', 'ap_get_all_reputation_events' );

		return true;
	}

	return new WP_Error( 'failed_to_delete_rep_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