Question: Most solutions I found are for front-end use. This is for a plugin, so the all activity is in the back-end.

How do I get the page ID that's being currently use(edited) in the admin?

**Note** I'm out of the loop. I just need to get the ID of page(not posts) that I'm currently seeing in the back-end.

Answer: 
This is probably the "most secure" way of checking what the current post is on the post edit (and add) page in wp admin.

```
function wpse114111_get_current_post_id(): ?WP_Post {
    global $post;

        if (empty($post) && array_key_exists('post', $_GET)) {
            $post = get_post($_GET['post']);
        }

        // Optional: get an empty post object from the post_type
        if (empty($post) && array_key_exists('post_type', $_GET)) {
            $object = new stdClass();
            $object->post_type = $_GET['post_type'];
            return new WP_Post($object);
        }

        if (empty($post)) {
            return null;
        }

        return $post;
}

```
You just use this code in the **functions.php** file, It will give you a current edit page or post ID

```
function get_the_current_page_id(){
$post_id = null;
if( isset( $_REQUEST['post']) || isset($_REQUEST['post_ID'] ) ){
    $post_id = empty( $_REQUEST['post_ID'] ) ? $_REQUEST['post'] : $_REQUEST['post_ID' ];
}

//print_r($post_id) For check
//die();
}

//get_the_current_page_id() //Call the function

```