Last active
August 29, 2015 14:04
-
-
Save nickfox/dc3876f755fb395b6483 to your computer and use it in GitHub Desktop.
This file contains 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: rewrite test | |
Description: rewrite test | |
Author: Nick | |
Version: 1.0 | |
*/ | |
register_activation_hook(__FILE__, 'activate'); | |
function activate() | |
{ | |
// matches https://www.mycelltracker.com/tracker/8BA21D90-3F90-407F-BAAE-800B04B1F5EB | |
add_rewrite_rule('tracker/[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}/?', 'index.php?pagename=tracker&t=$matches[1]', 'top'); | |
//add_rewrite_tag('%tracker%','([^&]+)'); | |
flush_rewrite_rules(); | |
} | |
add_filter( 'query_vars', 'my_query_vars' ); | |
function my_query_vars($query_vars) | |
{ | |
$query_vars[] = 't'; | |
return $query_vars; | |
} | |
add_filter('template_redirect', 'my_template_redirect'); | |
function my_template_redirect() | |
{ | |
exit(var_dump(get_query_var('t'))); | |
} | |
register_deactivation_hook(__FILE__, 'deactivate'); | |
function deactivate() | |
{ | |
flush_rewrite_rules(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment