title: How to get Post ID in Wordpress Admin
body: <p>I'm developing a Wordpress plugin and I need to get the current <strong>Post ID</strong><br>
   in the <strong>Write Post / Write Page editing screen</strong> (outside the loop).  </p>
  
  <p>I also need to do it before the "admin_print_scripts" hook, since I would like to pass some data to a javascript file.</p>
  
  <p>I can't use:  </p>
  
  <pre><code>$id = $_GET['post'];
  </code></pre>
  
  <p>because the url doesn't include this variable when you are adding a new post or page.</p>
  
  <p>So far I've tried these options but none of them worked:  </p>
  
  <p>A) This returns an ID of 0</p>
  
  <pre><code>function myplugin_setup() {
      global $wp_query;
      $id = $wp_query-&gt;get_queried_object_id();
      var_dump($id);
  }
  
  add_action('admin_init', 'myplugin_setup' );  
  </code></pre>
  
  <p>B) This returns an ID of null</p>
  
  <pre><code>function myplugin_setup() {
      global $wp_query;
      $id = $wp_query-&gt;post-&gt;ID;
      var_dump($id);
  }
  
  add_action('admin_init', 'myplugin_setup' );
  </code></pre>
  
  <p>C) This also returns an ID of null</p>
  
  <pre><code>function myplugin_setup() {
      global $post;
      $id = $post-&gt;ID;
      var_dump($id);
  }
  
  add_action('admin_init', 'myplugin_setup' );
  </code></pre>