
前言介紹
- 這款 WordPress 外掛「If File Exists」是 2009-06-11 上架。
- 目前有 10 個安裝啟用數。
- 上一次更新是 2025-04-18,距離現在已有 314 天。
- 外掛最低要求 WordPress 2.7 以上版本才可以安裝。
- 有 1 人給過評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
外掛標籤
file | exists | existence | filesystem | coffee2code |
內容簡介
這個外掛提供了 c2c_if_file_exists()、c2c_if_theme_file_exists()、c2c_if_plugin_file_exists() 函數,用來檢查檔案是否存在,並可回傳 true/false 或顯示包含檔案資訊的字串。
若未傳送格式字串,這些函數會回傳簡單的布林值(true 或 false),指示特定檔案是否存在。
否則,傳送給它的格式字串將用於構建回應字串,可以自定義顯示檔案資訊(例如檔案名稱、檔案網址或檔案路徑)。若 $echo 參數為 true,該字串將在網頁上顯示。無論 $echo 的值為何,該回應字串都會被函數返回。
預設情況下,c2c_if_file_exists() 假設您要查找相對於預設的 WordPress 上傳目錄的檔案。如果要搜索其他目錄,請將它作為 $dir 參數指定。c2c_if_theme_file_exists() 假設您要查找相對於當前啟用主題的主目錄的檔案。c2c_if_plugin_file_exists() 則假設您要查找相對於包含 WordPress 外掛的目錄的檔案。
連結: 外掛主頁 | WordPress 外掛目錄頁 | GitHub | 作者主頁
開發人員文件
開發人員文件可在 DEVELOPER-DOCS.md 中找到。該文件涵蓋了外掛提供的模板標記和鉤子。
總的來說,這些是外掛提供的模板標記:
c2c_if_file_exists() :檢查文件是否存在,回傳 true/false 或顯示包含檔案資訊的字串。
c2c_if_plugin_file_exists() :檢查文件是否存在(相對於外掛目錄),回傳 true/false 或顯示包含檔案資訊的字串。
c2c_if_theme_file_exists() :檢查文件是否存在(相對於目前啟用的主題目錄),回傳 true/false 或顯示包含檔案資訊的字串。如果目前主題是子主題,則函數將首先檢查子主題的目錄中是否存在該檔案,如果找不到,則再檢查父主題的目錄中是否存在。
這些是外掛提供的鉤子:
c2c_if_file_exists :篩選器,允許使用另一種方法安全地調用 c2c_if_file_exists(),以便在停用或刪除該外掛時,您對函數的調用不會在您的網站中引起錯誤。
c2c_if_plugin_file_exists :篩選器,允許使用另一種方法安全地調用 c2c_if_plugin_file_exists(),以便在停用或刪除該外掛時,您對函數的調用不會在您的網站中引起錯誤。
c2c_if_theme_file_exists :篩選器,允許使用另一種方法安全地調用 c2c_if_theme_file_exists(),以便在停用或刪除該外掛時,您對函數的調用不會在您的網站中引起錯誤。
原文外掛簡介
This plugin provides the functions c2c_if_file_exists(), c2c_if_theme_file_exists(), c2c_if_plugin_file_exists() that check if a file exists and either return true/false or display a string containing information about the file.
If a format string is not passed to it, the functions returns a simple boolean (true or false) indicating if the specified file exists.
Otherwise, the format string provided to it will be used to construct a response string, which can be customized to display information about the file (such as directory, extension, name, path, size, or url). If the $echo argument is true, that string is displayed on the page. Regardless of the value of $echo, the response string is returned by the function.
By default, c2c_if_file_exists() assumes you are looking for the file relative to the default WordPress upload directory. If you wish to search another directory, specify it as the $dir argument. c2c_if_theme_file_exists() assumes you are looking for a file relative to the currently active theme’s home directory. c2c_if_plugin_file_exists() assumes you are looking for a file relative to the directory that contains WordPress plugins.
Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage
Developer Documentation
Developer documentation can be found in DEVELOPER-DOCS.md. That documentation covers the template tags and hooks provided by the plugin.
As an overview, these are the template tags provided by the plugin:
c2c_if_file_exists() : Checks if a file exists and returns true/false or displays a string containing information about the file.
c2c_if_plugin_file_exists() : Checks if a file exists (relative to the plugins directory) and returns true/false or displays a string containing information about the file.
c2c_if_theme_file_exists() : Checks if a file exists (relative to the current theme’s directory) and returns true/false or displays a string containing information about the file. If the current theme is a child theme, then the function will check if the file exists first in the child theme’s directory, and if not there, then it will check the parent theme’s directory.
These are the hooks provided by the plugin:
c2c_if_file_exists : Filter that allows use of an alternative approach to safely invoke c2c_if_file_exists() in such a way that if the plugin were deactivated or deleted, then your calls to the function won’t cause errors in your site.
c2c_if_plugin_file_exists : Filter that allows use of an alternative approach to safely invoke c2c_if_plugin_file_exists() in such a way that if the plugin were deactivated or deleted, then your calls to the function won’t cause errors in your site.
c2c_if_theme_file_exists : Filter that allows use of an alternative approach to safely invoke c2c_if_theme_file_exists() in such a way that if the plugin were deactivated or deleted, then your calls to the function won’t cause errors in your site.
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「If File Exists」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
2.0 | 2.1 | 2.2 | 2.3 | 2.4 | 1.0.1 | 1.0.3 | 2.1.1 | 2.1.2 | 2.1.3 | 2.2.1 | 2.2.2 | 2.2.3 | 2.2.4 | 2.2.5 | 2.2.6 | 2.2.7 | 2.2.8 | 2.2.9 | 2.3.1 | 2.3.2 | trunk | 2.2.10 |
延伸相關外掛(你可能也想知道)
Disable Search 》此外掛可防止 WordPress 處理和允許任何來自網站前端的搜尋請求。具體來說,此外掛:, , 若主題使用標準的 get_search_form() 函式來顯示搜尋表單,則無法顯...。
Text Replace 》這個外掛讓你輕鬆地定義出應用於文章中的文字或 HTML,以替代實際出現在文章中的字詞或片語。這是一個方便的技巧,可用於創建常見、冗長或經常更改的文本/HTM...。Duplicate Widget 》r />, 一個小工具,可以作為另一個小工具的副本(用於在另一個側邊欄中同步使用), 只需定義一次小工具,即可在多個側邊欄中使用。這樣可以避免手動配置每個...。
Admin Trim Interface 》這個外掛使用WordPress hook、CSS(如果可能的話)和Javascript(最後的手段)的組合,來移除特定的管理介面元素。這些元素可能被一些人認為是多餘的介面元素...。
Force Admin Color Scheme 》雖然通常是 WordPress 的個別設定,在某些情況下,強制將單一管理者配色方案強加於站點所有使用者上可能是必要的,例如:, , 為同一組用戶使用的多個網站提供...。
Single Category Permalink 》這款外掛可以將連結 (分類或文章)的完整分類架構縮減為僅顯示最低階層的分類。, 預設情況下,WordPress 會將自訂連結結構中的 %category% 佔位符號,替換為該...。
Years Ago Today 》此外掛提供一個簡單的管理儀表板小工具,列出這一天往年在您的網站上發布的所有文章。使用者可以選擇(透過他們的個人資料)訂閱每天的電子郵件,提供鏈接和...。Disable Directory Listings 》此外掛可防止虛擬目錄列出目錄內容,或在虛擬目錄列出時顯示自定義頁面。 , 如果網站的某個目錄中沒有索引檔案(例如 index.html 或 index.php),則 Apache ...。
Random File 》此外掛提供模板標籤,允許您檢索指定目錄中隨機選擇的文件名稱、路徑(相對或絕對)、URL,或完整標記的鏈接。, 函數的參數允許您根據給定的文件擴展名限制可...。
Extra Sentence Space 》即使您在撰寫文章時在每個句子之後添加兩個空格(假設您遵循建議使用此間隔的寫作風格),當在瀏覽器中查看時,瀏覽器會將連續的空格合併為一個空格。此外掛會...。
Admin Expert Mode 》WordPress長期以來一直在管理界面中提供內嵌文檔,針對各種功能和輸入欄位進行說明,包括摘錄、引用、自定義欄位、頁面父類別等等。對於WordPress新手而言,...。
Show Pending Comments Count 》注意:此外掛自 WordPress 4.3 版本開始已被棄用,因為 WordPress 現在已經能夠以比此外掛更美觀的方式顯示待審核評論的數量,所以如果您使用的是 WP 4.3 或...。
Safe Function Call 》安全地呼叫一個函數、類別方法或物件方法,以一種不會因為這些外掛停用而產生錯誤的方式。, 提供了各種輔助函數,可以提供此主題的方便變化:, , _sfc(): 安...。
Peer Categories 》這個外掛提供了一個模板標籤,作為 WordPress 內建模板標籤 the_category() 的修改版本。 the_category() 列出直接分配給指定文章的所有類別。 c2c_peer_cate...。
Parentless Categories 》這個外掛提供了一個模板標籤,作為 WordPress 內建模板標籤the_category()的修改版本。 the_category()列出了直接指定給帖子的所有類別。 c2c_parentless_cat...。
