自動嵌入鏈接

自動嵌入鏈接

自動嵌入鏈接允許用户自動將任何 Youtube 視頻、 Twitter 推文、 Imgur 圖像、 Vine 視頻和 Instagram 照片直接嵌入話題和回覆中。這是由 WordPress 內部的 oEMBED 功能提供支持的。有關 oEMBED 在 bbPress 和 WordPress 中支持的完整列表,請訪問此處

要啓用在 bbPress 話題和回覆上使用 oEMBED 的能力:

  1. 轉到 WordPress 後端中的設置 > 論壇
  2. 然後在論壇功能部分確保啓用 「將媒體 (YouTube 、 Twitter 、 Flickr 等) 直接嵌入話題和回覆中」

如何嵌入

您所要做的就是放置您嘗試嵌入的對象的完整 url 。例如,在回覆中,您可以將其放入回覆內容框中。

Check out this cool video:

[YouTube 鏈接網址]

那是一個很酷的視頻。

然後在您看到 YouTube 鏈接 URL 的地方,當您提交帖子時,您會看到完整的 youtube 視頻。

如何調整嵌入對象的寬度

嵌入對象的寬度調整為當前活動主題的寬度。要調整對象的寬度,您需要將其添加到子主題的 functions.php 文件中

if ( ! isset( $content_width ) ) $content_width = 600;

您可以將 600 更改為更適合您的主題的內容。

如何添加對更多網站的支持

請轉到這篇 WordPress 法典文章: 我如何添加或更改對網站的支持

論壇管理

論壇管理

常見任務

本指南將列出版主將在其論壇中執行的最常見的管理任務。本指南將來可能會拆分為多個指南。

處理垃圾郵件

這是一份指南,可讓您開始與論壇上的垃圾郵件作鬥爭。建議在您的論壇上設置版主,但本指南中列出的插件有助於極大地限制垃圾郵件發送者的數量。有計劃添加一個單獨的和簡化的指南,以保護您的網站免受攻擊。

導航鏈接返回 404s 錯誤

導航鏈接返回 404s 錯誤

這是安裝 bbPress 後的常見錯誤。問題涉及您的 WordPress 安裝或服務器配置。

原因

原因可能是以下任何一種

  • 未安裝 Apache mod_rewrite 模塊
  • 您的 WordPress .htaccess 文件丟失或無法被 Web 服務器寫入。

解決方案

該問題很容易解決,請通過這些步驟嘗試解決您的問題。

  1. 首先確保您的服務器上安裝了 mod_rewrite 模塊。
  2. 現在轉到 「設置」>「永久鏈接」 並將您的永久鏈接選項設置為默認值以外的選項。

如果問題仍然存在,請確保您已經解決了此處所述的常見問題:故障排除

如果在所有這些之後問題仍然存在,請聯繫您的網絡託管服務商支持以獲得有關您的問題的其他支持。

訂閲

訂閲

訂閲話題或論壇允許用户接收新帖子的電子郵件通知。

  • 當用户訂閲某個話題時,他們應該會收到一封包含該話題中任何新回覆的新電子郵件。
  • 當用户訂閲論壇時,他們應該會收到一封包含在論壇中創建的新話題的新電子郵件。

要啓用訂閲話題和論壇的功能:

  1. 轉到 WordPress 後端中的設置 > 論壇
  2. 然後在論壇功能部分確保啓用 「允許用户訂閲論壇和話題」

訂閲論壇或話題

對於訂閲論壇或話題的用户,他們需要單擊通常位於帖子頂部的 Subscribe 鏈接。每當他們點擊訂閲鏈接時,它現在會自動顯示為取消訂閲,話題是 ajax,但論壇會刷新。

論壇訂閲

用户還可以通過單擊旁邊帶有描述的複選框來訂閲話題,「通過電子郵件通知我後續回覆」 。

訂閲

訂閲論壇或話題後,用户訂閲的帖子現在將顯示在其論壇個人資料的訂閲部分。

退訂論壇或話題

