title: Create custom rewrite rule for my WordPress plugin
body: <p>I'm writing a plug-in for WordPress which in fact will be a separate ordering module (it will be placed in an IFRAME on the site I'm developing as well as others) but with its admin tied into WordPress. I wrote the administration part without too much hassle, however I'm having trouble with the front-end.</p>
  
  <p>First of all I'd like my script to be accessible via www.mysite.com/order/ and, <a href="http://codex.wordpress.org/Custom_Queries#Permalinks_for_Custom_Archives" rel="nofollow noreferrer">as per the WordPress codex</a>, I found I need to place the following code into my main plugin file:</p>
  
  <pre><code>add_action('init', 'ta_flush_rewrite_rules');
  
  function ta_flush_rewrite_rules() 
  {
    global $wp_rewrite;
    $wp_rewrite-&gt;flush_rules();
  }
  
  add_action('generate_rewrite_rules', 'ta_add_rewrite_rules');
  
  function ta_add_rewrite_rules( $wp_rewrite ) {
    $new_rules = array("order/(.+)" =&gt; "/wp-content/plugins/my-plugin/order.php");
    $wp_rewrite-&gt;rules = $new_rules + $wp_rewrite-&gt;rules;
  }
  </code></pre>
  
  <p>But it doesn't work and I don't really want to get dirty with .htaccess hacking.</p>
  
  <p>Furthermore even if this would work, the order.php file is a separate file from my plugin. This means that I'll have to include some WordPress files in order to have access to the database and other helper classes and functions. That brings us to question number 2: is there a way for the URL to call a function of my plugin to render the order page?</p>