From 74751c883df1685350f931a3968ccad1b04b4769 Mon Sep 17 00:00:00 2001 From: ulaulaman Date: Tue, 29 Jun 2021 01:10:36 +0200 Subject: [PATCH] Modifiche alla sidebar per risolvere issue --- sidebars/costellazioni.php | 92 +++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 40 deletions(-) diff --git a/sidebars/costellazioni.php b/sidebars/costellazioni.php index dd648b0..7801f5b 100644 --- a/sidebars/costellazioni.php +++ b/sidebars/costellazioni.php @@ -23,60 +23,72 @@ add_shortcode( 'menucostellazioni', function () { add_shortcode( 'sbcostellazioni', function () { $custom = get_post_custom(); - foreach( $custom as $key => $value ) { - $key_name = get_post_custom_values( $key = 'ascensione_retta_centrale' ); - $field1 = '

Ascensione retta centrale: '.$key_name[0].'

'; - $key_name = get_post_custom_values( $key = 'declinazione_centrale' ); - $field2 = '

Declinazione centrale: '.$key_name[0].'

'; - $key_name = get_post_custom_values( $key = 'urlmappa' ); - $mappa = '

'; - if ( $key_name[1] <> null ) { - $mappa1 = '

'; - } else { $mappa1 = null; } - if ( $key_name[2] <> null ) { - $mappa2 = '

'; - } else { $mappa2 = null; } + if ( empty($custom) ) { + $out = null; + } else { + foreach( $custom as $key => $value ) { + $key_name = get_post_custom_values( $key = 'ascensione_retta_centrale' ); + $field1 = '

Ascensione retta centrale: '.$key_name[0].'

'; + $key_name = get_post_custom_values( $key = 'declinazione_centrale' ); + $field2 = '

Declinazione centrale: '.$key_name[0].'

'; + $key_name = get_post_custom_values( $key = 'urlmappa' ); + $mappa = '

'; + if ( $key_name[1] <> null ) { + $mappa1 = '

'; + } else { $mappa1 = null; } + if ( $key_name[2] <> null ) { + $mappa2 = '

'; + } else { $mappa2 = null; } + } + $out = $mappa.$mappa1.$mappa2.$field1.$field2; } - $map = $mappa.$mappa1.$mappa2; $type = 'emisfero '; $terms = get_the_terms ( $post->ID, 'emisfero' ); - $numcat = sizeof( $terms ); - $i = 0; - foreach ( $terms as $term ) { - $term_link = get_term_link( $term, 'emisfero' ); - $i++; - if ( $i < $numcat ) { - $type = $type.', '; - } else { - $type = $type.''; - } + if ( empty($terms) ) { + $type = null; + } else { + $numcat = sizeof( $terms ); + $i = 0; + foreach ( $terms as $term ) { + $term_link = get_term_link( $term, 'emisfero' ); + $i++; + if ( $i < $numcat ) { + $type = $type.', '; + } else { + $type = $type.''; + } + } + $out = $out.'

Visibile in: '.$type.'

'; } $terms = get_the_terms ( $post->ID, 'stagione' ); - $numcat = sizeof( $terms ); - if ( $numcat > 1 ) { - $season = 'Stagioni: '; + if ( empty($terms) ){ + $season = null; } else { - $season = 'Stagione: '; - } - $i = 0; - foreach ( $terms as $term ) { - $term_link = get_term_link( $term, 'stagione' ); - $i++; - if ( $i < $numcat ) { - $season = $season.', '; + $numcat = sizeof( $terms ); + if ( $numcat > 1 ) { + $season = 'Stagioni: '; } else { - $season = $season.''; - } + $season = 'Stagione: '; + } + $i = 0; + foreach ( $terms as $term ) { + $term_link = get_term_link( $term, 'stagione' ); + $i++; + if ( $i < $numcat ) { + $season = $season.', '; + } else { + $season = $season.''; + } + } + $out = $out.'

'.$season.'

'; } - - $visibile = '

Visibile in: '.$type.'

'.$season.'

'; $auth = do_shortcode('[blog-post-coauthors]'); $cura = '

Scheda a cura di

'.$auth.'

'; - $out = $map.$field1.$field2.$visibile.$cura; + $out = $out.$cura; return $out; } ); \ No newline at end of file