在訂閲部分,用户可以查看或管理他們訂閲的所有論壇或話題。對於要取消訂閲任何論壇或話題的用户,他們需要做的就是轉到他們個人資料中的訂閲部分,在訂閲的論壇和 訂閲的話題下, 他們可以單擊紅色的 X 取消訂閲。

他們還可以轉到每個論壇或話題並單擊取消訂閲鏈接以取消訂閲他們訂閲的每個帖子,特別是對於話題,他們還可以取消選中複選框以不再接收電子郵件通知。

訂閲部分

bbp_setup_current_user

bbp_setup_current_user

該 bbp_setup_current_user() 函數與 WordPress 的 set_current_user 操作相關聯。在內部,它只調用 bbp_setup_current_user 動作,bbPress 使用該動作向希望掛鈎 bbPress 用户功能的第三方插件宣佈自己。

這有點黑客技巧,因為插件依賴項在 WordPress 中不存在,但它仍然是定位 bbPress 並專門為其創建插件的絕佳方式。

空白頁

空白頁

此問題包括當您嘗試訪問該站點時出現空白屏幕加載。此問題的兩個常見原因是由插件和主題引起的。

如果您可以訪問管理面板,那麼查明此問題的最佳方法是嘗試一一停用除 bbPress 之外的所有插件。如果這不起作用,請嘗試將您的主題更改為默認主題,如二十二。

原因

原因可能是以下任何一種。

  • 內存限制
  • 主題
  • 插件
  • 自定義 php 代碼函數
  • 長篇帖子緩存

解決方案

按照主題/插件問題的常見故障排除步驟操作,並清除故障排除中列出的緩存。如果這不能解決您的問題,請嘗試以下方法之一來增加內存限制以解決此問題。

使用 php.ini 增加內存限制

如果您可以訪問 PHP.ini 文件,請更改 PHP.ini 中

的行 如果您的行顯示 32M,請嘗試 64M 。

使用 wp-config.php 增加內存限制

打開位於 WordPress 目錄根目錄下的 wp-config.php 文件。現在將以下代碼添加到文件中。

define('WP_MEMORY_LIMIT', '64M');  

使用 htaccess 增加您的內存限制

您也可以將這段代碼添加到您的 htaccess 代碼中。

php_value memory_limit 64M  

如果您無法通過上述方法解決問題,則意味着您的託管服務提供商阻止了內存限制的增加。立即聯繫您的網絡託管服務商的支持人員。

收藏夾

收藏夾

將話題標記為最喜歡的,允許用户在以後添加書籤並查看他們最喜歡的話題。

要啓用收藏話題的功能:

  1. 轉到 WordPress 後端中的設置 > 論壇
  2. 然後在論壇功能部分確保啓用 「允許用户將話題標記為收藏」

將話題標記為收藏

要使用户收藏某個話題,他們需要單擊通常位於話題頂部的 「收藏」 鏈接。

 

最喜歡的

 

當用户單擊收藏夾鏈接時,它現在將使用 ajax 自動顯示為 收藏夾。收藏後,該話題現在也將顯示在用户論壇個人資料收藏夾部分。

從收藏夾中刪除話題

在收藏夾部分,用户可以查看或管理他們標記為收藏的所有話題。如果用户要從他們個人資料的收藏夾部分中刪除任何話題,他們需要單擊每個話題附近的紅色 X,或者他們也可以從此列表中轉到該話題,然後再次單擊 「已收藏」 鏈接,然後該話題將從他們的收藏夾中刪除。

 

收藏夾部分

bbp_setup_current_user 被錯誤調用

bbp_setup_current_user 被錯誤調用

當該調試通知被觸發 WP_DEBUG 常量定義為 true*不是*的 bbPress 其他試圖訪問一些關於當前用户和插件之前 $wp->init() 和/或 init 動作已經取消 wp-settings.php 。

該通知是為了提醒您 bbPress 被強制進入可能導致其他 (可能嚴重的) 訪問控制問題的配置,WordPress 沒有鈎子可以讓 bbPress 正確規避或恢復到安全操作條件。

