[WordPress] 外掛分享: Custom CSS and JS

前言介紹

  • 這款 WordPress 外掛「Custom CSS and JS」是 2010-02-04 上架。
  • 目前有 1000 個安裝啟用數。
  • 上一次更新是 2010-05-20,距離現在已有 5463 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 2.8 以上版本才可以安裝。
  • 尚未有人給過這款外掛評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

pjdietz |

外掛標籤

css | post | javascript | stylesheet |

內容簡介

Custom CSS and JS 是一款外掛,允許您透過添加自訂欄位,將樣式表和 JavaScript 添加到任何個別文章中。CSS 和腳本都可以是內部或外部的。只要佈景主題調用 "wp_head",自訂 CSS 和 JavaScript 便可使用於顯示該文章的任何佈景主題中。

如何使用本外掛

若要使用本外掛,在文章中添加下列自訂欄位中的任何一種或多種組合。

custom_css
添加自訂 CSS 外部樣式表,請添加名稱為 custom_css 的自訂欄位,欄位值為 CSS 檔案的路徑。

cusrom_css_code
添加自訂 CSS 內部樣式表,請添加名稱為 custom_css_code 的自訂欄位,欄位值為您的 CSS 代碼(請勿包含樣式標籤)。

custom_js
添加自訂 JavaScript 外掛,請添加名稱為 custom_js 的自訂欄位,欄位值為 JavaScript 檔案的路徑。

custom_js_code
添加自訂 JavaScript 內部腳本,請添加名稱為 custom_js_code 的自訂欄位,欄位值為您的 JavaScript 代碼(請勿包含 script 標籤)。

自訂欄位順序

外部樣式和腳本顯示於內部的樣式和腳本之前。
如果您為相同的自訂欄位添加多個項目,這些項目將按照其添加順序進行顯示。

哦,但如果我不喜歡這些標籤怎麼辦?

只需編輯 custom-css-js.php 並更改在文件頂部定義的常數即可。

注意

此外掛僅適用於個別文章和頁面。不適用於列表頁面(例如目錄頁面、搜索結果等)。

原文外掛簡介

Custom CSS and JS allows you to add stylesheets and JavaScripts to any individual post by adding custom fields. Both CSS and scripts can be either internal or external. Since this is a plugin, the custom CSS and JavaScript are available to any theme used to display the post, as long as the themes call “wp_head”.
Using the Plugin
To use the plugin, add any combination of the following custom fields to your post.
custom_css
Add an external stylesheet by adding a custom field with the name custom_css. The value of the field should be the path to your css file.
cusrom_css_code
Add an internal stylesheet by adding a custom field with the name custom_css_code. Include your CSS code as the value. (Do not include the style tags.)
custom_js
Add an external JavaScript by adding a custom field with the name custom_js. The value of the field should be the path to your script.
custom_js_code
Add an internal JavaScript by adding a custom field with the name custom_js_code. Include your JavaScript code as the value. (Do not include the script tags.)
Custom Fields Order

The external styles and scripts are included before the internal ones.
If you include multiple entries for a given field, the entries will be included in order.

Okay, but what if I don’t like those tags?
Just edit custom-css-js.php and change the constants defined near the top of the file.
Note
This plugin only works with individual posts and pages. It does not work for list pages (e.g., the index page, search results).

各版本下載點

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

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


最新版本

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

  • Shortcoder — Create Shortcodes for Anything 》Shortcoder 外掛可讓您建立 HTML、JavaScript、CSS 和其他代碼片段的自訂捷徑。現在,這些捷徑可以在文章/頁面中使用,並且該片段將取代其位置。, ✍ 輕鬆建立...。
  • Enable jQuery Migrate Helper 》隨著 WordPress 5.5 的更新,一個名為 jquery-migrate 的遷移工具不再默認啟用。這可能會導致一些主題或外掛在運行舊代碼時缺少功能或出現意外行為。, 此外掛...。
  • Async JavaScript 》使用 Async Javascript 解決 above-the-fold 內容的 Render-blocking Javascript 問題。, Render-blocking Javascript 會導致 above-the-fold 內容在 Javascr...。
  • Speculative Loading 》- 這個 WordPress 外掛支援 Speculation Rules API,該 API 可以根據使用者互動,定義規則來動態預取或預渲染特定的 URL。, - 請參閱 Speculation Rules WICG...。
  • Scripts n Styles 》這個外掛讓管理員用戶能夠將自訂的 CSS 和 JavaScript 直接添加到個別文章、頁面或任何註冊的自訂文章類型中,也可以將類別添加到 body 標籤和文章容器中。還...。
  • jQuery Updater 》此外掛更新jQuery至最新的官方穩定版本,該版本通常不會在WordPress最新的穩定版本中提供。, jQuery Migrate也包含在內,以實現向下相容性。, 不會替換任何檔...。
  • Theme Authenticity Checker (TAC) 》掃描所有主題文件,尋找潛在的惡意或不需要的程式碼。, TAC 是什麼, TAC 代表主題真實性檢查器。TAC 搜尋每個安裝主題的原始檔案,尋找惡意程式碼的跡象。如...。
  • Code Embed 》注意: WordPress 5.0 及以上版本的使用者請查看常見問題以了解如何在區塊編輯器中使用此外掛。, Code Embed 外掛允許您在文章中嵌入程式碼(JavaScript 和 H...。
  • Read More Without Refresh 》你想顯示更多內容,但不影響使用者體驗嗎?, 我的外掛可以幫你解決這個問題!, 這個外掛透過短碼,可以隱藏預先定義好的文字,而根據你的選擇,只顯示剩下的...。
  • Raw HTML 》is capability is only granted to administrators. If you’re not an admin, you will need to ask them to add it to your role., Raw HTML is not r...。
  • SOGO Add Script to Individual Pages Header Footer 》已經在 Gutenberg 上進行測試, 創建一個簡單的方式,為個別頁面、文章或自訂文章類型的標題和頁腳添加 JavaScript 代碼,, 例如: 在感謝頁面上添加轉換代碼, ...。
  • BJ Lazy Load 》延遲載入可使您的網站加載速度更快,並節省頻寬。, 此外掛可取代您所有的文章圖片、文章縮略圖、大頭貼圖片和內容的 iframe,並使用佔位圖片,當訪客滾動頁面...。
  • Web Worker Offloading 》**總結:**, 這個外掛將 JavaScript 執行工作委派給 Web Worker,在釋放主執行緒的同時提高了效能。這將導致互動至下一次繪製(INP)分數的提升。值得注意的...。
  • WP Super Minify • Minify, Compress and Cache HTML, CSS & JavaScript 》這個外掛可以在需要時結合、縮小和緩存內聯的 JavaScript 和 CSS 文件,以加快頁面加載速度,並使用Minify PHP Framework。, 啟用此外掛後,您會發現您的 HTM...。
  • Use Google Libraries 》e's content distribution network (CDN) URLs for the supported libraries., This hook is used to replace the default WordPress registered script sour...。

文章
Filter
Apply Filters
Mastodon