]*?href=([\'"])(.+?)\1/is', $the_content, $matches ) ) return esc_url_raw( $matches[1] ); return ''; } endif; // if ( ! function_exists( 'wpcom_themes_url_grabber' ) ) /** * Return the first audio file found for a post. * * @param int $post_id ID for parent post. * @return WP_Post The audio attachment object. */ function skeptical_audio_grabber( $post_id ) { if ( function_exists( 'get_attached_media' ) ) { $media = get_attached_media( 'audio', $post_id ); return array_shift( $media ); } $audios = get_children( array( 'post_parent' => $post_id, 'post_type' => 'attachment', 'post_mime_type' => 'audio', 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC', ) ); $audios = (array) apply_filters( 'get_attached_media', $audios, 'audio', get_post( $post_id ) ); return array_shift( $audios ); }