是的,这可能和以前一样。我不知道你为什么认为过滤器不再传递参数了。
add_filter(\'attachment_fields_to_edit\', \'user16975_edit_fields\', 10, 2);
function user16975_edit_fields($form_fields, $attachment){
// check for an audio attachment
if ( substr($attachment->post_mime_type, 0, 5) == \'audio\' ) {
$playertag = $playertag = "[audio ".wp_get_attachment_url($attachment->ID)."]";
$form_fields["audioplayer"] = array(
"label" => "Audio player",
"input" => "html",
"html" => "<button type=\'button\' class=\'button\' data-link-url=\'$playertag\' audioplayer=\'audio-player-{$attachment->ID}\'>Audio Player</button>",
);
}
return $form_fields;
}
结果如下: