feat: rilascio 1.1.0, piu' categorie insieme, periodo dal/al, parola nel titolo e scelta del carattere nel blocco e nello shortcode
All checks were successful
Release su wordpress.org / rilascio (push) Successful in 35s

This commit is contained in:
Lorenzo Iovino 2026-09-29 16:11:42 +02:00
parent 1b1dda3281
commit 368682bd07
8 changed files with 112 additions and 11 deletions

View file

@ -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'] );

View file

@ -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
*/