自动嵌入链接

自动嵌入链接

自动嵌入链接允许用户自动将任何 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