title: How to add a nonce to an inline script in WordPress
body: <p>I'm trying to add a nonce to the inline scripts inserted in WordPress by wp_add_inline_script and wp_localize_script, but I can't figure out how to do it. It looks there are no WordPress filters for that. My goal is to have a nonce for inline scripts, so I can define a Content Security Policy that would not break common plugins that insert inline scripts. At the end the result should be something that looks like:</p>
  
  <pre><code>&lt;script type="text/javascript" nonce="xxxxxxxxxx"&gt;....&lt;/script&gt;
  </code></pre>
  
  <p>where xxxxxxxx is the nonce.</p>
  
  <p>Do you have any ideas?</p>