From aa1d6ecf84800a0aa2a17da35798ed99ec6a22bb Mon Sep 17 00:00:00 2001 From: Kevin Leary Date: Tue, 19 Feb 2013 12:43:00 -0500 Subject: [PATCH] Add _save method to `attachment` post type actions I've added a metabox to media attachments for a project I'm working on. At first, fields weren't saving. I discovered that the built-in "attachment" post type doesn't use the `save_post` action and instead uses `edit_attachment` and `add_attachment`. This patch fixes the saving issue and allows custom meta boxes to be attached to the `attachment` post type. --- wp-content/wpalchemy/MetaBox.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wp-content/wpalchemy/MetaBox.php b/wp-content/wpalchemy/MetaBox.php index 27bccdb..644fb4b 100755 --- a/wp-content/wpalchemy/MetaBox.php +++ b/wp-content/wpalchemy/MetaBox.php @@ -572,6 +572,10 @@ function _init() } add_action('save_post', array($this,'_save')); + + // Save meta for "attachment" post type + add_action('edit_attachment', array($this,'_save')); + add_action('add_attachment', array($this,'_save')); $filters = array('save', 'head', 'foot'); @@ -2370,4 +2374,4 @@ function clean(&$arr) } } -/* eof */ \ No newline at end of file +/* eof */