
前言介紹
- 這款 WordPress 外掛「Enhanced Body Class」是 2019-02-19 上架。
- 目前尚無安裝啟用數,是個很新的外掛。如有要安裝使用,建議多測試確保功能沒問題!
- 上一次更新是 2025-04-25,距離現在已有 307 天。
- 外掛最低要求 WordPress 4.6 以上版本才可以安裝。
- 外掛要求網站主機運作至少需要 PHP 版本 5.6.40 以上。
- 尚未有人給過這款外掛評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
revnoah |
外掛標籤
內容簡介
WordPress 外掛,可將涉及使用者的類別新增至 body 標籤。此功能適用於網站的前端和後端。
透過這些 CSS 類別,您可以輕鬆地按角色或特定使用者自訂樣式。
功能
在前端和管理頁面上切換顯示
切換角色、使用者名稱和使用者 ID 的類別
使用範本提示載入自訂主題 CSS 檔案以供前端和管理
樣式表
新增至主題資料夾 (選用): enhanced-body-class-frontend.css
新增至主題資料夾 (選用): enhanced-body-class-admin.css
腳本
新增至主題資料夾 (選用): enhanced-body-class-frontend.js
新增至主題資料夾 (選用): enhanced-body-class-admin.js
樣式
.user-role-{rolename} 示例:.user-role-author
.user-name-{username} 示例:.user-name-bobdobbs
.user-id-{ID} 示例:.user-id-1
使用方式
啟用 body 標籤上的類別後,您需要使用 CSS 或 JavaScript 自訂顯示方式。
在外掛設定中啟用「使用者角色」於「管理頁面」上
透過查看網頁源碼觀察 BODY 標籤的類別。您可能需要重新整理頁面以查看更新後的類別。
進入目前的主題並創建檔案 enhanced-body-class-admin.css
編輯 enhanced-body-class-admin.css 並添加以下內容:
body.user-role-administrator { background-color: cyan; }
重新整理頁面,現在您應該會看到青色的背景,接著您可以更新 CSS 以改變特定頁面元素的顯示方式。
實際使用
這個外掛程式是為了隱藏流行的照片庫中特定角色中的某些元素而開發的。
建立主題檔案 enhanced-body-class-admin.css
`
body.user-role-contributor #updategallery #gallerydiv { display: none; }
`
建立主題檔案 enhanced-body-class-admin.js
`
jQuery(document).ready(function($) {
$(‘body.user-role-contributor select#bulkaction option[value=”copy_to”]’).attr(‘disabled’, ‘disabled’);
});
`
關於此外掛程式
這個外掛程式由 Noah J. Stewart 於特定問題的回應中創建。在 2019 年 1 月,Noah Stewart 與他的父親 Jim Stewart 接觸,關於他所在的天文俱樂部使用的 WordPress 照片庫外掛程式出現了問題,他們有幾個基於角色的選項上的自訂問題。像任何優秀的圖形藝術家一樣,Jim 試圖改善網站使用者的介面,最簡單的解決問題的方法是使用 CSS 來選擇性地隱藏某些元素,即對於具有作者角色的不可見內容,對於具有管理員角色的使用者應該是可見的。
原文外掛簡介
WordPress 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.
Features
Toggle display on frontend and admin pages
Toggle classes for role, user name and user id
Template hinting to load custom theme css files for frontend and admin
Stylesheets
Add to theme folder (optional): enhanced-body-class-frontend.css
Add to theme folder (optional): enhanced-body-class-admin.css
Scripts
Add to theme folder (optional): enhanced-body-class-frontend.js
Add to theme folder (optional): enhanced-body-class-admin.js
Styles
.user-role-{rolename} ex: .user-role-author
.user-name-{username} ex: .user-name-bobdobbs
.user-id-{ID} ex: .user-id-1
Usage
After activating the class on the body tag, it will be up to you to use css or javascript to customize the display.
Activate ‘User Role’ on ‘Admin Pages’ in plugin settings
Observe classes on BODY tag by viewing the webpage source. You may need to refresh the page to see the updated class.
Navigate to current theme and create file enhanced-body-class-admin.css
Edit enhanced-body-class-admin.css and add the following:
body.user-role-administrator { background-color: cyan; }
Refresh the page. You should now see a cyan background. You can now update the css to change the display of specific
page elements.
Real Usage
This plugin was developed to hide certain elements in a popular photo gallery from users with a specific role.
Create the theme file enhanced-body-class-admin.css
`
body.user-role-contributor #updategallery #gallerydiv { display: none; }
`
Create the theme file enhanced-body-class-admin.js
`
jQuery(document).ready(function($) {
$(‘body.user-role-contributor select#bulkaction option[value=”copy_to”]’).attr(‘disabled’, ‘disabled’);
});
`
About This Plugin
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.
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Enhanced Body Class」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
延伸相關外掛(你可能也想知道)
暫無相關外掛推薦。
