title: How to add target=_blank automatically to PDF links using PHP?
body: <p>I'm wondering is it possible to automatically add <code>target=_blank</code> to any PDF link I have on my website, so that it will convert</p>
  
  <pre><code>&lt;a href="pdf1.pdf"&gt;link text&lt;/a&gt;
  &lt;a href="pdf2.pdf"&gt;link text&lt;/a&gt;
  </code></pre>
  
  <p>to</p>
  
  <pre><code>&lt;a href="Pdf1.pdf" target="_blank"&gt;link text&lt;/a&gt;
  &lt;a href="Pdf2.pdf" target="_blank"&gt;link text&lt;/a&gt;
  </code></pre>
  
  <p>as this site has a lot of PDFs, and it would be easier to do this automatically rather than have to set them all one-by-one.</p>
  
  <p>I have tried the Javascript solution:</p>
  
  <pre><code>$(".newWindow a[href$='pdf']").attr('target','_blank');
  </code></pre>
  
  <p>But am wondering is there a way to do this automatically in PHP, perhaps by adding something to Wordpress's functions file?</p>