[WordPress] 外掛分享: Customizer Framework

前言介紹

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

外掛協作開發者

philipnewcomer |

外掛標籤

option | wrapper | framework | customizer | theme customizer |

內容簡介

一個輕量且易於使用的 WordPress Customizer 框架。提供簡單且直覺的 API,可註冊 Customizer 設置,包括進階控制類型。根據控制類型自動進行設置淨化。消除了為每個獨立 Customizer 設置註冊設置、控制和淨化函數的繁瑣任務。

該框架可供插件和佈景主題使用,但由於目前將設置保存為佈景主題修改,因此任何插件設置都會特定於活動佈景主題。支援選項類型設置正在計劃中。

此外掛目前處於 beta 階段,未來可能會有重大更改。

問題和支援

在 GitHub 上貢獻該專案。

為何需要 Customizer 框架?

最近的 WordPress Customizer API 也有一些影響舊 Settings API 的問題。Settings API 過於複雜、不直覺且混亂。結果出現了一批主題選項框架,以使開發人員更容易創建主題選項。Customizer API 好一些,但仍比必要的更複雜,註冊 Customizer 設置仍是設置函數、控制函數和淨化函數的混亂。現在,Settings API 框架提供的易用性現在可用於 Customizer 中,即 Customizer Framework 外掛。

Customizer Framework 旨在成為對雜亂 Customizer API 的輕量級包裝,讓 WordPress 開發人員可以再次樂在其中。現在,開發人員可以專注於創建利用 Customizer 的優秀佈景主題,而不必花費時間書寫 500 行代碼才能創建 10 個 Customizer 設置。好吧,我可能有點誇張。但並不多。你真的想花時間註冊 Customizer 設置,然後為該設置註冊控制,再編寫淨化函數嗎?而這只是一個設置!然後還有進階控制,例如圖像或顏色,需要實例化它們自己的控制類,需要更加混亂和不直覺的代碼。你為什麼還要關心設置和控制之間的區別?你難道沒有更好的事情可以花時間去做,比如創建優秀的 WordPress 佈景主題嗎?我想是這樣的。

使用方法

啟用該外掛,或在佈景主題中include它。

在創建任何設置之前,您需要創建任何要使用的新 Customizer section。任何自定義部分都需要在您可以向其添加設置之前存在。

最後,初始化一個新 CustomizerFramework 類別,並添加您的設置:

function mytheme_register_settings( $settings ) {

$settings[] = array(
'id' => 'example_setting',
'label' => 'Example Setting Label',
'section' => 'example-section',
'type' => 'text', // 選擇性,預設為 'text'
'default' => 'Example section default text', // 選擇性
);

}
add_filter( 'customizer_framework_settings', 'mytheme_register_settings' );

設置類型

以下是目前可用的設置類型:

checkbox
color
dropdown-pages
image
radio
select
text
textarea

原文外掛簡介

A lightweight and easy-to-use framework for the WordPress Customizer. Provides a simple and intuitive API for registering Customizer settings, including advanced control types. Automatically sanitizes settings based on the control type. Eliminates the tedious task of registering a setting, control, and sanitization function for each individual Customizer setting.
The framework may be used by both plugins and themes, although since at this time the settings are saved as theme mods, any plugin settings will be specific to the active theme. Support for option type settings is planned.
This plugin is currently in beta, and may be subject to major changes as it matures.
Issues and Support
Contribute to the project on GitHub.
Why a Framework for the Customizer?
The recent WordPress Customizer API suffers from some of the same issues afflicting the old Settings API. The Settings API was overcomplicated, unintuitive, and confusing. The result was a crop of theme option frameworks that have sprung up to make it easier for developers to create theme options. The Customizer API is a bit better, but it’s still more complicated than necessary, and registering Customizer settings is still a convoluted mess of settings functions, controls functions, and sanitization functions. Now, the ease of use which the theme option frameworks have provided for the Settings API is available for the Customizer, in the Customizer Framework plugin.
The Customizer Framework aims to be a lightweight wrapper around the convoluted Customizer API, which makes it fun to be a WordPress developer again. Developers can now focus their time on creating great themes that utilize the Customizer, not on writing 500 lines of code in order to create 10 Customizer settings. Okay, so I might be exaggerating a bit. But not by much. Do you really want to spend your time registering a Customizer setting, then registering a control for that setting, and then writing a sanitization function for that setting? And that’s only for one setting! And then there’s the advanced controls, such as image or color, that require you to instantiate their own control class, requiring even more convoluted and unintuitive code. And why should you even have to care about the differece between a setting and a control? Don’t you have better things to spend your time on, like creating great WordPress themes? I thought so.
Usage
Activate the plugin, or include it in your theme.
Before creating any settings, you need to create any new Customizer sections that you wish to use. Any custom sections need to exist before you can add settings to them.
Finally, initialize a new CustomizerFramework class, and add your settings:
function mytheme_register_settings( $settings ) {

$settings[] = array(
'id' => 'example_setting',
'label' => 'Example Setting Label',
'section' => 'example-section',
'type' => 'text', // Optional, defaults to 'text'
'default' => 'Example section default text', // Optional
);

}
add_filter( 'customizer_framework_settings', 'mytheme_register_settings' );

Setting Types
Here are the currently available setting types:

checkbox
color
dropdown-pages
image
radio
select
text
textarea (requires WordPress 4.0)

The radio and select types require an additional choices parameter, containing an array of the valid choices:
'choices' => array(
'choice_1' => 'Choice 1',
'choice_2' => 'Choice 2',
'choice_3' => 'Choice 3',
),
'default' => 'choice_1',

In addition, on WordPress 4.0, you can specify any additional HTML5 input types, such as url or date. You can also include an atts parameter, containing an array of additional input attributes which should be applied to the input:
'type' => 'url',
'atts' => array(
'placeholder' => 'http://',
'class' => 'a-custom-css-class',
),

Sanitization
All settings are sanitized automatically, based on the setting type. If you wish to specify your own sanitization function for a setting, add a sanitize_cb parameter, containing the function name to be called, which should return the sanitized value.
'sanitize_cb' => 'my_custom_example_setting_sanitization_function',

各版本下載點

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

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


0.1 | trunk |

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

  • WP Admin UI Customize 》, 儀表板, 顯示選項標籤, 輸出 - 元網站, 管理工具列 (Toolbar), 側邊選單 (Side menu), 元箱的管理, 登入畫面, 其他功能, , 這些自訂化都是可以實現的。, , ...。
  • ACF Options For Polylang 》您使用了高級自訂欄位來建立選項頁面,並且安裝了 Polylang 外掛以獲得令人驚嘆的多語言網站嗎?, 可惜的是,Polylang 並不處理 ACF 的選項頁面。這意味著您...。
  • Rel Nofollow Checkbox 》此外掛在插入/編輯連結彈出視窗中,增加了一個簡單的核取方塊,可加入 nofollow 屬性。。
  • WP-RecentComments 》在 WordPress 側邊欄中顯示最新評論。您可以限制評論的數量,設定摘要的最大長度,過濾反向鏈接評論。您還可以啟用或禁用頭像,調整其大小和位置。此外,它還...。
  • Subscription Options 》人們訂閱部落格和其內容最常用的方法是通過 RSS、電子郵件和 Twitter。有些人還會轉載到 Facebook 上。此外掛會在小工具區中放置相關訂閱圖標,讓使用者輸入...。
  • WordPress Mobile Themes 》允許你選擇另一個主題用於手機和平板電腦的用戶。, 可以為手機和平板電腦的用戶設定不同的主題。, 支援的語言:, , 美式英文/en_US (默認), 簡體中文/zh_CN (...。
  • Ajax Dropdowns 》這個外掛可以在同一頁面上使用下拉式選單顯示多種文章類型的內容。下拉式選單可以透過 Ajax、內嵌或重定向查詢文章,並在您的網站前端顯示。, 功能特色, , 無...。
  • Easy Theme Options 》此外掛可新增創建多個網站選項,以定制你的主題或網站。, 特點, 你可輕鬆創建多種欄位類型,例如:, , 文本輸入框, 密碼輸入框, 文字區, 核取方塊, 下拉式選...。
  • Screen Options and Help Show Customize 》這款 WordPress 外掛可設置顯示選項以及幫助選項的設定,還可以設置幾乎所有的默認頁面。, 此外,還可以更改每個使用者角色的顯示。, 支援多站點。, 日本語說...。
  • Options View 》編輯選項和使用者元數據(usermeta)表的內容。, =選項表(Options table)和使用者元數據表(Usermeta table)=, * 解序列化選項表(option table)的值,...。
  • Custom Variables 》透過這個外掛,您可以建立自己的變數及在 WordPress 網站上使用。當您需要更新變數時,這會更加便利。例如,您的聯絡電話在網站上顯示於四個地方。當您需要更...。
  • Menu Maker 》Menu Maker 外掛有助於建立您網站的選單,常常用於創建導覽選單。您可以在 Troidus.com 查詢更新。, 使用說明, 大多數情況下,外掛都很容易上手。但是對於文...。
  • EPOW – Custom Product Options for WooCommerce 》, 試用演示 | 文件 | Facebook 社團, , , EPOW – WooCommerce Custom Product Options 是一個很好用的外掛,可以讓您更輕鬆地新增自定義選項至您的產品。有了...。
  • Options 》此外掛在 options.php 頁面添加了一個「設定 > 選項」鏈接。, 如果您想貢獻,請在github.com上發送拉取請求。, 此外掛由 WordPress 顧問、網頁開發人員和數據...。
  • Xhanch – My Advanced Settings 》Xhanch – 我的進階設定 (由 Xhanch Studio 開發) 是一個提供常見 WordPress 功能但 WordPress 預設並未提供的外掛程式。使用此外掛,您可以利用/啟用/...。

文章
Filter
Apply Filters
Mastodon