Tribe__Events__Community__Main::addRoutes( object $router )
Add wprouter and callbacks.
Contents
Parameters
- $router
-
(object) (Required) The router object.
Return
(void)
Source
File: src/Tribe/Main.php
public function addRoutes( $router ) {
$tec_template = tribe_get_option( 'tribeEventsTemplate' );
switch ( $tec_template ) {
case '' :
$template_name = Tribe__Events__Templates::getTemplateHierarchy( 'default-template' );
break;
case 'default' :
$template_name = 'page.php';
break;
default :
$template_name = $tec_template;
}
$template_name = apply_filters( 'tribe_events_community_template', $template_name );
// edit venue
$router->add_route( 'ce-edit-venue-route', array(
'path' => '^' . $this->getCommunityRewriteSlug() . '/' . $this->rewriteSlugs['edit'] . '/' . $this->rewriteSlugs['venue'].'/(\d+)$',
'query_vars' => array(
'tribe_event_id' => 1,
),
'page_callback' => array(
get_class(),
'editCallback',
),
'page_arguments' => array(
'tribe_event_id'
),
'access_callback' => true,
'title' => __( 'Edit a Venue', 'tribe-events-community' ),
'template' => $template_name,
) );
// edit organizer
$router->add_route( 'ce-edit-organizer-route', array(
'path' => '^' . $this->getCommunityRewriteSlug() . '/' . $this->rewriteSlugs['edit'] . '/' . $this->rewriteSlugs['organizer'] . '/(\d+)$',
'query_vars' => array(
'tribe_event_id' => 1,
),
'page_callback' => array(
get_class(),
'editCallback',
),
'page_arguments' => array(
'tribe_event_id'
),
'access_callback' => true,
'title' => __( 'Edit an Organizer', 'tribe-events-community' ),
'template' => $template_name,
) );
// edit event
$router->add_route( 'ce-edit-route', array(
'path' => '^' . $this->getCommunityRewriteSlug() . '/' . $this->rewriteSlugs['edit'] . '/' . $this->rewriteSlugs['event'] . '/(\d+/?)$',
'query_vars' => array(
'tribe_community_event_id' => 1,
),
'page_callback' => array(
get_class(),
'editCallback',
),
'page_arguments' => array(
'tribe_community_event_id'
),
'access_callback' => true,
'title' => apply_filters( 'tribe_ce_edit_event_page_title', __( 'Edit an Event', 'tribe-events-community' ) ),
'template' => $template_name,
) );
// edit redirect
$router->add_route( 'ce-edit-redirect-route', array(
'path' => '^' . $this->getCommunityRewriteSlug() . '/' . $this->rewriteSlugs['edit'] . '/(\d+)$',
'query_vars' => array(
'tribe_id' => 1,
),
'page_callback' => array(
get_class(),
'redirectCallback',
),
'page_arguments' => array(
'tribe_id'
),
'access_callback' => true,
'title' => __( 'Redirect', 'tribe-events-community' ),
'template' => $template_name,
) );
// add event
$router->add_route( 'ce-add-route', array(
'path' => '^' . $this->getCommunityRewriteSlug() . '/' . $this->rewriteSlugs['add'] . '$',
'query_vars' => array(),
'page_callback' => array(
get_class(),
'addCallback',
),
'page_arguments' => array(),
'access_callback' => true,
'title' => apply_filters( 'tribe_ce_submit_event_page_title', __( 'Submit an Event', 'tribe-events-community' ) ),
'template' => $template_name,
) );
$router->add_route( 'ce-redirect-to-add-route', array(
'path' => $this->getCommunityRewriteSlug() . '/?$',
'page_callback' => 'wp_redirect',
'page_arguments' => array( home_url( $this->getCommunityRewriteSlug() . '/' . $this->rewriteSlugs['add'] ), 301 ),
'template' => false,
'access_callback' => true,
) );
// delete event
$router->add_route( 'ce-delete-route', array(
'path' => '^' . $this->getCommunityRewriteSlug() . '/' . $this->rewriteSlugs['list'] . '/(\d+)$',
'query_vars' => array(
'tribe_event_id' => 1,
),
'page_callback' => array(
get_class(),
'deleteCallback',
),
'page_arguments' => array(
'tribe_event_id'
),
'access_callback' => true,
'title' => apply_filters( 'tribe_ce_remove_event_page_title', __( 'Remove an Event', 'tribe-events-community' ) ),
'template' => $template_name,
) );
// list events
$router->add_route( 'ce-list-route', array(
'path' => '^' . $this->getCommunityRewriteSlug() . '/' . $this->rewriteSlugs['list'] . '(/page/(\d+))?/?$',
'query_vars' => array(
'page' => 2,
),
'page_callback' => array(
get_class(),
'listCallback',
),
'page_arguments' => array( 'page' ),
'access_callback' => true,
'title' => apply_filters( 'tribe_ce_event_list_page_title', __( 'My Events', 'tribe-events-community' ) ),
'template' => $template_name,
) );
}
Changelog
| Version | Description |
|---|---|
| 1.0 | Introduced. |