[WordPress] 外掛分享: The Admin Theme Experience

前言介紹

  • 這款 WordPress 外掛「The Admin Theme Experience」是 2013-12-23 上架。
  • 目前有 10 個安裝啟用數。
  • 上一次更新是 2013-12-24,距離現在已有 4149 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 3.8.0 以上版本才可以安裝。
  • 尚未有人給過這款外掛評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

gregross |

外掛標籤

admin color scheme theme |

內容簡介

此外掛說明:

這是一個正確主題的概念驗證,專為管理區域而設計。

這個外掛在這個時間不應該被使用

它只是一個概念驗證,以提交到 WordPress 的「特色作為外掛」開發模式。

它有兩個主要目標:

簡化管理人員顏色主題的創建。
將網站主題體驗帶入管理主題。

簡化

目前創建管理人員顏色主題的過程需要您創建 WordPress 外掛程式。沒有理由顏色主題作者要熟練 PHP 和 WordPress 開發才能創建和部署管理人員顏色主題。

因此,管理主題體驗(ATHX)從主題文件中刪除所有 PHP 依存關係。它通過在管理主題(目前位於外掛目錄中,但如果被加入核心,它將位於 wp-admin/themes 目錄中以與 wp-content/themes 結構相呼應)中創建一個新目錄來實現這一點。

管理主題目錄中至少有 2 個檔案:

style.css – 用於主題的樣式表,它遵循網站主題的標頭格式。
readme.txt – 一個標準的 WordPress 讀我檔案。

此外,可以在主題中包含幾個可選文件:

style-rtl.css – 主題的從右到左版本
style.scss 和 style-rtl.scss – SASS 文件用於創建樣式表。
screenshot.png – 用於新管理主題選擇器的屏幕截圖。
任意數量的其他對主題有用的文件。

已包括更新版本的 _admin.scss 和 _variables.scss,它們還支援創建從右到左的樣式表(有關此的更多信息,請繼續閱讀)。

目標是在 WordPress.org 上建立第三個(主題、外掛和管理主題)管理主題倉庫,與今天已存在的主題儲存庫相似。

網站主題體驗

在「您的個人資料」頁面中當前的管理主題選擇器實在功能不足。幸運的是,WordPress 3.8 引入了一個全新的主題選擇器(THX)用於網站主題,那麼為什麼不將其用於管理主題呢?

使用新的 style.css 標頭信息以及屏幕截圖,為 users.php 菜單添加新菜單項,「您的管理主題」。這目前會加載 THX 的簡化版本(將补充,但這只是 0.1 版;)。

此外,該外掛將取代「您的個人資料」頁面中現有的主題選擇器,改為連結到新頁面。

技術註記

這是 0.1 版,因此需要注意以下幾點:

值得注意的是,新代碼未以任何方式形式使用 wp_admin_css_color()。
上傳主題目前尚未實現。
在幾個地方使用了一些模糊的地方,在核心實現中,某些功能/類將被更改以支援多個儲存庫和類型的主題。對於 POC,由於使用外掛來更改核心功能/類具有一定的困難,因此尚未執行此操作。
插件通過始終將當前的 WordPress 管理主題設置為預設值來工作。它將「真正的」管理主題存儲在「admin_xp_color」用戶選項中。這確保適當的 CSS 文件已加載,這是所有內置管理主題使用的(以及到目前為止我見過的所有第三方主題)。之後,它會加載主題的 style.css 文件。在核心實現中,第二個用戶選項將不需要,代碼將被簡化。
作為 POC,許多項目,例如多站點支援和合適的類型檔案檢驗,在未來的版本中將有所改進。

原文外掛簡介

Proof of concept for proper theme’s for the admin area.
THIS PLUGIN SHOULD NOT BE USED AT THIS TIME
It is only a proof of concept for submission to the “Features-As-Plugins” development model for WordPress.
It has two primary goals:

Simplify the creation of admin color themes.
Bring the Site Theme Experience to admin themes.

Simplify
The current process of creating an admin color theme requires you to create a WordPress plugin. There is no reason a color theme author should have to also be proficient in PHP and WordPress development to be able to create and deploy an admin color theme.
To this end, The Admin Theme Experience (ATHX) removes all PHP dependences from the theme files. It does this my creating a new directory for admin themes (currently located in the plugin directory, however if brought in to the core, it would live in the wp-admin/themes directory to mirror the wp-content/themes structure).
Inside the admin theme directory are at minimum 2 files:

style.css – The style sheet to use for the theme, it follows the standard format of header information for a site theme.
readme.txt – A standard WordPress readme file.

In addition, several optional files can be included in the theme:

