Advertisement
Guest User

Meta Box Flex syntax

a guest
Jul 24th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.95 KB | None | 0 0
  1. <?php
  2.  
  3. add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) {
  4.     // Flex and flex-item type.
  5.     $meta_boxes[] = array(
  6.         'title' => 'Meta box flex simple',
  7.         'fields' => array(
  8.             array(
  9.                 'type' => 'flex', // This will define a flex container.
  10.                 'flex' => array(), // Flex attributes.
  11.                 'fields' => array(
  12.                     array(
  13.                         'type' => 'flex-item',
  14.                         'flex' => array(), // Flex attributes.
  15.                         'fields' => array(
  16.                             array(
  17.                                 'type' => 'text',
  18.                                 'id'   => 'field-a',
  19.                                 'title' => 'Field A',
  20.                             ),
  21.                             array(
  22.                                 'type' => 'text',
  23.                                 'id'   => 'field-b',
  24.                                 'title' => 'Field B',
  25.                             ),
  26.                         ),
  27.                     ),
  28.                     array(
  29.                         'type' => 'flex-item',
  30.                         'flex' => array(), // Flex attributes.
  31.                         'fields' => array(
  32.                             array(
  33.                                 'type' => 'text',
  34.                                 'id'   => 'field-c',
  35.                                 'title' => 'Field C',
  36.                             ),
  37.                         ),
  38.                     ),
  39.                 ),
  40.             ),
  41.         ),
  42.     );
  43.  
  44.     $meta_boxes[] = array(
  45.         'title' => 'Meta box flex in a group',
  46.         'fields' => array(
  47.             array(
  48.                 'type' => 'group',
  49.                 'fields' => array(
  50.                     array(
  51.                         'type' => 'flex', // This will define a flex container.
  52.                         'flex' => array(), // Flex attributes.
  53.                         'fields' => array(
  54.                             array(
  55.                                 'type' => 'flex-item',
  56.                                 'flex' => array(), // Flex attributes.
  57.                                 'fields' => array(
  58.                                     array(
  59.                                         'type' => 'text',
  60.                                         'id'   => 'field-a',
  61.                                         'title' => 'Field A',
  62.                                     ),
  63.                                     array(
  64.                                         'type' => 'text',
  65.                                         'id'   => 'field-b',
  66.                                         'title' => 'Field B',
  67.                                     ),
  68.                                 ),
  69.                             ),
  70.                             array(
  71.                                 'type' => 'flex-item',
  72.                                 'flex' => array(), // Flex attributes.
  73.                                 'fields' => array(
  74.                                     array(
  75.                                         'type' => 'text',
  76.                                         'id'   => 'field-c',
  77.                                         'title' => 'Field C',
  78.                                     ),
  79.                                 ),
  80.                             ),
  81.                         ),
  82.                     ),
  83.                 ),
  84.             ),
  85.         ),
  86.     );
  87.  
  88.     return $meta_boxes;
  89. } );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement