[WordPress] 外掛分享: Macro Expander

首頁外掛目錄 › Macro Expander
⚠ 此外掛已下架 — 不再更新維護,建議勿安裝。
40+
安裝啟用
尚無評分
6789 天前
最後更新
問題解決
WordPress 2.0+ v1.1 上架:2007-08-15

內容簡介

您可以透過在部落格文章中輸入特殊指令來呼叫巨集:

[[keyword]]

當讀取到這個指令後,會呼叫名為 "macro_keyword" 的 PHP 函式,並且將其輸出插入頁面中。

您也可以向巨集傳遞參數:

[[keyword][param]]

或多個參數:

[[keyword][param1][param2]]

這些參數由 ][ 字元分隔,可以理解為用另一組方括號括住的列表。

此外,這個外掛的 PHP 檔案中有一個範例函式,示範您如何編寫巨集。它被稱為 "[[test]]",並且在「macro_test」函式中予以定義。這個「test」巨集最多可以接受兩個選用的參數。

在 1.1 版中新增功能:如果您想在 RSS 內容中包含巨集,您必須定義第二個名為 "macro_rss_keyword" 的函式。如果沒有這個函式,該巨集將不會被包含在 RSS 輸出中。

已知問題

這是個快速的駭客包,沒有進行全面的測試,但在我看來它似乎很有效。

WordPress 已經在 [[keyword]] 的前後添加了 <p> 和 </p> 標籤,這個外掛不會將這些標籤移除。

您不能在參數中使用 " 和 '(以及可能還有其他一些字元),因為 WordPress 會在外掛有機會解析參數之前,使用大括號引號替換它們。不過,您可以使用空格。

或許可以傳遞一個 $is_rss 參數,而不是使用兩個獨立的函式?

或許可以更改語法為: ?!

關於

版本 1.1(2007 年 6 月 8 日)- 參數分隔符號現在是 ][,而不是 |。新增 macro_rss_* 函式,用於 RSS 內容。

版本 1.0(2007 年 6 月 7 日)- 初始版本

由 Matthijs Hollemans 撰寫

http://www.hollemansproductions.com/wordpress-macro-expander-plugin.html

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.1) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Macro Expander」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

You invoke a macro by typing a special command in your blog post:
[[keyword]]
Upon reading this command, the PHP function named “macro_keyword” is called and
its output is inserted on the page.
You can also pass a parameter to the macro:
[[keyword][param]]
Or multiple parameters:
[[keyword][param1][param2]]
The parameters are separated by the ][ characters, or rather, you can look at it
as a list of things in brackets surrounded by another pair of brackets.
The PHP file for this plugin has an example function that shows you how to write
macros. It is called “[[test]]” and is defined in the function “macro_test”. The
“test” macro takes up to two parameters, both optional.
New in 1.1: If you want to include the macros in RSS content, you will have to
define a second function named “macro_rss_keyword”. If this function is not
present, the macro will not be included in the RSS output.
Known Issues

This is a quick hack, not extensively tested but it seems to work for me.

WordPress already adds the

and
tags around the [[keyword]] before
the plugin is called — the plugin doesn’t remove those.

You can’t use ” and ‘ (and possibly a handful of other characters) in
parameters because WordPress replaces them with curly quotes before the
plugin has a chance to parse them. You can use spaces, though.

Maybe pass an $is_rss parameter instead of using 2 separate functions?

Maybe change syntax to: ?!

About

Version 1.1 (8 June 2007) – The parameter separator is now ][ instead of |.
Added macro_rss_* functions for the RSS content.

Version 1.0 (7 June 2007) – First version

Written by Matthijs Hollemans
http://www.hollemansproductions.com/wordpress-macro-expander-plugin.html

延伸相關外掛

文章
Filter
Mastodon