style-rtl.css – A right to left version of the theme
style.scss and style-rtl.scss – SASS files to create the stylesheets.
screenshot.png – A screen shot to use in the new admin theme selector.
Any number of additional files that are useful to the theme.

Updated version of _admin.scss and _variables.scss have been included that support the creation of rtl sytlesheets as well (read on for more information on this later).
The goal would be to create a third (themes, plugins and admin themes) repository on WordPress.org for admin themes, similar to the theme repository that exists today.
Site Theme Experience
The current admin theme selector in the ‘Your Profile’ page is woefully underpowered. Fortunately WordPress 3.8 introduced a brand spanking, super shiny, theme selector (THX) for the site themes, so why not use it for admin themes as well?
Using the new style.css header information as well as the screen shot, a new menu item is added to the users.php menu, ‘Your Admin Theme’. This currently loads a slimmed down version of THX (this will be fleshed out, but this is only version 0.1 ;).
The plugin also replaces the existing theme selector in the ‘Your Profile’ page with a link to the new page.
Technical Notes
This is version 0.1, so there are some things to note:

Of note is that the new code does not use wp_admin_css_color() in any way, shape or form.
Uploading of themes is currently not implemented.
There is some fudge used in a few places, in a core implementation some functions/class would be altered to support multiple repositories and types of themes. For the POC this has not been done as altering core functions/classes is difficult with a plugin.
The plugin works by ALWAYS setting the current WordPress admin theme to default. It stores the “real” admin theme in the “admin_xp_color” user option. This ensure that the appropriate css files are loaded which all of the built in admin themes use (and all the third party ones I’ve seen so far). After that, it loads the theme’s style.css file. In a core implementation the second user option would not be required and the code simplified.
As a POC, many items, like multi-site support and proper capabilities checking, has not yet been implemented.
As this changes the contents of the theme directories, the built in admin theme’s have been moved over to the plugins new themes directory and updated to match the new requirements. This has been done by hand and no new .scss files have been used to generate them at this time. The “Modern Grey” theme however does use the new _admin.scss file to generate it’s style.css.

History
Just after WordPress 3.8 b1 came out I found myself not liking the new default admin color scheme all that much. It was a lot darker than the old one and just didn’t appeal to me.
So I started looking at how to build an admin color theme. This was before the officially sanctioned “Admin Color Schemes” plugin came out and I found the documentation to be slightly confusing overall. To the point that I put the idea away, figuring someone else would probably make a plugin to do the work for me 🙂
Once “Admin Color Schemes” was released, it became much clearer what you had to do. However it also made clear the fact that the admin color scheme code was fundamentally broken. I say this because:

The built in themes can do things add on themes can’t (for example a simple @include ‘../colors.css’).
Because of the above, you have to hook the load of the admin page and hack in the colors.css file.
A hook for a single admin color theme might be ok, but what about 10 or 20 or more for large sites?
You have to register all the color theme’s you have on EVERY page load.
_admin.css cannot generate both rtl and ltr files.

On top of that, the theme picker in the profile page became much too large to be part of the profile page. “Admin Color Schemes” adds 8 new themes, my own “Grey Admin Color Schemes” adds 4. A large site could have countless themes all adding to the profile page.
Likewise, with only 4 “preview” colors, it makes it VERY hard to tell what the theme is actually going to look like. My “Grey Admin Color Schemes” share much of the same color pallet, but are clearly different as soon as you see them in action.
The final nitpick I had with the existing code is that as soon as you click on a new admin theme, it gets saved as your theme. This goes counter to the “Save” button at the bottom of the page and the traditional work flow of the profile page.
I tried several different things to “save” the old system:

I tried including wp-admin/css/colors.css in my css file, but that doesn’t work as you either have to use a relative path to it, which breaks if the user has split the location of the wp-content and wp-admin directories, or you have to make your colors.css a php file so you can use the WordPress functions to find the wp-admin folder.
I rewrote colors.css to be a .scss file, however I found other missing components in it and LOTS of extra items that were not covered by the _admin.scss file. This ended up being a real mess.
I rewrote _admin.scss to include the missing items from colors.css and other locations. This was a trip down the rabbit hole, no matter how far I went, it just kept going and going and going…
I thought about extending wp_admin_css_color() to allow for an array to be passed instead of a single css file, but that just covered up many of the other issues listed above.

In the end, I decided the old method was just too limited and wrote this plugin to try and fix the problem.
Turns out it was easier than I thought… kind of 😉

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「The Admin Theme Experience」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


0.1 | trunk |

延伸相關外掛(你可能也想知道)

暫無相關外掛推薦。

文章
Filter
Apply Filters
Mastodon