I need to get the current page id in WordPress plugin page outside the loop. And the code I wrote for getting current page id is in my plugin page.
page id
I guess that this is the proper solution:
$id = get_queried_object_id();
which equals to:
function get_queried_object_id() { global $wp_query; return $wp_query->get_queried_object_id(); }