From 718f8315ea7ab9f603e395e7a00f66dff63dbb92 Mon Sep 17 00:00:00 2001 From: ulaulaman Date: Thu, 19 Nov 2020 22:06:02 +0100 Subject: [PATCH] Backup code snippet --- backupsnippet/snippet.php | 104 +++++++++++++++++++++++++++++++++++++- 1 file changed, 103 insertions(+), 1 deletion(-) diff --git a/backupsnippet/snippet.php b/backupsnippet/snippet.php index 48e2360..2406f8a 100644 --- a/backupsnippet/snippet.php +++ b/backupsnippet/snippet.php @@ -389,7 +389,7 @@ $custom_content .= '

Ultimo aggiornamento il '. $updated_ } add_filter( 'the_content', 'wpb_last_updated_date' ); -#sidebar corso brera +#sidebar corso brera old add_shortcode( 'sbcorsobase', function () { $logo = '

'; @@ -468,3 +468,105 @@ add_shortcode( 'sbastroscheda', function () { return $out; } ); + +# sidebar teatro +add_shortcode( 'sbteatro', function () { + + $custom = get_post_custom(); + foreach( $custom as $key => $value ) { + $key_name = get_post_custom_values( $key = 'urllocandina' ); + if ( $key_name[0] <> null ) { + $locandina = '
'; + } else { $locandina = null; } + + $key_name = get_post_custom_values( $key = 'contatto' ); + if ( $key_name[0] <> null ) { + $contatto = '

Contatto: '.$key_name[0].'

'; + } else { $contatto = null; } + + $key_name = get_post_custom_values( $key = 'locandinafile' ); + if ( $key_name[0] <> null ) { + $file = '
(scarica la locandina)
'; + } else { $file = null; } + } + + $terms = get_the_terms ( $post->ID, 'formato_spettacolo' ); + $numcat = sizeof( $terms ); + $i = 0; + foreach ( $terms as $term ) { + $term_link = get_term_link( $term, 'formato_spettacolo' ); + $i++; + if ( $i < $numcat ) { + $formato = $formato.', '; + } else { + $formato = $formato.''; + } + } + + $terms = get_the_terms ( $post->ID, 'durata_spettacolo' ); + $numcat = sizeof( $terms ); + foreach ( $terms as $term ) { + $term_link = get_term_link( $term, 'durata_spettacolo' ); + $durata = '

Durata:

'; + } + + $terms = get_the_terms ( $post->ID, 'eta_spettatori' ); + $numcat = sizeof( $terms ); + $i = 0; + foreach ( $terms as $term ) { + $term_link = get_term_link( $term, 'eta_spettatori' ); + $i++; + if ( $i < $numcat ) { + $spettatori = $spettatori.', '; + } else { + $spettatori = $spettatori.''; + } + } + + $consigliato = '

Consigliato per: '.$spettatori; + + $terms = get_the_terms ( $post->ID, 'citta_spettacolo' ); + $numcat = sizeof( $terms ); + $i = 0; + foreach ( $terms as $term ) { + $term_link = get_term_link( $term, 'citta_spettacolo' ); + $i++; + if ( $i < $numcat ) { + $city = $city.', '; + } else { + $city = $city.''; + } + } + + if ( $city <> null ) { + $tour= '

Città o sede INAF di riferimento: '.$city; + } else { + $tour = null; + } + + + $out = '

'.$locandina.$file.'

'.$formato.'

'.$durata.$consigliato.$tour.$contatto; + + return $out; +} ); + +# codice che recupera automaticamente le voci di un menu a partire dal suo id +# source: https://wordpress.stackexchange.com/questions/111060/retrieving-a-list-of-menu-items-in-an-array +add_shortcode( 'menuprova', function () { + + //$menuLocations = get_nav_menu_locations(); + //$menuID = $menuLocations['Sedi INAF']; + $primaryNav = wp_get_nav_menu_items(728); // menu di prova 728 + + foreach ( $primaryNav as $navItem ) { + + $nav = $nav. '
  • '.$navItem->title.'
  • '; + +} + + $menu = '

    Menu di prova

    '; + + $out = $menu; + + return $out; +} );