How to check if a rewrite rule exists

If I understand correctly then you can hook into the rewrite api/process and flush or manipulate the rules that way?
Read: Plugin Hooks on this page

http://codex.wordpress.org/Function_Reference/WP_Rewrite

Maybe something like:

// flush_rules() if our rules are not yet included
function my_flush_rules()
{
    $rules = get_option( 'rewrite_rules' );
    if ( ! isset( $rules['(project)/(\d*)$'] ) ) { 
        global $wp_rewrite; $wp_rewrite->flush_rules();
    }
}
add_action( 'wp_loaded','my_flush_rules' );

Leave a Comment