Skip to content

Instantly share code, notes, and snippets.

@fitzhaile
Forked from jchristopher/gist:4217475
Created February 12, 2013 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fitzhaile/4772339 to your computer and use it in GitHub Desktop.
Save fitzhaile/4772339 to your computer and use it in GitHub Desktop.
<?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