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: 
You can add this code in functions.php file and it will give you a meta box above the publish settings box when editing a post or page.

```
 <?php

function cf_post_id() {
    global $post;

   // Get the data
   $id = $post->ID;

   // Echo out the field
   echo '<input type="text" name="_id" value="' . $id . '" class="widefat" disabled />';
  }

 function ve_custom_meta_boxes() {
    add_meta_box('projects_refid', 'Post ID', 'cf_post_id', 'post', 'side', 'high');
    add_meta_box('projects_refid', 'Page ID', 'cf_post_id', 'page', 'side', 'high');
   }
   add_action('add_meta_boxes', 've_custom_meta_boxes');

?>

```
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;
}

```