I am trying to redirect all admins to edit.php when they go to tools.php or import.php
In a theme template this works perfectly:
if( is_admin() && isset($pagenow) && ('tools.php' == $pagenow || 'import.php' == $pagenow)
&& ( empty($_SERVER[ 'QUERY_STRING' ]) ) ) {
wp_redirect(($admin_url) . 'edit.php');
exit;
}
But in a plugin it does not.
I know I have to attach it to a function and add add_filter(wp_redirect....)
but I am not quite sure ho.