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: https://develop.svn.wordpress.org/trunk@13093 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
dfb58c1866
commit
8e79d5c2ac
|
@ -79,21 +79,6 @@ function get_bookmark_field( $field, $bookmark, $context = 'display' ) {
|
|||
return sanitize_bookmark_field($field, $bookmark->$field, $bookmark->link_id, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve bookmark data based on ID.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @deprecated Use get_bookmark()
|
||||
* @see get_bookmark()
|
||||
*
|
||||
* @param int $bookmark_id ID of link
|
||||
* @param string $output Either OBJECT, ARRAY_N, or ARRAY_A
|
||||
* @return object|array
|
||||
*/
|
||||
function get_link($bookmark_id, $output = OBJECT, $filter = 'raw') {
|
||||
return get_bookmark($bookmark_id, $output, $filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the list of bookmarks
|
||||
*
|
||||
|
|
|
@ -487,6 +487,7 @@ function get_linksbyname($cat_name = "noname", $before = '', $after = '<br />',
|
|||
* Gets the links associated with the named category.
|
||||
*
|
||||
* @since 1.0.1
|
||||
* @deprecated 2.1
|
||||
* @deprecated Use wp_list_bookmarks()
|
||||
* @see wp_list_bookmarks()
|
||||
*
|
||||
|
@ -661,6 +662,7 @@ function get_links_withrating($category = -1, $before = '', $after = '<br />', $
|
|||
* Gets the auto_toggle setting.
|
||||
*
|
||||
* @since 0.71
|
||||
* @deprecated 2.1
|
||||
* @deprecated No alternative function available
|
||||
*
|
||||
* @param int $id The category to get. If no category supplied uses 0
|
||||
|
@ -741,6 +743,7 @@ function wp_list_cats($args = '') {
|
|||
|
||||
/**
|
||||
* @since 0.71
|
||||
* @deprecated 2.1
|
||||
* @deprecated Use wp_dropdown_categories()
|
||||
* @see wp_dropdown_categories()
|
||||
*
|
||||
|
@ -931,13 +934,14 @@ function permalink_link() {
|
|||
* Print the permalink to the RSS feed.
|
||||
*
|
||||
* @since 0.71
|
||||
* @deprecated 2.3
|
||||
* @deprecated Use the_permalink_rss()
|
||||
* @see the_permalink_rss()
|
||||
*
|
||||
* @param string $file
|
||||
*/
|
||||
function permalink_single_rss($deprecated = '') {
|
||||
_deprecated_function(__FUNCTION__, '0.0', 'the_permalink_rss()');
|
||||
_deprecated_function( __FUNCTION__, '0.0', 'the_permalink_rss()' );
|
||||
the_permalink_rss();
|
||||
}
|
||||
|
||||
|
@ -946,14 +950,15 @@ function permalink_single_rss($deprecated = '') {
|
|||
*
|
||||
* @see get_links() for argument information that can be used in $args
|
||||
* @since 1.0.1
|
||||
* @deprecated Use get_bookmarks()
|
||||
* @see get_bookmarks()
|
||||
* @deprecated 2.1
|
||||
* @deprecated Use wp_list_bookmarks()
|
||||
* @see wp_list_bookmarks()
|
||||
*
|
||||
* @param string $args a query string
|
||||
* @return null|string
|
||||
*/
|
||||
function wp_get_links($args = '') {
|
||||
_deprecated_function(__FUNCTION__, '0.0', 'wp_list_bookmarks()');
|
||||
_deprecated_function( __FUNCTION__, '0.0', 'wp_list_bookmarks()' );
|
||||
|
||||
if ( strpos( $args, '=' ) === false ) {
|
||||
$cat_id = $args;
|
||||
|
@ -985,6 +990,7 @@ function wp_get_links($args = '') {
|
|||
* Gets the links associated with category by id.
|
||||
*
|
||||
* @since 0.71
|
||||
* @deprecated 2.1
|
||||
* @deprecated Use get_bookmarks()
|
||||
* @see get_bookmarks()
|
||||
*
|
||||
|
@ -1306,7 +1312,7 @@ function create_user($username, $password, $email) {
|
|||
* @deprecated 2.5
|
||||
*/
|
||||
function gzip_compression() {
|
||||
_deprecated_function( __FUNCTION__, '2.5', '' );
|
||||
_deprecated_function( __FUNCTION__, '2.5' );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1855,7 +1861,7 @@ function make_url_footnote( $content ) {
|
|||
* @return string Translated context string without pipe
|
||||
*/
|
||||
function _c( $text, $domain = 'default' ) {
|
||||
_deprecated_function(__FUNCTION__, '2.9', '_x' );
|
||||
_deprecated_function( __FUNCTION__, '2.9', '_x()' );
|
||||
return translate_with_context( $text, $domain );
|
||||
}
|
||||
|
||||
|
@ -1872,7 +1878,7 @@ function _c( $text, $domain = 'default' ) {
|
|||
*
|
||||
*/
|
||||
function _nc( $single, $plural, $number, $domain = 'default' ) {
|
||||
_deprecated_function(__FUNCTION__, '2.9', '_nx' );
|
||||
_deprecated_function( __FUNCTION__, '2.9', '_nx()' );
|
||||
return before_last_bar( _n( $single, $plural, $number, $domain ) );
|
||||
}
|
||||
|
||||
|
@ -1890,4 +1896,182 @@ function get_alloptions() {
|
|||
_deprecated_function( __FUNCTION__, '3.0', 'wp_load_alloptions()' );
|
||||
return wp_load_alloptions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve HTML content of attachment image with link.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @deprecated 2.5.0
|
||||
* @deprecated Use wp_get_attachment_link()
|
||||
* @see wp_get_attachment_link()
|
||||
*
|
||||
* @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) {
|
||||
_deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_link()' );
|
||||
$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 2.5.0
|
||||
* @deprecated Use wp_get_attachment_image_src()
|
||||
* @see wp_get_attachment_image_src()
|
||||
*
|
||||
* @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 ) {
|
||||
_deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image_src()' );
|
||||
$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 2.5.0
|
||||
* @deprecated Use wp_get_attachment_image()
|
||||
* @see wp_get_attachment_image()
|
||||
*
|
||||
* @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 ) {
|
||||
_deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' );
|
||||
$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 2.5.0
|
||||
* @deprecated Use wp_get_attachment_image()
|
||||
* @see wp_get_attachment_image()
|
||||
*
|
||||
* @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) {
|
||||
_deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' );
|
||||
$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);
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieve bookmark data based on ID.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @deprecated 2.1.0
|
||||
* @deprecated Use get_bookmark()
|
||||
* @see get_bookmark()
|
||||
*
|
||||
* @param int $bookmark_id ID of link
|
||||
* @param string $output OBJECT, ARRAY_N, or ARRAY_A
|
||||
* @return object|array
|
||||
*/
|
||||
function get_link($bookmark_id, $output = OBJECT, $filter = 'raw') {
|
||||
_deprecated_function( __FUNCTION__, '2.1', 'get_bookmark()' );
|
||||
return get_bookmark($bookmark_id, $output, $filter);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -1636,9 +1636,10 @@ endif;
|
|||
|
||||
if ( !function_exists('wp_setcookie') ) :
|
||||
/**
|
||||
* Sets a cookie for a user who just logged in.
|
||||
* Sets a cookie for a user who just logged in. This function is deprecated.
|
||||
*
|
||||
* @since 1.5
|
||||
* @deprecated 2.5
|
||||
* @deprecated Use wp_set_auth_cookie()
|
||||
* @see wp_set_auth_cookie()
|
||||
*
|
||||
|
@ -1658,9 +1659,10 @@ endif;
|
|||
|
||||
if ( !function_exists('wp_clearcookie') ) :
|
||||
/**
|
||||
* Clears the authentication cookie, logging the user out.
|
||||
* Clears the authentication cookie, logging the user out. This function is deprecated.
|
||||
*
|
||||
* @since 1.5
|
||||
* @deprecated 2.5
|
||||
* @deprecated Use wp_clear_auth_cookie()
|
||||
* @see wp_clear_auth_cookie()
|
||||
*/
|
||||
|
@ -1672,25 +1674,26 @@ endif;
|
|||
|
||||
if ( !function_exists('wp_get_cookie_login') ):
|
||||
/**
|
||||
* Gets the user cookie login.
|
||||
* Gets the user cookie login. This function is deprecated.
|
||||
*
|
||||
* This function is deprecated and should no longer be extended as it won't be
|
||||
* used anywhere in WordPress. Also, plugins shouldn't use it either.
|
||||
*
|
||||
* @since 2.0.3
|
||||
* @deprecated 2.5
|
||||
* @deprecated No alternative
|
||||
*
|
||||
* @return bool Always returns false
|
||||
*/
|
||||
function wp_get_cookie_login() {
|
||||
_deprecated_function( __FUNCTION__, '2.5', '' );
|
||||
_deprecated_function( __FUNCTION__, '2.5' );
|
||||
return false;
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( !function_exists('wp_login') ) :
|
||||
/**
|
||||
* Checks a users login information and logs them in if it checks out.
|
||||
* Checks a users login information and logs them in if it checks out. This function is deprecated.
|
||||
*
|
||||
* Use the global $error to get the reason why the login failed. If the username
|
||||
* is blank, no error will be set, so assume blank username on that case.
|
||||
|
@ -1709,6 +1712,7 @@ if ( !function_exists('wp_login') ) :
|
|||
* @return bool False on login failure, true on successful check
|
||||
*/
|
||||
function wp_login($username, $password, $deprecated = '') {
|
||||
_deprecated_function( __FUNCTION__, '2.5', 'wp_signon()' );
|
||||
global $error;
|
||||
|
||||
$user = wp_authenticate($username, $password);
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue