I'm trying to store query variables to a localized variable in the frontend of my plugin. rpSearch shows up like it should but page and share_id are "0" and "" respectively when I test the url with Monkeyman Rewrite Analyzer it looks like it should give me the data i need
function rewrite() {
add_rewrite_rule('^reseplanerare/dela/([^/]+)/?$','index.php?pagename=reseplanerare&page=share&share_id=$matches[1]', 'top');
add_rewrite_rule('^reseplanerare/planera/([^/]+)/?$', 'index.php?pagename=reseplanerare&page=plan', 'top');
}
function register_query_vars( $vars ) {
$vars[] = 'page';
$vars[] = 'share_id';
return $vars;
}
function public_enqueue_scripts() {
global $wp_query;
wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/public/main.js#module', array('jquery'), $this->plugin_ver,true);
wp_localize_script( $this->plugin_name, 'rpSearch', array(
'page' => urldecode($wp_query->query_vars['page']),
'share_id' => urldecode($wp_query->query_vars['share_id'])
));
}