不幸的是,很難從 bbPress 中確切地確定是什麼其他插件導致了這種情況發生,因此 bbp_setup_current_user 出現在日誌中。

此外,沒有任何 wp_set_current_user 操作;該 wp_set_current_user() 功能是在 WordPress 2.0.3 中引入的,set_current_user 為了向後兼容,該操作仍然存在。

也可以看看:

  • #WP24169 關於定製器也做錯了
  • #WP23106 關於添加一個動作以允許插件可靠地連接和修復功能
  • 這個 WordPress 加載順序問題導致了許多 bbPress Trac 票證

Step by step guide to setting up a bbPress forum – part 5

Step by step guide to setting up a bbPress forum – part 5

Step by step guide to setting up a bbPress forum – part 5
Codex Home → Step by step guide to setting up a bbPress forum – part 5
1. Using  Filters
Actions and Filters add a powerful way that you can alter how bbPress (and of course WordPress) work.
For the newcomer to WordPress, they are also probably one of the hardest areas to understand and to find information on. This tutorial tries to demystify some of this area, and help newcomers code those changes that will make their site work how they wish.
Part 4 dealt with 『actions』, this section deals with 『filters.』
It does repeat some of the initial text in Actions as it is applicable to both.
2. Introduction.
If you are familiar with functions and filters, you』ll probably not need to read much of this article, but I presume if you』re here, then like me you see snippets and 『brief』 explanations that get you to the stage where you are pretty sure what you want can be done, but can』t quite work out the exact way or get it to work.
So at this stage, make a cup of coffee, shut the kids out of the room, and I』ll try and take you through what I have learnt so far about filters.
If you can improve either the explanation, correct any errors I have made, or help in any other way, just post a topic on 「requests and feedback」 on the support forums, and I』ll pick it up.
3.  Filters
If actions ADD stuff at a particular point (see part 4 ), Filters are a way to ALTER what is being displayed (typically which bits of data or the format/order) at a particular point, without needing to change the code in the file.
This can be very handy if

the data is displayed in multiple places (eg the way an author name is displayed) – you change it once for all occurances
the file you want to alter is in the core of the code, so you don』t want to change the original file
You start to write plugins for others to use – filters let you alter lots of coding without touching the actual php files

