From 9c5a51745f827f24859159f123614f985a4467dd Mon Sep 17 00:00:00 2001 From: bisco Date: Thu, 25 Jun 2026 17:50:53 +0200 Subject: [PATCH] fix: hide empty show metadata --- README.md | 5 +++-- docs/runbook.md | 4 ++++ tests/functional/tests/portal.spec.ts | 1 + wordpress/mu-plugins/azionelab-content.php | 7 ++++++- wordpress/theme/azionelab/front-page.php | 4 +++- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5552268..6c971cb 100644 --- a/README.md +++ b/README.md @@ -148,8 +148,9 @@ uses different host paths or image user IDs. - **Appearance > Customize**: hero, manifesto, laboratory, teacher, lessons, contacts, social links, and footer. -- **Shows**: poster, title, short description, year, place, and order. The short - description is the **Descrizione breve** field inside **Dettagli spettacolo**. +- **Shows**: poster, title, short description, year, place, and order. The line above + each title is built from **Anno** and **Luogo** inside **Dettagli spettacolo**. The + text below the title is **Descrizione breve**. - **Gallery**: image, category, caption/title, and order. - **Settings > General**: site name and tagline. diff --git a/docs/runbook.md b/docs/runbook.md index 5f4dedd..759b9ff 100644 --- a/docs/runbook.md +++ b/docs/runbook.md @@ -53,6 +53,10 @@ HTTPS redirects during production startup. Edit **Spettacoli**, open the show, then use **Dettagli spettacolo > Descrizione breve**. That field is rendered below the title in the homepage show card. +The small uppercase line above the title is not the description. It is built from +**Dettagli spettacolo > Anno** and **Luogo**. Empty fields are hidden on the public +card. + ## A service cannot write to its volume 1. Stop the affected service. diff --git a/tests/functional/tests/portal.spec.ts b/tests/functional/tests/portal.spec.ts index 4fda51c..459087d 100644 --- a/tests/functional/tests/portal.spec.ts +++ b/tests/functional/tests/portal.spec.ts @@ -22,6 +22,7 @@ test("renders the complete seeded single page", async ({ page }) => { await expect(page.locator(".feature-card")).toHaveCount(3); await expect(page.locator(".show-card")).toHaveCount(2); await expect(page.locator(".gallery-item")).toHaveCount(4); + await expect(page.locator(".show-meta", { hasText: /^0$/ })).toHaveCount(0); const positions = await page.evaluate((ids) => ids.map((id) => { const element = document.getElementById(id); diff --git a/wordpress/mu-plugins/azionelab-content.php b/wordpress/mu-plugins/azionelab-content.php index c33ca4c..5b19b22 100644 --- a/wordpress/mu-plugins/azionelab-content.php +++ b/wordpress/mu-plugins/azionelab-content.php @@ -56,6 +56,7 @@ add_action( 'add_meta_boxes', 'azionelab_add_meta_boxes' ); function azionelab_show_meta_box( WP_Post $post ): void { wp_nonce_field( 'azionelab_save_meta', 'azionelab_meta_nonce' ); $year = get_post_meta( $post->ID, 'azl_show_year', true ); + $year = '0' === (string) $year ? '' : $year; $location = get_post_meta( $post->ID, 'azl_show_location', true ); ?>

@@ -96,7 +97,11 @@ function azionelab_save_meta( int $post_id ): void { $post_type = get_post_type( $post_id ); if ( 'azl_show' === $post_type ) { $excerpt = isset( $_POST['azl_show_excerpt'] ) ? sanitize_textarea_field( wp_unslash( $_POST['azl_show_excerpt'] ) ) : ''; - $year = isset( $_POST['azl_show_year'] ) ? absint( $_POST['azl_show_year'] ) : 0; + $year = ''; + if ( isset( $_POST['azl_show_year'] ) && '' !== trim( (string) wp_unslash( $_POST['azl_show_year'] ) ) ) { + $submitted_year = absint( $_POST['azl_show_year'] ); + $year = $submitted_year >= 1900 && $submitted_year <= 2100 ? (string) $submitted_year : ''; + } $location = isset( $_POST['azl_show_location'] ) ? sanitize_text_field( wp_unslash( $_POST['azl_show_location'] ) ) : ''; update_post_meta( $post_id, 'azl_show_year', $year ); update_post_meta( $post_id, 'azl_show_location', $location ); diff --git a/wordpress/theme/azionelab/front-page.php b/wordpress/theme/azionelab/front-page.php index 44d354e..b1988d7 100644 --- a/wordpress/theme/azionelab/front-page.php +++ b/wordpress/theme/azionelab/front-page.php @@ -119,11 +119,13 @@ $features = array( $fallback = azionelab_asset( 0 === $show_index % 2 ? 'show-one.svg' : 'show-two.svg' ); $image = get_the_post_thumbnail_url( get_the_ID(), 'large' ) ?: $fallback; $year = get_post_meta( get_the_ID(), 'azl_show_year', true ); + $year = '0' === (string) $year ? '' : $year; $location = get_post_meta( get_the_ID(), 'azl_show_location', true ); + $show_meta = implode( ' · ', array_filter( array( $year, $location ) ) ); ?>

Locandina di <?php the_title_attribute(); ?> -

+