How To Accept Multiple Parameters in WordPress Filters如何接受多個參數在WordPress過濾器
This is for WordPress Plugin and Theme developers.這是為wordpress插件和主題發展。 Don’t read further if you are not one of them.不讀進一步如果您是不是其中之一。
To get an extra argument in your filter (say for a ‘bloginfo’ filter) you have to specify not 2 but actually 4 as number of arguments in add_filter (read below for details).以獲得額外的論據,在您的過濾器(說一個' bloginfo '過濾器)你有沒有指定二,但實際上4數目的論據add_filter (閱讀下面的詳細資料) 。 The returned data are: first argument, filter name, first argument, second argument返回的數據是:第一個論點,篩選器名稱,第一個論點,第二個論點
BTW: One place where this function is needed is for writing ‘bloginfo’ filter.的BTW :一個地方,這個功能需要的是書面' bloginfo '過濾器。 It passes two arguments - value and key.它通過兩個論點-價值和關鍵。
So when I add_filter I have to write:因此,當我add_filter我已寫:
add_filter(’bloginfo’, ‘my_filter’,10, 4 ); add_filter ( ' bloginfo ' , ' my_filter ' , 10 , 4 ) ;
10 is the priority十是優先
4 is the argument count四是論點計數
And then I access the second argument as:然後我進入第二個論點為:
function remove_css($first_argument,$dummy,$dummy,$second_argument) 功能remove_css ( $ first_argument元,假美元,假美元, second_argument )
I haven’t tried for more than 2 arguments but I suspect it will be equally funky.我並沒有試圖為超過2的論據,但我懷疑它也將同樣時髦。 I have reopened我已重開 ticket 901票務901 and update the comments.和更新的評論。
Filed under提起下 CMS Software CMS軟件 , , Pro Blogging贊成Blogging , , Web網頁 , , WordPress在WordPress | |
| |
RSS 2.0 2.0 | |
Trackback Trackback跟踪 this Article |此文章|
Email this Article電子郵件此文章
You may also like to read您也可以想讀 |



April 21st, 2006 at 3:47 am 2006年4月21日在上午03時47分
salam薩拉姆