So in essence think of it that actions add and filters alter.  But what does  a filter actually filter?  Well it filters a function, so we need to understand functions before we move forward
4. An explanation of functions
A function is a bunch of code that when combined does something.  In WordPress, functions are used to both hide complexity,  save repeating endless lines of code all over the place, and improve manageability.
So in bbpress the lines of code that go to the database, and fetch the identity of the author of a post is all put into a function  called  bbp_get_reply_author_id.  Anytime we want to do this, we can just quote that function, and save ourselves using many lines.  And if the guys behind bbPress want to change how that works, they do it just once and all the instances that use this then use the new function.
So lets create a simple function (we』ll get to some real bbPress examples later!)
function hello () {
$text="Hello Robin" ;
echo $text ;
}
Line 1 creates the function
Line 2 sets a variable of $text to Hello Robin
Line 3 writes that text to the screen
Then whenever called within a wordpess php file eg
hello () ;
it will write the result.
We might put this function in our functions.php file, or put it within a plugin.
Now bbPress is a plugin, and in bbPress there are hundreds of functions in many locations.
So imagine that someone else has written the 『hello』 function above and buried this function in in their plugin, and that this function is used in many places. However you don』t want it to say 「Hello Robin」 but 「Hello Fred」. Now you could find the function within the plugin and alter the code in the file, but on any upgrade of the plugin, you』ll lose the changes. So it would be better if you could just alter that variable $text, and filters offer a way to do that.
5. Not all functions are filterable
The above function cannot be filtered as it has not been written to allow this – hopefully all the functions you will come across have been – so let』s re-write it to be filterable.
function hello () {
$text="Hello Robin" ;
$text=apply_filters('hello',$text) ;
Echo $text ;
}
Line 3 has been added. In essence it says that if a filter exists, then substitute the value of $text in that filter to the function.
So now if we create a filter and add a function to it that changes $text, whatever value of $text is in that filter replaces the original value of $text in the function. So we can make 「Hello Robin」 become 「Hello Fred」 without altering any code.
So lets create a filter for this.  As with actions, we do this by creating a function.
So the original code above is buried in someone else plugin. Our new code will sit in our functions file or in a plugin, and alter the effect of that original code, changing $text=」Hello Robin」 to $text=」Hello Fred」.
So the resultant code looks like
//function to change 'Hello Robin' to 'Hello Fred' in 'hello' function
function called_anything () {
$text="Hello Fred" ;
return $text ;
}
add_filter('hello','called_anything') ;
So lets run through this.
5.1 Names
First let』s deal with naming
We are creating a function, and functions can be called anything.  However every function (and there are thousands of them in there already) MUST have a unique name across your website.  Given that you have the core wordpress and probably lots of plugins, it is important that you don』t create a duplicate name.  Calling it something like in my case 『robin_w_hello』 would probably make it pretty unique.
Adding a comment line at the start of your function to remind you what this is doing is also important, as you』ll never remember what this bit does when you start to have lots of these in your files.
5.2 Bringing in variables
In line 1 we called our function using function called_anything () .  The () is the area in which to put any variables we want to bring into our function.  So if I wanted to alter $text rather than replace it, I』d put it into the () so that it was brought in ie function called_anything ($text). In this case I could then  use some string manipulation to say strip the hello from the front.  So if you want to manipulate data from the core function import them here.
5.3 Return the data
Line 3 includes a return command.  This ensures that the data is passed back to the main function.  If omitted, then any variables you were planning to change will be blank, and therefore not show.
5.4 Add_filter &  Remove filter
In the last line we add a filter to 『hello』  named 『called_anything』
In this case we are adding filter. There is another command called remove_filter for removing a filter – useful if someone else』s plugin has a filter that makes a change you don』t want.
6. The apply_filter can have a different name from the function !
Ok so if you are not going mad by now, you are applying a filter with a name to your function, not applying a filter to your function』s name. So that apply_filter can have a different name from your function, and indeed you can have several filters in a function.
So whilst we had a line above in our function 『hello』 saying
$text=apply_filters('hello',$text) ;
the 『hello』 bit of 「apply_filter(『hello'」 is the name of the filter, and could be anything (or rather anything unique to your site!)
So whilst no one would actually write a function this way, we could have
function hello () {
$text1="Hello Robin" ;
$text1=apply_filters('hello_change1',$text) ;
$text2="goodbye Robin" ;
$text1=apply_filters('hello_change2',$text) ;
Echo $text1.$text2;
}
Now I wouldn』t tell you this unless you needed to know it, so you will frequently find filters in wordpress and bbPress are not the same as their function name. Indeed we will see later on that they are quite often different, but have a logic to them, which once known means that you can work it out.
7. Creating a filter for an array
An array is a set of data held within a single data name
So for instance
$data = array(
「name」 => 「Robin」,
「age」 => 「21」,
);
The array $data now contains both my name and my age.
Most bbPress functions create arrays, as they use multiple data, so lets create a function that has an array, and outputs some data
function hello () {
$data = array(
'name' => 'Robin',
'age' => '21',
'text' => ' years old.',
);
$data=apply_filters('hello',$data) ;
echo $data['name']." is ".$data['age'].$data['text'] ;
}
Calling hello() in a php file will cause the result
「Robin is 21 years old.」
Let』s say we want to change the wording to say 「Robin is 21 years young.」
So we need to alter the $data[『text』] to say 」 years young.」
So we will write a function to do that, and the add a filter to implement it
The result looks like this
//this adds a filter to change $data['text'] to ' years young'
function called_anything ($data) {
$data ['text'] = ' years young.' ;
return $data ;
}
add_filter('hello','called_anything') ;
Let』s run through that
If we just had 『function called_anything()』 then anything we change we will reset the entire array, so we need to 『bring in』 the current values. 『called_anything ($data)』 brings across the array into our new function.
The second line changes the 『text』 value, and the third line returns the new array back to the original function
So now the array looks like
『name』 => 『Robin』,
『age』 => 』21』,
『text』 => 『 years young.』,
and the output will be 「Robin is 21 years young」 – job done !
So now we』re ready to look at some real bbPress examples.
8. Finding the code
So where is the code that we need to look at?
This is of course the first issue with bbPress (as with any other part of WordPress) – finding out what file needs to be altered.
For bbPress, all the critical template files (the most likely you』ll want to alter) are held in the folder
Wp-content/plugins/bbpress/tempaltes/default/bbpress
Whilst many of the names give a good clue to what they do, you』ll probably need to delve into a few before you find the one you want.
I plan to make a list of these templates and what they do if/when I work it out!
But let』s start from the point where you have got something displaying in WordPress that you want to alter. You have found the template file that covers this, and within that you have a function that is displaying the data that you want to alter or alter the display of.
So we』ll need to create a filter.
9. Where to add filters
In this tutorial, we』ll generate the code you need, but obviously that code needs to go somewhere. So where do we put it?
We add actions or filters either to the functions file, or create them as a plugin.
Both methods have their uses.
If you like using plugins, then they』re a good way to add changes, and work well if you have a number of sites, as the plugin is easily uploaded to each. But they do require a bit more knowledge to code. But google the subject and you』ll find lots of help on creating one. Then just put the code into it, and upload to your site.
The alternate is to use a functions file. As you are now at the 「advanced」 stage of using WordPress, you should either be developing your own themes, or using a Childtheme to store the specifics.
If you still just have a main theme from someone else (eg a wordpress default theme, a free theme or a premium theme), then you should create a childtheme. This simply uses the main theme, and the you can add your tweaks to the childtheme. Then if the main theme is updated, you tweaks in the childtheme are not overwritten. For help on creating a childtheme google 「child theme wordpress video」 and you』ll find lots of demonstrations. If someone has built a site for you, it may already be a in a child theme, and again the video』s will let you see whether this is the case.
Within our childtheme, we』ll put a functions.php file, and the actions and filters we set up will go in there.
10. Example of code we can alter
So to start to understand what we need to do, lets have a look at something we might want to change
In the forums display we have a count of topics and replies next to each forum viz :

Let』s say we want to remove these counts and make it look like

Now we could do this by altering the template that does this. In fact the codex has a page Layout and functionality – Examples you can use . Section 2 shows how to change this by altering a template called loop-single-forum. But if we alter that template, then we will need to store it in a different place so that it is not overwritten by later updates. This can be quite easily done, and there is no reason why you shouldn』t do this, but adding a filter is an equally valid alternative.
So where to start?
Well let』s start by summarising what we are going to do, then you can follow the steps.
a) look at the templates to find which one has the function we want to alter
b) look at the codex to see if that function is there
c) if it is then we can see the arguments,
d) if not, then we』ll need to look for the function definition
e) and then code the filter
Looks easy(ish), but it』s a bit like being a detective, you have to follow the clues.
a) Well we start by finding out that bbPress stores all the main 「display」 areas of the plugin in a template folder held at
wp-content/plugins/bbpress/templates/default/bbpress
I plan to have a list of which templates do what, but for the moment it』s really a case of intelligent guesswork and lots of opening files and examining. Typically anything with lists in it will be running a loop (going through a list), so loop-something is a good bet.
So since we are loking at a list of forums, we loom at the templates that have loop and forum. At some stage we open loop-single-forum and in there we see a progression from forum title, forum description, sub-forums, and then some topic, reply and freshness counts.
Click here to see the file – opens in a new window so you can switch between this and the code.
The sub-forum list part on line 30
bbp_list_forums();
looks like a likely candidate, so let』s look at that. We』ll do that next.
b) So lets look at the codex to see what is written about this function. Go to the documentation (this section) and select any article – you』re actually reading this one, so that』s fine. On the left hand side you』ll see a 「related」 area. You』ll need to scroll back up from this article to see it. Look down the list for the function – in this case 『bbp_list_forums』, and it』s listed (not all are – yet!)
Open this up and you』ll see that it lists the arguments (again not all do yet, so see d) below if yours is not there.

