Advertisement
downloadtaky

Grouped MetaBoxes

May 6th, 2018
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.15 KB | None | 0 0
  1. <?php
  2.     add_filter( 'rwmb_meta_boxes', function ( $meta_boxes ) {
  3.         $prefix       = 'et2018-';
  4.         $meta_boxes[] = array(
  5.             'id'         => 'configuratore-spine',
  6.             'title'      => 'Configuratore post',
  7.             'post_types' => 'post',
  8.             'context'    => 'normal',
  9.             'fields'     => array(
  10.                 array(
  11.                     'id'          => 'selettore_categoria',
  12.                     'type'        => 'taxonomy',
  13.                     'name'        => 'Selezione categoria',
  14.                     'desc'        => 'Scegli in quale categoria salvare il post',
  15.                     'placeholder' => 'Scegli la categoria',
  16.                     'taxonomy'    => 'category',
  17.                     'field_type'  => 'select_advanced',
  18.                 ),
  19.                 /* Gruppo birra */
  20.                 array(
  21.                     'id'          => 'gruppo_birra',
  22.                     'name'        => 'Specifiche birre',
  23.                     'type'        => 'group',
  24.                     'collapsible' => true,
  25.                     'group_title' => array( 'field' => 'name' ), // ID of the subfield
  26.                     'save_state'  => true,
  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 FROM HERE*/
  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 . 'disponibilita',
  212.                             'name' => 'Disponibilità',
  213.                             'type' => 'checkbox',
  214.                             'desc' => 'Disponibile o no?',
  215.                             'std'  => 1,
  216.                         ),
  217.                         array(
  218.                             'id'          => $prefix . 'nome_birra',
  219.                             'type'        => 'text',
  220.                             'name'        => 'Nome Birra',
  221.                             'desc'        => 'Il nome della birra',
  222.                             'placeholder' => 'Nome birra',
  223.                         ),
  224.                         array(
  225.                             'id'          => $prefix . 'nome_birrificio',
  226.                             'type'        => 'text',
  227.                             'name'        => 'Nome birrificio',
  228.                             'desc'        => "Inserire il nome del birrificio con l'iniziale maiuscola",
  229.                             'placeholder' => 'Nome birrificio',
  230.                         ),
  231.                         array(
  232.                             'id'   => $prefix . 'gradazione',
  233.                             'type' => 'number',
  234.                             'name' => 'Gradazione birra',
  235.                             'desc' => 'Inserire la gradazione senza segni (NO: % e nemmeno: °)',
  236.                             'step' => '0.1',
  237.                         ),
  238.                         array(
  239.                             'id'   => $prefix . 'stile_birra',
  240.                             'type' => 'text',
  241.                             'name' => 'Stile birra',
  242.                             'desc' => 'Inserire lo stile della birra',
  243.                         ),
  244.                         array(
  245.                             'id'      => $prefix . 'gusto_prevalente',
  246.                             'name'    => 'Gusto prevalente',
  247.                             'type'    => 'radio',
  248.                             'desc'    => 'Gusto prevalente della birra',
  249.                             'options' => array(
  250.                                 'amaro'   => 'Amaro',
  251.                                 'dolce'   => 'Dolce',
  252.                                 'acido'   => 'Acido',
  253.                                 'tostato' => 'Tostato',
  254.                             ),
  255.                             'inline'  => true,
  256.                         ),
  257.                         array(
  258.                             'id'      => $prefix . 'gusto_descrittori',
  259.                             'name'    => 'Scegli i descrittori della birra',
  260.                             'type'    => 'checkbox_list',
  261.                             'desc'    => 'La lista dei descrittori presa da qui: https://www.pintamedicea.com/birra/2017/la-ruota-dei-sapori-di-meilgaard/',
  262.                             'options' => array(
  263.                                 'fruttato'    => 'Fruttato',
  264.                                 'floreale'    => 'Floreale',
  265.                                 'luppolato'   => 'Luppolato',
  266.                                 'resinoso'    => 'Resinoso',
  267.                                 'alcolico'    => 'Alcolico/Solvente',
  268.                                 'malto'       => 'Malto',
  269.                                 'caramello'   => 'Caramello',
  270.                                 'tostato'     => 'Tostato/Bruciato',
  271.                                 'acido'       => 'Acido',
  272.                                 'dolce'       => 'Dolce',
  273.                                 'amaro'       => 'Amaro',
  274.                                 'astringente' => 'Astringente',
  275.                             ),
  276.                             'inline'  => 1,
  277.                         ),
  278.                         array(
  279.                             'id'   => $prefix . 'img_low_res',
  280.                             'type' => 'single_image',
  281.                             'name' => 'Immagine a bassa qualità',
  282.                             'desc' => 'Carica qui l\'immagine a bassa qualità',
  283.                         ),
  284.                         array(
  285.                             'id'   => $prefix . 'img_high_res',
  286.                             'type' => 'single_image',
  287.                             'name' => 'Immagine alta qualità',
  288.                             'desc' => 'Carica qui l\'immagine ad alta qualità',
  289.                         ),
  290.                         array(
  291.                             'id'   => $prefix . 'descrizione',
  292.                             'type' => 'textarea',
  293.                             'name' => esc_html__( 'Descrizione birra', 'et-2018-template' ),
  294.                         ),
  295.                         array(
  296.                             'id'          => 'avanzate',
  297.                             'type'        => 'group',
  298.                             'clone'       => true,
  299.                             'collapsible' => true,
  300.                             'save_state'  => true,
  301.                             'group_title' => array( 'field' => 'person' ),
  302.                             'fields'      => array(
  303.                                 array(
  304.                                     'id'      => $prefix . 'formato_birra',
  305.                                     'name'    => 'Formati disponibili',
  306.                                     'type'    => 'radio',
  307.                                     'desc'    => 'Che formati sono disponibili?',
  308.                                     'options' => array(
  309.                                         '33cl'   => '33cl',
  310.                                         '375cl'  => '37.5cl',
  311.                                         '50cl'   => '50cl',
  312.                                         '75cl'   => '75cl',
  313.                                         'magnum' => 'Magnum',
  314.                                         'bgb'    => 'BGB',
  315.                                         'fusto'  => 'Fusto',
  316.                                     ),
  317.                                     'inline'  => 1,
  318.                                 ),
  319.                                 array(
  320.                                     'id'         => $prefix . 'prezzo_birra',
  321.                                     'type'       => 'text',
  322.                                     'name'       => 'Costo birra',
  323.                                     'desc'       => 'A quanto vendiamo quella birra? Senza simboli',
  324.                                     'step'       => '0.1',
  325.                                 ),
  326.                                 array(
  327.                                     'id'         => $prefix . 'annata_birra',
  328.                                     'type'       => 'number',
  329.                                     'name'       => 'Annata birra',
  330.                                     'desc'       => 'Di che annate sono le birre che hai?',
  331.                                 ),
  332. //et2018-quantita_birra is what I would like to show and modify in quick edit
  333.                                 array(
  334.                                     'id'          => $prefix . 'quantita_birra',
  335.                                     'type'        => 'text',
  336.                                     'name'        => 'Quantità birra',
  337.                                     'desc'        => 'Quante ne hai in magazzino o cella?',
  338.                                     'placeholder' => 'Quante ne hai?',
  339.                                     'step'        => '0.1',
  340.                                 ),
  341.                             ),
  342.                         ),
  343.                     ),
  344.                 ),
  345.             ),
  346.         );
  347.  
  348.         return $meta_boxes;
  349.     } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement