wp_get_attachment_link() variable upgrade, props noel, fixes #9036
git-svn-id: https://develop.svn.wordpress.org/trunk@10495 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
678b67ded7
commit
75c6fc4c3a
|
@ -689,18 +689,24 @@ function gallery_shortcode($attr) {
|
|||
* Display previous image link that has the same post parent.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @param string $size Optional, default is 'thumbnail'. Size of image, either array or string. 0 or 'none' will default to post_title or $text;
|
||||
* @param string $text Optional, default is false. If included, link will reflect $text variable.
|
||||
* @return string HTML content.
|
||||
*/
|
||||
function previous_image_link() {
|
||||
adjacent_image_link(true);
|
||||
function previous_image_link($size = 'thumbnail', $text = false) {
|
||||
adjacent_image_link(true, $size, $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display next image link that has the same post parent.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @param string $size Optional, default is 'thumbnail'. Size of image, either array or string. 0 or 'none' will default to post_title or $text;
|
||||
* @param string $text Optional, default is false. If included, link will reflect $text variable.
|
||||
* @return string HTML content.
|
||||
*/
|
||||
function next_image_link() {
|
||||
adjacent_image_link(false);
|
||||
function next_image_link($size = 'thumbnail', $text = false) {
|
||||
adjacent_image_link(false, $size, $text);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -712,7 +718,7 @@ function next_image_link() {
|
|||
*
|
||||
* @param bool $prev Optional. Default is true to display previous link, true for next.
|
||||
*/
|
||||
function adjacent_image_link($prev = true) {
|
||||
function adjacent_image_link($prev = true, $size = 'thumbnail', $text = false) {
|
||||
global $post;
|
||||
$post = get_post($post);
|
||||
$attachments = array_values(get_children( array('post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') ));
|
||||
|
@ -724,7 +730,7 @@ function adjacent_image_link($prev = true) {
|
|||
$k = $prev ? $k - 1 : $k + 1;
|
||||
|
||||
if ( isset($attachments[$k]) )
|
||||
echo wp_get_attachment_link($attachments[$k]->ID, 'thumbnail', true);
|
||||
echo wp_get_attachment_link($attachments[$k]->ID, $size, true, false, $text);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -908,12 +908,13 @@ function the_attachment_link($id = 0, $fullsize = false, $deprecated = false, $p
|
|||
* @uses apply_filters() Calls 'wp_get_attachment_link' filter on HTML content with same parameters as function.
|
||||
*
|
||||
* @param int $id Optional. Post ID.
|
||||
* @param string $size Optional. Image size.
|
||||
* @param string $size Optional, default is 'thumbnail'. Size of image, either array or string.
|
||||
* @param bool $permalink Optional, default is false. Whether to add permalink to image.
|
||||
* @param bool $icon Optional, default is false. Whether to include icon.
|
||||
* @param string $text Optional, default is false. If string, then will be link text.
|
||||
* @return string HTML content.
|
||||
*/
|
||||
function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false, $icon = false) {
|
||||
function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false) {
|
||||
$id = intval($id);
|
||||
$_post = & get_post( $id );
|
||||
|
||||
|
@ -924,11 +925,15 @@ function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false
|
|||
$url = get_attachment_link($_post->ID);
|
||||
|
||||
$post_title = attribute_escape($_post->post_title);
|
||||
|
||||
$link_text = wp_get_attachment_image($id, $size, $icon);
|
||||
if ( !$link_text )
|
||||
|
||||
if ( $text ) {
|
||||
$link_text = attribute_escape($text);
|
||||
} elseif ( ( is_int($size) && $size != 0 ) or ( is_string($size) && $size != 'none' ) or $size != false ) {
|
||||
$link_text = wp_get_attachment_image($id, $size, $icon);
|
||||
} else {
|
||||
$link_text = $_post->post_title;
|
||||
|
||||
}
|
||||
|
||||
return apply_filters( 'wp_get_attachment_link', "<a href='$url' title='$post_title'>$link_text</a>", $id, $size, $permalink, $icon );
|
||||
}
|
||||
|
||||
|
@ -1191,7 +1196,7 @@ function wp_post_revision_title( $revision, $link = true ) {
|
|||
$autosavef = __( '%s [Autosave]' );
|
||||
$currentf = __( '%s [Current Revision]' );
|
||||
|
||||
$date = date_i18n( $datef, strtotime( $revision->post_modified ) );
|
||||
$date = date_i18n( $datef, strtotime( $revision->post_modified_gmt . ' +0000' ) );
|
||||
if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) )
|
||||
$date = "<a href='$link'>$date</a>";
|
||||
|
||||
|
|
Loading…
Reference in New Issue