Created
November 3, 2011 20:27
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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