title: Wordpress REST Api: add_action( 'rest_api_init', callback) does not call the callback
body: <p><strong>Problem:</strong></p>
  <p>I'm trying to register a custom endpoint for a Wordpress plugin. The problem I face is that when I call the add_action('rest_api_init', callback), the callback function is not being called. In that callback function lives the &quot;register_rest_route()&quot; method, which in it's turn is not being called and I am unable to register any custom endpoints.</p>
  <ul>
  <li>I'm using docker for development</li>
  <li>No errors are being thrown</li>
  </ul>
  <p><strong>Code:</strong></p>
  <pre><code>public function register()
      {
          $this-&gt;setup_init();
  
      }
      
      public function setup_init()
      {
          var_dump('print1');
  
          add_action('rest_api_init', array($this, 'register_custom_endpoints'));
      }
      
      public function register_custom_endpoints()
      {
  
          var_dump('print2');
          die();
  
          register_rest_route('test', '/test', array(
              'methods'  =&gt; 'GET',
              'callback' =&gt; 'menu_setup',
          ));
      }
  </code></pre>
  <p><strong>Question:</strong></p>
  <p>The code reaches the &quot;var_dump('print1')&quot;, but the the &quot;var_dump('print2')&quot; is never reached. Am I missing something here?</p>