Action and filter hook#1
Closed
marcus-downing wants to merge 7 commits into
Closed
Conversation
Owner
|
Fantastic, this is great! I've got some time blocked out in June to spend on all of my plugins, this will be near the top of my to-do list. In the meantime anybody can feel free to pull and test on their end as well. Thanks again! |
Owner
|
Hey Marcus, this is so great but I must admit I forgot to merge this pull request when I updated Attachments to version 3.0. I'm going to put these back in by hand, but unfortunately won't be able to get to it for a couple weeks. I've got a task on the roadmap for version 3 to add in actions/filters as well. |
Owner
|
Hi Marcus. I'm actually going to close this since its for the deprecated version, but I'm working on adding all of your work to the 3.0 branch and will be sure to give you props. Thanks again! |
stevensjn
pushed a commit
to stevensjn/attachments
that referenced
this pull request
Apr 24, 2023
Merge from origin repo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 ] ]