Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: wp_insert_attachment_data

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
4522      /**
4523       * Filter attachment post data before it is updated in or added
4524       * to the database.
4525       *
4526       * @since 3.9.0
4527       *
4528       * @param array $data   Array of sanitized attachment post data.
4529       * @param array $object Array of un-sanitized attachment post data.
4530       */
4531      $data = apply_filters( 'wp_insert_attachment_data', $data, $object );
4532      $data = wp_unslash( $data );
4533
4534      if ( $update ) {
4535           $wpdb->update( $wpdb->posts, $data, array( 'ID' => $post_ID ) );
4536      } else {
4537           // If there is a suggested ID, use it if not already present
4538           if ( !empty($import_id) ) {
4539                $import_id = (int) $import_id;
4540                if ( ! $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE ID = %d", $import_id) ) ) {