In `wp_get_attachment_link()`, accept an `id` or `WP_Post` as the first parameter.
Props several27, DrewAPicture. Fixes #33277. Built from https://develop.svn.wordpress.org/trunk@33669 git-svn-id: http://core.svn.wordpress.org/trunk@33636 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
89c39e7eab
commit
677d47ebc5
|
@ -1555,6 +1555,7 @@ function the_attachment_link( $id = 0, $fullsize = false, $deprecated = false, $
|
||||||
* Retrieve an attachment page link using an image or icon, if possible.
|
* Retrieve an attachment page link using an image or icon, if possible.
|
||||||
*
|
*
|
||||||
* @since 2.5.0
|
* @since 2.5.0
|
||||||
|
* @since 4.4.0 The `$id` parameter can now accept either a post ID or `WP_Post` object.
|
||||||
*
|
*
|
||||||
* @param int|WP_Post $id Optional. Post ID or post object.
|
* @param int|WP_Post $id Optional. Post ID or post object.
|
||||||
* @param string $size Optional, default is 'thumbnail'. Size of image, either array or string.
|
* @param string $size Optional, default is 'thumbnail'. Size of image, either array or string.
|
||||||
|
@ -1565,7 +1566,6 @@ function the_attachment_link( $id = 0, $fullsize = false, $deprecated = false, $
|
||||||
* @return string HTML content.
|
* @return string HTML content.
|
||||||
*/
|
*/
|
||||||
function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false, $attr = '' ) {
|
function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false, $attr = '' ) {
|
||||||
$id = intval( $id );
|
|
||||||
$_post = get_post( $id );
|
$_post = get_post( $id );
|
||||||
|
|
||||||
if ( empty( $_post ) || ( 'attachment' != $_post->post_type ) || ! $url = wp_get_attachment_url( $_post->ID ) )
|
if ( empty( $_post ) || ( 'attachment' != $_post->post_type ) || ! $url = wp_get_attachment_url( $_post->ID ) )
|
||||||
|
@ -1577,7 +1577,7 @@ function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = fals
|
||||||
if ( $text ) {
|
if ( $text ) {
|
||||||
$link_text = $text;
|
$link_text = $text;
|
||||||
} elseif ( $size && 'none' != $size ) {
|
} elseif ( $size && 'none' != $size ) {
|
||||||
$link_text = wp_get_attachment_image( $id, $size, $icon, $attr );
|
$link_text = wp_get_attachment_image( $_post->ID, $size, $icon, $attr );
|
||||||
} else {
|
} else {
|
||||||
$link_text = '';
|
$link_text = '';
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.4-alpha-33668';
|
$wp_version = '4.4-alpha-33669';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue