Guest User

Untitled

a guest
Sep 15th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.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.     $post_type = $post_author = $post_date = '';
  6.     $post_id   = isset( $_GET['post'] ) ? (int) $_GET['post'] : null;
  7.     if ( $post_id ) {
  8.         $post        = get_post( $post_id );
  9.         $post_type   = $post->post_type;
  10.         $post_author = $post->post_author;
  11.         $post_date   = date( 'Y-m-d', strtotime( $post->post_date ) );
  12.     }
  13.  
  14.     $prefix = '';
  15.  
  16.     $meta_boxes[] = array (
  17.         'title' => esc_html__( 'Filtración', 'text-domain' ),
  18.         'id' => 'filtracion',
  19.         'post_types' => array(
  20.             0 => 'articulo',
  21.             1 => 'noticia',
  22.             2 => 'para-empresa',
  23.         ),
  24.         'context' => 'normal',
  25.         'priority' => 'high',
  26.         'fields' => array(
  27.             array (
  28.                 'id' => $prefix . 'text_63oz10nwock',
  29.                 'type' => 'text',
  30.                 'name' => esc_html__( 'Post type', 'text-domain' ),
  31.                 'desc' => esc_html__( 'Current post type.', 'text-domain' ),
  32.                 'required' => 1,
  33.                 'std' => $post_type,
  34.             ),
  35.             array (
  36.                 'id' => $prefix . 'author_hva4qxl9l8',
  37.                 'type' => 'user',
  38.                 'name' => esc_html__( 'Post author', 'text-domain' ),
  39.                 'desc' => esc_html__( 'Current post author.', 'text-domain' ),
  40.                 'field_type' => 'select_advanced',
  41.                 'required' => 1,
  42.                 'multiple' => true,
  43.                 'std' => $post_author,
  44.             ),
  45.             array (
  46.                 'id' => $prefix . 'date_mgw46wuomoh',
  47.                 'type' => 'date',
  48.                 'name' => esc_html__( 'Post Date', 'text-domain' ),
  49.                 'desc' => esc_html__( 'Current post date.', 'text-domain' ),
  50.                 'required' => 1,
  51.                 'std' => $post_date,
  52.             ),
  53.         ),
  54.     );
  55.  
  56.     return $meta_boxes;
  57. }
Add Comment
Please, Sign In to add comment