Advertisement
downloadtaky

custom metabox

May 3rd, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.36 KB | None | 0 0
  1. <?php
  2. /**
  3.      * MetaBox personalizzati
  4.      */
  5. add_filter( 'rwmb_meta_boxes', function ( $meta_boxes ) {
  6.     $prefix = 'et2018-';
  7.     $meta_boxes[] = array(
  8.         'id'         => 'configuratore-spine',
  9.         'title'      => 'Configuratore post',
  10.         'post_types' => 'post',
  11.         'context'    => 'normal',
  12.         'fields'     => array(
  13.             array(
  14.                 'id'          =>'selettore_categoria',
  15.                 'type'        => 'taxonomy',
  16.                 'name'        => 'Selezione categoria',
  17.                 'desc'        => 'Scegli in quale categoria salvare il post',
  18.                 'placeholder' => 'Scegli la categoria',
  19.                 'taxonomy'    => 'category',
  20.                 'field_type'  => 'checkbox_tree',
  21.             ),
  22.             /* Gruppo Birra */
  23.             array(
  24.                 'id'      => 'gruppo_birra',
  25.                 'type'    => 'group',
  26.                 'name'    => 'Specifiche birre',
  27.                 'visible' => array(
  28.                     'when'     => array(
  29.                         array( 'selettore_categoria', 'contains', '2' ),
  30.                         //array( 'selettore_categoria', 'contains', '28' ),
  31.                     ),
  32.                     'relation' => 'or',
  33.                 ),
  34.                 'fields'  => array(
  35.                     array(
  36.                         'id'          => $prefix.'nome_birra',
  37.                         'type'        => 'text',
  38.                         'name'        => 'Nome Birra',
  39.                         'desc'        => 'Il nome della birra',
  40.                         'placeholder' => 'Nome birra',
  41.                     ),
  42.                     array(
  43.                         'id'          => $prefix.'nome_birrificio',
  44.                         'type'        => 'text',
  45.                         'name'        => 'Nome birrificio',
  46.                         'desc'        => "Inserire il nome del birrificio con l'iniziale maiuscola",
  47.                         'placeholder' => 'Nome birrificio',
  48.                     ),
  49.                     array(
  50.                         'id'   => $prefix.'gradazione',
  51.                         'type' => 'number',
  52.                         'name' => 'Gradazione birra',
  53.                         'desc' => 'Inserire la gradazione senza segni (NO: % e nemmeno: °)',
  54.                         'step' => '0.1',
  55.                     ),
  56.                     array(
  57.                         'id'   => $prefix.'stile_birra',
  58.                         'type' => 'text',
  59.                         'name' => 'Stile birra',
  60.                         'desc' => 'Inserire lo stile della birra',
  61.                     ),
  62.                     array(
  63.                         'id'     => $prefix.'gusto_prevalente',
  64.                         'name'   => 'Gusto prevalente',
  65.                         'type'   => 'radio',
  66.                         'desc'   => 'Gusto prevalente della birra',
  67.                         'options' => array(
  68.                             'amaro' => 'Amaro',
  69.                             'dolce' => 'Dolce',
  70.                             'acido' => 'Acido',
  71.                             'tostato' => 'Tostato',
  72.                         ),
  73.                         'inline' => true,
  74.                     ),
  75.                     array(
  76.                         'id'      => $prefix.'gusto_descrittori',
  77.                         'name'    => 'Scegli i descrittori della birra',
  78.                         'type'    => 'checkbox_list',
  79.                         'desc'    => 'La lista dei descrittori presa da qui: https://www.pintamedicea.com/birra/2017/la-ruota-dei-sapori-di-meilgaard/',
  80.                         'options' => array(
  81.                             'fruttato'    => 'Fruttato',
  82.                             'floreale'    => 'Floreale',
  83.                             'luppolato'   => 'Luppolato',
  84.                             'resinoso'    => 'Resinoso',
  85.                             'alcolico'    => 'Alcolico/Solvente',
  86.                             'malto'       => 'Malto',
  87.                             'caramello'   => 'Caramello',
  88.                             'tostato'     => 'Tostato/Bruciato',
  89.                             'acido'       => 'Acido',
  90.                             'dolce'       => 'Dolce',
  91.                             'amaro'       => 'Amaro',
  92.                             'astringente' => 'Astringente',
  93.                         ),
  94.                         'inline'  => 1,
  95.                     ),
  96.                     array(
  97.                         'id'   => $prefix.'prezzo_birra',
  98.                         'type' => 'text',
  99.                         'name' => 'Costo birra',
  100.                         'desc' => 'A quanto vendiamo quella birra? Senza simboli',
  101.                         'clone'      => 1,
  102.                         'sort_clone' => true,
  103.                         'step' => '0.1',
  104.                     ),
  105.                     array(
  106.                         'id'   => $prefix.'disponibilita',
  107.                         'name' => 'Disponibilità',
  108.                         'type' => 'checkbox',
  109.                         'desc' => 'Disponibile o no?',
  110.                         'std'  => 1,
  111.                     ),
  112.                     array(
  113.                         'id'      => $prefix.'formato_birra',
  114.                         'name'    => 'Formati disponibili',
  115.                         'type'    => 'checkbox_list',
  116.                         'desc'    => 'Che formati sono disponibili?',
  117.                         'options' => array(
  118.                             '33cl'   => '33cl',
  119.                             '375cl'  => '37.5cl',
  120.                             '50cl'   => '50cl',
  121.                             '75cl'   => '75cl',
  122.                             'magnum' => 'Magnum',
  123.                             'bgb'    => 'BGB',
  124.                             'fusto'  => 'Fusto',
  125.                         ),
  126.                         'inline'  => 1,
  127.                     ),
  128.                     array(
  129.                         'id'          => $prefix.'quantita_birra',
  130.                         'type'        => 'text',
  131.                         'name'        => 'Quantità birra',
  132.                         'desc'        => 'Quante ne hai in magazzino o cella?',
  133.                         'placeholder' => 'Quante ne hai?',
  134.                     ),
  135.                     array(
  136.                         'id'         => $prefix.'annata_birra',
  137.                         'type'       => 'number',
  138.                         'name'       => 'Annata birra',
  139.                         'desc'       => 'Di che annate sono le birre che hai?',
  140.                         'clone'      => 1,
  141.                         'sort_clone' => true,
  142.                     ),
  143.                 ),
  144.             ),
  145.             /* Gruppo Panini */
  146.             array(
  147.                 'id'      => 'gruppo_panini',
  148.                 'type'    => 'group',
  149.                 'name'    => 'Specifiche panini',
  150.                 'visible' => array(
  151.                     'when'     => array(
  152.                         array( 'selettore_categoria', 'contains', '36' ),
  153.                         //array( 'selettore_categoria', 'contains', '5' ),
  154.                     ),
  155.                     'relation' => 'or',
  156.                 ),
  157.                 'fields'  => array(
  158.                     array(
  159.                         'id'   => $prefix.'link_youtube',
  160.                         'type' => 'text',
  161.                         'name' => 'Link YouTube',
  162.                         'desc' => 'Link alla canzone',
  163.                     ),
  164.                     array(
  165.                         'id'   => $prefix.'img_low_res',
  166.                         'type' => 'single_image',
  167.                         'name' => 'Immagine a bassa qualità',
  168.                         'desc' => 'Carica qui l\'immagine a bassa qualità',
  169.                     ),
  170.                     array(
  171.                         'id'   => $prefix.'img_high_res',
  172.                         'type' => 'single_image',
  173.                         'name' => 'Immagine alta qualità',
  174.                         'desc' => 'Carica qui l\'immagine ad alta qualità',
  175.                     ),
  176.                     array(
  177.                         'id' => $prefix . 'descrizione',
  178.                         'type' => 'textarea',
  179.                         'name' => esc_html__( 'Descrizione pietanza', 'et-2018-template' ),
  180.                     ),
  181.                     array(
  182.                         'id'   => $prefix.'costo',
  183.                         'type' => 'number',
  184.                         'name' => 'Costo pietanza',
  185.                         'desc' => 'A quanto vendiamo quel piatto?',
  186.                         'step' => '0.1',
  187.                     ),
  188.                     array(
  189.                         'id'   => $prefix.'versionemini',
  190.                         'name' => 'Versione mini',
  191.                         'type' => 'checkbox',
  192.                         'desc' => 'Disponibile o no?',
  193.                         'std'  => 0,
  194.                     ),
  195.                 ),
  196.             ),
  197.             /* Gruppo Cantina */
  198.             array(
  199.                 'id'      => 'gruppo_cantina',
  200.                 'type'    => 'group',
  201.                 'name'    => 'Specifiche birre',
  202.                 'visible' => array(
  203.                     'when'     => array(
  204.                         //array( 'selettore_categoria', 'contains', '2' ),
  205.                         array( 'selettore_categoria', 'contains', '28' ),
  206.                     ),
  207.                     'relation' => 'or',
  208.                 ),
  209.                 'fields'  => array(
  210.                     array(
  211.                         'id'          => $prefix.'nome_birra',
  212.                         'type'        => 'text',
  213.                         'name'        => 'Nome Birra',
  214.                         'desc'        => 'Il nome della birra',
  215.                         'placeholder' => 'Nome birra',
  216.                     ),
  217.                     array(
  218.                         'id'          => $prefix.'nome_birrificio',
  219.                         'type'        => 'text',
  220.                         'name'        => 'Nome birrificio',
  221.                         'desc'        => "Inserire il nome del birrificio con l'iniziale maiuscola",
  222.                         'placeholder' => 'Nome birrificio',
  223.                     ),
  224.                     array(
  225.                         'id'   => $prefix.'gradazione',
  226.                         'type' => 'number',
  227.                         'name' => 'Gradazione birra',
  228.                         'desc' => 'Inserire la gradazione senza segni (NO: % e nemmeno: °)',
  229.                         'step' => '0.1',
  230.                     ),
  231.                     array(
  232.                         'id'   => $prefix.'stile_birra',
  233.                         'type' => 'text',
  234.                         'name' => 'Stile birra',
  235.                         'desc' => 'Inserire lo stile della birra',
  236.                     ),
  237.                     array(
  238.                         'id'     => $prefix.'gusto_prevalente',
  239.                         'name'   => 'Gusto prevalente',
  240.                         'type'   => 'radio',
  241.                         'desc'   => 'Gusto prevalente della birra',
  242.                         'options' => array(
  243.                             'amaro' => 'Amaro',
  244.                             'dolce' => 'Dolce',
  245.                             'acido' => 'Acido',
  246.                             'tostato' => 'Tostato',
  247.                         ),
  248.                         'inline' => true,
  249.                     ),
  250.                     array(
  251.                         'id'      => $prefix.'gusto_descrittori',
  252.                         'name'    => 'Scegli i descrittori della birra',
  253.                         'type'    => 'checkbox_list',
  254.                         'desc'    => 'La lista dei descrittori presa da qui: https://www.pintamedicea.com/birra/2017/la-ruota-dei-sapori-di-meilgaard/',
  255.                         'options' => array(
  256.                             'fruttato'    => 'Fruttato',
  257.                             'floreale'    => 'Floreale',
  258.                             'luppolato'   => 'Luppolato',
  259.                             'resinoso'    => 'Resinoso',
  260.                             'alcolico'    => 'Alcolico/Solvente',
  261.                             'malto'       => 'Malto',
  262.                             'caramello'   => 'Caramello',
  263.                             'tostato'     => 'Tostato/Bruciato',
  264.                             'acido'       => 'Acido',
  265.                             'dolce'       => 'Dolce',
  266.                             'amaro'       => 'Amaro',
  267.                             'astringente' => 'Astringente',
  268.                         ),
  269.                         'inline'  => 1,
  270.                     ),
  271.                     array(
  272.                         'id'   => $prefix.'prezzo_birra',
  273.                         'type' => 'text',
  274.                         'name' => 'Costo birra',
  275.                         'desc' => 'A quanto vendiamo quella birra? Senza simboli',
  276.                         'clone'      => 1,
  277.                         'sort_clone' => true,
  278.                         'step' => '0.1',
  279.                     ),
  280.                     array(
  281.                         'id'   => $prefix.'disponibilita',
  282.                         'name' => 'Disponibilità',
  283.                         'type' => 'checkbox',
  284.                         'desc' => 'Disponibile o no?',
  285.                         'std'  => 1,
  286.                     ),
  287.                     array(
  288.                         'id'      => $prefix.'formato_birra',
  289.                         'name'    => 'Formati disponibili',
  290.                         'type'    => 'checkbox_list',
  291.                         'desc'    => 'Che formati sono disponibili?',
  292.                         'options' => array(
  293.                             '33cl'   => '33cl',
  294.                             '375cl'  => '37.5cl',
  295.                             '50cl'   => '50cl',
  296.                             '75cl'   => '75cl',
  297.                             'magnum' => 'Magnum',
  298.                             'bgb'    => 'BGB',
  299.                             'fusto'  => 'Fusto',
  300.                         ),
  301.                         'inline'  => 1,
  302.                     ),
  303.                     array(
  304.                         'id'          => $prefix.'quantita_birra',
  305.                         'type'        => 'text',
  306.                         'name'        => 'Quantità birra',
  307.                         'desc'        => 'Quante ne hai in magazzino o cella?',
  308.                         'placeholder' => 'Quante ne hai?',
  309.                         'clone'      => 1,
  310.                         'sort_clone' => true,
  311.                         'step' => '0.1',
  312.                         'admin_columns' => 'after title',
  313.                     ),
  314.                     array(
  315.                         'id'         => $prefix.'annata_birra',
  316.                         'type'       => 'number',
  317.                         'name'       => 'Annata birra',
  318.                         'desc'       => 'Di che annate sono le birre che hai?',
  319.                         'clone'      => 1,
  320.                         'sort_clone' => true,
  321.                     ),
  322.                     array(
  323.                         'id'   => $prefix.'img_low_res',
  324.                         'type' => 'single_image',
  325.                         'name' => 'Immagine a bassa qualità',
  326.                         'desc' => 'Carica qui l\'immagine a bassa qualità',
  327.                     ),
  328.                     array(
  329.                         'id'   => $prefix.'img_high_res',
  330.                         'type' => 'single_image',
  331.                         'name' => 'Immagine alta qualità',
  332.                         'desc' => 'Carica qui l\'immagine ad alta qualità',
  333.                     ),
  334.                     array(
  335.                         'id' => $prefix . 'descrizione',
  336.                         'type' => 'textarea',
  337.                         'name' => esc_html__( 'Descrizione birra', 'et-2018-template' ),
  338.                     ),
  339.                 ),
  340.             ),
  341.         ),
  342.     );
  343.  
  344.     return $meta_boxes;
  345. } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement