Php scoping questions in reference to singletons, globals, wordpress, and wordpress plugins -
i'm having trouble getting wordpress json-api update post api call work. i'm current on wordpress 3.8.1, json-api 1.1.1, , json-api-auth 1.7. i'm using wordpress json-api-auth plugin return nonce , cookie update_post api call. after that, use call update_post endpoint update post exists. using error_log cmd, have found issue lies in block of code:
wp-includes/query.php (in get_posts method) 2971 // check post status determine if post should displayed. 2972 if ( !empty($this->posts) && ($this->is_single || $this->is_page) ) { 2973 $status = get_post_status($this->posts[0]); 2974 $post_status_obj = get_post_status_object($status); 2975 //$type = get_post_type($this->posts[0]); 2976 if ( !$post_status_obj->public ) { 2977 if ( ! is_user_logged_in() ) { 2978 // user must logged in view unpublished posts. 2979 $this->posts = array(); 2980 } else { 2981 if ( $post_status_obj->protected ) { 2982 // user must have edit permissions on draft preview. 2983 if ( ! current_user_can($edit_cap, $this->posts[0]->id) ) { 2984 $this->posts = array(); 2985 } else { 2986 $this->is_preview = true; 2987 if ( 'future' != $status ) 2988 $this->posts[0]->post_date = current_time('mysql'); 2989 } 2990 } elseif ( $post_status_obj->private ) { 2991 if ( ! current_user_can($read_cap, $this->posts[0]->id) ) 2992 $this->posts = array(); 2993 } else { 2994 $this->posts = array(); 2995 } 2996 } 2997 } the call is_user_logged_in() returning false because $current_user == 0, logged in according api. have tried create json_user global variable in generate_auth_cookie (wp-content/plugins/json-api-auth/controllers/auth.php) , set current_user variable in set_posts_query function (wp-content/plugins/json-api/singletons/introspector.php) before calling query_posts function in wp-includes/query.php. error_log returns $current_user->id still 0 after $current_user = $json_user. i'm sure there i'm missing , workaround idea terrible. how change $current_user object other 0?
Comments
Post a Comment