I'm attempting my first proper WP plugin, so bear with me. I'm trying to replace the
image_attachment_fields_to_edit function in 2.5, to control the defaults for inserting image uploads in posts.
My first step has been to put this in my plugin to override the default function:
remove_filter('attachment_fields_to_edit', 'image_attachment_fields_to_edit', 10, 2); add_filter('attachment_fields_to_edit', 'slt_image_attachment_fields_to_edit', 10, 2);
Then I've literally copied the whole of the
image_attachment_fields_to_edit function to my new function,
slt_image_attachment_fields_to_edit. I thought I could do this, then just leave essential things as they are, and modify other bits.
The problem is that my modification seem to somehow get "merged" with the default function. For example, if I change
$form_fields['post_excerpt']['helps'] = __('Alternate text, e.g. "The Mona Lisa"');
$form_fields['post_excerpt']['helps'] = __('Alternate text, e.g. "Ceci n'est pas une pipe"');
then both bits of text get output. If I add
$form_fields['post_excerpt']['required'] = true;
then the Caption is marked as required (in the markup at least - I've not got as far as testing its impact on functionality - any hints here appreciated if I'm on the wrong track!). But, if I change
$form_fields['post_title']['required'] = true;
$form_fields['post_title']['required'] = false;
the Title is still marked as required.
Not sure if I'm missing something basic about overriding WP functions with plugins or if I've happened upon a WP peculiarity. Any help appreciated!