Guest User

Untitled

a guest
Sep 15th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.07 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__( 'Campos de filtración', 'text-domain' ),
  18.         'id' => 'campos-de-filtracion',
  19.         'post_types' => array(
  20.             0 => 'noticias',
  21.             1 => 'articulos',
  22.             2 => 'cuentos',
  23.             3 => 'estudios',
  24.             4 => 'regalos',
  25.             5 => 'encuestas',
  26.             6 => 'ejercicios-web',
  27.             7 => 'podcasts',
  28.             8 => 'webcasts',
  29.             9 => 'seminarios-web',
  30.             10 => 'reciclados',
  31.         ),
  32.         'context' => 'normal',
  33.         'priority' => 'high',
  34.         'fields' => array(
  35.             array (
  36.                 'id' => $prefix . 'text_sfzlrrqoz5d',
  37.                 'type' => 'text',
  38.                 'name' => esc_html__( 'Tipo de publicación', 'text-domain' ),
  39.                 'required' => 1,
  40.                 'std' => $post_type,
  41.             ),
  42.             array (
  43.                 'id' => $prefix . 'date_1cpjomreww5',
  44.                 'type' => 'date',
  45.                 'name' => esc_html__( 'Fecha de publicación', 'text-domain' ),
  46.                 'required' => 1,
  47.                 'std' => $post_date,
  48.             ),
  49.             array (
  50.                 'id' => $prefix . 'user_75nelpiq4a',
  51.                 'type' => 'user',
  52.                 'name' => esc_html__( 'Autor de la publicación', 'text-domain' ),
  53.                 'field_type' => 'select_advanced',
  54.                 'multiple' => true,
  55.                 'required' => 1,
  56.                 'std' => $post_author
  57.             ),
  58.         ),
  59.     );
  60.  
  61.     return $meta_boxes;
  62. }
Add Comment
Please, Sign In to add comment