
內容簡介
JSM file_get_contents() Shortcode 是一個安全且可靠的 WordPress 外掛,提供 PHP 的 file_get_contents() 函數的短代碼功能,讓使用者能夠輕鬆地從指定的 URL 或本地檔案中獲取內容並顯示。
【主要功能】
• 支援從 URL 或本地檔案獲取內容
• 可選擇性地緩存內容以提升效能
• 提供多種短代碼屬性以自訂內容顯示
• 支援 HTML 字元轉義以增強安全性
• 可設定內容包裝格式如 <pre> 和 <code>
外掛標籤
開發者團隊
② 後台搜尋「JSM file_get_contents() Shortcode」→ 直接安裝(推薦)
原文外掛簡介
A safe and reliable WordPress shortcode for PHP’s file_get_contents() function.
Shortcode Attributes
body = Keep only the content between
HTML tags (default is true).cache = Number of seconds to cache the contents (defaults is 3600 seconds).
class = Add a class to the content ‘div’ container (default is none).
code = Wrap the content in a
container (default is false).code_class = Add a class to the ‘code’ container (default is none).
code_lang = Escape HTML characters, wrap the content in a
container, and add a language class to the ‘code’ container (default is none).
esc_html = Escape HTML characters (default is false).
esc_html_pre_code = Escape HTML characters and wrap the content in a
container (default is false).
file = Path to a local file (relative to the wp-content/ folder).
filter = Apply the named filter to the content (default is none).
more = Add a more link on non-singular web pages (default is true).
pre = Wrap the content in a
container (default is false).
pre_class = Add a class to the ‘pre’ container (default is none).
pre_code = Wrap the content in a
container (default is false).
pre_lang = Escape HTML characters, wrap the content in a
container, and add a language class to the ‘pre’ container (default is none).
pre_title = Add a title to the ‘pre’ container (default is none).
url = URL or file URI.
utf8 = Encode HTML entities (default is true).
Note that all file paths (not URLs) are relative to the wp-content/ folder. For security reasons, it is not possible to include files outside the wp-content/ folder. As an example, the shortcode attributes url="file://dir/file.html" and file="/dir/file.html" are both read as wordpress/wp-contents/dir/file.html. The .. folder name is also stripped from file paths to prevent backing out of the wp-content/ folder.
Shortcode Name
The WPFGC_SHORTCODE_NAME constant can be defined in your wp-config.php file to add an additional custom shortcode name (the default shortcode names are ‘wp-file-get-contents’ and ‘wpfgc’).
define( 'WPFGC_SHORTCODE_NAME', 'include' );
Shortcode Examples
[wpfgc url="http://example.com/dir/file.html"]
[wpfgc url="http://example.com/counter/" cache="7200"]
[wpfgc url="file://dir/file.html"]
[wpfgc file="/dir/file.txt" pre="true" filter="my_custom_filter_name" cache="600"]
[wpfgc file="examples/example-1.php" code_lang="php"]
