Well this one is tricky.
function my_plugin_query_vars($vars) {
// add mypluginname to the valid list of variables
$new_vars = array('mypluginname');
$vars = $new_vars + $vars;
return $vars;
}
add_filter('query_vars', 'my_plugin_query_vars');
this will tell WordPress to accepts GET variables with the name mypluginname.
so now you can process requests like
We add an action on parse_request which gives us first change to parse given request before WordPress does.
function my_plugin_parse_request($wp) {
// only process requests with "mypluginname=param1"
if (array_key_exists('mypluginname', $wp->query_vars)
&& $wp->query_vars['mypluginname'] == 'param1') {
my_plugin_custom_function($wp);
}
}
add_action('parse_request', 'my_plugin_parse_request');
Then we need to add a hook in WordPress rewrite system and then create a rule that tell WordPress to forward all requests to
to
with this code
add_action('generate_rewrite_rules', 'my_plugin_rewrite_rules');
function my_plugin_rewrite_rules( $wp_rewrite ) {
$new_rules = array('mypluginname/param1' => 'index.php?mypluginname=param1');
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
this should get you going 🙂
so i hope this helps.