Action and filter hook #1
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As suggested in this thread, I've added a number of action and filter hooks throughout the Attachments code that should make it easier to customise and integrate it with other aspects of a site.
I note with approval that most of the visible strings are already internationalised, meaning they can be changed for a specific site (if for example a client wanted to call them "Documents" rather than "Attachments".
I've been quite generous with the actions, since people might want to put their modifications in different places depending on their unique needs.
Actions
attachments_init- after initialising the pluginattachments_edit_post_types_before- at the start of the settings page (but after the heading)attachments_edit_post_types_after- at the end of the settings page (but before the Save button)attachments_meta_before- at the start of the meta boxattachments_list_before- at the start of the list in the meta box (but after the Attach button, and only if there are attachments to display)attachments_list_item_before- at the start of a single attachment's entry in the meta box (but after the title)attachments_list_item_after- at the end of a single attachment's entry in the meta boxattachments_list_after- at the end of the list in the meta box (but only if there are attachments to display)attachments_meta_after- at the end of the meta boxattachments_save- after saving attachmentsFilters
attachments_post_types- the post type options to display on the settings page[ id => { labels: { name }, name } ]attachments_save_attachment_ids- the ids of attachments to save for a given post (also passes$post_id)[ id ]attachments_save_attachment_details- the attachment data to be serialised (also passes$attachment_idand$post_id)[ id, title, caption, order ]attachments_get_filesize_formatted- the formatted file size for a given attachment (also passes$path)stringattachments_get_attachments- the list of attachments for the given post[ [ id, name, mime, title, caption, filesize, location, order ] ]