From 368682bd077ed43978c6c32949bd48c531cdc519 Mon Sep 17 00:00:00 2001 From: Lorenzo Iovino Date: Tue, 29 Sep 2026 16:11:42 +0200 Subject: [PATCH] feat: rilascio 1.1.0, piu' categorie insieme, periodo dal/al, parola nel titolo e scelta del carattere nel blocco e nello shortcode --- blocks/eventi/block.json | 8 ++++-- blocks/eventi/index.js | 25 +++++++++++++++++ includes/render.php | 44 ++++++++++++++++++++++++++++-- includes/shortcode.php | 3 +- languages/piazza-in-festa-it_IT.po | 24 ++++++++++++++++ languages/readme-it_IT.po | 4 +-- piazza-in-festa.php | 4 +-- readme.txt | 11 ++++++-- 8 files changed, 112 insertions(+), 11 deletions(-) diff --git a/blocks/eventi/block.json b/blocks/eventi/block.json index a321292..c5de3e9 100644 --- a/blocks/eventi/block.json +++ b/blocks/eventi/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "piazza-in-festa/eventi", - "version": "1.0.1", + "version": "1.1.0", "title": "Piazza in Festa", "category": "widgets", "icon": "calendar-alt", @@ -22,7 +22,11 @@ "tema": { "type": "string", "default": "chiaro" }, "colore": { "type": "string", "default": "" }, "titolo": { "type": "string", "default": "" }, - "altezza": { "type": "string", "default": "320" } + "altezza": { "type": "string", "default": "320" }, + "dal": { "type": "string", "default": "" }, + "al": { "type": "string", "default": "" }, + "cerca": { "type": "string", "default": "" }, + "font": { "type": "string", "default": "" } }, "editorScript": "file:./index.js" } diff --git a/blocks/eventi/index.js b/blocks/eventi/index.js index b053f7b..3307ca3 100644 --- a/blocks/eventi/index.js +++ b/blocks/eventi/index.js @@ -99,6 +99,17 @@ set({ categoria: v }); } }), + campo( + 'cerca', + __('Word in the title', 'piazza-in-festa'), + __('Optional, at least 3 letters, for instance: natale.', 'piazza-in-festa') + ), + campo( + 'dal', + __('Starting from', 'piazza-in-festa'), + __('Optional. Only events that start in the period, format YYYY-MM-DD.', 'piazza-in-festa') + ), + campo('al', __('Until', 'piazza-in-festa'), __('Optional, format YYYY-MM-DD.', 'piazza-in-festa')), campo('limite', __('How many events', 'piazza-in-festa'), __('From 1 to 20.', 'piazza-in-festa')), el(SelectControl, { label: __('Layout', 'piazza-in-festa'), @@ -132,6 +143,20 @@ } }), campo('colore', __('Accent colour', 'piazza-in-festa'), __('Hex code, for instance #b4315a.', 'piazza-in-festa')), + el(SelectControl, { + label: __('Font', 'piazza-in-festa'), + value: a.font, + options: [ + { label: __('Visitor device font', 'piazza-in-festa'), value: '' }, + { label: 'Helvetica / Arial', value: 'helvetica' }, + { label: 'Georgia', value: 'serif' } + ], + __next40pxDefaultSize: true, + __nextHasNoMarginBottom: true, + onChange: function (v) { + set({ font: v }); + } + }), campo('titolo', __('Heading', 'piazza-in-festa'), __('Leave it empty for no heading.', 'piazza-in-festa')), campo('altezza', __('Starting height (px)', 'piazza-in-festa'), __('It adapts by itself once loaded.', 'piazza-in-festa')) ) diff --git a/includes/render.php b/includes/render.php index c1cb3f4..3edf2b7 100644 --- a/includes/render.php +++ b/includes/render.php @@ -25,6 +25,10 @@ function pinfesta_defaults() { 'colore' => '', 'titolo' => '', 'altezza' => '320', + 'dal' => '', + 'al' => '', + 'cerca' => '', + 'font' => '', ); } @@ -97,8 +101,44 @@ function pinfesta_build_url( $args ) { $query['regione'] = sanitize_text_field( $args['regione'] ); } - if ( in_array( $args['categoria'], pinfesta_categorie(), true ) ) { - $query['categoria'] = $args['categoria']; + // One category or several, comma separated. Unknown ones are dropped, so a + // typo widens the widget instead of emptying it. + $categorie = array(); + + foreach ( explode( ',', (string) $args['categoria'] ) as $item ) { + $item = trim( $item ); + + if ( in_array( $item, pinfesta_categorie(), true ) ) { + $categorie[] = $item; + } + } + + if ( $categorie ) { + $query['categoria'] = implode( ',', array_unique( $categorie ) ); + } + + // Period: only events that start between these two dates (YYYY-MM-DD), for + // a page about Christmas or the summer. Anything that is not a date is + // ignored. + foreach ( array( 'dal', 'al' ) as $chiave_data ) { + $data = trim( (string) $args[ $chiave_data ] ); + + if ( preg_match( '/^\d{4}-\d{2}-\d{2}$/', $data ) ) { + $query[ $chiave_data ] = $data; + } + } + + // A word in the title, for instance "natale" inside the markets. + $cerca = sanitize_text_field( $args['cerca'] ); + + if ( mb_strlen( $cerca ) >= 3 ) { + $query['cerca'] = mb_substr( $cerca, 0, 40 ); + } + + // The widget lives in an iframe and cannot inherit the site's font: the + // service offers a few safe stacks to pick from. + if ( in_array( $args['font'], array( 'helvetica', 'serif' ), true ) ) { + $query['font'] = $args['font']; } $limite = absint( $args['limite'] ); diff --git a/includes/shortcode.php b/includes/shortcode.php index bf9ac95..55b5d28 100644 --- a/includes/shortcode.php +++ b/includes/shortcode.php @@ -7,7 +7,8 @@ * read there is what you write here. * * [piazza-in-festa comuni="alba,barolo,la-morra" limite="5"] - * [piazza-in-festa regione="Piemonte" categoria="sagra_enogastronomica"] + * [piazza-in-festa regione="Piemonte" categoria="sagra_enogastronomica,mercatini"] + * [piazza-in-festa regione="Veneto" categoria="mercatini" cerca="natale" dal="2026-11-01" al="2027-01-06"] * * @package PiazzaInFesta */ diff --git a/languages/piazza-in-festa-it_IT.po b/languages/piazza-in-festa-it_IT.po index 31f9e57..0537654 100644 --- a/languages/piazza-in-festa-it_IT.po +++ b/languages/piazza-in-festa-it_IT.po @@ -150,3 +150,27 @@ msgstr "calendario" msgctxt "block keyword" msgid "agenda" msgstr "agenda" + +msgid "Word in the title" +msgstr "Parola nel titolo" + +msgid "Optional, at least 3 letters, for instance: natale." +msgstr "Facoltativa, almeno 3 lettere, per esempio: natale." + +msgid "Starting from" +msgstr "Dal" + +msgid "Optional. Only events that start in the period, format YYYY-MM-DD." +msgstr "Facoltativo. Solo gli eventi che iniziano nel periodo, formato AAAA-MM-GG." + +msgid "Until" +msgstr "Al" + +msgid "Optional, format YYYY-MM-DD." +msgstr "Facoltativo, formato AAAA-MM-GG." + +msgid "Font" +msgstr "Carattere" + +msgid "Visitor device font" +msgstr "Carattere del dispositivo del visitatore" diff --git a/languages/readme-it_IT.po b/languages/readme-it_IT.po index 4e02b26..864c3f5 100644 --- a/languages/readme-it_IT.po +++ b/languages/readme-it_IT.po @@ -95,8 +95,8 @@ msgid "As with any embedded content, that request reaches the service with the v msgstr "Come per qualsiasi contenuto incorporato, quella richiesta arriva al servizio con l'indirizzo IP del visitatore e lo user agent del browser. Il plugin non manda niente dal tuo server, non conserva niente sui tuoi visitatori e non usa cookie propri." #. Found in description paragraph. -msgid "When a visitor opens a page that contains the block or the shortcode, their browser loads a page from https://piazzainfesta.it/embed with the parameters you configured: the towns or the region, the category, how many events to show, and the appearance options (theme, colour, heading). If you saved a service key in the settings, the key is part of that address as well." -msgstr "Quando un visitatore apre una pagina che contiene il blocco o lo shortcode, il suo browser carica una pagina da https://piazzainfesta.it/embed con i parametri che hai configurato: i comuni o la regione, la categoria, quanti eventi mostrare e le opzioni di aspetto (tema, colore, titolo). Se hai salvato una chiave del servizio nelle impostazioni, anche la chiave fa parte di quell'indirizzo." +msgid "When a visitor opens a page that contains the block or the shortcode, their browser loads a page from https://piazzainfesta.it/embed with the parameters you configured: the towns or the region, the categories, the optional period and word in the title, how many events to show, and the appearance options (theme, colour, font, heading). If you saved a service key in the settings, the key is part of that address as well." +msgstr "Quando un visitatore apre una pagina che contiene il blocco o lo shortcode, il suo browser carica una pagina da https://piazzainfesta.it/embed con i parametri che hai configurato: i comuni o la regione, le categorie, l'eventuale periodo e la parola nel titolo, quanti eventi mostrare e le opzioni di aspetto (tema, colore, carattere, titolo). Se hai salvato una chiave del servizio nelle impostazioni, anche la chiave fa parte di quell'indirizzo." #. Found in description paragraph. msgid "This plugin displays events served by Piazza in Festa, an external service run by the plugin author." diff --git a/piazza-in-festa.php b/piazza-in-festa.php index 17caaa8..173a701 100644 --- a/piazza-in-festa.php +++ b/piazza-in-festa.php @@ -3,7 +3,7 @@ * Plugin Name: Piazza in Festa * Plugin URI: https://piazzainfesta.it/widget * Description: Show the upcoming local events of the Italian towns you follow: village feasts, concerts, fairs, exhibitions. Shortcode and block, updated daily. - * Version: 1.0.1 + * Version: 1.1.0 * Requires at least: 6.5 * Requires PHP: 7.4 * Author: Piazza in Festa @@ -17,7 +17,7 @@ defined( 'ABSPATH' ) || exit; -define( 'PINFESTA_VERSION', '1.0.1' ); +define( 'PINFESTA_VERSION', '1.1.0' ); define( 'PINFESTA_FILE', __FILE__ ); define( 'PINFESTA_DIR', plugin_dir_path( __FILE__ ) ); define( 'PINFESTA_URL', plugin_dir_url( __FILE__ ) ); diff --git a/readme.txt b/readme.txt index 6166aa7..7b57b69 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: eventi, sagre, comuni, pro loco, turismo Requires at least: 6.5 Tested up to: 7.1 Requires PHP: 7.4 -Stable tag: 1.0.1 +Stable tag: 1.1.0 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -36,7 +36,7 @@ The plugin is free and complete: every option described here works, with or with This plugin displays events served by **Piazza in Festa**, an external service run by the plugin author. -When a visitor opens a page that contains the block or the shortcode, their browser loads a page from `https://piazzainfesta.it/embed` with the parameters you configured: the towns or the region, the category, how many events to show, and the appearance options (theme, colour, heading). If you saved a service key in the settings, the key is part of that address as well. +When a visitor opens a page that contains the block or the shortcode, their browser loads a page from `https://piazzainfesta.it/embed` with the parameters you configured: the towns or the region, the categories, the optional period and word in the title, how many events to show, and the appearance options (theme, colour, font, heading). If you saved a service key in the settings, the key is part of that address as well. As with any embedded content, that request reaches the service with the visitor's IP address and browser user agent. The plugin sends nothing from your server, stores nothing about your visitors, and sets no cookies of its own. @@ -90,6 +90,13 @@ You can set the theme (light or dark), the accent colour and the heading. The re == Changelog == += 1.1.0 = +* Several categories at once, comma separated in the shortcode. +* Period filter (`dal`, `al`): only events that start between two dates, for a page about Christmas or the summer. +* Word in the title (`cerca`), for instance "natale" inside the Christmas markets. +* Font choice for the widget: the visitor's device font, Helvetica or Georgia. +* The service now picks events by quality: posters and verified details first, no council notices, no months-long containers. + = 1.0.1 = * Directory tags in Italian (eventi, sagre, comuni, pro loco, turismo), so that towns and Pro Loco can find the plugin. No code changes.