Guest User

MetaBox

a guest
Sep 12th, 2019
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.24 KB | None | 0 0
  1. add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
  2.  
  3. function your_prefix_register_meta_boxes( $meta_boxes ) {
  4.     $prefix = '';
  5.  
  6.     $meta_boxes[] = array (
  7.         'title' => esc_html__( 'Document Options', 'text-domain' ),
  8.         'id' => 'document-options',
  9.         'post_types' => array(
  10.             0 => 'document',
  11.         ),
  12.         'context' => 'normal',
  13.         'priority' => 'high',
  14.         'validation' => array (
  15.             'rules'  => array(
  16.                 'file_upload_x3h8w2hgtqg' => array(
  17.                     'extension' => "pdf",
  18.                     // More rules here
  19.                 ),
  20.                 // Rules for other fields
  21.             ),
  22.         ),
  23.         'fields' => array(
  24.             array (
  25.                 'id' => $prefix . 'wysiwyg_rv3nfg4gl9',
  26.                 'name' => esc_html__( 'Description of Document Set', 'text-domain' ),
  27.                 'type' => 'wysiwyg',
  28.                 'options' => array(
  29.                     'media_buttons' => false,
  30.                 ),
  31.             ),
  32.             array (
  33.                 'id' => $prefix . 'file_upload_x3h8w2hgtqg',
  34.                 'type' => 'file_upload',
  35.                 'name' => esc_html__( 'File upload', 'text-domain' ),
  36.                 'max_status' => 1,
  37.                 'force_delete' => 1,
  38.             ),
  39.             array (
  40.                 'id' => $prefix . 'user_c33ln3ltujc',
  41.                 'type' => 'user',
  42.                 'name' => esc_html__( 'User', 'text-domain' ),
  43.                 'field_type' => 'select_advanced',
  44.                 'multiple' => true,
  45.             ),
  46.         ),
  47.     );
  48.  
  49.     return $meta_boxes;
  50. }
Add Comment
Please, Sign In to add comment