Advertisement
marjwyatt

cmb2 metaboxes

Jun 6th, 2016
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.89 KB | None | 0 0
  1. <?php
  2. /**
  3.  * CPT Metaboxes
  4.  *
  5.  * This file registers any custom metaboxes
  6.  *
  7.  *
  8.  * @package      All Themes Core Functionality Plugin
  9.  * @since        1.0.0
  10.  * @author       Marj Wyatt aka Virtually Marj <marj@virtuallymarj.com>
  11.  * @copyright    Copyright (c) 2013, Virtually Marj
  12.  * @license  http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)
  13.  * @link     https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress
  14.  */
  15.  
  16. /**
  17.  * Create Metaboxes
  18.  */
  19.  
  20. function vm_metaboxes( $meta_boxes ) {
  21.     // Start with an underscore to hide fields from custom fields list
  22.     $prefix = '_vm_';
  23.  
  24.     $meta_boxes[] = array(
  25.         'id' => 'page-options',
  26.         'title' => 'Page Options',
  27.         'pages' => array('page'),
  28.         'context' => 'normal',
  29.         'priority' => 'high',
  30.         'show_names' => true,
  31.         'fields' => array(
  32.             array(
  33.                 'name' => 'Subtitle',
  34.                 'desc' => '',
  35.                 'id' => 'vm_page_subtitle2',
  36.                 'type' => 'text'
  37.             ),
  38.         ),
  39.     );
  40.    
  41.     $meta_boxes[] = array(
  42.         'id'         => 'portfolio-details',
  43.         'title'      => 'Project Details Box',
  44.         'pages'      => array( 'post'), // Post type
  45.         'context'    => 'normal',
  46.         'priority'   => 'high',
  47.         'show_names' => true, // Show field names on the left
  48.         'fields'     => array(
  49.             array(
  50.                 'name' => 'MP3 File',
  51.                 'desc' => 'Upload your Audio File',
  52.                 'id'   => $prefix . 'postMP3',
  53.                 'type' => 'file',
  54.             ),
  55.             array(
  56.                 'name' => 'Project Thumbnail',
  57.                 'desc' => 'Upload an image to go along with your song',
  58.                 'id'   => $prefix . 'postThumb',
  59.                 'type' => 'file',
  60.             ),
  61.         ),
  62.     );
  63.  
  64.     $meta_boxes[] = array(
  65.         'id'         => 'post-optin',
  66.         'title'      => 'Post Optin Widget',
  67.         'pages'      => array( 'post', 'page'), // Post type
  68.         'context'    => 'normal',
  69.         'priority'   => 'high',
  70.         'show_names' => true, // Show field names on the left
  71.         'fields'     => array(
  72.             array(
  73.                 'name' => 'Optin Code',
  74.                 'desc' => 'Enter script or HTML for your Form',
  75.                 'id'   => $prefix . 'postOptin',
  76.                 'type' => 'textarea_code',
  77.             ),
  78.         ),
  79.     );
  80.  
  81.     $meta_boxes[] = array(
  82.         'id'         => 'project-details',
  83.         'title'      => 'Project Details Box',
  84.         'pages'      => array( 'portfolio'), // Post type
  85.         'context'    => 'normal',
  86.         'priority'   => 'high',
  87.         'show_names' => true, // Show field names on the left
  88.         'fields'     => array(
  89.             array(
  90.                 'name'     => 'Genre Select',
  91.                 'desc'     => 'Choose One Category',
  92.                 'id'       => $prefix . 'projectTaxonomy',
  93.                 'type'     => 'taxonomy_select',
  94.                 'taxonomy' => 'website-type', // Taxonomy Slug
  95.             ),
  96.             array(
  97.                 'name' => 'MP3 File',
  98.                 'desc' => 'Upload your Audio File',
  99.                 'id'   => $prefix . 'projectMP3',
  100.                 'type' => 'file',
  101.             ),
  102.             array(
  103.                 'name' => 'Project Thumbnail',
  104.                 'desc' => 'Upload an image to go along with your song',
  105.                 'id'   => $prefix . 'projectThumb',
  106.                 'type' => 'file',
  107.             ),
  108.             array(
  109.                 'name'    => 'Other Contributors',
  110.                 'desc'    => 'List backup vocalists and/or band members',
  111.                 'id'      => $prefix . 'projectContributors',
  112.                 'type'    => 'wysiwyg',
  113.                 'options' => array(
  114.                     'textarea_rows' => 5,
  115.                     'wpautop' => true, // use wpautop?
  116.                     'teeny' => true, // output the minimal editor config used in Press This
  117.                     'tinymce' => true, // load TinyMCE, can be used to pass settings directly to TinyMCE using an array()
  118.                     'media_buttons' => false, ),
  119.             ),
  120.             array(
  121.                 'name' => 'Artist Name',
  122.                 'desc' => 'Name of Primary Artist',
  123.                 'id'   => $prefix . 'projectArtist',
  124.                 'type' => 'text',
  125.             ),
  126.             array(
  127.                 'name' => 'Album Name',
  128.                 'desc' => 'Enter name of Album if any',
  129.                 'id'   => $prefix . 'projectAlbum',
  130.                 'type' => 'text',
  131.             ),
  132.             array(
  133.                 'name' => 'Test Text Small',
  134.                 'desc' => 'field description (optional)',
  135.                 'id'   => $prefix . 'projectTextSmall',
  136.                 'type' => 'text_small',
  137.             ),
  138.             array(
  139.                 'name' => 'oEmbed',
  140.                 'desc' => 'Enter a youtube, twitter, or instagram URL. Supports services listed at <a href="http://codex.wordpress.org/Embeds">http://codex.wordpress.org/Embeds</a>.',
  141.                 'id'   => $prefix . 'projectEmbed',
  142.                 'type' => 'oembed',
  143.             ),
  144.  
  145.         ),
  146.     );
  147.     return $meta_boxes;
  148. }
  149. //add_filter( 'cmb2_meta_boxes' , 'vm_metaboxes' );
  150. add_action( 'cmb2_admin_init', 'vm_metaboxes' );
  151.  
  152. /**
  153.  * Initialize Metabox Class
  154.  * @since 1.0.0
  155.  * see /lib/metabox/example-functions.php for more information
  156.  *
  157.  */
  158.  
  159. function vm_initialize_cmb2_meta_boxes() {
  160.     /*if ( !class_exists( 'cmb_Meta_Box' ) ) {
  161.         require_once( VM_DIR . '/lib/cmb2-metabox/init.php' );
  162.     }*/
  163.  if ( file_exists(  __DIR__ . '/cmb2-metabox/init.php' ) ) {
  164.   require_once  __DIR__ . '/cmb2-metabox/init.php';
  165. } elseif ( file_exists(  __DIR__ . '/CMB2/init.php' ) ) {
  166.   require_once  __DIR__ . '/CMB2/init.php';
  167. }
  168. }
  169. add_action( 'init', 'vm_initialize_cmb2_meta_boxes', 9999 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement