[WordPress] 外掛分享: ACF RGBA Color Picker

首頁外掛目錄 › ACF RGBA Color Picker
WordPress 外掛 ACF RGBA Color Picker 的封面圖片
6,000+
安裝啟用
★★★★★
5/5 分(5 則評價)
451 天前
最後更新
問題解決
WordPress 4.7+ v1.2.3 上架:2017-03-18

內容簡介

RGBA Color Picker 是一個支援 RGBA 模式透明顏色的顏色選取器外掛。

自訂顏色調板

這個外掛提供了根據自己的需要客製化顏色調板的功能。使用acf/rgba_color_picker/palette 過濾器可以自定義自己的顏色調板。除此之外,你也可以在欄位設定中為每個欄位定義各自的顏色調板。

版本 1.2.0 的新增功能:

當選擇器中的顏色數量很多時,色彩區域就會變得非常小。為了避免這種情況,現在色彩區域會以幾行展示(每行最多容納 10 種顏色)。這樣就可以定義更多的標準調色板。

此外,現在顏色選取器是絕對定位的,這樣打開顏色選取器時就不會影響頁面上的其他元素了。

此外,此外掛僅與 ACF PRO(版本 5.5.0 或更高版本)兼容。

本地化

英語
德語

自訂顏色調板

使用 acf/rgba_color_picker/palette 過濾器創建自己的標準顏色調板供顏色選取器使用。與預設的標準顏色調板一樣,可以在欄位設定中單獨為每個欄位設定自己的標準顏色調板。

固定的顏色調板

將以下代碼放入您的主題 functions.php 檔案(您可以使用 HEX 或 RGBA 配置的顏色值,也可以混合使用):

<?php
function set_acf_rgba_color_picker_palette() {
$palette = array(
'#FFF',
'#0018ff',
'#00FF36',
'rgba(255,168,0,0.7)'
);

return $palette;
}
add_filter('acf/rgba_color_picker/palette', 'set_acf_rgba_color_picker_palette');
?>

動態顏色調板

如果您有一個選項頁面,其中定義了一些標準顏色,請像這樣從這些選項中創建一個陣列:

<?php
function set_acf_rgba_color_picker_palette() {
// optional - add colors which are not set in the options page
$palette = array(
'#FFF',
'#000'
);

if ( have_rows('YOUR_COLOR_REPEATER_FIELD', 'YOUR_OPTIONS_PAGE') ) {
while( have_rows('YOUR_COLOR_REPEATER_FIELD', 'YOUR_OPTIONS_PAGE') ) { the_row();
$palette[] = get_sub_field('YOUR_COLOR_FIELD');
}
}

return $palette;
}
add_filter('acf/rgba_color_picker/palette', 'set_acf_rgba_color_picker_palette');
?>

這是一個使用重試欄位來設置顏色的示例;如果您將您的顏色存儲在字符串中,請將此字符串轉換為陣列。

隱藏顏色調板

如果您不想顯示顏色調板,請將過濾器的返回值設置為 false:

<?php
add_filter('acf/rgba_color_picker/palette', '__return_false');
?>

將顏色調板設置為 false 將禁用並隱藏欄位設置中的 "顏色調板" 和 "隱藏顏色調板" 選項。

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.2.3) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「ACF RGBA Color Picker」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

The RGBA Color Picker is a color picker that supports transparency colors in RGBA-Mode.
Custom color palette
The plugin offers the possibility to customize the color palette according to your own wishes. You can define your own custom color palette with the acf/rgba_color_picker/palette filter. In addition, you can define an individual color palette for each field in the field settings.
New in version 1.2.0
If there are a lot of colors for the color palette, the color fields are getting very tiny. To prevent this, the color fields are now displayed in several rows (with a maximum of 10 colors per row). So it is possible to define a lot of colors for the standard palette.
Furthermore, the color picker is now absolutely positioned and this does not shift other elements of the page every time the color picker is opened.
This plugin works only with the ACF PRO (version 5.5.0 or higher).
Localizations

English
Deutsch

Custom color palette
Use the acf/rgba_color_picker/palette filter to create your own standard color palette for the color picker. Your custom standard color palette, just like the default color palette, can be overridden in the field settings for each field individually.
Fixed color palette
Put a code like this into your themes functions.php (you can use HEX or RGBA color values and can also mix them):

Dynamic color palette
If you have an options page where you define some standard colors, create an array from this options like this:

This is an example using a repeater field to set the colors; if you store your colors within a string, convert this string into an array.
Hiding color palette
If you dont want to show a color palette set the return value of the filter to false:

Setting the color palette to false will disable and hide the “Color Palette” and “Hide Color Palette” options in the field settings.

文章
Filter
Apply Filters
Mastodon