Recommendations
-
I would recommend refactoring the plugin to use the post slug
$post->post_name
rather than picking apart the permalink structure. This method would also work on installs that do not use “pretty permalinks”.You should also consider sanitizing the added classes with sanitize_html_class().
I also think it would be a good idea to prefix the value with the posttype for example to prevent un-intended results.
( ie:{$posttype}_{$post->post_name}
)
This kind of change would break selectors for people using the current implementation though so an option would be needed for backwards compat.For example: A post/page with title “Hide” on a site using the popular twitter bootstrap framework would render the entire site invisible.
Cheers ??
https://www.ads-software.com/plugins/add-url-slugs-as-body-classes/
- The topic ‘Recommendations’ is closed to new replies.