Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: attachment_fields_to_save

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
217      if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) {
218           $post = $_post = get_post($attachment_id, ARRAY_A);
219           if ( isset($attachment['post_content']) )
220                $post['post_content'] = $attachment['post_content'];
221           if ( isset($attachment['post_title']) )
222                $post['post_title'] = $attachment['post_title'];
223           if ( isset($attachment['post_excerpt']) )
224                $post['post_excerpt'] = $attachment['post_excerpt'];
225
226           $post = apply_filters('attachment_fields_to_save', $post, $attachment);
227
228           if ( isset($post['errors']) ) {
229                $errors[$attachment_id] = $post['errors'];
230                unset($post['errors']);
231           }
232
233           if ( $post != $_post )
234                wp_update_post($post);
235