Last active
October 13, 2015 15:37
-
-
Save jchristopher/4217475 to your computer and use it in GitHub Desktop.
Attachments - New Instance
This file contains hidden or 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 | |
function my_attachments( $attachments ) | |
{ | |
$args = array( | |
// title of the meta box (string) | |
'label' => 'My Attachments', | |
// all post types to utilize (string|array) | |
'post_type' => array( 'post', 'page' ), | |
// allowed file type(s) (array) (image|video|text|audio|application) | |
'filetype' => null, // no filetype limit | |
// include a note within the meta box (string) | |
'note' => 'Attach files here!', | |
// text for 'Attach' button in meta box (string) | |
'button_text' => __( 'Attach Files', 'attachments' ), | |
// text for modal 'Attach' button (string) | |
'modal_text' => __( 'Attach', 'attachments' ), | |
/** | |
* Fields for the instance are stored in an array. Each field consists of | |
* an array with three keys: name, type, label. | |
* | |
* name - (string) The field name used. No special characters. | |
* type - (string) The registered field type. | |
* Fields available: text, textarea | |
* label - (string) The label displayed for the field. | |
*/ | |
'fields' => array( | |
array( | |
'name' => 'title', // unique field name | |
'type' => 'text', // registered field type | |
'label' => __( 'Title', 'attachments' ), // label to display | |
), | |
array( | |
'name' => 'caption', // unique field name | |
'type' => 'textarea', // registered field type | |
'label' => __( 'Caption', 'attachments' ), // label to display | |
), | |
array( | |
'name' => 'copyright', // unique field name | |
'type' => 'text', // registered field type | |
'label' => __( 'Copyright', 'attachments' ), // label to display | |
), | |
), | |
); | |
$attachments->register( 'my_attachments', $args ); // unique instance name | |
} | |
add_action( 'attachments_register', 'my_attachments' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment