Advertisement
longnguyenwp

Clone default value

Apr 14th, 2020
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.00 KB | None | 0 0
  1. <?php
  2. add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
  3.  
  4. function your_prefix_register_meta_boxes( $meta_boxes ) {
  5.     $prefix = '';
  6.  
  7.     $meta_boxes[] = array (
  8.         'title' => esc_html__( 'Group', 'text-domain' ),
  9.         'id' => 'group',
  10.         'post_types' => array(
  11.             0 => 'post',
  12.         ),
  13.         'context' => 'normal',
  14.         'priority' => 'high',
  15.         'fields' => array(
  16.             array (
  17.                 'id' => $prefix . 'group',
  18.                 'type' => 'group',
  19.                 'name' => esc_html__( 'Group', 'text-domain' ),
  20.                 'fields' => array(
  21.                     array (
  22.                         'id' => $prefix . 'radio',
  23.                         'name' => esc_html__( 'Radio', 'text-domain' ),
  24.                         'type' => 'radio',
  25.                         'std' => 'home',
  26.                         'options' => array(
  27.                             'organisation_this' => esc_html__( 'This organisation', 'text-domain' ),
  28.                             'organisation_other' => esc_html__( 'Other organisation', 'text-domain' ),
  29.                             'home' => esc_html__( 'Home address', 'text-domain' ),
  30.                         ),
  31.                         'clone' => 1,
  32.                         'clone_default' => 1,
  33.                     ),
  34.                     array (
  35.                         'id' => $prefix . 'text',
  36.                         'type' => 'text',
  37.                         'name' => esc_html__( 'Text Field', 'text-domain' ),
  38.                         'std' => 'Default text',
  39.                         'clone_default' => 1,
  40.                     ),
  41.                     array (
  42.                         'id' => $prefix . 'checkbox',
  43.                         'name' => esc_html__( 'Checkbox', 'text-domain' ),
  44.                         'type' => 'checkbox',
  45.                         'desc' => esc_html__( 'Default Description', 'text-domain' ),
  46.                         'std' => 1,
  47.                     ),
  48.                     array (
  49.                         'id' => $prefix . 'checkbox',
  50.                         'name' => esc_html__( 'Checkbox List', 'text-domain' ),
  51.                         'type' => 'checkbox_list',
  52.                         'std' => 3,
  53.                         'options' => array(
  54.                             1 => esc_html__( '1', 'text-domain' ),
  55.                             2 => esc_html__( '2', 'text-domain' ),
  56.                             3 => esc_html__( '3', 'text-domain' ),
  57.                         ),
  58.                         'clone' => 1,
  59.                         'inline' => 1,
  60.                         'clone_default' => 1,
  61.                     ),
  62.                     array (
  63.                         'id' => $prefix . 'select',
  64.                         'name' => esc_html__( 'Select Field', 'text-domain' ),
  65.                         'type' => 'select',
  66.                         'std' => 2,
  67.                         'placeholder' => esc_html__( 'Select an Item', 'text-domain' ),
  68.                         'options' => array(
  69.                             1 => esc_html__( '1', 'text-domain' ),
  70.                             2 => esc_html__( '2', 'text-domain' ),
  71.                             3 => esc_html__( '3', 'text-domain' ),
  72.                             4 => esc_html__( '4', 'text-domain' ),
  73.                         ),
  74.                         'clone' => 1,
  75.                         'clone_default' => 1,
  76.                     ),
  77.                     array (
  78.                         'id' => $prefix . 'select_advanced',
  79.                         'name' => esc_html__( 'Select Advanced', 'text-domain' ),
  80.                         'type' => 'select_advanced',
  81.                         'std' => 'c',
  82.                         'placeholder' => esc_html__( 'Select an Item', 'text-domain' ),
  83.                         'options' => array(
  84.                             'a' => esc_html__( 'A', 'text-domain' ),
  85.                             'b' => esc_html__( 'B', 'text-domain' ),
  86.                             'c' => esc_html__( 'C', 'text-domain' ),
  87.                             'd' => esc_html__( 'D', 'text-domain' ),
  88.                         ),
  89.                         'clone' => 1,
  90.                         'clone_default' => 1,
  91.                     ),
  92.                 ),
  93.                 'clone' => 1,
  94.                 'default_state' => 'expanded',
  95.                 'clone_default' => 1,
  96.                 'collapsible' => true,
  97.             ),
  98.         ),
  99.     );
  100.  
  101.     return $meta_boxes;
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement