From 8f73e42fc9d5dd88f94eb4dd4fd80782db37af95 Mon Sep 17 00:00:00 2001 From: ulaulaman Date: Sat, 16 Oct 2021 00:56:32 +0200 Subject: [PATCH] 2021.1016 Aggiunti due nuovi parametri --- book-template.php | 122 +++++++++++++++++++++++++--------------------- 1 file changed, 66 insertions(+), 56 deletions(-) diff --git a/book-template.php b/book-template.php index 844a1ac..0249a56 100644 --- a/book-template.php +++ b/book-template.php @@ -2,12 +2,14 @@ /* Plugin Name: Book Template Description: Plugin che aggiunge uno shortcode per la creazione di un box con i dati editoriali di un libro o di un fumetto. -Version: 2020.0813 +Version: 2021.1016 Author: Gianluigi Filippelli Author URI: http://dropseaofulaula.blogspot.it/ -Plugin URI: https://ulaulaman.github.io/book-template/ +Plugin URI: https://ulaulaman.github.io/#BookTemplate +GitHub Plugin URI: https://github.com/ulaulaman/book-template License: GPLv2 or later */ + # Caricamento traduzioni add_action('plugins_loaded', 'bt_load_translations'); function bt_load_translations() { @@ -51,68 +53,76 @@ function bookdata_class_meta_box( $post ) { ?> # Creazione shortcode dati editoriali add_shortcode( 'bookdata', 'bookdata' ); - function bookdata ($atts, $content = null) { + function bookdata ( $atts, $content = null ) { - extract( - shortcode_atts( - array( - 'title' => null, - 'author' => null, - 'translator' => null, - 'publisher' => null, - 'date' => null, - 'pages' => null, - 'type' => null, - 'col' => null, - 'price' => null, - 'age' => null, - 'isbn' => null, - 'issn' => null, - 'notes' => null, - ), - $atts - ) - ); + extract( + shortcode_atts( + array( + 'intro' => null, + 'title' => null, + 'url' => null, + 'author' => null, + 'translator' => null, + 'publisher' => null, + 'date' => null, + 'pages' => null, + 'type' => null, + 'col' => null, + 'price' => null, + 'age' => null, + 'isbn' => null, + 'issn' => null, + 'notes' => null, + ), + $atts + ) + ); - $intro = __( 'Abbiamo parlato di:', 'book-template' ); + $book='

'; - $book = '

'.$intro.'
'.$title.'
'.$author; - - if ( $translator <> null ) - {$translator = __( 'Traduzione di ', 'book-template' ).$translator; - $book = $book.'
'.$translator;} - else - {$book = $book;} + if ( $intro <> null ) { + $book = $book.''.$intro.''; + } else { + $book = $book.''.__( 'Abbiamo parlato di:', 'book-template' ).''; + } - $pages = $pages.' '.__( 'pagine', 'book-template' ); - - if ( $col <> null ) - {$book = $book.'
'.$publisher.', '.$date.'
'.$pages.', '.$type.', '.$col.' – '.$price;} - else - {$book = $book.'
'.$publisher.', '.$date.'
'.$pages.', '.$type.' – '.$price;} + if ( $url <> null ) { + $book = $book.'
'.$title.'
'.$author; + } else { + $book = $book.'
'.$title.'
'.$author; + } - if ( $age <> null ) - {$book = $book.'
'.__( 'Lettura consigliata per ', 'book-template' ).$age;} - else - {$book = $book;} + if ( $translator <> null ) { + $book = $book.'
'.__( 'Traduzione di ', 'book-template' ).$translator; + } - if ( $isbn <> null ) - {$book = $book.'
ISBN: '.$isbn;} - else - { - if ( $issn <> null ) - {$book = $book.'
ISSN: '.$issn;} - else - {$book = $book;} - } + $pages = $pages.' '.__( 'pagine', 'book-template' ); - if ( $notes <> null ) - {$book = $book.'
'.$notes;} - else - {$book = $book;} + if ( $col <> null ) { + $book = $book.'
'.$publisher.', '.$date.'
'.$pages.', '.$type.', '.$col.' – '.$price; + } else { + $book = $book.'
'.$publisher.', '.$date.'
'.$pages.', '.$type.' – '.$price; + } - $text = $book; - return $text; + if ( $age <> null ) { + $book = $book.'
'.__( 'Lettura consigliata ', 'book-template' ).$age; + } + + if ( $isbn <> null ) { + $book = $book.'
ISBN: '.$isbn; + } else { + if ( $issn <> null ) { + $book = $book.'
ISSN: '.$issn; + } + } + + if ( $notes <> null ) { + $book = $book.'
'.$notes; + } + + $book = $book.'

'; + + return $book; } ?>