I have a plugin where I need to reserve some slugs so I am using the filters wp_unique_post_slug_is_bad_flat_slug
and wp_unique_post_slug_is_bad_hierarchical_slug
. I apply them like this on my plugin code:
if ( is_admin() ) {
add_filter( 'wp_unique_post_slug_is_bad_hierarchical_slug', 'is_bad_hierarchical_slug', 10, 4 );
add_filter( 'wp_unique_post_slug_is_bad_flat_slug', 'is_bad_flat_slug', 10, 3 );
}
Is using is_admin()
correct? Or should I check for other user roles or just not check for anything and just apply them always?