Here's a bit of code to be sure I'm not doing anything wrong...
function wp_myplug_rewrite_rules($rules)
{
WPD_print("in wp_myplug_rewrite_rules");
global $wp_rewrite,$wpdb,$wp_myplug_prefix;
$table_name = $wpdb->prefix . $wp_myplug_prefix."_links";
$results = $wpdb->get_results("SELECT * FROM ".$table_name,OBJECT);
$new_rules=Array();
if($results)
{
foreach($results as $result) {
WPD_print(" --> " . get_category_slug($result->category) . " => " . $result->slug);
$the_slug = substr(get_category_slug($result->category)."/".$result->slug,1);
$new_rules[$the_slug."$"]='index.php?wpaaction=wp_myplug_redirect&wpaslug='.urlencode($result->slug);
}
$new_rules=array_merge($new_rules,$rules);
}
WPD_print("out wp_myplug_rewrite_rules");
return $new_rules;
}
function wp_myplug_init()
{
global $wp_rewrite;
WPD_print("wp_myplug_init");
if (isset($wp_rewrite) && $wp_rewrite->using_permalinks()) {
WPD_print(" in if");
add_filter('rewrite_rules_array', 'wp_myplug_rewrite_rules');
add_filter('query_vars','wp_myplug_add_query_vars');
add_action('parse_request','wp_myplug_parse_request');
WPD_print(" after if");
}
}
add_action('init','wp_myplug_init');
The WPD_print function simply logs a debug statement in my footer.
I can see that it does go in the IF statement with two add_filters and add_action, but the code in the rewrite_rules_array never gets executed...
What am I doing wrong here?