Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: added_postmeta

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
1161      foreach ( (array) $post_links as $url ) {
1162           if ( $url != '' && !$wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, $url . '%' ) ) ) {
1163                if ( $headers = wp_get_http_headers( $url) ) {
1164                     $len = (int) $headers['content-length'];
1165                     $type = $headers['content-type'];
1166                     $allowed_types = array( 'video', 'audio' );
1167                     if ( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) {
1168                          $meta_value = "$url\n$len\n$type\n";
1169                          $wpdb->insert($wpdb->postmeta, array('post_id' => $post_ID, 'meta_key' => 'enclosure', 'meta_value' => $meta_value) );
1170                          do_action( 'added_postmeta', $wpdb->insert_id, $post_ID, 'enclosure', $meta_value );
1171                     }
1172                }
1173           }
1174      }
1175 }
1176
1177 /**
1178  * Perform a HTTP HEAD or GET request.
1179  *