Make WordPress Core

Changeset 13093


Ignore:
Timestamp:
02/13/2010 06:39:51 AM (17 years ago)
Author:
nacin
Message:

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

Location:
trunk/wp-includes
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/bookmark.php

    r13017 r13093  
    7878
    7979        return sanitize_bookmark_field($field, $bookmark->$field, $bookmark->link_id, $context);
    80 }
    81 
    82 /**
    83  * Retrieve bookmark data based on ID.
    84  *
    85  * @since 2.0.0
    86  * @deprecated Use get_bookmark()
    87  * @see get_bookmark()
    88  *
    89  * @param int $bookmark_id ID of link
    90  * @param string $output Either OBJECT, ARRAY_N, or ARRAY_A
    91  * @return object|array
    92  */
    93 function get_link($bookmark_id, $output = OBJECT, $filter = 'raw') {
    94         return get_bookmark($bookmark_id, $output, $filter);
    9580}
    9681
  • trunk/wp-includes/deprecated.php

    r12871 r13093  
    126126        global $wp_query, $post;
    127127
    128         _deprecated_function( __FUNCTION__, '1.5', __('new WordPress Loop')  );
     128        _deprecated_function( __FUNCTION__, '1.5', __('new WordPress Loop') );
    129129
    130130        // Since the old style loop is being used, advance the query iterator here.
     
    318318        $post_author_data = get_userdata($post->post_author);
    319319
    320         if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' &&  $author_data->user_level < 2))
     320        if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' && $author_data->user_level < 2))
    321321                         || ($author_data->user_level > $post_author_data->user_level)
    322322                         || ($author_data->user_level >= 10) ) {
     
    488488 *
    489489 * @since 1.0.1
     490 * @deprecated 2.1
    490491 * @deprecated Use wp_list_bookmarks()
    491492 * @see wp_list_bookmarks()
     
    662663 *
    663664 * @since 0.71
     665 * @deprecated 2.1
    664666 * @deprecated No alternative function available
    665667 *
     
    668670 */
    669671function get_autotoggle($id = 0) {
    670         _deprecated_function( __FUNCTION__, '2.1'  );
     672        _deprecated_function( __FUNCTION__, '2.1' );
    671673        return 0;
    672674}
     
    742744/**
    743745 * @since 0.71
     746 * @deprecated 2.1
    744747 * @deprecated Use wp_dropdown_categories()
    745748 * @see wp_dropdown_categories()
     
    932935 *
    933936 * @since 0.71
     937 * @deprecated 2.3
    934938 * @deprecated Use the_permalink_rss()
    935939 * @see the_permalink_rss()
     
    938942 */
    939943function permalink_single_rss($deprecated = '') {
    940         _deprecated_function(__FUNCTION__, '0.0', 'the_permalink_rss()');
     944        _deprecated_function( __FUNCTION__, '0.0', 'the_permalink_rss()' );
    941945        the_permalink_rss();
    942946}
     
    947951 * @see get_links() for argument information that can be used in $args
    948952 * @since 1.0.1
    949  * @deprecated Use get_bookmarks()
    950  * @see get_bookmarks()
     953 * @deprecated 2.1
     954 * @deprecated Use wp_list_bookmarks()
     955 * @see wp_list_bookmarks()
    951956 *
    952957 * @param string $args a query string
     
    954959 */
    955960function wp_get_links($args = '') {
    956         _deprecated_function(__FUNCTION__, '0.0', 'wp_list_bookmarks()');
     961        _deprecated_function( __FUNCTION__, '0.0', 'wp_list_bookmarks()' );
    957962
    958963        if ( strpos( $args, '=' ) === false ) {
     
    986991 *
    987992 * @since 0.71
     993 * @deprecated 2.1
    988994 * @deprecated Use get_bookmarks()
    989995 * @see get_bookmarks()
     
    11511157 */
    11521158function links_popup_script($text = 'Links', $width=400, $height=400, $file='links.all.php', $count = true) {
    1153         _deprecated_function( __FUNCTION__, '2.1'  );
     1159        _deprecated_function( __FUNCTION__, '2.1' );
    11541160
    11551161        if ( $count )
     
    13071313*/
    13081314function gzip_compression() {
    1309         _deprecated_function( __FUNCTION__, '2.5', '' );
     1315        _deprecated_function( __FUNCTION__, '2.5' );
    13101316        return false;
    13111317}
     
    13941400 */
    13951401function get_the_author_description() {
    1396         _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'description\')'  );
     1402        _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'description\')' );
    13971403        return get_the_author_meta('description');
    13981404}
     
    14071413 */
    14081414function the_author_description() {
    1409         _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'description\')'  );
     1415        _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'description\')' );
    14101416        the_author_meta('description');
    14111417}
     
    14221428 */
    14231429function get_the_author_login() {
    1424         _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'login\')'  );
     1430        _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'login\')' );
    14251431        return get_the_author_meta('login');
    14261432}
     
    14351441 */
    14361442function the_author_login() {
    1437         _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'login\')'  );
     1443        _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'login\')' );
    14381444        the_author_meta('login');
    14391445}
     
    14501456 */
    14511457function get_the_author_firstname() {
    1452         _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'first_name\')'  );
     1458        _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'first_name\')' );
    14531459        return get_the_author_meta('first_name');
    14541460}
     
    14631469 */
    14641470function the_author_firstname() {
    1465         _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'first_name\')'  );
     1471        _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'first_name\')' );
    14661472        the_author_meta('first_name');
    14671473}
     
    14781484 */
    14791485function get_the_author_lastname() {
    1480         _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'last_name\')'  );
     1486        _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'last_name\')' );
    14811487        return get_the_author_meta('last_name');
    14821488}
     
    14911497 */
    14921498function the_author_lastname() {
    1493         _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'last_name\')'  );
     1499        _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'last_name\')' );
    14941500        the_author_meta('last_name');
    14951501}
     
    15061512 */
    15071513function get_the_author_nickname() {
    1508         _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'nickname\')'  );
     1514        _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'nickname\')' );
    15091515        return get_the_author_meta('nickname');
    15101516}
     
    15191525 */
    15201526function the_author_nickname() {
    1521         _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'nickname\')'  );
     1527        _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'nickname\')' );
    15221528        the_author_meta('nickname');
    15231529}
     
    15341540 */
    15351541function get_the_author_email() {
    1536         _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'email\')'  );
     1542        _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'email\')' );
    15371543        return get_the_author_meta('email');
    15381544}
     
    15471553 */
    15481554function the_author_email() {
    1549         _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'email\')'  );
     1555        _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'email\')' );
    15501556        the_author_meta('email');
    15511557}
     
    15621568 */
    15631569function get_the_author_icq() {
    1564         _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'icq\')'  );
     1570        _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'icq\')' );
    15651571        return get_the_author_meta('icq');
    15661572}
     
    15751581 */
    15761582function the_author_icq() {
    1577         _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'icq\')'  );
     1583        _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'icq\')' );
    15781584        the_author_meta('icq');
    15791585}
     
    15901596 */
    15911597function get_the_author_yim() {
    1592         _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'yim\')'  );
     1598        _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'yim\')' );
    15931599        return get_the_author_meta('yim');
    15941600}
     
    16031609 */
    16041610function the_author_yim() {
    1605         _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'yim\')'  );
     1611        _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'yim\')' );
    16061612        the_author_meta('yim');
    16071613}
     
    16181624 */
    16191625function get_the_author_msn() {
    1620         _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'msn\')'  );
     1626        _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'msn\')' );
    16211627        return get_the_author_meta('msn');
    16221628}
     
    16311637 */
    16321638function the_author_msn() {
    1633         _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'msn\')'  );
     1639        _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'msn\')' );
    16341640        the_author_meta('msn');
    16351641}
     
    16461652 */
    16471653function get_the_author_aim() {
    1648         _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'aim\')'  );
     1654        _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'aim\')' );
    16491655        return get_the_author_meta('aim');
    16501656}
     
    16591665 */
    16601666function the_author_aim() {
    1661         _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'aim\')'  );
     1667        _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'aim\')' );
    16621668        the_author_meta('aim');
    16631669}
     
    16751681 */
    16761682function get_author_name( $auth_id = false ) {
    1677         _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'display_name\')'  );
     1683        _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'display_name\')' );
    16781684        return get_the_author_meta('display_name', $auth_id);
    16791685}
     
    16901696 */
    16911697function get_the_author_url() {
    1692         _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'url\')'  );
     1698        _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'url\')' );
    16931699        return get_the_author_meta('url');
    16941700}
     
    17031709 */
    17041710function the_author_url() {
    1705         _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'url\')'  );
     1711        _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'url\')' );
    17061712        the_author_meta('url');
    17071713}
     
    17181724 */
    17191725function get_the_author_ID() {
    1720         _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'ID\')'  );
     1726        _deprecated_function( __FUNCTION__, '2.8', 'get_the_author_meta(\'ID\')' );
    17211727        return get_the_author_meta('ID');
    17221728}
     
    17311737*/
    17321738function the_author_ID() {
    1733         _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'ID\')'  );
     1739        _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'ID\')' );
    17341740        the_author_meta('ID');
    17351741}
     
    17701776 */
    17711777function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
    1772         _deprecated_function( __FUNCTION__, '2.9', 'the_content_feed'  );
     1778        _deprecated_function( __FUNCTION__, '2.9', 'the_content_feed' );
    17731779        $content = get_the_content($more_link_text, $stripteaser, $more_file);
    17741780        $content = apply_filters('the_content_rss', $content);
     
    18161822 */
    18171823function make_url_footnote( $content ) {
    1818         _deprecated_function( __FUNCTION__, '2.9', ''  );
     1824        _deprecated_function( __FUNCTION__, '2.9', '' );
    18191825        preg_match_all( '/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches );
    18201826        $links_summary = "\n";
     
    18561862 */
    18571863function _c( $text, $domain = 'default' ) {
    1858         _deprecated_function(__FUNCTION__, '2.9', '_x' );
     1864        _deprecated_function( __FUNCTION__, '2.9', '_x()' );
    18591865        return translate_with_context( $text, $domain );
    18601866}
     
    18731879 */
    18741880function _nc( $single, $plural, $number, $domain = 'default' ) {
    1875         _deprecated_function(__FUNCTION__, '2.9', '_nx' );
     1881        _deprecated_function( __FUNCTION__, '2.9', '_nx()' );
    18761882        return before_last_bar( _n( $single, $plural, $number, $domain ) );
    18771883}
     
    18911897        return wp_load_alloptions();
    18921898}
     1899
     1900/**
     1901 * Retrieve HTML content of attachment image with link.
     1902 *
     1903 * @since 2.0.0
     1904 * @deprecated 2.5.0
     1905 * @deprecated Use wp_get_attachment_link()
     1906 * @see wp_get_attachment_link()
     1907 *
     1908 * @param int $id Optional. Post ID.
     1909 * @param bool $fullsize Optional, default is false. Whether to use full size image.
     1910 * @param array $max_dims Optional. Max image dimensions.
     1911 * @param bool $permalink Optional, default is false. Whether to include permalink to image.
     1912 * @return string
     1913 */
     1914function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) {
     1915        _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_link()' );
     1916        $id = (int) $id;
     1917        $_post = & get_post($id);
     1918
     1919        if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) )
     1920                return __('Missing Attachment');
     1921
     1922        if ( $permalink )
     1923                $url = get_attachment_link($_post->ID);
     1924
     1925        $post_title = esc_attr($_post->post_title);
     1926
     1927        $innerHTML = get_attachment_innerHTML($_post->ID, $fullsize, $max_dims);
     1928        return "<a href='$url' title='$post_title'>$innerHTML</a>";
     1929}
     1930
     1931/**
     1932 * Retrieve icon URL and Path.
     1933 *
     1934 * @since 2.1.0
     1935 * @deprecated 2.5.0
     1936 * @deprecated Use wp_get_attachment_image_src()
     1937 * @see wp_get_attachment_image_src()
     1938 *
     1939 * @param int $id Optional. Post ID.
     1940 * @param bool $fullsize Optional, default to false. Whether to have full image.
     1941 * @return array Icon URL and full path to file, respectively.
     1942 */
     1943function get_attachment_icon_src( $id = 0, $fullsize = false ) {
     1944        _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image_src()' );
     1945        $id = (int) $id;
     1946        if ( !$post = & get_post($id) )
     1947                return false;
     1948
     1949        $file = get_attached_file( $post->ID );
     1950
     1951        if ( !$fullsize && $src = wp_get_attachment_thumb_url( $post->ID ) ) {
     1952                // We have a thumbnail desired, specified and existing
     1953
     1954                $src_file = basename($src);
     1955                $class = 'attachmentthumb';
     1956        } elseif ( wp_attachment_is_image( $post->ID ) ) {
     1957                // We have an image without a thumbnail
     1958
     1959                $src = wp_get_attachment_url( $post->ID );
     1960                $src_file = & $file;
     1961                $class = 'attachmentimage';
     1962        } elseif ( $src = wp_mime_type_icon( $post->ID ) ) {
     1963                // No thumb, no image. We'll look for a mime-related icon instead.
     1964
     1965                $icon_dir = apply_filters( 'icon_dir', get_template_directory() . '/images' );
     1966                $src_file = $icon_dir . '/' . basename($src);
     1967        }
     1968
     1969        if ( !isset($src) || !$src )
     1970                return false;
     1971
     1972        return array($src, $src_file);
     1973}
     1974
     1975/**
     1976 * Retrieve HTML content of icon attachment image element.
     1977 *
     1978 * @since 2.0.0
     1979 * @deprecated 2.5.0
     1980 * @deprecated Use wp_get_attachment_image()
     1981 * @see wp_get_attachment_image()
     1982 *
     1983 * @param int $id Optional. Post ID.
     1984 * @param bool $fullsize Optional, default to false. Whether to have full size image.
     1985 * @param array $max_dims Optional. Dimensions of image.
     1986 * @return string HTML content.
     1987 */
     1988function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) {
     1989        _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' );
     1990        $id = (int) $id;
     1991        if ( !$post = & get_post($id) )
     1992                return false;
     1993
     1994        if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) )
     1995                return false;
     1996
     1997        list($src, $src_file) = $src;
     1998
     1999        // Do we need to constrain the image?
     2000        if ( ($max_dims = apply_filters('attachment_max_dims', $max_dims)) && file_exists($src_file) ) {
     2001
     2002                $imagesize = getimagesize($src_file);
     2003
     2004                if (($imagesize[0] > $max_dims[0]) || $imagesize[1] > $max_dims[1] ) {
     2005                        $actual_aspect = $imagesize[0] / $imagesize[1];
     2006                        $desired_aspect = $max_dims[0] / $max_dims[1];
     2007
     2008                        if ( $actual_aspect >= $desired_aspect ) {
     2009                                $height = $actual_aspect * $max_dims[0];
     2010                                $constraint = "width='{$max_dims[0]}' ";
     2011                                $post->iconsize = array($max_dims[0], $height);
     2012                        } else {
     2013                                $width = $max_dims[1] / $actual_aspect;
     2014                                $constraint = "height='{$max_dims[1]}' ";
     2015                                $post->iconsize = array($width, $max_dims[1]);
     2016                        }
     2017                } else {
     2018                        $post->iconsize = array($imagesize[0], $imagesize[1]);
     2019                        $constraint = '';
     2020                }
     2021        } else {
     2022                $constraint = '';
     2023        }
     2024
     2025        $post_title = esc_attr($post->post_title);
     2026
     2027        $icon = "<img src='$src' title='$post_title' alt='$post_title' $constraint/>";
     2028
     2029        return apply_filters( 'attachment_icon', $icon, $post->ID );
     2030}
     2031
     2032/**
     2033 * Retrieve HTML content of image element.
     2034 *
     2035 * @since 2.0.0
     2036 * @deprecated 2.5.0
     2037 * @deprecated Use wp_get_attachment_image()
     2038 * @see wp_get_attachment_image()
     2039 *
     2040 * @param int $id Optional. Post ID.
     2041 * @param bool $fullsize Optional, default to false. Whether to have full size image.
     2042 * @param array $max_dims Optional. Dimensions of image.
     2043 * @return string
     2044 */
     2045function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) {
     2046        _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' );
     2047        $id = (int) $id;
     2048        if ( !$post = & get_post($id) )
     2049                return false;
     2050
     2051        if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims))
     2052                return $innerHTML;
     2053
     2054
     2055        $innerHTML = esc_attr($post->post_title);
     2056
     2057        return apply_filters('attachment_innerHTML', $innerHTML, $post->ID);
     2058}
     2059
     2060/*
     2061 * Retrieve bookmark data based on ID.
     2062 *
     2063 * @since 2.0.0
     2064 * @deprecated 2.1.0
     2065 * @deprecated Use get_bookmark()
     2066 * @see get_bookmark()
     2067 *
     2068 * @param int $bookmark_id ID of link
     2069 * @param string $output OBJECT, ARRAY_N, or ARRAY_A
     2070 * @return object|array
     2071 */
     2072function get_link($bookmark_id, $output = OBJECT, $filter = 'raw') {
     2073        _deprecated_function( __FUNCTION__, '2.1', 'get_bookmark()' );
     2074        return get_bookmark($bookmark_id, $output, $filter);
     2075}
     2076
    18932077?>
  • trunk/wp-includes/pluggable.php

    r13080 r13093  
    16371637if ( !function_exists('wp_setcookie') ) :
    16381638/**
    1639  * Sets a cookie for a user who just logged in.
     1639 * Sets a cookie for a user who just logged in. This function is deprecated.
    16401640 *
    16411641 * @since 1.5
     1642 * @deprecated 2.5
    16421643 * @deprecated Use wp_set_auth_cookie()
    16431644 * @see wp_set_auth_cookie()
     
    16591660if ( !function_exists('wp_clearcookie') ) :
    16601661/**
    1661  * Clears the authentication cookie, logging the user out.
     1662 * Clears the authentication cookie, logging the user out. This function is deprecated.
    16621663 *
    16631664 * @since 1.5
     1665 * @deprecated 2.5
    16641666 * @deprecated Use wp_clear_auth_cookie()
    16651667 * @see wp_clear_auth_cookie()
     
    16731675if ( !function_exists('wp_get_cookie_login') ):
    16741676/**
    1675  * Gets the user cookie login.
     1677 * Gets the user cookie login. This function is deprecated.
    16761678 *
    16771679 * This function is deprecated and should no longer be extended as it won't be
     
    16791681 *
    16801682 * @since 2.0.3
     1683 * @deprecated 2.5
    16811684 * @deprecated No alternative
    16821685 *
     
    16841687 */
    16851688function wp_get_cookie_login() {
    1686         _deprecated_function( __FUNCTION__, '2.5', '' );
     1689        _deprecated_function( __FUNCTION__, '2.5' );
    16871690        return false;
    16881691}
     
    16911694if ( !function_exists('wp_login') ) :
    16921695/**
    1693  * Checks a users login information and logs them in if it checks out.
     1696 * Checks a users login information and logs them in if it checks out. This function is deprecated.
    16941697 *
    16951698 * Use the global $error to get the reason why the login failed. If the username
     
    17101713 */
    17111714function wp_login($username, $password, $deprecated = '') {
     1715        _deprecated_function( __FUNCTION__, '2.5', 'wp_signon()' );
    17121716        global $error;
    17131717
  • trunk/wp-includes/post-template.php

    r13032 r13093  
    954954
    955955/**
    956  * Retrieve HTML content of attachment image with link.
    957  *
    958  * @since 2.0.0
    959  * @deprecated Use {@link wp_get_attachment_link()}
    960  * @see wp_get_attachment_link() Use instead.
    961  *
    962  * @param int $id Optional. Post ID.
    963  * @param bool $fullsize Optional, default is false. Whether to use full size image.
    964  * @param array $max_dims Optional. Max image dimensions.
    965  * @param bool $permalink Optional, default is false. Whether to include permalink to image.
    966  * @return string
    967  */
    968 function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) {
    969         $id = (int) $id;
    970         $_post = & get_post($id);
    971 
    972         if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) )
    973                 return __('Missing Attachment');
    974 
    975         if ( $permalink )
    976                 $url = get_attachment_link($_post->ID);
    977 
    978         $post_title = esc_attr($_post->post_title);
    979 
    980         $innerHTML = get_attachment_innerHTML($_post->ID, $fullsize, $max_dims);
    981         return "<a href='$url' title='$post_title'>$innerHTML</a>";
    982 }
    983 
    984 /**
    985  * Retrieve icon URL and Path.
    986  *
    987  * @since 2.1.0
    988  * @deprecated Use {@link wp_get_attachment_image_src()}
    989  * @see wp_get_attachment_image_src() Use instead.
    990  *
    991  * @param int $id Optional. Post ID.
    992  * @param bool $fullsize Optional, default to false. Whether to have full image.
    993  * @return array Icon URL and full path to file, respectively.
    994  */
    995 function get_attachment_icon_src( $id = 0, $fullsize = false ) {
    996         $id = (int) $id;
    997         if ( !$post = & get_post($id) )
    998                 return false;
    999 
    1000         $file = get_attached_file( $post->ID );
    1001 
    1002         if ( !$fullsize && $src = wp_get_attachment_thumb_url( $post->ID ) ) {
    1003                 // We have a thumbnail desired, specified and existing
    1004 
    1005                 $src_file = basename($src);
    1006                 $class = 'attachmentthumb';
    1007         } elseif ( wp_attachment_is_image( $post->ID ) ) {
    1008                 // We have an image without a thumbnail
    1009 
    1010                 $src = wp_get_attachment_url( $post->ID );
    1011                 $src_file = & $file;
    1012                 $class = 'attachmentimage';
    1013         } elseif ( $src = wp_mime_type_icon( $post->ID ) ) {
    1014                 // No thumb, no image. We'll look for a mime-related icon instead.
    1015 
    1016                 $icon_dir = apply_filters( 'icon_dir', get_template_directory() . '/images' );
    1017                 $src_file = $icon_dir . '/' . basename($src);
    1018         }
    1019 
    1020         if ( !isset($src) || !$src )
    1021                 return false;
    1022 
    1023         return array($src, $src_file);
    1024 }
    1025 
    1026 /**
    1027  * Retrieve HTML content of icon attachment image element.
    1028  *
    1029  * @since 2.0.0
    1030  * @deprecated Use {@link wp_get_attachment_image()}
    1031  * @see wp_get_attachment_image() Use instead of.
    1032  *
    1033  * @param int $id Optional. Post ID.
    1034  * @param bool $fullsize Optional, default to false. Whether to have full size image.
    1035  * @param array $max_dims Optional. Dimensions of image.
    1036  * @return string HTML content.
    1037  */
    1038 function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) {
    1039         $id = (int) $id;
    1040         if ( !$post = & get_post($id) )
    1041                 return false;
    1042 
    1043         if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) )
    1044                 return false;
    1045 
    1046         list($src, $src_file) = $src;
    1047 
    1048         // Do we need to constrain the image?
    1049         if ( ($max_dims = apply_filters('attachment_max_dims', $max_dims)) && file_exists($src_file) ) {
    1050 
    1051                 $imagesize = getimagesize($src_file);
    1052 
    1053                 if (($imagesize[0] > $max_dims[0]) || $imagesize[1] > $max_dims[1] ) {
    1054                         $actual_aspect = $imagesize[0] / $imagesize[1];
    1055                         $desired_aspect = $max_dims[0] / $max_dims[1];
    1056 
    1057                         if ( $actual_aspect >= $desired_aspect ) {
    1058                                 $height = $actual_aspect * $max_dims[0];
    1059                                 $constraint = "width='{$max_dims[0]}' ";
    1060                                 $post->iconsize = array($max_dims[0], $height);
    1061                         } else {
    1062                                 $width = $max_dims[1] / $actual_aspect;
    1063                                 $constraint = "height='{$max_dims[1]}' ";
    1064                                 $post->iconsize = array($width, $max_dims[1]);
    1065                         }
    1066                 } else {
    1067                         $post->iconsize = array($imagesize[0], $imagesize[1]);
    1068                         $constraint = '';
    1069                 }
    1070         } else {
    1071                 $constraint = '';
    1072         }
    1073 
    1074         $post_title = esc_attr($post->post_title);
    1075 
    1076         $icon = "<img src='$src' title='$post_title' alt='$post_title' $constraint/>";
    1077 
    1078         return apply_filters( 'attachment_icon', $icon, $post->ID );
    1079 }
    1080 
    1081 /**
    1082  * Retrieve HTML content of image element.
    1083  *
    1084  * @since 2.0.0
    1085  * @deprecated Use {@link wp_get_attachment_image()}
    1086  * @see wp_get_attachment_image() Use instead.
    1087  *
    1088  * @param int $id Optional. Post ID.
    1089  * @param bool $fullsize Optional, default to false. Whether to have full size image.
    1090  * @param array $max_dims Optional. Dimensions of image.
    1091  * @return string
    1092  */
    1093 function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) {
    1094         $id = (int) $id;
    1095         if ( !$post = & get_post($id) )
    1096                 return false;
    1097 
    1098         if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims))
    1099                 return $innerHTML;
    1100 
    1101 
    1102         $innerHTML = esc_attr($post->post_title);
    1103 
    1104         return apply_filters('attachment_innerHTML', $innerHTML, $post->ID);
    1105 }
    1106 
    1107 /**
    1108956 * Wrap attachment in <<p>> element before content.
    1109957 *
Note: See TracChangeset for help on using the changeset viewer.