diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index e63058fb60..8cc38019ee 100644 --- a/wp-includes/comment-template.php +++ b/wp-includes/comment-template.php @@ -545,11 +545,11 @@ function comments_link( $deprecated = '', $deprecated_2 = '' ) { * @return int The number of comments a post has */ function get_comments_number( $post_id = 0 ) { + $post_id = absint( $post_id ); + if ( !$post_id ) $post_id = get_the_ID(); - $post_id = absint($post_id); - $post = get_post($post_id); if ( ! isset($post->comment_count) ) $count = 0; diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index d1f2413d0e..c0dffbd42c 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -461,13 +461,13 @@ function get_feed_link($feed = '') { * @param string $feed Optional. Feed type. * @return string */ -function get_post_comments_feed_link($post_id = '', $feed = '') { - if ( !$post_id ) +function get_post_comments_feed_link($post_id = 0, $feed = '') { + $post_id = absint( $post_id ); + + if ( ! $post_id ) $post_id = get_the_ID(); - $post_id = absint($post_id); - - if ( empty($feed) ) + if ( empty( $feed ) ) $feed = get_default_feed(); if ( '' != get_option('permalink_structure') ) { diff --git a/wp-includes/post.php b/wp-includes/post.php index b9ca5b6f77..cab70ced0b 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -1267,16 +1267,16 @@ function delete_post_meta_by_key($post_meta_key) { * @param int $post_id post ID * @return array */ -function get_post_custom($post_id = 0) { - if ( !$post_id ) +function get_post_custom( $post_id = 0 ) { + $post_id = absint( $post_id ); + + if ( ! $post_id ) $post_id = get_the_ID(); - $post_id = (int) $post_id; + if ( ! wp_cache_get( $post_id, 'post_meta' ) ) + update_postmeta_cache( $post_id ); - if ( ! wp_cache_get($post_id, 'post_meta') ) - update_postmeta_cache($post_id); - - return wp_cache_get($post_id, 'post_meta'); + return wp_cache_get( $post_id, 'post_meta' ); } /** @@ -1333,18 +1333,18 @@ function get_post_custom_values( $key = '', $post_id = 0 ) { * @param int $post_id Optional. Post ID. * @return bool Whether post is sticky. */ -function is_sticky($post_id = null) { - if ( !$post_id ) +function is_sticky( $post_id = 0 ) { + $post_id = absint( $post_id ); + + if ( ! $post_id ) $post_id = get_the_ID(); - $post_id = absint($post_id); + $stickies = get_option( 'sticky_posts' ); - $stickies = get_option('sticky_posts'); - - if ( !is_array($stickies) ) + if ( ! is_array( $stickies ) ) return false; - if ( in_array($post_id, $stickies) ) + if ( in_array( $post_id, $stickies ) ) return true; return false;