Tribe__Events__Community__Main::doDelete( int $tribe_event_id )
Delete view for an event.
Contents
Parameters
- $tribe_event_id
-
(int) (Required) The event's ID.
Return
(string) The deletion view.
Source
File: src/Tribe/Main.php
public function doDelete( $tribe_event_id ) {
$this->default_template_compatibility();
if ( wp_verify_nonce( $_GET['_wpnonce'], 'tribe_community_events_delete' ) && current_user_can( 'delete_post', $tribe_event_id ) ) {
//does this event even exist?
$event = get_post( $tribe_event_id );
if ( isset( $event->ID ) ) {
if ( $this->trashItemsVsDelete ) {
wp_trash_post( $tribe_event_id );
$this->enqueueOutputMessage( __( 'Trashed Event #', 'tribe-events-community' ) . $tribe_event_id );
} else {
wp_delete_post( $tribe_event_id, true );
$this->enqueueOutputMessage( __( 'Deleted Event #', 'tribe-events-community' ) . $tribe_event_id );
}
} else {
$this->enqueueOutputMessage( sprintf( __( 'This event (#%s) does not appear to exist.', 'tribe-events-community' ), $tribe_event_id ) );
}
} else {
$this->enqueueOutputMessage( __( 'You do not have permission to delete this event.', 'tribe-events-community' ) );
}
$output = '<div id="tribe-community-events" class="delete">';
ob_start();
$this->enqueue_assets();
include Tribe__Events__Templates::getTemplateHierarchy( 'community/modules/delete' );
$output .= ob_get_clean();
/**
* Sets the URL normally used to take users back to the main Community Events list view.
*
* @param string $back_url
*/
$back_url = apply_filters( 'tribe_events_community_deleted_event_back_url', tribe( 'community.main' )->getUrl( 'list' ) );
$output .= '<a href="' . esc_url( $back_url ) . '">« ' . _x( 'Back', 'As in "go back to previous page"', 'tribe-events-community' ) . '</a>';
$output .= '</div>';
return $output;
}
Changelog
| Version | Description |
|---|---|
| 1.0 | Introduced. |