[WordPress] 外掛分享: Replace Asset Source

WordPress 外掛 Replace Asset Source 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「Replace Asset Source」是 2021-10-27 上架。
  • 目前有 50 個安裝啟用數。
  • 上一次更新是 2022-11-02,距離現在已有 914 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 5.0.1 以上版本才可以安裝。
  • 外掛要求網站主機運作至少需要 PHP 版本 5.6 以上。
  • 有 3 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

leej3nn20 |

外掛標籤

asset | style | script | replace css | replace javascript |

內容簡介

這個外掛可以將任何外掛或佈景主題的資源來源替換為您自己所需的來源。主要目的是幫助 WordPress 使用者更改某些外掛使用的緩慢第三方腳本或樣式,進而優化該些國家的網站載入速度。

通常,您需要使用一些編程技巧來查找目標外掛的原始 enqueue 方法,然後將其dequeue,再enqueue您自己的資源檔案版本。但是,您需要小心,並遵循原始外掛enqueue原方式,以及依據相同的依賴關係以及版本號碼。否則,您可能會遇到一些意外問題。

有了這個外掛的幫助,您可以輕鬆地替換資源檔案,而不需要任何編程技巧。

此外掛不是用來自動本機托管第三方資源檔案,但您也可以這樣使用。請上傳您自己的本地檔案版本到更好和安全的文件夾中(可能是您的佈景主題文件夾),獲取公共可訪問的URL,在外掛的設定頁面使用它。試試看並玩得開心。

工作原理

一旦設定新的替換,此外掛將檢查所有排隊的腳本和樣式資源URL。如果找到符合的URL,它將使用您的替換URL替換目標URL。

此外掛不會dequeue目標資源,也不會enqueue您的替換資源。如果新的enqueue不遵循原始外掛或佈景主題,例如缺少依賴項或版本號不正確等,可能會發生問題。

如果目標資源URL不是開發人員使用標準的 WordPress enqueue script方法,替換將無法運作。

使用案例

從2021年9月底開始,馬來西亞發生阻擋,不允許所有當地ISP網路訪問maxcdn.bootstrapcdn.com。

如果您網站上有個外掛使用在maxcdn.bootstrapcdn.com上托管的資源檔案,馬來西亞的訪客會遇到超級緩慢的載入問題。

有了這個外掛的幫助,您可以輕鬆地將此資源檔案的URL替換為Cdnjs.cloudflare.com,而不會干擾原始外掛的功能。

此使用案例的教程如下:

解決馬來西亞的 maxcdn bootstrapcdn 問題

原文外掛簡介

Replace any plugin or theme asset source with your own desired source. Main purpose is to help WordPress users to change the slow third party scripts or styles which using by some plugins but slow load speed in certain countries.
Usually, you could use some coding skills to find the original enqueue method from the target plugin, then dequeue it, and enqueue your own version of asset file. But you need to take care and follow the same way how the original plugin enqueued and the dependency plus version. Otherwise, you might encounter some unexpected issues.
With the help of this plugin, you can easily replace the asset source file without coding skills.
This plugin is not meant to auto local host the third party asset file, but you could use for it too. Upload your own local version of asset file in a better and secured folder (maybe from your theme folder), get the public accessible url, use it on the plugin setting page. Just try it out and have fun.
How It Works
Once a new replacement set, this plugin will do a match on all queued asset styles and scripts source. If found the matching source, it will replaces target source URL with your replacement URL.
This plugin is not going to dequeue the target asset and enqueue your replacement asset. Issue might be happened if the new enqueue not follow the original plugin or theme like missing dependency or version incorrect etc.
If the target asset url not using the standard WordPress enqueue script method by the developer, the replacement will not works.
Use Case
There is a block in Malaysia since end of September 2021, which not allowed all local ISP network to access maxcdn.bootstrapcdn.com.
If there is a plugin in your site using the asset file hosted on maxcdn.bootstrapcdn.com, the visitor from Malaysia will encounter super slow loading issue.
With the help of this plugin, you can easily replace this asset file url to maybe cdnjs.cloudflare.com without disturbing the functionality of the original plugin.
Tutorial for this use case:
Solve maxcdn bootstrapcdn problem in Malaysia

各版本下載點

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

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


1.0.1 | 1.0.2 | 1.1.0 | 1.2.0 | 1.3.0 | 1.3.1 | trunk |

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

  • Head & Footer Code 》Head & Footer Code 插件可以讓你在不是開發人員的情況下,添加自定義代碼片段(JavaScript、CSS 或 HTML)到網頁中。您可以將代碼放置在 (...。
  • LuckyWP Scripts Control 》「LuckyWP Scripts Control」外掛允許您將自訂代碼插入和管理網站。例如,您可以插入 Google Analytics 代碼、Google Search Console 驗證元標記、Facebook ...。
  • Unfiltered MU 》Unfiltered MU 提供給管理者和編輯者 unfiltered_html 功能。這可避免 WordPress MU/WordPress 3.0 多站點從這些使用者的文章中刪除