Skip to content

Instantly share code, notes, and snippets.

@enru
Created November 3, 2011 20:27
Show Gist options
  • Select an option

  • Save enru/1337686 to your computer and use it in GitHub Desktop.

Select an option

Save enru/1337686 to your computer and use it in GitHub Desktop.
An example of how to give a WordPress plugin it's own URL/route
<?php
/*
Plugin Name: redirect/routes test
Plugin URI: http://blog.enru.co.uk/2011-11-04-wordpress-plugin-with-own-url.html
Description: An example of how to give a WordPress plugin it's own URL/route
Version: 0.1
Author: Neill Russell
Author URI: http://www.enru.co.uk
License: Beerware
*/
add_action('init', 'my_rewrite');
function my_rewrite() {
global $wp_rewrite;
add_rewrite_rule('redir/$', WP_PLUGIN_URL . '/redir.php', 'top');
$wp_rewrite->flush_rules(true); // This should really be done in a plugin activation
}
add_filter ( 'the_content', 'content_filter');
function content_filter() {
return 'beer';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment