Make WordPress Core


Ignore:
Timestamp:
10/02/2013 09:09:52 PM (11 years ago)
Author:
ocean90
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r25661 r25669  
    26562656 *
    26572657 * @global wpdb $wpdb    WordPress database abstraction object.
    2658  * @global int  $user_ID
    26592658 *
    26602659 * @since 1.0.0
     
    26672666 *     @type string 'post_status'           The post status. Default 'draft'.
    26682667 *     @type string 'post_type'             The post type. Default 'post'.
    2669  *     @type int    'post_author'           The ID of the user who added the post. Default $user_ID, the current user ID.
     2668 *     @type int    'post_author'           The ID of the user who added the post. Default the current user ID.
    26702669 *     @type bool   'ping_status'           Whether the post can accept pings. Default value of 'default_ping_status' option.
    26712670 *     @type int    'post_parent'           Set this for the post it belongs to, if any. Default 0.
     
    26832682 */
    26842683function wp_insert_post( $postarr, $wp_error = false ) {
    2685     global $wpdb, $user_ID;
    2686 
    2687     $defaults = array('post_status' => 'draft', 'post_type' => 'post', 'post_author' => $user_ID,
     2684    global $wpdb;
     2685
     2686    $user_id = get_current_user_id();
     2687
     2688    $defaults = array('post_status' => 'draft', 'post_type' => 'post', 'post_author' => $user_id,
    26882689        'ping_status' => get_option('default_ping_status'), 'post_parent' => 0,
    26892690        'menu_order' => 0, 'to_ping' =>  '', 'pinged' => '', 'post_password' => '',
     
    27502751
    27512752    if ( empty($post_author) )
    2752         $post_author = $user_ID;
     2753        $post_author = $user_id;
    27532754
    27542755    // Don't allow contributors to set the post slug for pending review posts
     
    39443945 * @since 2.0.0
    39453946 * @uses $wpdb
    3946  * @uses $user_ID
    39473947 * @uses do_action() Calls 'edit_attachment' on $post_ID if this is an update.
    39483948 * @uses do_action() Calls 'add_attachment' on $post_ID if this is not an update.
     
    39543954 */
    39553955function wp_insert_attachment($object, $file = false, $parent = 0) {
    3956     global $wpdb, $user_ID;
    3957 
    3958     $defaults = array('post_status' => 'inherit', 'post_type' => 'post', 'post_author' => $user_ID,
     3956    global $wpdb;
     3957
     3958    $user_id = get_current_user_id();
     3959
     3960    $defaults = array('post_status' => 'inherit', 'post_type' => 'post', 'post_author' => $user_id,
    39593961        'ping_status' => get_option('default_ping_status'), 'post_parent' => 0, 'post_title' => '',
    39603962        'menu_order' => 0, 'to_ping' =>  '', 'pinged' => '', 'post_password' => '', 'post_content' => '',
     
    39733975
    39743976    if ( empty($post_author) )
    3975         $post_author = $user_ID;
     3977        $post_author = $user_id;
    39763978
    39773979    $post_type = 'attachment';
     
    44974499 * @since 2.2.0
    44984500 *
    4499  * @uses $user_ID
    4500  *
    45014501 * @param string $post_type currently only supports 'post' or 'page'.
    45024502 * @return string SQL code that can be added to a where clause.
     
    45194519 */
    45204520function get_posts_by_author_sql( $post_type, $full = true, $post_author = null, $public_only = false ) {
    4521     global $user_ID, $wpdb;
     4521    global $wpdb;
    45224522
    45234523    // Private posts
     
    45494549        } elseif ( is_user_logged_in() ) {
    45504550            // Users can view their own private posts.
    4551             $id = (int) $user_ID;
     4551            $id = get_current_user_id();
    45524552            if ( null === $post_author || ! $full ) {
    45534553                $sql .= " OR post_status = 'private' AND post_author = $id";
Note: See TracChangeset for help on using the changeset viewer.