Snippets
Created by
Joey Hernandez
last modified
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | <?php
/**
* Custom Metaboxes | Template/Object Type
*/
class ProjectPrefix_Metadata_Team {
static $instance = false;
public function __construct() {
$this->_add_actions();
}
public function projectprefix_team_metaboxes() {
// Start with an underscore to hide fields from custom fields list
$prefix = '_projectprefix_';
/**
* Initiate the metabox
*/
$cmb = new_cmb2_box( array(
'id' => 'team',
'title' => __( 'Team Member Options', 'projectprefix' ),
'object_types' => array( 'team', ), // Post type
'context' => 'advanced',
'priority' => 'high',
'show_names' => true, // Show field names on the left
'closed' => false,
) );
$cmb->add_field( array(
'name' => __( 'Title', 'cmb2' ),
'id' => $prefix . 'title',
'type' => 'text',
) );
$cmb->add_field( array(
'name' => __( 'Google+ URL', 'cmb2' ),
'id' => $prefix . 'googleplus_url',
'type' => 'text_url',
) );
$cmb->add_field( array(
'name' => __( 'Facebook URL', 'cmb2' ),
'id' => $prefix . 'facebook_url',
'type' => 'text_url',
) );
$cmb->add_field( array(
'name' => __( 'Twitter URL', 'cmb2' ),
'id' => $prefix . 'twitter_url',
'type' => 'text_url',
) );
$cmb->add_field( array(
'name' => __( 'Instagram URL', 'cmb2' ),
'id' => $prefix . 'instagram_url',
'type' => 'text_url',
) );
$cmb->add_field( array(
'name' => __( 'LinkedIn URL', 'cmb2' ),
'id' => $prefix . 'linkedin_url',
'type' => 'text_url',
) );
$cmb->add_field( array(
'name' => 'Order',
'id' => $prefix . 'order',
'type' => 'text',
'default' => 0,
'column' => array(
'position' => 2,
'name' => 'Order',
),
'desc' => 'Use multiples of 5.',
) );
}
/**
* Singleton
*
* Returns a single instance of the current class.
*/
public static function singleton() {
if ( ! self::$instance )
self::$instance = new self;
return self::$instance;
}
/**
* Add Actions
*
* Defines all the WordPress actions and filters used by this class.
*/
protected function _add_actions() {
add_action( 'cmb2_admin_init', array( $this, 'projectprefix_team_metaboxes' ) );
}
}
|
Comments (0)
You can clone a snippet to your computer for local editing. Learn more.