Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show a bubble when the event is in draft status #80

Merged
merged 3 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion templates/event.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@

<div class="event-details-page">
<div class="event-details-head">
<h1><?php echo esc_html( $event_title ); ?></h1>
<h1>
<?php echo esc_html( $event_title ); ?>
<?php if ( 'draft' === $event->post_status ): ?>
<span class="event-label-draft"><?php echo esc_html( $event->post_status ); ?></span>
<?php endif; ?>
</h1>
<p>Host: <a href="<?php echo esc_attr( get_author_posts_url( $event->post_author ) ); ?>"><?php echo esc_html( get_the_author_meta( 'display_name', $event->post_author ) ); ?></a></p>
</div>
<div class="event-details-left">
Expand Down
20 changes: 20 additions & 0 deletions wporg-gp-translation-events.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,26 @@ function gp_event_nav_menu_items( array $items ): array {
// Add the events link to the GlotPress main menu.
add_filter( 'gp_nav_menu_items', 'gp_event_nav_menu_items' );

/**
* 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.
* @return array The modified post data.
*/
function generate_event_slug( $data ) {
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, 1 );

add_action(
'gp_init',
function () {
Expand Down
Loading