Replace use of global $user_ID in favor of get_current_user_id(). fixes #25372.

git-svn-id: https://develop.svn.wordpress.org/trunk@25669 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90)
2013-10-02 21:09:52 +00:00
parent dac3f63f9c
commit 6311fbbfdb
4 changed files with 22 additions and 22 deletions

View File

@@ -2140,7 +2140,7 @@ class WP_Query {
* @return array List of posts.
*/
function get_posts() {
global $wpdb, $user_ID;
global $wpdb;
$this->parse_query();
@@ -2713,18 +2713,20 @@ class WP_Query {
unset($p_status);
}
$user_id = get_current_user_id();
if ( !empty($e_status) ) {
$statuswheres[] = "(" . join( ' AND ', $e_status ) . ")";
}
if ( !empty($r_status) ) {
if ( !empty($q['perm'] ) && 'editable' == $q['perm'] && !current_user_can($edit_others_cap) )
$statuswheres[] = "($wpdb->posts.post_author = $user_ID " . "AND (" . join( ' OR ', $r_status ) . "))";
$statuswheres[] = "($wpdb->posts.post_author = $user_id " . "AND (" . join( ' OR ', $r_status ) . "))";
else
$statuswheres[] = "(" . join( ' OR ', $r_status ) . ")";
}
if ( !empty($p_status) ) {
if ( !empty($q['perm'] ) && 'readable' == $q['perm'] && !current_user_can($read_private_cap) )
$statuswheres[] = "($wpdb->posts.post_author = $user_ID " . "AND (" . join( ' OR ', $p_status ) . "))";
$statuswheres[] = "($wpdb->posts.post_author = $user_id " . "AND (" . join( ' OR ', $p_status ) . "))";
else
$statuswheres[] = "(" . join( ' OR ', $p_status ) . ")";
}
@@ -2757,7 +2759,7 @@ class WP_Query {
// Add private states that are limited to viewing by the author of a post or someone who has caps to read private states.
$private_states = get_post_stati( array('private' => true) );
foreach ( (array) $private_states as $state )
$where .= current_user_can( $read_private_cap ) ? " OR $wpdb->posts.post_status = '$state'" : " OR $wpdb->posts.post_author = $user_ID AND $wpdb->posts.post_status = '$state'";
$where .= current_user_can( $read_private_cap ) ? " OR $wpdb->posts.post_status = '$state'" : " OR $wpdb->posts.post_author = $user_id AND $wpdb->posts.post_status = '$state'";
}
$where .= ')';