title: In a Wordpress plugin, why doesn't `register_rest_route()` work when called in the activation hook?
body: <p>I have this (example) plugin:</p>
  
  <pre><code>&lt;?php
  /*
  Plugin Name: My Great Plugin
  */
  
  function hello() {
      return 'Hello, world!';
  }
  
  function my_great_plugin_init() {
      add_action( 'rest_api_init', function() {
          register_rest_route( 'great-plugin/v1', '/hello', array(
              'methods' =&gt; 'GET',
              'callback' =&gt; 'hello',
          ) );
      } );
  }
  
  register_activation_hook( __FILE__, 'my_great_plugin_init');
  ?&gt;
  </code></pre>
  
  <p>When I activate this plugin, the <code>/wp-json/great-plugin/v1/hello</code> route does not exist. However, if I move the <code>add_action</code> call to the top level, like so:</p>
  
  <pre><code>&lt;?php
  /*
  Plugin Name: My Great Plugin
  */
  
  function hello() {
      return 'Hello, world!';
  }
  
  add_action( 'rest_api_init', function() {
      register_rest_route( 'great-plugin/v1', '/hello', array(
          'methods' =&gt; 'GET',
          'callback' =&gt; 'hello',
      ) );
  } );
  ?&gt;
  </code></pre>
  
  <p>then the <code>/wp-json/great-plugin/v1/hello</code> route exists and responds to <code>GET</code> requests with <code>"Hello, world!"</code>. Why doesn't the endpoint get registered when the registration happens during the activation hook?</p>