這個外掛並未在最新的 3 個 WordPress 主要版本上進行測試。開發者可能不再對這個外掛進行維護或提供技術支援,並可能會與更新版本的 WordPress 產生使用上的相容性問題。

File Inliner

外掛說明

This plugin displays the content of a file in a post. The content of the file
(called a “snippet”) is put in a <pre></pre> block by default.

It has the following advantages over pasting the content of the file in your post
yourself:

  • When the file is modified, no need to modify the posts referring to it
  • Indentation is preserved by default (useful to show code snippets)
  • Can optionally provide a link to the file (no need to copy-paste your snippet)

If requested (see the preserveformat parameter), the content of the file
is put in a <div></div> block, with each line (delimited by
the carriage return) in its own <p></p> block.

Usage

Syntax: [file lang="some_lang" start="a_line_number" end="a_line_number" link="on_or_off" style="some_style_properties" preserveformat="on_or_off"]path/to/your/file[/file]

Note: The order of the attributes is mandatory!

Example: Inlining of a file

In your post, write [file]path/to/your/file[/file]. That’s it!

Example: Using a syntax highlighter plugin

If you write [file lang="cpp"]path/to/your/file[/file] (for instance),
and if the syntax highlighter plugin you use supports
the <pre lang="*"></pre> syntax (most does), then the content
of your file will be processed by the syntax highlighter plugin as usual.

Example: Provide a link to the file

If you write [file link="on"]path/to/your/file[/file], a link will
be automatically added to the top left of the text area.

Example: Inline a subset of a file

If you write [file start="10" end="20"]path/to/your/file[/file],
only the lines 10 to 20 of the file will be displayed. You can omit the start
(ie. “from beginning to line 20”) or the end (ie. “from line 10 to the end of
the file”) if you want.

Example: Set the color of the text to red

In your post, write [file style="color: #FF0000;"]path/to/your/file[/file].

Example: Prevent the plugin to process a [file][/file] block

Just write [file off]your content[/file].

Note: The ‘off’ attribute must come BEFORE any other ones.

螢幕擷圖

  • Inlining of a text file
  • Inlining of a C++ file, with syntax highlighting (using CodeHighlighter)
  • Inlining of a Python file, with syntax highlighting (using CodeHighlighter), and a download link
  • Inlining of some lines of a Python file, with syntax highlighting (using CodeHighlighter), and a download link

安裝方式

  1. Upload fileinliner.php to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress

常見問題集

How is the content of the file retrieved by the plugin?

The PHP function
file_get_contents
is used. Your file must be readable by the web server.

Can I use a URL instead of a path to the file?

From the file_get_contents
documentation: A URL can be used as a filename with this function if the
fopen wrappers
have been enabled.

Check your server configuration.

使用者評論

這個外掛目前沒有任何使用者評論。

參與者及開發者

以下人員參與了開源軟體〈File Inliner〉的開發相關工作。

參與者

將〈File Inliner〉外掛本地化為台灣繁體中文版

對開發相關資訊感興趣?

任何人均可瀏覽程式碼、查看 SVN 存放庫,或透過 RSS 訂閱開發記錄