Make WordPress Core

Ticket #18491: 18491_2.patch

File 18491_2.patch, 1.8 KB (added by Jayjdk, 15 years ago)

Updated the function to follow the WordPress Coding Standards

  • post-template.php

     
    11531153 * @param string $text Optional, default is false. If string, then will be link text.
    11541154 * @return string HTML content.
    11551155 */
    1156 function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false) {
    1157         $id = intval($id);
     1156function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false ) {
     1157        $id = intval( $id );
    11581158        $_post = & get_post( $id );
    11591159
    1160         if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) )
    1161                 return __('Missing Attachment');
     1160        if ( empty( $_post ) || ( 'attachment' != $_post->post_type ) || ! $url = wp_get_attachment_url( $_post->ID ) )
     1161                return __( 'Missing Attachment' );
    11621162
    11631163        if ( $permalink )
    1164                 $url = get_attachment_link($_post->ID);
     1164                $url = get_attachment_link( $_post->ID );
    11651165
    1166         $post_title = esc_attr($_post->post_title);
     1166        $post_title = esc_attr( $_post->post_title );
    11671167
    1168         if ( $text ) {
    1169                 $link_text = esc_attr($text);
    1170         } elseif ( ( is_int($size) && $size != 0 ) or ( is_string($size) && $size != 'none' ) or $size != false ) {
    1171                 $link_text = wp_get_attachment_image($id, $size, $icon);
    1172         } else {
     1168        if ( $text )
     1169                $link_text = esc_attr( $text );
     1170        elseif ( ( is_int( $size ) && $size != 0 ) || ( is_string( $size ) && $size != 'none' ) || $size != false )
     1171                $link_text = wp_get_attachment_image( $id, $size, $icon );
     1172        else
    11731173                $link_text = '';
    1174         }
    11751174
    1176         if( trim($link_text) == '' )
     1175        if ( trim( $link_text ) == '' )
    11771176                $link_text = $_post->post_title;
    11781177
    11791178        return apply_filters( 'wp_get_attachment_link', "<a href='$url' title='$post_title'>$link_text</a>", $id, $size, $permalink, $icon, $text );