Enhanced Body Class is a plugin to add user-related classes to the body tag. This can be enabled on the frontend and backend of the site. The css classes allow you to easily customize styling by role or a specific user.
The plugin is stored in the build folder.
- Upload the plugin files to the
/wp-content/plugins/enhanced-body-class
directory, or install the plugin through the WordPress plugins screen directly. - Activate the plugin through the 'Plugins' screen in WordPress
- Use the Settings->Enhanced Body Class screen to configure the plugin. You must choose either frontend or admin to see changes.
- Customize output by adding any of the files below based on the front or admin settings you selected.
The plugin adds a menu item to the Settings menu. It is advisable to review and, if desired, update these settings after activating the plugin.
This plugin operates by adding classes to the body tag on pages. The classes are all related to the current user, and can be helpful in stlying based on roles and other characteristics.
- Add to theme folder (optional): enhanced-body-class-frontend.css
- Add to theme folder (optional): enhanced-body-class-admin.css
- Add to theme folder (optional): enhanced-body-class-frontend.js
- Add to theme folder (optional): enhanced-body-class-admin.js
.user-role-{role}
ex. .user-role-author
.user-name-{name}
ex. .user-name-bobdobbs
.user-id-{ID}
ex. .user-id-123
Please review the CONTRIBUTING.md file if you are interested in helping develop or maintain this plugin. Also, please be aware that contributors are expected to adhere to the CODE_OF_CONDUCT.md and use the PULL_REQUEST_TEMPLATE.md when submitting code.
You will need npm and phpcs to get started. Use npm install
to install gulp and other libraries
required to help package the plugin for publishing. Source files are in the source
folder. The
code style is defined in the phpcs.xml
file and requires phpcs
to validate the code.
This plugin was created by Noah J. Stewart in response to a specific problem. In January 2019, Noah Stewart was contacted by his father Jim Stewart regarding a WordPress photo gallery plugin that his astronomy club was using. They were having trouble customizing a few of the role-based options in a popular gallery plugin. Like any good graphic artist, Jim was trying to improve the interface for the site users. The simplest approach to the problem was to use css to selectively hide certain elements, ie. invisible content users with the author role that should be visible to users with the administrator role.
The WordPress plugin Enhanced Body Class is open-sourced software licensed under the ISC license.