Move deprecated functions to deprecated.php. Deprecate get_the_attachment_link() for wp_get_attachment_link(), get_attachment_icon_src() for wp_get_attachment_image_src(),
get_attachment_icon() and get_attachment_innerHTML() for wp_get_attachment_image(), get_link() for get_bookmark(). Add missing deprecated version numbers. Add inline documentation to pluggable functions that are deprecated. See #11388 git-svn-id: http://svn.automattic.com/wordpress/trunk@13093 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -952,158 +952,6 @@ function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false
|
||||
return apply_filters( 'wp_get_attachment_link', "<a href='$url' title='$post_title'>$link_text</a>", $id, $size, $permalink, $icon, $text );
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve HTML content of attachment image with link.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @deprecated Use {@link wp_get_attachment_link()}
|
||||
* @see wp_get_attachment_link() Use instead.
|
||||
*
|
||||
* @param int $id Optional. Post ID.
|
||||
* @param bool $fullsize Optional, default is false. Whether to use full size image.
|
||||
* @param array $max_dims Optional. Max image dimensions.
|
||||
* @param bool $permalink Optional, default is false. Whether to include permalink to image.
|
||||
* @return string
|
||||
*/
|
||||
function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) {
|
||||
$id = (int) $id;
|
||||
$_post = & get_post($id);
|
||||
|
||||
if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) )
|
||||
return __('Missing Attachment');
|
||||
|
||||
if ( $permalink )
|
||||
$url = get_attachment_link($_post->ID);
|
||||
|
||||
$post_title = esc_attr($_post->post_title);
|
||||
|
||||
$innerHTML = get_attachment_innerHTML($_post->ID, $fullsize, $max_dims);
|
||||
return "<a href='$url' title='$post_title'>$innerHTML</a>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve icon URL and Path.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @deprecated Use {@link wp_get_attachment_image_src()}
|
||||
* @see wp_get_attachment_image_src() Use instead.
|
||||
*
|
||||
* @param int $id Optional. Post ID.
|
||||
* @param bool $fullsize Optional, default to false. Whether to have full image.
|
||||
* @return array Icon URL and full path to file, respectively.
|
||||
*/
|
||||
function get_attachment_icon_src( $id = 0, $fullsize = false ) {
|
||||
$id = (int) $id;
|
||||
if ( !$post = & get_post($id) )
|
||||
return false;
|
||||
|
||||
$file = get_attached_file( $post->ID );
|
||||
|
||||
if ( !$fullsize && $src = wp_get_attachment_thumb_url( $post->ID ) ) {
|
||||
// We have a thumbnail desired, specified and existing
|
||||
|
||||
$src_file = basename($src);
|
||||
$class = 'attachmentthumb';
|
||||
} elseif ( wp_attachment_is_image( $post->ID ) ) {
|
||||
// We have an image without a thumbnail
|
||||
|
||||
$src = wp_get_attachment_url( $post->ID );
|
||||
$src_file = & $file;
|
||||
$class = 'attachmentimage';
|
||||
} elseif ( $src = wp_mime_type_icon( $post->ID ) ) {
|
||||
// No thumb, no image. We'll look for a mime-related icon instead.
|
||||
|
||||
$icon_dir = apply_filters( 'icon_dir', get_template_directory() . '/images' );
|
||||
$src_file = $icon_dir . '/' . basename($src);
|
||||
}
|
||||
|
||||
if ( !isset($src) || !$src )
|
||||
return false;
|
||||
|
||||
return array($src, $src_file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve HTML content of icon attachment image element.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @deprecated Use {@link wp_get_attachment_image()}
|
||||
* @see wp_get_attachment_image() Use instead of.
|
||||
*
|
||||
* @param int $id Optional. Post ID.
|
||||
* @param bool $fullsize Optional, default to false. Whether to have full size image.
|
||||
* @param array $max_dims Optional. Dimensions of image.
|
||||
* @return string HTML content.
|
||||
*/
|
||||
function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) {
|
||||
$id = (int) $id;
|
||||
if ( !$post = & get_post($id) )
|
||||
return false;
|
||||
|
||||
if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) )
|
||||
return false;
|
||||
|
||||
list($src, $src_file) = $src;
|
||||
|
||||
// Do we need to constrain the image?
|
||||
if ( ($max_dims = apply_filters('attachment_max_dims', $max_dims)) && file_exists($src_file) ) {
|
||||
|
||||
$imagesize = getimagesize($src_file);
|
||||
|
||||
if (($imagesize[0] > $max_dims[0]) || $imagesize[1] > $max_dims[1] ) {
|
||||
$actual_aspect = $imagesize[0] / $imagesize[1];
|
||||
$desired_aspect = $max_dims[0] / $max_dims[1];
|
||||
|
||||
if ( $actual_aspect >= $desired_aspect ) {
|
||||
$height = $actual_aspect * $max_dims[0];
|
||||
$constraint = "width='{$max_dims[0]}' ";
|
||||
$post->iconsize = array($max_dims[0], $height);
|
||||
} else {
|
||||
$width = $max_dims[1] / $actual_aspect;
|
||||
$constraint = "height='{$max_dims[1]}' ";
|
||||
$post->iconsize = array($width, $max_dims[1]);
|
||||
}
|
||||
} else {
|
||||
$post->iconsize = array($imagesize[0], $imagesize[1]);
|
||||
$constraint = '';
|
||||
}
|
||||
} else {
|
||||
$constraint = '';
|
||||
}
|
||||
|
||||
$post_title = esc_attr($post->post_title);
|
||||
|
||||
$icon = "<img src='$src' title='$post_title' alt='$post_title' $constraint/>";
|
||||
|
||||
return apply_filters( 'attachment_icon', $icon, $post->ID );
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve HTML content of image element.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @deprecated Use {@link wp_get_attachment_image()}
|
||||
* @see wp_get_attachment_image() Use instead.
|
||||
*
|
||||
* @param int $id Optional. Post ID.
|
||||
* @param bool $fullsize Optional, default to false. Whether to have full size image.
|
||||
* @param array $max_dims Optional. Dimensions of image.
|
||||
* @return string
|
||||
*/
|
||||
function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) {
|
||||
$id = (int) $id;
|
||||
if ( !$post = & get_post($id) )
|
||||
return false;
|
||||
|
||||
if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims))
|
||||
return $innerHTML;
|
||||
|
||||
|
||||
$innerHTML = esc_attr($post->post_title);
|
||||
|
||||
return apply_filters('attachment_innerHTML', $innerHTML, $post->ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap attachment in <<p>> element before content.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user