<?php
/**
* The Events Calendar: All Venue slugs get prefixed with a custom string. Works in wp-admin and Community Events.
*
* !!! Change the prefix to your own !!!
*
* @link https://gist.github.com/cliffordp/ac4a68769787352369ab0c5e41dc28ab This snippet.
*/
function cliff_prefix_venue_slugs( $data ) {
// TODO: Change this to what you want!!!
$prefix = 'xvenue-';
if (
(
'publish' === $data['post_status']
|| 'draft' === $data['post_status']
|| 'pending' === $data['post_status']
)
&& class_exists( 'Tribe__Events__Venue' )
&& Tribe__Events__Venue::POSTTYPE === $data['post_type']
&& 0 !== strpos( $data['post_name'], $prefix ) // is not already prefixed, such as when moving from Deleted back to Published
) {
$data['post_name'] = $prefix . $data['post_name'];
}
return $data;
}
add_filter( 'wp_insert_post_data', 'cliff_prefix_venue_slugs' );