問題描述
我找不到關於什麼是以及如何使用 Drop-in 外掛的檔案或討論。這個 Q& A,Populate content on install 提出了這個問題。
是 wp-content/install.php 檔案重新定義可插拔函式 wp_install_defaults 一個 Drop-in 外掛嗎?
我的研究成果
以下列表來自 hakre’s article(這似乎是 Interwebs 中所有其他副本的起源) 。
File Type of Plugin Loaded Context
advanced-cache.php Advanced caching plugin. on WP_CACHE value Single
db.php Custom database class always Single
db-error.php Custom database error message on error Single
install.php Custom install script on install Single
maintenance.php Custom maintenance message on maintenance Single
object-cache.php External object cache always Single
sunrise.php Executed before Multisite is loaded on SUNRISE value Multi
blog-deleted.php Custom blog deleted message on deleted blog Multi
blog-inactive.php Custom blog inactive message on inactive blog Multi
blog-suspended.php Custom blog suspended message on archived or spammed blog Multi
Source: Data taken from global function _get_dropins() in wp-admin/includes/plugin.php.
在法典中,Drop-in 是 defined as:
The concrete PHP-file
首先,[wp-hackers] 列表中沒有任何內容。並搜尋 「drop-in + wordcamp」 我只有 found this 相關我的重點:
One of the great strengths of WordPress is its plugin system. In the upcoming 2.1 release, there is very little you can』t do as a drop-in plugin. This makes it easy to use WordPress as a CMS and keep your customizations separate from the main codeline; which in turn simplifies upgrades and maintenance.
最佳解決方案
回答你的問題,是的
事實上,還有很多其他的功能可以覆蓋在該檔案中,它被作為”wp-admin/includes/upgrade.php”& 內部有很多功能被覆蓋
不幸的是,關於 drop-in 外掛的資訊沒有太多資訊,但我會嘗試放幾點
-
它們與正常的外掛不同,因為它們不能被包裝透過 wordpress 管理員安裝。
-
使用它們意味著所有者手動將外掛上傳到正確的位置。所以假設它是寫的& 由業主自己新增。
-
這些外掛只是為了具有特定於 wordpress 網站的程式碼。
-
由於所有者新增它們,因此無法從管理面板控制 (啟用/停用) 。核心內容包含 include 語句。
-
他們不需要任何檔案頭。
總而言之,它們是硬編碼為要包含的 php 檔案 (如果存在),每當 wordpress 載入相應的功能時。
要使用它們,只需在”wp-content” 目錄& 它將被自動包含。該檔案當然可以包括任意數量的其他檔案。
EDIT
正如 toscho 指出的那樣,1)Drop-ins(如果可用) 也在 wordpress 管理面板中列出了所有其他外掛。雖然與其他外掛不同,但是您沒有控制 de-activate 。 2)Wordpress 在升級時 (核心升級) 不改變”wp-content” 目錄。因此,這些外掛在升級之間從不改變。 3) 您可以在 wp-config.php 中定義一個常量來將”wp-content” 目錄更改為其他目錄。您需要定義的常數是 WP_CONTENT_DIR 。這也會更改其他常量 (如 plugins 目錄) 的預設值,因此,如果需要,還需要照顧它
參考文獻
注:本文內容整合自 Google/Baidu/Bing 輔助翻譯的英文資料結果。如果您對結果不滿意,可以加入我們改善翻譯效果:薇曉朵技術論壇。