Advertisement
Guest User

Untitled

a guest
Dec 19th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.74 KB | None | 0 0
  1. $prefix = '_sitename_';
  2.  
  3.     $year_select_array = array();
  4.     for ($i=date('Y')+1; $i >= 1900 ; $i--) {
  5.         $year_select_array[$i] = $i;
  6.     }
  7.  
  8.     $default_text_field_columns = 200; //the max width will fix it if it's too big
  9.  
  10.     $meta_boxes[] = array(
  11.         'id'         => 'reference-citation',
  12.         'title'      => 'Citation',
  13.         'post_types' => 'reference',
  14.         'context'    => 'after_editor',
  15.         'priority'   => 'high',
  16.  
  17.         'fields' => array(
  18.             array(
  19.                 'name'            => 'Publication Type',
  20.                 'id'              => $prefix . 'publication_type',
  21.                 'type'            => 'select',
  22.                 // Array of 'value' => 'Label' pairs
  23.                 'options' => array(
  24.                     'article' => 'Article',
  25.                     'book' => 'Book',
  26.                     'book-chapter' => 'Book Chapter',
  27.                     'presentation' => 'Presentation',
  28.                 ),
  29.                 // Placeholder text
  30.                 'std' => 'article',
  31.             ),
  32.             array(
  33.                 'name' => 'Title',
  34.                 'id'   => $prefix . 'article_title',
  35.                 'type' => 'text',
  36.                 'size' =>  $default_text_field_columns,
  37.                 'desc' => 'Add article, chapter or presentation title',
  38.                 'visible'  => array(
  39.                     'when' => array(
  40.                         array( $prefix . 'publication_type', '=', 'article'),
  41.                         array( $prefix . 'publication_type', '=', 'book-chapter'),
  42.                         array( $prefix . 'publication_type', '=', 'presentation')
  43.                      ),
  44.                     'relation' => 'or'
  45.                 )
  46.             ),
  47.             array(
  48.                 'name' => 'Publication Title',// Book title, or Journal title
  49.                 'desc' => 'Add journal or book title',
  50.                 'id'   => $prefix . 'publication_title',
  51.                 'type' => 'text',
  52.                 'size' =>  $default_text_field_columns,
  53.                 'visible' => array(
  54.                     'when' => array(
  55.                         array( $prefix . 'publication_type', '=', 'article'),  
  56.                         array( $prefix . 'publication_type', '=', 'book'),
  57.                         array( $prefix . 'publication_type', '=', 'book-chapter'),
  58.                     ),
  59.                     'relation' => 'or'
  60.                 )
  61.             ),
  62.             array(
  63.                 'name' => 'Author(s)',
  64.                 'id'   => $prefix . 'author',
  65.                 'type' => 'text',
  66.                 'size' =>  $default_text_field_columns
  67.             ),
  68.    
  69.             array(
  70.                 'id'   => $prefix . 'editor',
  71.                 'type' => 'text', // New HTML 5 input type
  72.                 'name' => 'Editors(s)',
  73.                 'size' =>  $default_text_field_columns,
  74.                 'visible' =>  array( $prefix . 'publication_type', '=', 'book-chapter'),
  75.             ),
  76.             array(
  77.                 'id'   => $prefix . 'publisher',
  78.                 'type' => 'text', // New HTML 5 input type
  79.                 'name' => 'Publisher',
  80.                 'size' =>  $default_text_field_columns,
  81.                 'visible' => array(
  82.                     'when' => array(  
  83.                         array( $prefix . 'publication_type', '=', 'book'),
  84.                         array( $prefix . 'publication_type', '=', 'book-chapter'),
  85.                     ),
  86.                     'relation' => 'or'
  87.                 )
  88.             ),
  89.             array(
  90.                 'name' => 'Publication City',
  91.                 'desc' => 'Add the city where the publisher is based or where the presentation took place',
  92.                 'id'   => $prefix . 'publication_city',
  93.                 'type' => 'text',
  94.                 'size' =>  $default_text_field_columns,
  95.                 'visible' => array(
  96.                     'when' => array(  
  97.                         array( $prefix . 'publication_type', '=', 'book'),
  98.                         array( $prefix . 'publication_type', '=', 'book-chapter'),
  99.                         array( $prefix . 'publication_type', '=', 'presentation'),
  100.                     ),
  101.                     'relation' => 'or'
  102.                 )
  103.             ),
  104.             array(
  105.                 'id'   => $prefix . 'volume_issue_number',
  106.                 'type' => 'fieldset_text', // New HTML 5 input type
  107.                 'name' => 'Volume(Issue)',
  108.                 'class' => 'volume-issue-fieldset',
  109.                 'options' => array(
  110.                     'volume'    => 'Volume',
  111.                     'issue' => 'Issue',
  112.                 ),
  113.                 'visible' => array($prefix . 'publication_type', '=', 'article'),
  114.             ),
  115.             array(
  116.                 'id'   => $prefix . 'page_number',
  117.                 'type' => 'text', // New HTML 5 input type
  118.                 'name' => 'Page Number(s)',
  119.                 'size' =>  $default_text_field_columns,
  120.                 'visible' => array(
  121.                     'when' => array(  
  122.                         array( $prefix . 'publication_type', '=', 'article'),
  123.                         array( $prefix . 'publication_type', '=', 'book-chapter'),
  124.                     ),
  125.                     'relation' => 'or'
  126.                 )
  127.             ),
  128.             array(
  129.                 'name'            => 'Publication year',
  130.                 'id'              => $prefix . 'publication_year',
  131.                 'type'            => 'select',
  132.                 // Array of 'value' => 'Label' pairs
  133.                 'options' => $year_select_array,
  134.                 // Placeholder text
  135.                 'placeholder'     => 'Select a year',
  136.             ),
  137.         )
  138.     );
  139.  
  140. return $meta_boxes;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement