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
230                $image_alt = get_post_meta( $post_ID, '_wp_attachment_image_alt', true );
231                if ( $image_alt != stripslashes( $post_data['_wp_attachment_image_alt'] ) ) {
232                     $image_alt = wp_strip_all_tags( stripslashes( $post_data['_wp_attachment_image_alt'] ), true );
233                     // update_meta expects slashed
234                     update_post_meta( $post_ID, '_wp_attachment_image_alt', addslashes( $image_alt ) );
235                }
236           }
237
238           $attachment_data = isset( $post_data['attachments'][ $post_ID ] ) ? $post_data['attachments'][ $post_ID ] : array();
239           $post_data = apply_filters( 'attachment_fields_to_save', $post_data, $attachment_data );
240      }
241
242      add_meta( $post_ID );
243
244      update_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );
245
246      wp_update_post( $post_data );
247
248      // Now that we have an ID we can fix any attachment anchor hrefs