Changeset 13093
- Timestamp:
- 02/13/2010 06:39:51 AM (15 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/bookmark.php
r13017 r13093 78 78 79 79 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.086 * @deprecated Use get_bookmark()87 * @see get_bookmark()88 *89 * @param int $bookmark_id ID of link90 * @param string $output Either OBJECT, ARRAY_N, or ARRAY_A91 * @return object|array92 */93 function get_link($bookmark_id, $output = OBJECT, $filter = 'raw') {94 return get_bookmark($bookmark_id, $output, $filter);95 80 } 96 81 -
trunk/wp-includes/deprecated.php
r12871 r13093 126 126 global $wp_query, $post; 127 127 128 _deprecated_function( __FUNCTION__, '1.5', __('new WordPress Loop') 128 _deprecated_function( __FUNCTION__, '1.5', __('new WordPress Loop') ); 129 129 130 130 // Since the old style loop is being used, advance the query iterator here. … … 318 318 $post_author_data = get_userdata($post->post_author); 319 319 320 if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' && 320 if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' && $author_data->user_level < 2)) 321 321 || ($author_data->user_level > $post_author_data->user_level) 322 322 || ($author_data->user_level >= 10) ) { … … 488 488 * 489 489 * @since 1.0.1 490 * @deprecated 2.1 490 491 * @deprecated Use wp_list_bookmarks() 491 492 * @see wp_list_bookmarks() … … 662 663 * 663 664 * @since 0.71 665 * @deprecated 2.1 664 666 * @deprecated No alternative function available 665 667 * … … 668 670 */ 669 671 function get_autotoggle($id = 0) { 670 _deprecated_function( __FUNCTION__, '2.1' 672 _deprecated_function( __FUNCTION__, '2.1' ); 671 673 return 0; 672 674 } … … 742 744 /** 743 745 * @since 0.71 746 * @deprecated 2.1 744 747 * @deprecated Use wp_dropdown_categories() 745 748 * @see wp_dropdown_categories() … … 932 935 * 933 936 * @since 0.71 937 * @deprecated 2.3 934 938 * @deprecated Use the_permalink_rss() 935 939 * @see the_permalink_rss() … … 938 942 */ 939 943 function permalink_single_rss($deprecated = '') { 940 _deprecated_function( __FUNCTION__, '0.0', 'the_permalink_rss()');944 _deprecated_function( __FUNCTION__, '0.0', 'the_permalink_rss()' ); 941 945 the_permalink_rss(); 942 946 } … … 947 951 * @see get_links() for argument information that can be used in $args 948 952 * @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() 951 956 * 952 957 * @param string $args a query string … … 954 959 */ 955 960 function wp_get_links($args = '') { 956 _deprecated_function( __FUNCTION__, '0.0', 'wp_list_bookmarks()');961 _deprecated_function( __FUNCTION__, '0.0', 'wp_list_bookmarks()' ); 957 962 958 963 if ( strpos( $args, '=' ) === false ) { … … 986 991 * 987 992 * @since 0.71 993 * @deprecated 2.1 988 994 * @deprecated Use get_bookmarks() 989 995 * @see get_bookmarks() … … 1151 1157 */ 1152 1158 function 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' ); 1154 1160 1155 1161 if ( $count ) … … 1307 1313 */ 1308 1314 function gzip_compression() { 1309 _deprecated_function( __FUNCTION__, '2.5' , '');1315 _deprecated_function( __FUNCTION__, '2.5' ); 1310 1316 return false; 1311 1317 } … … 1394 1400 */ 1395 1401 function 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\')' ); 1397 1403 return get_the_author_meta('description'); 1398 1404 } … … 1407 1413 */ 1408 1414 function the_author_description() { 1409 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'description\')' 1415 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'description\')' ); 1410 1416 the_author_meta('description'); 1411 1417 } … … 1422 1428 */ 1423 1429 function 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\')' ); 1425 1431 return get_the_author_meta('login'); 1426 1432 } … … 1435 1441 */ 1436 1442 function the_author_login() { 1437 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'login\')' 1443 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'login\')' ); 1438 1444 the_author_meta('login'); 1439 1445 } … … 1450 1456 */ 1451 1457 function 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\')' ); 1453 1459 return get_the_author_meta('first_name'); 1454 1460 } … … 1463 1469 */ 1464 1470 function 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\')' ); 1466 1472 the_author_meta('first_name'); 1467 1473 } … … 1478 1484 */ 1479 1485 function 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\')' ); 1481 1487 return get_the_author_meta('last_name'); 1482 1488 } … … 1491 1497 */ 1492 1498 function 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\')' ); 1494 1500 the_author_meta('last_name'); 1495 1501 } … … 1506 1512 */ 1507 1513 function 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\')' ); 1509 1515 return get_the_author_meta('nickname'); 1510 1516 } … … 1519 1525 */ 1520 1526 function the_author_nickname() { 1521 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'nickname\')' 1527 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'nickname\')' ); 1522 1528 the_author_meta('nickname'); 1523 1529 } … … 1534 1540 */ 1535 1541 function 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\')' ); 1537 1543 return get_the_author_meta('email'); 1538 1544 } … … 1547 1553 */ 1548 1554 function the_author_email() { 1549 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'email\')' 1555 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'email\')' ); 1550 1556 the_author_meta('email'); 1551 1557 } … … 1562 1568 */ 1563 1569 function 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\')' ); 1565 1571 return get_the_author_meta('icq'); 1566 1572 } … … 1575 1581 */ 1576 1582 function the_author_icq() { 1577 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'icq\')' 1583 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'icq\')' ); 1578 1584 the_author_meta('icq'); 1579 1585 } … … 1590 1596 */ 1591 1597 function 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\')' ); 1593 1599 return get_the_author_meta('yim'); 1594 1600 } … … 1603 1609 */ 1604 1610 function the_author_yim() { 1605 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'yim\')' 1611 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'yim\')' ); 1606 1612 the_author_meta('yim'); 1607 1613 } … … 1618 1624 */ 1619 1625 function 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\')' ); 1621 1627 return get_the_author_meta('msn'); 1622 1628 } … … 1631 1637 */ 1632 1638 function the_author_msn() { 1633 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'msn\')' 1639 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'msn\')' ); 1634 1640 the_author_meta('msn'); 1635 1641 } … … 1646 1652 */ 1647 1653 function 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\')' ); 1649 1655 return get_the_author_meta('aim'); 1650 1656 } … … 1659 1665 */ 1660 1666 function the_author_aim() { 1661 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'aim\')' 1667 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'aim\')' ); 1662 1668 the_author_meta('aim'); 1663 1669 } … … 1675 1681 */ 1676 1682 function 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\')' ); 1678 1684 return get_the_author_meta('display_name', $auth_id); 1679 1685 } … … 1690 1696 */ 1691 1697 function 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\')' ); 1693 1699 return get_the_author_meta('url'); 1694 1700 } … … 1703 1709 */ 1704 1710 function the_author_url() { 1705 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'url\')' 1711 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'url\')' ); 1706 1712 the_author_meta('url'); 1707 1713 } … … 1718 1724 */ 1719 1725 function 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\')' ); 1721 1727 return get_the_author_meta('ID'); 1722 1728 } … … 1731 1737 */ 1732 1738 function the_author_ID() { 1733 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'ID\')' 1739 _deprecated_function( __FUNCTION__, '2.8', 'the_author_meta(\'ID\')' ); 1734 1740 the_author_meta('ID'); 1735 1741 } … … 1770 1776 */ 1771 1777 function 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' ); 1773 1779 $content = get_the_content($more_link_text, $stripteaser, $more_file); 1774 1780 $content = apply_filters('the_content_rss', $content); … … 1816 1822 */ 1817 1823 function make_url_footnote( $content ) { 1818 _deprecated_function( __FUNCTION__, '2.9', '' 1824 _deprecated_function( __FUNCTION__, '2.9', '' ); 1819 1825 preg_match_all( '/<a(.+?)href=\"(.+?)\"(.*?)>(.+?)<\/a>/', $content, $matches ); 1820 1826 $links_summary = "\n"; … … 1856 1862 */ 1857 1863 function _c( $text, $domain = 'default' ) { 1858 _deprecated_function( __FUNCTION__, '2.9', '_x' );1864 _deprecated_function( __FUNCTION__, '2.9', '_x()' ); 1859 1865 return translate_with_context( $text, $domain ); 1860 1866 } … … 1873 1879 */ 1874 1880 function _nc( $single, $plural, $number, $domain = 'default' ) { 1875 _deprecated_function( __FUNCTION__, '2.9', '_nx' );1881 _deprecated_function( __FUNCTION__, '2.9', '_nx()' ); 1876 1882 return before_last_bar( _n( $single, $plural, $number, $domain ) ); 1877 1883 } … … 1891 1897 return wp_load_alloptions(); 1892 1898 } 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 */ 1914 function 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 */ 1943 function 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 */ 1988 function 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 */ 2045 function 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 */ 2072 function 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 1893 2077 ?> -
trunk/wp-includes/pluggable.php
r13080 r13093 1637 1637 if ( !function_exists('wp_setcookie') ) : 1638 1638 /** 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. 1640 1640 * 1641 1641 * @since 1.5 1642 * @deprecated 2.5 1642 1643 * @deprecated Use wp_set_auth_cookie() 1643 1644 * @see wp_set_auth_cookie() … … 1659 1660 if ( !function_exists('wp_clearcookie') ) : 1660 1661 /** 1661 * Clears the authentication cookie, logging the user out. 1662 * Clears the authentication cookie, logging the user out. This function is deprecated. 1662 1663 * 1663 1664 * @since 1.5 1665 * @deprecated 2.5 1664 1666 * @deprecated Use wp_clear_auth_cookie() 1665 1667 * @see wp_clear_auth_cookie() … … 1673 1675 if ( !function_exists('wp_get_cookie_login') ): 1674 1676 /** 1675 * Gets the user cookie login. 1677 * Gets the user cookie login. This function is deprecated. 1676 1678 * 1677 1679 * This function is deprecated and should no longer be extended as it won't be … … 1679 1681 * 1680 1682 * @since 2.0.3 1683 * @deprecated 2.5 1681 1684 * @deprecated No alternative 1682 1685 * … … 1684 1687 */ 1685 1688 function wp_get_cookie_login() { 1686 _deprecated_function( __FUNCTION__, '2.5' , '');1689 _deprecated_function( __FUNCTION__, '2.5' ); 1687 1690 return false; 1688 1691 } … … 1691 1694 if ( !function_exists('wp_login') ) : 1692 1695 /** 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. 1694 1697 * 1695 1698 * Use the global $error to get the reason why the login failed. If the username … … 1710 1713 */ 1711 1714 function wp_login($username, $password, $deprecated = '') { 1715 _deprecated_function( __FUNCTION__, '2.5', 'wp_signon()' ); 1712 1716 global $error; 1713 1717 -
trunk/wp-includes/post-template.php
r13032 r13093 954 954 955 955 /** 956 * Retrieve HTML content of attachment image with link.957 *958 * @since 2.0.0959 * @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 string967 */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.0988 * @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 existing1004 1005 $src_file = basename($src);1006 $class = 'attachmentthumb';1007 } elseif ( wp_attachment_is_image( $post->ID ) ) {1008 // We have an image without a thumbnail1009 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.01030 * @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.01085 * @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 string1092 */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 /**1108 956 * Wrap attachment in <<p>> element before content. 1109 957 *
Note: See TracChangeset
for help on using the changeset viewer.