Last active
August 29, 2015 14:01
-
-
Save RadGH/c4b3a2d43a36b9b2ac97 to your computer and use it in GitHub Desktop.
Quick matadata group and field declaration for the Custom Metadata Manager plugin.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Format: | |
array( | |
group_key => ( | |
post_type = TYPES, | |
args = ARGS, | |
fields = FIELDS, | |
), | |
group_key => ... | |
) | |
Groups and fields are structured automatically. | |
*/ | |
$custom_fields = array( | |
'download-meta' => array( | |
'post_type' => 'download', | |
'args' => array('label' => 'Download Information'), | |
'fields' => array( | |
'file' => array( | |
'label' => 'Downloadable File:', | |
'field_type' => 'upload', | |
), | |
'filename' => array( | |
'label' => 'Filename (Required, include extension):', | |
'field_type' => 'text', | |
), | |
), | |
), | |
'download-reqs' => array( | |
'post_type' => 'download', | |
'args' => array('label' => 'Download Requirements'), | |
'fields' => array( | |
'allow_anon' => array( | |
'label' => 'Allow anonymous/guest downloads', | |
'field_type' => 'checkbox', | |
), | |
), | |
), | |
); | |
foreach( $custom_fields as $group_id => $group ) { | |
x_add_metadata_group( $group_id, $group['post_type'], $group['args'] ); | |
foreach( $group['fields'] as $key => $field ) { | |
$field['group'] = $group_id; | |
x_add_metadata_field( $key, $group['post_type'], $field ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment