Skip to content

Commit

Permalink
Fixes style
Browse files Browse the repository at this point in the history
  • Loading branch information
amieiro committed Feb 15, 2024
1 parent 3b21431 commit 5976bdd
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions wporg-gp-translation-events.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {

Check warning on line 308 in wporg-gp-translation-events.php

View workflow job for this annotation

GitHub Actions / PHP

The method parameter $postarr is never used
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',
Expand Down

0 comments on commit 5976bdd

Please sign in to comment.