wp_get_http_headers example


    $post_links = apply_filters( 'enclosure_links', $post_links$post->ID );

    foreach ( (array) $post_links as $url ) {
        $url = strip_fragment_from_url( $url );

        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, $wpdb->esc_like( $url ) . '%' ) ) ) {

            $headers = wp_get_http_headers( $url );
            if ( $headers ) {
                $len           = isset( $headers['Content-Length'] ) ? (int) $headers['Content-Length'] : 0;
                $type          = isset( $headers['Content-Type'] ) ? $headers['Content-Type'] : '';
                $allowed_types = array( 'video', 'audio' );

                // Check to see if we can figure out the mime type from the extension.                 $url_parts = parse_url( $url );
                if ( false !== $url_parts && ! empty( $url_parts['path'] ) ) {
                    $extension = pathinfo( $url_parts['path'], PATHINFO_EXTENSION );
                    if ( ! empty( $extension ) ) {
                        foreach ( wp_get_mime_types() as $exts => $mime ) {
                            
Home | Imprint | This part of the site doesn't use cookies.