From f3ba249747ec6e5d352f76677b78a746339edc12 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Wed, 9 Nov 2011 19:20:33 +0000 Subject: [PATCH] Check post type and bail earlier in wp_get_attachment_url(). props mitchoyoshitaka, fixes #17579. git-svn-id: https://develop.svn.wordpress.org/trunk@19231 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/post.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 3e65634015..24370d8150 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -3890,6 +3890,9 @@ function wp_get_attachment_url( $post_id = 0 ) { if ( !$post =& get_post( $post_id ) ) return false; + if ( 'attachment' != $post->post_type ); + return false; + $url = ''; if ( $file = get_post_meta( $post->ID, '_wp_attached_file', true) ) { //Get attached file if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) { //Get upload directory @@ -3907,7 +3910,7 @@ function wp_get_attachment_url( $post_id = 0 ) { $url = apply_filters( 'wp_get_attachment_url', $url, $post->ID ); - if ( 'attachment' != $post->post_type || empty( $url ) ) + if ( empty( $url ) ) return false; return $url;