Tribe__Events__Community__Main::getUrl( string $action, int $id = null, string $page = null, string $post_type = null )
Get the URL for a specific action.
Contents
Parameters
- $id
-
(int) (Optional) The id of whatever is being done, if applicable.
Default value: null
- $page
-
(string) (Optional) The page being used.
Default value: null
- $post_type
-
(string) (Optional) The post type being used.
Default value: null
- $action
-
(string) (Required) The action being performed.
Return
(string) The url.
Source
File: src/Tribe/Main.php
public function getUrl( $action, $id = null, $page = null, $post_type = null ) {
if ( ! empty( $id ) && $action == 'edit' && function_exists( 'tribe_is_recurring_event' ) && tribe_is_recurring_event( $id ) ) {
if ( $parent = wp_get_post_parent_id( $id ) ) {
$id = $parent;
}
}
if ( '' == get_option( 'permalink_structure' ) ) {
add_action( 'admin_notices', array( $this, 'notice_permalinks' ) );
} else {
if ( ! empty ( $id ) ) {
if ( $post_type ) {
if ( $post_type == Tribe__Events__Main::POSTTYPE ) {
return home_url() . '/' . $this->getCommunityRewriteSlug() . '/' . $this->rewriteSlugs[ $action ] . '/' . $this->rewriteSlugs['event'] . '/' . $id . '/';
}
if ( $post_type == Tribe__Events__Main::ORGANIZER_POST_TYPE ) {
return home_url() . '/' . $this->getCommunityRewriteSlug() . '/' . $this->rewriteSlugs[ $action ] . '/' . $this->rewriteSlugs['organizer'] . '/' . $id . '/';
}
if ( $post_type == Tribe__Events__Main::VENUE_POST_TYPE ) {
return home_url() . '/' . $this->getCommunityRewriteSlug() . '/' . $this->rewriteSlugs[ $action ] . '/' . $this->rewriteSlugs['venue'] . '/' . $id . '/';
}
} else {
return home_url() . '/' . $this->getCommunityRewriteSlug() . '/' . $this->rewriteSlugs[ $action ] . '/' . $id . '/';
}
} else {
if ( $page ) {
return home_url() . '/' . $this->getCommunityRewriteSlug() . '/' . $this->rewriteSlugs[ $action ] . '/page/' . $page . '/';
} else {
return home_url() . '/' . $this->getCommunityRewriteSlug() . '/' . $this->rewriteSlugs[ $action ];
}
}
}
}
Changelog
| Version | Description |
|---|---|
| 1.0 | Introduced. |