"Some" may call this all kinds of things, but that doesn't make "them" correct.
As a "page load" problem, these classes are trivial. They add very few characters to a page.
As a security problem, also trivial. Most have zero security consequence at all-- so what it this is a "page"--, and those that do have only minor consequences and only if the custom template is written very, very poorly. Additionally, most template names can be guessed by thinking about the template hierarchy built into Core, so removing the classes gains you very little. What you've got is something closely related to "premature optimization".
You should also be aware that removing the classes could potentially break formatting provided by themes or plugins, as these can, and reasonable should be able to, depend upon Core classes.
You are also removing admin-bar
and logged-in
classes, which could effect Core
functionality.
However, the body_class
filter lets you do what you want. The following will very aggressively remove all but the postid-{ID}
class.
function body_class_wpse_211556($classes) {
$qobj = get_queried_object();
// var_dump($qobj); die;
$classes = array();
if (!empty($qobj) && is_a($qobj,'wp_post')) {
$classes[] ='postid-'.$qobj->ID;
}
return $classes;
}
add_filter('body_class','body_class_wpse_211556',PHP_INT_MAX);