WordPress Hooks Explorer

Listing all hooks extracted WordPress Core


Details about attachment_fields_to_edit

Back to home

Files

Filename Hook Type Line Number PHP Doc
wp-admin/includes/media.php apply_filters 1497 /**
* Filters the attachment fields to edit.
*
* @since 2.5.0
*
* @param array $form_fields An array of attachment form fields.
* @param WP_Post $post The WP_Post attachment object.
*/
wp-admin/includes/media.php apply_filters 1922 /** This filter is documented in wp-admin/includes/media.php */
$args = apply_filters( 'get_media_item_args', $args );

$form_fields = array();

if ( $args['in_modal'] ) {
foreach ( get_attachment_taxonomies( $post ) as $taxonomy ) {
$t = (array) get_taxonomy( $taxonomy );

if ( ! $t['public'] || ! $t['show_ui'] ) {
continue;
}

if ( empty( $t['label'] ) ) {
$t['label'] = $taxonomy;
}

if ( empty( $t['args'] ) ) {
$t['args'] = array();
}

$terms = get_object_term_cache( $post->ID, $taxonomy );

if ( false === $terms ) {
$terms = wp_get_object_terms( $post->ID, $taxonomy, $t['args'] );
}

$values = array();

foreach ( $terms as $term ) {
$values[] = $term->slug;
}

$t['value'] = implode( ', ', $values );
$t['taxonomy'] = true;

$form_fields[ $taxonomy ] = $t;
}
}

/*
* Merge default fields with their errors, so any key passed with the error
* (e.g. 'error', 'helps', 'value') will replace the default.
* The recursive merge is easily traversed with array casting:
* foreach ( (array) $things as $thing )
*/

Hook Parameters

Parameter Type Name Description
array $form_fields An array of attachment form fields.
WP_Post $post The WP_Post attachment object.
array $form_fields An array of attachment form fields.
WP_Post $post The WP_Post attachment object.