diff --git a/wporg-gp-translation-events.php b/wporg-gp-translation-events.php index fffb4aea..2bcab0d4 100644 --- a/wporg-gp-translation-events.php +++ b/wporg-gp-translation-events.php @@ -299,22 +299,23 @@ function gp_event_nav_menu_items( array $items ): array { /** * Generate a slug for the event post type when we save a draft event. * + * Generate a slug based on the event title if it's not provided. + * * @param array $data An array of slashed post data. * @param array $postarr An array of sanitized, but otherwise unmodified post data. * @return array The modified post data. */ function generate_event_slug( $data, $postarr ) { - if ( $data[ 'post_type' ] === 'event' && $data[ 'post_status' ] === 'draft' ) { - // Generate a slug based on the event title if it's not provided - if ( empty( $data[ 'post_name' ] ) ) { - $data[ 'post_name' ] = sanitize_title( $data[ 'post_title' ] ); + if ( 'event' === $data['post_type'] && 'draft' === $data['post_status'] ) { + if ( empty( $data['post_name'] ) ) { + $data['post_name'] = sanitize_title( $data['post_title'] ); } } return $data; } -add_filter('wp_insert_post_data', 'generate_event_slug', 10, 2); +add_filter( 'wp_insert_post_data', 'generate_event_slug', 10, 2 ); add_action( 'gp_init',