Avoid a PHP notice when using WP_Query::get_queried_object() in pre_get_posts action.

props wpsmith.
fixes #28412.
Built from https://develop.svn.wordpress.org/trunk@28667


git-svn-id: http://core.svn.wordpress.org/trunk@28485 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Move is_admin check to a more appropriate place.

see #11330.
Built from https://develop.svn.wordpress.org/trunk@28668


git-svn-id: http://core.svn.wordpress.org/trunk@28486 1a063a9b-81f0-0310-95a4-ce76da25c4cd