'parent', 'id' => 'term_id' ); //TODO: decouple this function start_lvl( &$output, $depth, $args ) { $indent = str_repeat( "\t", $depth ); $output .= "$indent
' . __( 'Manage', 'attachmenttaxsupp' ) . ' ' . $taxonomy->labels->name . '
' . __( 'Manage', 'attachmenttaxsupp' ) . ' ' . $taxonomy->labels->name . '
'; $html .= wp_nonce_field( 'update_attachment', '_wpnonce_attachmenttaxsupp', true, false ); if ( 'async-upload' == $current_screen->id ) { $html .= ''; } $form_fields[$key]['input'] = 'html'; $form_fields[$key]['html'] = $html; } } } return $form_fields; } /** * Save Image Form * * @todo If some checkboxes are checked and you uncheck all on a media page, it doesn't save * * @param object $post Post. * @param object $attachment Attchment. * @return object Post. */ function attachment_fields_to_save( $post, $attachment ) { if ( empty( $_POST ) || !wp_verify_nonce( $_POST['_wpnonce_attachmenttaxsupp'], 'update_attachment' ) ) return $post; if ( isset( $_POST['tax_input'] ) && is_array( $_POST['tax_input'] ) ) { foreach ( $_POST['tax_input'] as $tax => $arr ) { if ( taxonomy_exists( $tax ) ) { $val = null; if ( isset( $arr[$post['ID']] ) ) $val = array_map( 'absint', $arr[$post['ID']] ); wp_set_object_terms( $post['ID'], $val, $tax ); } } } else { $taxes = get_taxonomies( array( 'show_ui' => true, '_builtin' => false ) ); foreach ( $taxes as $tax ) { wp_set_object_terms( $post['ID'], array(), $tax ); } } return $post; } } ?>