Tribe__Events__Community__Main::set_rewrite_slugs()
Sets up the rewrite slugs.
Grabs the slugs from options, allows other plugins to filter them, then sets a value from $this->default_rewrite_slugs if they are blank.
Note these slugs are NOT translated, as this can lead to 404s on multi-lingual sites.
Source
File: src/Tribe/Main.php
public function set_rewrite_slugs() {
$this->communityRewriteSlug = sanitize_title( $this->getOption( 'communityRewriteSlug', 'community' ) );
/**
* Allows for filtering the main community rewrite slug.
*
* @since 4.6.3
*
* @param string $rewrite_slug The slug value.
*/
$this->communityRewriteSlug = apply_filters( 'tribe_community_events_rewrite_slug', $this->communityRewriteSlug );
// Set default if we end up with an empty string.
if ( empty( $this->communityRewriteSlug ) ) {
$this->communityRewriteSlug = 'community';
}
$this->rewriteSlugs['edit'] = sanitize_title( $this->getOption( 'community-edit-slug', $this->default_rewrite_slugs['edit'], true ) );
$this->rewriteSlugs['add'] = sanitize_title( $this->getOption( 'community-add-slug', $this->default_rewrite_slugs['add'], true ) );
$this->rewriteSlugs['delete'] = sanitize_title( $this->getOption( 'community-delete-slug', $this->default_rewrite_slugs['delete'], true ) );
$this->rewriteSlugs['list'] = sanitize_title( $this->getOption( 'community-list-slug', $this->default_rewrite_slugs['list'], true ) );
$this->rewriteSlugs['venue'] = sanitize_title( $this->getOption( 'community-venue-slug', $this->default_rewrite_slugs['venue'], true ) );
$this->rewriteSlugs['organizer'] = sanitize_title( $this->getOption( 'community-organizer-slug', $this->default_rewrite_slugs['organizer'], true ) );
$this->rewriteSlugs['event'] = sanitize_title( $this->getOption( 'community-event-slug', $this->default_rewrite_slugs['event'], true ) );
/**
* Allows for filtering the community rewrite slugs.
*
* @since 4.6.3
*
* @param array The slug array.
*/
$this->rewriteSlugs = apply_filters( 'tribe_community_events_rewrite_slug', $this->rewriteSlugs );
foreach ( $this->rewriteSlugs as $key => $value ) {
/**
* Allows for filtering the rewrite slugs individually.
*
* @since 4.6.3
*
* @param string $value The slug value.
* @param string $key The slug key.
*/
$this->rewriteSlugs[ $key ] = apply_filters( 'tribe_community_events_' . $key . '_rewrite_slug', $value, $key );
}
// Just in case, reset any slugs that were empty or just whitespace with the defaults.
$this->rewriteSlugs = array_filter( array_map( 'trim', $this->rewriteSlugs ) );
$this->rewriteSlugs = array_merge( $this->default_rewrite_slugs, $this->rewriteSlugs );
}
Changelog
| Version | Description |
|---|---|
| 4.6.3 | Introduced. |