Make WordPress Core

Changeset 25669


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

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

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ajax-actions.php

    r25558 r25669  
    13731373
    13741374        // rename
    1375         $data['user_ID'] = $GLOBALS['user_ID'];
     1375        $data['user_ID'] = get_current_user_id();
    13761376
    13771377        if ( isset($data['post_parent']) )
  • trunk/src/wp-admin/includes/post.php

    r25505 r25669  
    5353                $post_data['to_ping'] = $post_data['trackback_url'];
    5454
    55         $post_data['user_ID'] = $GLOBALS['user_ID'];
     55        $post_data['user_ID'] = get_current_user_id();
    5656
    5757        if (!empty ( $post_data['post_author_override'] ) ) {
    … …  
    267267        add_meta( $post_ID );
    268268
    269         update_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );
     269        update_post_meta( $post_ID, '_edit_last', get_current_user_id() );
    270270
    271271        wp_update_post( $post_data );
    … …  
    539539 */
    540540function wp_write_post() {
    541         global $user_ID;
    542 
    543541        if ( isset($_POST['post_type']) )
    544542                $ptype = get_post_type_object($_POST['post_type']);
  • 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";
  • trunk/src/wp-includes/query.php

    r25668 r25669  
    21412141         */
    21422142        function get_posts() {
    2143                 global $wpdb, $user_ID;
     2143                global $wpdb;
    21442144
    21452145                $this->parse_query();
    … …  
    27142714                        }
    27152715
     2716                        $user_id = get_current_user_id();
     2717
    27162718                        if ( !empty($e_status) ) {
    27172719                                $statuswheres[] = "(" . join( ' AND ', $e_status ) . ")";
    … …  
    27192721                        if ( !empty($r_status) ) {
    27202722                                if ( !empty($q['perm'] ) && 'editable' == $q['perm'] && !current_user_can($edit_others_cap) )
    2721                                         $statuswheres[] = "($wpdb->posts.post_author = $user_ID " . "AND (" . join( ' OR ', $r_status ) . "))";
     2723                                        $statuswheres[] = "($wpdb->posts.post_author = $user_id " . "AND (" . join( ' OR ', $r_status ) . "))";
    27222724                                else
    27232725                                        $statuswheres[] = "(" . join( ' OR ', $r_status ) . ")";
    … …  
    27252727                        if ( !empty($p_status) ) {
    27262728                                if ( !empty($q['perm'] ) && 'readable' == $q['perm'] && !current_user_can($read_private_cap) )
    2727                                         $statuswheres[] = "($wpdb->posts.post_author = $user_ID " . "AND (" . join( ' OR ', $p_status ) . "))";
     2729                                        $statuswheres[] = "($wpdb->posts.post_author = $user_id " . "AND (" . join( ' OR ', $p_status ) . "))";
    27282730                                else
    27292731                                        $statuswheres[] = "(" . join( ' OR ', $p_status ) . ")";
    … …  
    27582760                                $private_states = get_post_stati( array('private' => true) );
    27592761                                foreach ( (array) $private_states as $state )
    2760                                         $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'";
     2762                                        $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'";
    27612763                        }
    27622764
Note: See TracChangeset for help on using the changeset viewer.