Within this are 「show topic count」 and 「show reply count」, and you』ll see that they are set to 「True」 – setting these to false should hide the detail.
You』ll also see a line saying 「To filter this array use add_filter(『bbp_before_list_forums_parse_args』, 『your_filter_name)」 – so that』s the filter we need. As we said earlier, the filter name may well be different to the function name. So bbp_list_forums uses 『bbp_before_list_forums_parse_args』 to alter the array. (In fact there is a further filter in this function which does have the function name, but we』ll ignore that for the moment!)
So we』ll create a function to change the topic and reply values to false so that they don』t display and add a filter to implement it.
The data is held in an array, so we need to use the code for that.
So lets start with the function
function hide_forum_counts ($args = array() ) {
$args['show_topic_count'] = false;
$args['show_reply_count'] = false;
return $args;
}

Then we』ll add the filter
add_filter ('bbp_before_list_forums_parse_args','hide_forum_counts') ;
This code will go in our functions file (or as a plugin).
d) But what if the codex doesn』t show the filter? How do we find what filter to use?
Ok, we can work this out. We』ll start as before with bbp_list_forums. We need to fund where that function is defined.
Now all the functions used in the templates wp-content/plugins/bbpress/templates are held in 5 template folders that are located as follows :
wp-content/plugins/bbpress/includes/forums/template.php
wp-content/plugins/bbpress/includes/topics/template.php
wp-content/plugins/bbpress/includes/replies/template.php
wp-content/plugins/bbpress/includes/users/template.php
wp-content/plugins/bbpress/includes/search/template.php
As we are listing forums, we could take a bet that it will be in wp-content/plugins/bbpress/includes/forums/template.php (which it is), but if you had no clue, then download the plugin to your PC, extract it to a directory, and use your PC』s serach function to find it. But do search for 『bbp_list_forums』 not 『bbp_list_forums()』 as bbPress functions will normally have arguments, so the () will contain stuff, and your search will produce a nil return!
So we find wp-content/plugins/bbpress/includes/forums/template.php
and open it up. Inside we see on line 744
function bbp_list_forums( $args = '' ) {
and way down on line 801
echo apply_filters( 'bbp_list_forums', $r['before'] . $output . $r['after'], $r );
so we』d think that the filter we want to add is to 「apply_filters( 『bbp_list_forums'」. But no, this filter is after all the function has happened. We simply want to change a couple of the input parameters.
At the beginning of the function we find :
// Parse arguments against default values
$r = bbp_parse_args( $args, array(
'before' => '<ul class="bbp-forums-list">',
'after' => '</ul>',
'link_before' => '<li class="bbp-forum">',
'link_after' => '</li>',
'count_before' => ' (',
'count_after' => ')',
'count_sep' => ', ',
'separator' => ', ',
'forum_id' => '',
'show_topic_count' => true,
'show_reply_count' => true,
), 'list_forums' );

This is a common format throughout bbPress, and indeed is similar to a function used throughout wordpress.
It uses a function called 『bbp_parse_args』 to create a filter against all the arguments.
The filter created is in the format 「bbp_before_」 followed by X followed by 「_parse_args」 The X is the third argument from the bbp-parse_args function – if you look at the code aboave you』ll see that it is actually
bbp-parse_args ($args, Array(...), 'list_forums' )
so in the last line we see 『list forums』 which is the X above . In practice this is the function without the bbp start bit.
so an array filter for bbp_list_forums is 『bbp_before_list_forums_parse_args』
and for say bbp_get_topic_pagination would be
bbp_before_get_topic_pagination_parse_args
Ok, so that』s a long explanation, that will need you to read several times, and I』ll add some more examples as I progress.
As said above, any feedback or clarity needed, post a topic at
requests and feedback