[WordPress] 外掛分享: Dark Mode Block

前言介紹

  • 這款 WordPress 外掛「Dark Mode Block」是 2024-01-18 上架。
  • 目前尚無安裝啟用數,是個很新的外掛。如有要安裝使用,建議多測試確保功能沒問題!
  • 上一次更新是 2024-03-06,距離現在已有 424 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 5.7 以上版本才可以安裝。
  • 外掛要求網站主機運作至少需要 PHP 版本 5.6 以上。
  • 有 4 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

codekraft |

外掛標籤

css | block | theme | dark mode |

內容簡介

Dark Mode Block是一個簡單而強大的WordPress區塊外掛,可以讓您的網站啟用暗模式,增強可讀性,減少眼睛的壓力,而不會改變網站的顏色。給予使用者在明暗模式之間無縫切換的靈活性。
設計得輕量並且效率高,整個前端腳本gzipped後重量不到一半。
功能:
- 使用使用者友善的圖示切換暗模式。
- 在低光環境中提升可讀性的同時保留網站的顏色方案。
- 降低眼壓的增強使用者體驗。
- 可定制的。
透過提供暗模式選項,使您的網站更具可訪問性和使用友好性。使用Dark Mode Block,您的使用者可以享受您的內容,而不會影響美觀度。

使用方式:
- 啟用插件後,將“Dark Mode”區塊添加到您的WordPress頁面或文章編輯器。
- 發布或更新您的內容。

自定義:
發揮您的創造力!此區塊可以根據個人喜好或模板進行全面定制,並且由於完全基於CSS,因此對於任何人來說都很容易修改和適應。
您甚至可以控制如何應用暗模式!目前,我已將反轉濾鏡應用於背景,因為我不知道您的模板中的變量。
然而,您可以彈性地設定文本顏色為背景,反之亦然,使它更好。
以下是如何操作:

將以下代碼添加到您的functions.php文件中。
根據您的偏好編輯$custom_css。

首先按照以下方式取消佇列的當前樣式:
add_action( 'wp_enqueue_scripts', function () {
/** 取消佇列預設的暗模式 */
wp_dequeue_style( 'codekraft-dark-mode-style' );
}, 9 );

然後添加您自己的樣式!
add_action( 'wp_head', function () {
/** @var {string} $custom_css - 用於暗模式的自定義CSS */
$custom_css = "html.dark-mode body {
--wp--preset--color--background: #232323;
--wp--preset--color--foreground: #f3f3f3;
}

.dark-mode-switch::before {
width: 1.6rem;
cursor: pointer;
display: flex;
font-size: 1.6rem;
line-height: 1.6rem;
content: '🌞'
}

.dark-mode .dark-mode-switch::before {
content: '🌚'
}";

echo "";
}, 20 );

請在WordPress支援論壇中發布您的自定義樣式和螢幕截圖以支持這個外掛!

原文外掛簡介

Dark Mode Block is a simple yet powerful WordPress block plugin that allows you to enable dark mode for your website, enhancing readability and reducing eye strain without altering your website’s colors. Give your users the flexibility to switch between light and dark modes seamlessly.
Designed to be lightweight and efficient the whole frontend script weights less than half of a kb gzipped 😉
Features:
– Toggle dark mode with a user-friendly icon.
– Preserve your website’s color scheme while improving readability in low-light environments.
– Enhanced user experience with reduced eye strain.
– Customizable
Make your website more accessible and user-friendly by offering a dark mode option. With Dark Mode Block, your users can enjoy your content without compromising on aesthetics.
Usage

After activating the plugin, add the “Dark Mode” block to your WordPress page or post editor.
Publish or update your content.

Customization
Unleash your creativity! This block is designed to be fully customizable graphically, and since it’s entirely CSS-based, it’s straightforward for anyone to modify and adapt it according to their own taste or template.
You even have control over how the dark mode is applied! Currently, I’ve applied an invert filter on the background as I don’t know the variables in your template.
However, you have the flexibility to make it even better by setting the text color as the background and vice versa.
Here’s how to do it:

Add the following code to your functions.php file.
Edit the $custom_css in order to fit your preferences

First dequeue the current style in this way:
add_action( 'wp_enqueue_scripts', function () {
/** dequeue the default dark mode */
wp_dequeue_style( 'codekraft-dark-mode-style' );
}, 9 );

Then add yours!
add_action( 'wp_head', function () {
/** @var {string} $custom_css - your custom css for the dark mode */
$custom_css = "html.dark-mode body {
--wp--preset--color--background: #232323;
--wp--preset--color--foreground: #f3f3f3;
}
.dark-mode-switch::before {
width: 1.6rem;
cursor: pointer;
display: flex;
font-size: 1.6rem;
line-height: 1.6rem;
content: '🌞'
}
.dark-mode .dark-mode-switch::before {
content: '🌚'
}";
echo "

";
}, 20 );

Please support the plugin posting your custom style and a screenshot in the WordPress support forum section!

各版本下載點

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

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


0.1.0 | 0.1.1 | trunk |

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

  • Spectra Gutenberg Blocks – Website Builder for the Block Editor 》a.com/tutorials/?utm_source=wp-repo&utm_medium=link&utm_campaign=readme" rel="nofollow ugc">Spectra tutorials, you can easily learn how to ...。
  • Breadcrumb NavXT 》Breadcrumb NavXT 是受歡迎的 WordPress 外掛 Breadcrumb Navigation XT 的後繼者,從頭開始編寫以比其前輩更好。此外掛可為您的 WordPress 網誌或網站生成定...。
  • WP Go Maps (formerly WP Google Maps) 》這是一款易於使用的 Google 地圖和 Open Layers 地圖外掛程式(包括地圖區塊)!, 使用提供的短代碼,快速輕鬆地向 WordPress 文章和/或頁面添加自定義 Googl...。
  • PDF Embedder 》這款外掛程式可以上傳 PDF 檔案,並將它們直接嵌入到您網站的文章和頁面中。添加圖像一樣簡單!您的 PDF 檔案會自動調整到其自然大小和形狀。您還可以指定寬...。
  • Otter Blocks – Gutenberg Blocks, Page Builder for Gutenberg Editor & FSE 》Otter 是一款 Gutenberg Blocks 頁面建構外掛,可為 WordPress Block Editor(又稱 Gutenberg)添加額外功能,讓您享受更好的頁面建構體驗,而無需使用傳統的...。
  • Layout Grid Block 》想要輕鬆設定自訂欄位寬度和位置的列排版嗎?也許您想要在文章中將內容對齊全局佈局網格。使用此佈局網格區塊,您可以實現以上兩個目標,或是其中一個。此外...。
  • Email Address Encoder 》這是一個輕量級的外掛,可以保護純文字的電子郵件地址和 mailto 鏈結免受電子郵件抓取機器人獵取,透過將它們編碼成十進位和十六進位實體。對文章、頁面、留...。
  • Crowdsignal Forms 》The Crowdsignal Forms 外掛可以讓您直接在區塊編輯器中建立和管理投票。, 建立投票與編寫項目清單一樣簡單快速,不再需要嵌入區塊或複製、貼上。, 自訂投票...。
  • Blocks Animation: CSS Animations for Gutenberg Blocks 》Blocks Animation 可以讓您以優雅的方式,為所有的 Gutenberg 區塊添加 CSS 動畫。, Blocks Animation 的用戶介面非常原生且直觀,您甚至不會注意到它已經被...。
  • Superb Addons: Blocks, Patterns & Theme Designer 》使用 Superb Gutenberg Blocks,只需幾秒鐘即可將全新的優秀功能添加到 WordPress 編輯器中!, Superb Gutenberg Blocks符合GDPR,且輕量且響應式。, 外掛是...。
  • Category Posts Widget 》Category Posts Widget是一個輕巧的小工具,設計用於一件事並且做得很好:顯示特定類別中最新的文章。, 基於詞語和類別的文章小工具, 這個免費小工具的高級版...。
  • Genesis Blocks 》Genesis Blocks 是一個能夠在 Gutenberg 段落編輯器中使用的頁面組件集。透過使用段落編輯器和 Genesis Blocks,您可以更加靈活地建立各種網站,並快速推出!...。
  • Flexible Table Block 》合併和分割儲存格, 您可以從多個選定的儲存格中合併或分割儲存格。, 靈活的樣式設置, 您可以針對表格、儲存格和標題標籤分別設置各種樣式。, 高級使用介面, ...。
  • Spider Blocker 》Spider Blocker 可以封鎖消耗頻寬和減慢服務器速度的大多數常見機器人。它會使用 Apache .htaccess 文件來減少對您的網站的影響。它也會從外部掃描器中隱藏自...。
  • Snow Monkey Blocks 》Snow Monkey Blocks 是一個為 Gutenberg 所設計的內容區塊外掛程式。使用此外掛,您可以快速且輕鬆地建立和發佈登陸頁面或高度設計的頁面,而且您不需要撰寫...。

文章
Filter
Apply Filters
Mastodon