Don't use the global anymore. Fixes #11624
git-svn-id: http://svn.automattic.com/wordpress/trunk@15549 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
bc0c1bb3f0
commit
950901ca92
|
@ -545,11 +545,10 @@ function comments_link( $deprecated = '', $deprecated_2 = '' ) {
|
||||||
* @return int The number of comments a post has
|
* @return int The number of comments a post has
|
||||||
*/
|
*/
|
||||||
function get_comments_number( $post_id = 0 ) {
|
function get_comments_number( $post_id = 0 ) {
|
||||||
global $id;
|
|
||||||
$post_id = (int) $post_id;
|
|
||||||
|
|
||||||
if ( !$post_id )
|
if ( !$post_id )
|
||||||
$post_id = (int) $id;
|
$post_id = get_the_ID();
|
||||||
|
|
||||||
|
$post_id = absint($post_id);
|
||||||
|
|
||||||
$post = get_post($post_id);
|
$post = get_post($post_id);
|
||||||
if ( ! isset($post->comment_count) )
|
if ( ! isset($post->comment_count) )
|
||||||
|
@ -564,7 +563,6 @@ function get_comments_number( $post_id = 0 ) {
|
||||||
* Display the language string for the number of comments the current post has.
|
* Display the language string for the number of comments the current post has.
|
||||||
*
|
*
|
||||||
* @since 0.71
|
* @since 0.71
|
||||||
* @uses $id
|
|
||||||
* @uses apply_filters() Calls the 'comments_number' hook on the output and number of comments respectively.
|
* @uses apply_filters() Calls the 'comments_number' hook on the output and number of comments respectively.
|
||||||
*
|
*
|
||||||
* @param string $zero Text for no comments
|
* @param string $zero Text for no comments
|
||||||
|
@ -573,12 +571,10 @@ function get_comments_number( $post_id = 0 ) {
|
||||||
* @param string $deprecated Not used.
|
* @param string $deprecated Not used.
|
||||||
*/
|
*/
|
||||||
function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {
|
function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {
|
||||||
global $id;
|
|
||||||
|
|
||||||
if ( !empty( $deprecated ) )
|
if ( !empty( $deprecated ) )
|
||||||
_deprecated_argument( __FUNCTION__, '1.3' );
|
_deprecated_argument( __FUNCTION__, '1.3' );
|
||||||
|
|
||||||
$number = get_comments_number($id);
|
$number = get_comments_number(get_the_ID());
|
||||||
|
|
||||||
if ( $number > 1 )
|
if ( $number > 1 )
|
||||||
$output = str_replace('%', number_format_i18n($number), ( false === $more ) ? __('% Comments') : $more);
|
$output = str_replace('%', number_format_i18n($number), ( false === $more ) ? __('% Comments') : $more);
|
||||||
|
@ -703,16 +699,14 @@ function comment_type($commenttxt = false, $trackbacktxt = false, $pingbacktxt =
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @uses apply_filters() Calls 'trackback_url' on the resulting trackback URL
|
* @uses apply_filters() Calls 'trackback_url' on the resulting trackback URL
|
||||||
* @uses $id
|
|
||||||
*
|
*
|
||||||
* @return string The trackback URL after being filtered
|
* @return string The trackback URL after being filtered
|
||||||
*/
|
*/
|
||||||
function get_trackback_url() {
|
function get_trackback_url() {
|
||||||
global $id;
|
|
||||||
if ( '' != get_option('permalink_structure') ) {
|
if ( '' != get_option('permalink_structure') ) {
|
||||||
$tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback');
|
$tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback');
|
||||||
} else {
|
} else {
|
||||||
$tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . $id;
|
$tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . get_the_ID();
|
||||||
}
|
}
|
||||||
return apply_filters('trackback_url', $tb_url);
|
return apply_filters('trackback_url', $tb_url);
|
||||||
}
|
}
|
||||||
|
@ -844,7 +838,6 @@ function wp_comment_form_unfiltered_html_nonce() {
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @global array $comment List of comment objects for the current post
|
* @global array $comment List of comment objects for the current post
|
||||||
* @uses $wpdb
|
* @uses $wpdb
|
||||||
* @uses $id
|
|
||||||
* @uses $post
|
* @uses $post
|
||||||
* @uses $withcomments Will not try to get the comments if the post has none.
|
* @uses $withcomments Will not try to get the comments if the post has none.
|
||||||
*
|
*
|
||||||
|
@ -961,7 +954,6 @@ function comments_popup_script($width=400, $height=400, $file='') {
|
||||||
* lists of posts
|
* lists of posts
|
||||||
*
|
*
|
||||||
* @since 0.71
|
* @since 0.71
|
||||||
* @uses $id
|
|
||||||
* @uses $wpcommentspopupfile
|
* @uses $wpcommentspopupfile
|
||||||
* @uses $wpcommentsjavascript
|
* @uses $wpcommentsjavascript
|
||||||
* @uses $post
|
* @uses $post
|
||||||
|
@ -974,7 +966,9 @@ function comments_popup_script($width=400, $height=400, $file='') {
|
||||||
* @return null Returns null on single posts and pages.
|
* @return null Returns null on single posts and pages.
|
||||||
*/
|
*/
|
||||||
function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) {
|
function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) {
|
||||||
global $id, $wpcommentspopupfile, $wpcommentsjavascript;
|
global $wpcommentspopupfile, $wpcommentsjavascript;
|
||||||
|
|
||||||
|
$id = get_the_ID();
|
||||||
|
|
||||||
if ( false === $zero ) $zero = __( 'No Comments' );
|
if ( false === $zero ) $zero = __( 'No Comments' );
|
||||||
if ( false === $one ) $one = __( '1 Comment' );
|
if ( false === $one ) $one = __( '1 Comment' );
|
||||||
|
@ -1168,7 +1162,7 @@ function cancel_comment_reply_link($text = '') {
|
||||||
* @return string Hidden input HTML for replying to comments
|
* @return string Hidden input HTML for replying to comments
|
||||||
*/
|
*/
|
||||||
function get_comment_id_fields() {
|
function get_comment_id_fields() {
|
||||||
global $id;
|
$id = get_the_ID();
|
||||||
|
|
||||||
$replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
|
$replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
|
||||||
$result = "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n";
|
$result = "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n";
|
||||||
|
|
|
@ -462,10 +462,10 @@ function get_feed_link($feed = '') {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function get_post_comments_feed_link($post_id = '', $feed = '') {
|
function get_post_comments_feed_link($post_id = '', $feed = '') {
|
||||||
global $id;
|
if ( !$post_id )
|
||||||
|
$post_id = get_the_ID();
|
||||||
|
|
||||||
if ( empty($post_id) )
|
$post_id = absint($post_id);
|
||||||
$post_id = (int) $id;
|
|
||||||
|
|
||||||
if ( empty($feed) )
|
if ( empty($feed) )
|
||||||
$feed = get_default_feed();
|
$feed = get_default_feed();
|
||||||
|
|
|
@ -12,24 +12,22 @@
|
||||||
* Display the ID of the current item in the WordPress Loop.
|
* Display the ID of the current item in the WordPress Loop.
|
||||||
*
|
*
|
||||||
* @since 0.71
|
* @since 0.71
|
||||||
* @uses $id
|
|
||||||
*/
|
*/
|
||||||
function the_ID() {
|
function the_ID() {
|
||||||
global $id;
|
echo get_the_ID();
|
||||||
echo $id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the ID of the current item in the WordPress Loop.
|
* Retrieve the ID of the current item in the WordPress Loop.
|
||||||
*
|
*
|
||||||
* @since 2.1.0
|
* @since 2.1.0
|
||||||
* @uses $id
|
* @uses $post
|
||||||
*
|
*
|
||||||
* @return unknown
|
* @return int
|
||||||
*/
|
*/
|
||||||
function get_the_ID() {
|
function get_the_ID() {
|
||||||
global $id;
|
global $post;
|
||||||
return $id;
|
return $post->ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -181,7 +179,7 @@ function the_content($more_link_text = null, $stripteaser = 0) {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function get_the_content($more_link_text = null, $stripteaser = 0) {
|
function get_the_content($more_link_text = null, $stripteaser = 0) {
|
||||||
global $id, $post, $more, $page, $pages, $multipage, $preview;
|
global $post, $more, $page, $pages, $multipage, $preview;
|
||||||
|
|
||||||
if ( null === $more_link_text )
|
if ( null === $more_link_text )
|
||||||
$more_link_text = __( '(more...)' );
|
$more_link_text = __( '(more...)' );
|
||||||
|
@ -216,10 +214,10 @@ function get_the_content($more_link_text = null, $stripteaser = 0) {
|
||||||
$output .= $teaser;
|
$output .= $teaser;
|
||||||
if ( count($content) > 1 ) {
|
if ( count($content) > 1 ) {
|
||||||
if ( $more ) {
|
if ( $more ) {
|
||||||
$output .= '<span id="more-' . $id . '"></span>' . $content[1];
|
$output .= '<span id="more-' . $post->ID . '"></span>' . $content[1];
|
||||||
} else {
|
} else {
|
||||||
if ( ! empty($more_link_text) )
|
if ( ! empty($more_link_text) )
|
||||||
$output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink() . "#more-$id\" class=\"more-link\">$more_link_text</a>", $more_link_text );
|
$output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink() . "#more-{$post->ID}\" class=\"more-link\">$more_link_text</a>", $more_link_text );
|
||||||
$output = force_balance_tags($output);
|
$output = force_balance_tags($output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,7 @@
|
||||||
* @return bool Whether post has an image attached.
|
* @return bool Whether post has an image attached.
|
||||||
*/
|
*/
|
||||||
function has_post_thumbnail( $post_id = NULL ) {
|
function has_post_thumbnail( $post_id = NULL ) {
|
||||||
global $id;
|
$post_id = ( NULL === $post_id ) ? get_the_ID() : $post_id;
|
||||||
$post_id = ( NULL === $post_id ) ? $id : $post_id;
|
|
||||||
return !! get_post_thumbnail_id( $post_id );
|
return !! get_post_thumbnail_id( $post_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,8 +31,7 @@ function has_post_thumbnail( $post_id = NULL ) {
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function get_post_thumbnail_id( $post_id = NULL ) {
|
function get_post_thumbnail_id( $post_id = NULL ) {
|
||||||
global $id;
|
$post_id = ( NULL === $post_id ) ? get_the_ID() : $post_id;
|
||||||
$post_id = ( NULL === $post_id ) ? $id : $post_id;
|
|
||||||
return get_post_meta( $post_id, '_thumbnail_id', true );
|
return get_post_meta( $post_id, '_thumbnail_id', true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,8 +57,7 @@ function the_post_thumbnail( $size = 'post-thumbnail', $attr = '' ) {
|
||||||
* @param string|array $attr Optional. Query string or array of attributes.
|
* @param string|array $attr Optional. Query string or array of attributes.
|
||||||
*/
|
*/
|
||||||
function get_the_post_thumbnail( $post_id = NULL, $size = 'post-thumbnail', $attr = '' ) {
|
function get_the_post_thumbnail( $post_id = NULL, $size = 'post-thumbnail', $attr = '' ) {
|
||||||
global $id;
|
$post_id = ( NULL === $post_id ) ? get_the_ID() : $post_id;
|
||||||
$post_id = ( NULL === $post_id ) ? $id : $post_id;
|
|
||||||
$post_thumbnail_id = get_post_thumbnail_id( $post_id );
|
$post_thumbnail_id = get_post_thumbnail_id( $post_id );
|
||||||
$size = apply_filters( 'post_thumbnail_size', $size );
|
$size = apply_filters( 'post_thumbnail_size', $size );
|
||||||
if ( $post_thumbnail_id ) {
|
if ( $post_thumbnail_id ) {
|
||||||
|
@ -73,4 +70,4 @@ function get_the_post_thumbnail( $post_id = NULL, $size = 'post-thumbnail', $att
|
||||||
return apply_filters( 'post_thumbnail_html', $html, $post_id, $post_thumbnail_id, $size, $attr );
|
return apply_filters( 'post_thumbnail_html', $html, $post_id, $post_thumbnail_id, $size, $attr );
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1268,10 +1268,8 @@ function delete_post_meta_by_key($post_meta_key) {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function get_post_custom($post_id = 0) {
|
function get_post_custom($post_id = 0) {
|
||||||
global $id;
|
|
||||||
|
|
||||||
if ( !$post_id )
|
if ( !$post_id )
|
||||||
$post_id = (int) $id;
|
$post_id = get_the_ID();
|
||||||
|
|
||||||
$post_id = (int) $post_id;
|
$post_id = (int) $post_id;
|
||||||
|
|
||||||
|
@ -1336,13 +1334,11 @@ function get_post_custom_values( $key = '', $post_id = 0 ) {
|
||||||
* @return bool Whether post is sticky.
|
* @return bool Whether post is sticky.
|
||||||
*/
|
*/
|
||||||
function is_sticky($post_id = null) {
|
function is_sticky($post_id = null) {
|
||||||
global $id;
|
if ( !$post_id )
|
||||||
|
$post_id = get_the_ID();
|
||||||
|
|
||||||
$post_id = absint($post_id);
|
$post_id = absint($post_id);
|
||||||
|
|
||||||
if ( !$post_id )
|
|
||||||
$post_id = absint($id);
|
|
||||||
|
|
||||||
$stickies = get_option('sticky_posts');
|
$stickies = get_option('sticky_posts');
|
||||||
|
|
||||||
if ( !is_array($stickies) )
|
if ( !is_array($stickies) )
|
||||||
|
|
Loading…
Reference in New Issue