Advertisement
selectiveform

Custom Metaboxes

Jun 30th, 2014
478
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.67 KB | None | 0 0
  1.     /**
  2.      * Repeatable Field Groups
  3.      */
  4.     $meta_boxes['field_group'] = array(
  5.         'id'         => 'field_group',
  6.         'title'      => __( 'Details', 'cmb' ),
  7.         'pages'      => array( 'post', ),
  8.         'fields'     => array(
  9.             array(
  10.                 'id'          => $prefix . 'repeat_group',
  11.                 'type'        => 'group',
  12.                 'description' => __( 'What are included in this service', 'cmb' ),
  13.                 'options'     => array(
  14.                     'group_title'   => __( 'Entry {#}', 'cmb' ), // {#} gets replaced by row number
  15.                     'add_button'    => __( 'Add Another Entry', 'cmb' ),
  16.                     'remove_button' => __( 'Remove Entry', 'cmb' ),
  17.                     'sortable'      => true, // beta
  18.                 ),
  19.                 // Fields array works the same, except id's only need to be unique for this group. Prefix is not needed.
  20.                 'fields'      => array(
  21.                     array(
  22.                         'name' => 'Description',
  23.                         'description' => 'Write a short description for this entry',
  24.                         'id'   => 'description',
  25.                         'type' => 'textarea_small',
  26.                     ),
  27.                 ),
  28.             ),
  29.         ),
  30.     );
  31.     /**
  32.      * Pricing metabox
  33.      */
  34.     $meta_boxes['test_metabox'] = array(
  35.         'id'         => 'test_metabox',
  36.         'title'      => __( 'Pricing', 'cmb' ),
  37.         'pages'      => array( 'post', ), // Post type
  38.         'context'    => 'normal',
  39.         'priority'   => 'high',
  40.         'show_names' => true, // Show field names on the left
  41.         // 'cmb_styles' => true, // Enqueue the CMB stylesheet on the frontend
  42.         'fields'     => array(
  43.             array(
  44.                 'name' => __( 'Quote', 'cmb' ),
  45.                 'desc' => __( 'field description (optional)', 'cmb' ),
  46.                 'id'   => $prefix . 'test_textmoney',
  47.                 'type' => 'text_money',
  48.                 // 'before'     => '£', // override '$' symbol if needed
  49.                 // 'repeatable' => true,
  50.             ),
  51.         ),
  52.     );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement