为什么要有测试站点?

为什么要有测试站点?

为什么我应该有一个测试站点?

许多 wordpress 用户只有一个实时站点,并在该站点上进行所有更改。在绝大多数情况下,这很好,而且效果很好。

但是 wordpress 论坛每天都有来自 WordPress 管理员的帖子,他们在他们的网站上进行了一些更改,但现在无法正常工作。

WordPress 核心非常强大,但是为了制作一个 wordpress 站点,我们大多数人都会添加主题和插件(包括 bbPress),而这些是由许多不同的人编写的。我们也可以通过添加 css 或添加函数来自己进行更改。 WordPress 还使用多种语言,将所有这些元素结合在一起意味着错误可能会蔓延。

因此,以下所有情况都可能导致问题:

  • 更新 wordpress 核心
  • 更新插件
  • 更新主题
  • 添加插件
  • 改变主题
  • 更改或添加功能
  • 更改或添加 css

虽然在大多数情况下这一切都很好,但所有这些都可能导致任何问题,从轻微的布局问题到最坏的 “白屏死机”(称为 WSOD),您的网站只显示一张空白的白纸。

对许多人来说,这是他们第一次遇到问题,他们不熟悉 FTP 和 PHPmyadmin,并且对于一个通常无法运行或看起来非常错误的实时站点,他们既感到恐慌、沮丧,又需要紧急帮助。

破坏您的实时站点也会在最不方便的时刻发生 – 只需两分钟的简单快速插件更新刚刚破坏了您的站点,您现在应该在十分钟内出去吃晚饭,而您的另一半正在对您大喊大叫,让您做好准备。

拥有测试站点意味着您可以更新 WordPress,添加或更新插件和主题,并确保它们在您实时执行此操作之前正常工作。如果它破坏了您的测试站点,您可以花时间找出问题所在,同时您的实时站点仍能正常运行。

但是拥有一个测试站点可以让您做更多、更多的事情。您可以测试 WordPress 、主题和插件设置更改以查看它们的作用;尝试更改样式以查看它们的外观;更改您的函数文件并添加新函数;创建一个子主题并玩弄您网站的外观和功能;添加新的 .php 文件并在其他人看到它们之前测试它们。

当然,您可以在闲暇时执行此操作,不再需要快速尝试某些内容,然后在您不喜欢的情况下还原您的站点。您可以做一半的更改,稍后再回来修补它。

如果以上所有内容都不能让您相信您不仅想要一个测试站点,而且绝对需要一个,那么让我补充一个关键点——备份。

现在您可能依赖您的主机提供商来备份您的站点,我怀疑所有主机提供商都会至少每天备份您的站点。如果您的网站因为您尝试更新插件而出现故障并且您的网站冻结,他们会让您恢复到昨天的版本 – 是吗?

嗯,可能是这种情况,但是您的提供商会在几分钟内完成吗?他们会一天 24 小时这样做吗?他们甚至在您的时区吗?昨天的备份是否足够好?– 是的,它可能会让您回到更新该插件之前的位置,但是您是否会丢失花费数小时撰写的博客条目,是否会丢失论坛帖子、商店订单、读者发表的评论、您拥有的设置改变了,css 和函数文件?– 事实上,今天您网站上的无数事物可能与昨天不同。

最终,如果您的主机提供商破产,那么您不仅失去了您的站点,而且他们将没有工作人员为您提供站点的副本,以便您可以在其他地方进行设置。

因此,依靠您的主机提供商进行备份并不是一个好策略。

因此,您自己进行备份 – 是吗?有很多备份产品,而且很多都可以作为插件使用。您也可以自己备份 WordPress,并复制您的数据库。

通常对于所有这些方法,您会将它们保存到您的 PC 中,或者现在越来越普遍地保存到 “云” 中。但复印只是解决方案的一半。复制是否有效,您是否测试过,您知道如何进行还原吗?这些不是您想要在现场测试或在您的网站关闭时第一次尝试的东西。那么您怎么知道您的备份伙伴(可用的备份插件之一)副本是否会在需要时实际恢复?

当我第一次开始使用 WordPress 时,我使用了这个插件,但发现我复制的一个副本根本无法恢复——如果那是我的关键副本,并且我的实时站点已关闭,然后我需要走得更远。幸运的是,我有很多其他备份伙伴副本,它们运行良好。

或者,如果您复制数据库,您怎么知道它们没有损坏,或者我发现它们太大而无法一次性恢复到我的数据库中。

除非您定期测试备份以查看它们是否有效,否则您既不知道副本是否正常工作,也不习惯恢复过程。这两个都是关键要求,如果不确定您是否可以恢复,您的备份充其量只是一种希望。

因此,测试站点可让您测试恢复备份 – 不是每天,但您当然应该测试恢复,比如每月一次,让您感到高兴,如果最坏的情况发生,您可以应对。

因此,如果我现在已经说服您应该拥有一个测试站点,那么您会想知道如何创建一个。

回到创建测试站点

上次修改 2021.12.25

创建测试站点

创建测试站点

创建测试站点非常有益,因为您可以了解 bbPress 和 WordPress 的工作原理,并同时测试它们。

  • 对于开发人员来说,创建一个测试站点可以帮助他们为 bbPress 开发插件或主题。
  • 对于常见的 WordPress 站点调整器,它可以在将更改传输到实时站点之前在其测试站点上测试简单的样式或功能更改。
  • 更重要的是,创建一个测试站点将允许您测试插件/主题升级的问题,以便更新不会使您的实时站点容易受到黑客的攻击或破坏您的站点。

这个简单的过程应该可以帮助您自信地升级,并且可以更大胆地使用您的站点,首先测试测试站点中的所有内容,只有在您对一切正常工作感到满意后才提交到实时站点。

如果您不相信您需要一个测试站点,那么请阅读我的推理:为什么要有一个测试站点?

创建测试站点有两种流行的选择:

  1. 在您的计算机上安装本地服务器环境客户端
  2. 使用现有域的子域。

本地安装

在您的计算机上创建测试站点是购买新域的一种很好且免费的替代方法。如果您想走这条路,您需要安装一个支持您的操作系统的应用程序,并允许您运行主机服务器通常安装的软件来在您的计算机上运行测试站点。

每个应用程序通过它支持的操作系统识别自己,并安装软件,包括  A pache 、 M ySQL 和 P HP(XAMPP 还包括 P erl)。以下是流行的本地服务器环境客户端列表,以及 WordPress 手册中的指南链接,可帮助您安装每个应用程序。

最流行的本地服务器包是:

  • WAMP – 适用于 Windows
  • MAMP – 适用于 Mac
  • XAMPP – 适用于 Windows 、 Mac 和 Linux

创建测试站点并使用列出的软件应用程序之一在您的计算机上安装 WordPress 后,您可以安装 bbPress 并对其进行测试。您可以看到插件如何与 bbPress 一起工作,主题如何工作,您还可以为 bbPress 开发插件或主题。

现有域的子域

子域将您的主域用作单独的站点。因此,如果您创建一个名为 “test” 的子域,那么您将使用 “test.mysite.com” 作为访问该站点的 URL 。

大多数主机提供商允许您创建子域。如果您访问您的托管区域,您应该会找到创建子域的选项。如何执行此操作因主机提供商而异,因此如果您需要任何帮助,请联系主机提供商的支持以获取有关如何为当前设置创建子域的任何信息。

创建后,您可以创建测试站点并获得以下好处:

  • 测试任何性能问题
  • 包含外部源 API 的测试插件

克隆现有站点

通过克隆或镜像您的实时站点,您可以先在测试站点上测试任何修改/升级,而不会影响您现有的实时站点。

所以您可以测试:

  • 主题和插件的新升级
  • 添加并测试任何新插件
  • 更改已安装的 WordPress 主题
  • 添加 css 、更改功能、布局以及与现有 WordPress 站点有关的任何内容

因此,您将首先仅在测试区域提交,如果您对结果感到满意,则可以将这些更改转移到您的实时站点。而且,如果插件有新的升级,您可以先在您的测试站点上测试升级,如果升级导致问题,您将知道在问题解决之前不要在您的实时站点上升级。

复制数据

所以现在您有一个测试域,其中包含您网站上的所有文件和文件夹,但您需要复制数据。

尝试操作

  1. 使用 phpMyAdmin 访问您的实时站点的数据库。
  2. 接下来,在左侧,您将看到所有创建的数据库。
  3. 查找并选择您的实时站点的数据库,您现在将看到来自该数据库的一系列表格。
  4. 您将在顶部的菜单中看到一个导出选项。单击它后,您将看到一些选项。
  5. 现在您可以进行快速导出,但我认为不建议这样做,我更喜欢您进行自定义导出,以允许您将数据压缩为 zip 格式并添加任何其他值以改进恢复。
  6. 所以现在启用 Custom 。
  7. 通常,您可以将数据库导出到单个包中,但是如果您有一个特别大的数据库,您可能无法一次性导出/导入。在导入过程中,您可能需要复制单个数据库表或对表进行分组。但是,您可以先尝试导出所有表以进行测试并确保一切正常。
  8. 在 “输出” 部分中,选择您选择的 zip 格式来压缩您的数据库数据。这可能会显着增加大型数据库的上传时间。它还可以让您克服主机提供商可能设置的某些文件上传大小限制。
  9. 在对象创建选项中,启用添加 DROP TABLE/VIEW /PROCEDURE/FUNCTION/EVENT 语句。在导入过程中,这将在恢复新表之前删除所有现有表,确保导入干净。
  10. 现在单击 Go,文件将下载到您的计算机上。

导入数据

已经以压缩文件格式下载了数据库数据,您现在可以将数据导入到新的或现有的数据库中。

如果您尚未创建新数据库。

  1. 转到 phpMyAdmin 主页。
  2. 单击顶部的数据库菜单项
  3. 您现在将看到一个用于创建新数据库的区域以及一个用于命名数据​​库的文本输入。
  4. 为测试站点的新数据库创建一个新名称。将下拉列表保留为 Collat​​ion 的默认设置,然后单击创建按钮。
  5. 您刚刚创建了新数据库。

将数据导入新数据库。

  1. 为您的测试站点选择您最近创建的数据库。
  2. 单击顶部的导入菜单项
  3. 现在单击 “选择文件” 按钮 ,然后从下载中选择实时站点的数据库数据。
  4. 单击 “前往” 按钮。等待导入完成,然后您应该会看到一条成功消息。
  5. 现在,您已将实时站点的数据库数据导入到测试站点数据库中。

更改站点引用

由于活动站点的数据已导入到测试数据库中,您将在 wp_options 表中看到您的活动站点的 url 。如果您不更改这些,您将被重定向到您的实时站点,因此更改它是关键。

  1. 在 phpmyadmin 中选择您的测试站点数据库
  2. 单击最顶部的 SQL 菜单项
  3. 现在在空框中输入以下 SQL 代码
UPDATE wp_options SET option_value = REPLACE(option_value, 'LIVESITE_URL', 'TESTSITE_URL');
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, 'LIVESITE_URL', 'TESTSITE_URL');
UPDATE wp_posts SET guid = REPLACE(guid, 'LIVESITE_URL', 'TESTSITE_URL');
UPDATE wp_posts SET post_content = REPLACE(post_content, 'LIVESITE_URL', 'TESTSITE_URL');

TESTSITE_URL 是您的测试站点的完整 URL 地址。

LIVESITE_URL 是您的实时站点的完整 URL 地址。

如果您对测试站点的数据库使用不同的内容,则可以更改 wp_ 前缀。

安装 WordPress

完成创建测试站点的数据库后,您需要安装 WordPress 。这将允许您在安装期间输入新数据库信息。您可以手动执行此操作,也可以使用主机提供的 WordPress 安装过程。
传输文件

  1. 首先使用 FTP 或 SFTP 客户端下载您的实时站点的 wp-content 文件夹的副本。
  2. 然后将您下载的文件夹内容上传到您的测试站点的 wp-content 文件夹。所有重要的文件,如主题、插件和媒体上传都将通过此传输。

其他步骤

设置测试站点后,您需要禁止用户访问和搜索机器人索引测试站点。

  1. 在仪表盘 > 设置 > 阅读中更改搜索引擎可见性以阻止搜索引擎索引您的测试站点。并且保持禁用任何 SEO 插件/功能应该会有所帮助。
  2. 由于这是一个测试站点,您不会允许任何人注册到您的站点。因此,安装 Restrict Site Access 将允许您将站点限制为您的 IP 地址,并且只允许您访问您的测试站点。

上次修改 2021.12.25

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

Tender

Tender

Tender
Codex Home → Getting Started → Importing Data → Import Forums → Tender
Tender 0.7 Importer for bbPress
https://github.com/JustinSainton/Tender-to-bbPress-Importer/
Uses Tender‘s neat JSON API to import discussions into bbPress

上次修改 2021.12.26

Custom Capabilities

Custom Capabilities

Custom Capabilities
Codex Home → Custom Capabilities
Whilst bbPress provides a good set of forum roles, with distinct capabilities, you may want to amend these or add new names.
However the latest combination of WordPress and bbPress does not work if the code to do this is in the functions.php file of the child theme (or indeed parent theme!).
If you put this code in a plugin, it seems to work fine.
If you are comfortable in changing files and FTPing them to your site, then visit bbpress role adder – Robin W’s website (rewweb.co.uk) for a plugin and template that should work
Adding new names
At the simplest levels, you can add a new role name and give it existing capabilities
This can be useful just for your own admin purposes, but also if like me you hate the “keymaster” role name, just create a new role and give it keymaster capabilities.
The following code creates three new roles with names ‘name 1′,’name 2′ and ‘name 3′ the first role has participant, the second moderator and the third keymaster.
Simply amend the code to create as many roles with whatever capabilities you need
add_action (‘wp_loaded’ , ‘load_new_roles’) ;
function load_new_roles ()
{
add_filter( ‘bbp_get_dynamic_roles’, ‘add_custom_role’, 1 );
}
function add_custom_role( $bbp_roles )
{
$bbp_roles[‘my_custom_role1’] = array(
‘name’ =>’name 1′,
‘capabilities’ =>bbp_get_caps_for_role( bbp_get_participant_role() ) // the same capabilities as participants
);
$bbp_roles[‘my_custom_role2’] = array(
‘name’ =>’name 2′,
‘capabilities’ =>bbp_get_caps_for_role( bbp_get_participant_role() ) // the same capabilities as participants
);
$bbp_roles[‘my_custom_role3’] = array(
‘name’ =>’name 3′,
‘capabilities’ =>bbp_get_caps_for_role( bbp_get_keymaster_role() ) // the same capabilities as keymaster
);
return $bbp_roles;
}
Creating new roles
If you want to add a new roles with specific capabilities, then you can add these
The code below adds a role called ‘tutor’ simply change the word tutor wherever it occurs to the name you want and decide what capabilities you want to the role to have.
//code to add tutor role

add_action (‘wp_loaded’ , ‘load_new_roles’) ;

function load_new_roles ()
{
add_filter( ‘bbp_get_dynamic_roles’, ‘add_new_roles’, 1 );
add_filter( ‘bbp_get_caps_for_role’, ‘add_role_caps_filter’, 10, 2 );
}
function add_new_roles( $bbp_roles )
{
/* Add a role called tutor */
$bbp_roles[‘bbp_tutor’] = array(
‘name’ =>’Tutor’,
‘capabilities’ =>custom_capabilities( ‘bbp_tutor’ )
);

return $bbp_roles;
}

function add_role_caps_filter( $caps, $role )
{
/* Only filter for roles we are interested in! */
if( $role == ‘bbp_tutor’ )
$caps = custom_capabilities( $role );

return $caps;
}

function custom_capabilities( $role )
{
switch ( $role )
{

/* Capabilities for ‘tutor’ role */
case ‘bbp_tutor’:
return array(
// Primary caps
‘spectate’ => true,
‘participate’ => true,
‘moderate’ => false,
‘throttle’ => false,
‘view_trash’ =>false,

// Forum caps
‘publish_forums’ =>false,
‘edit_forums’ => false,
‘edit_others_forums’ => false,
‘delete_forums’ => false,
‘delete_others_forums’ => false,
‘read_private_forums’ => true,
‘read_hidden_forums’ => false,

// Topic caps
‘publish_topics’ => true,
‘edit_topics’ => true,
‘edit_others_topics’ => false,
‘delete_topics’ => false,
‘delete_others_topics’ => false,
‘read_private_topics’ => true,

// Reply caps
‘publish_replies’ => true,
‘edit_replies’ => true,
‘edit_others_replies’ => false,
‘delete_replies’ => false,
‘delete_others_replies’ => false,
‘read_private_replies’ => true,

// Topic tag caps
‘manage_topic_tags’ => false,
‘edit_topic_tags’ => false,
‘delete_topic_tags’ => false,
‘assign_topic_tags’ => true,
);

break;

default :
return $role;
}
}
The code below adds two roles, tutor and pupil. Using this you should be able to add any number of roles
add_action (‘wp_loaded’ , ‘load_new_roles’) ;

function load_new_roles () {
add_filter( ‘bbp_get_dynamic_roles’, ‘add_new_roles’, 1 );
add_filter( ‘bbp_get_caps_for_role’, ‘add_role_caps_filter’, 10, 2 );
}
function add_new_roles( $bbp_roles )
{
/* Add a role called tutor */
$bbp_roles[‘bbp_tutor’] = array(
‘name’ =>’Tutor’,
‘capabilities’ =>custom_capabilities( ‘bbp_tutor’ )
);

/* Add a role called pupil */
$bbp_roles[‘bbp_pupil’] = array(
‘name’ =>’Pupil’,
‘capabilities’ =>custom_capabilities( ‘bbp_pupil’ )
);

return $bbp_roles;
}

function add_role_caps_filter( $caps, $role )
{
/* Only filter for roles we are interested in! */
if( $role == ‘bbp_tutor’ )
$caps = custom_capabilities( $role );

if( $role == ‘bbp_pupil’ )
$caps = custom_capabilities( $role );

return $caps;
}

function custom_capabilities( $role )
{
switch ( $role )
{

/* Capabilities for ‘tutor’ role */
case ‘bbp_tutor’:
return array(
// Primary caps
‘spectate’ => true,
‘participate’ => true,
‘moderate’ => false,
‘throttle’ => false,
‘view_trash’ =>false,

// Forum caps
‘publish_forums’ => false,
‘edit_forums’ => false,
‘edit_others_forums’ => false,
‘delete_forums’ => false,
‘delete_others_forums’ => false,
‘read_private_forums’ => true,
‘read_hidden_forums’ => false,

// Topic caps
‘publish_topics’ => true,
‘edit_topics’ => true,
‘edit_others_topics’ => false,
‘delete_topics’ => false,
‘delete_others_topics’ => false,
‘read_private_topics’ => true,

// Reply caps
‘publish_replies’ => true,
‘edit_replies’ => true,
‘edit_others_replies’ => false,
‘delete_replies’ => false,
‘delete_others_replies’ => false,
‘read_private_replies’ => true,

// Topic tag caps
‘manage_topic_tags’ => false,
‘edit_topic_tags’ => false,
‘delete_topic_tags’ => false,
‘assign_topic_tags’ => true,
);

/* Capabilities for ‘pupil’ role */
case ‘bbp_pupil’:
return array(
// Primary caps
‘spectate’ => true,
‘participate’ => true,
‘moderate’ => false,
‘throttle’ => false,
‘view_trash’ => false,

// Forum caps
‘publish_forums’ => false,
‘edit_forums’ => false,
‘edit_others_forums’ => false,
‘delete_forums’ => false,
‘delete_others_forums’ => false,
‘read_private_forums’ => true,
‘read_hidden_forums’ => false,

// Topic caps
‘publish_topics’ => true,
‘edit_topics’ => true,
‘edit_others_topics’ => false,
‘delete_topics’ => false,
‘delete_others_topics’ => false,
‘read_private_topics’ => true,

// Reply caps
‘publish_replies’ => true,
‘edit_replies’ => true,
‘edit_others_replies’ => false,
‘delete_replies’ => false,
‘delete_others_replies’ => false,
‘read_private_replies’ => true,

// Topic tag caps
‘manage_topic_tags’ => false,
‘edit_topic_tags’ => false,
‘delete_topic_tags’ => false,
‘assign_topic_tags’ => true,
);

break;

default :
return $role;
}
}

WP Symposium

WP Symposium

WP Symposium
Codex Home → Getting Started → Importing Data → Import Forums → WP Symposium
WP Symposium v14.x Importer for bbPress
Topics

WP Symposium ‘Group Topics’ from Groups are not imported.

Replies

WP Symposium ‘Forum comments’ or ‘Replies to replies’ and/or ‘Threaded replies’ are not imported.

上次修改 2021.12.26

e107

e107

e107
Codex Home → Getting Started → Importing Data → Import Forums → e107
e107 v1.x Importer for bbPress
Placeholder Text
e107 v2.x Importer for bbPress
e107 v2.x Importer ‘In Progress’ See #2422

上次修改 2021.12.26

Codex Standards & Guidelines

Codex Standards & Guidelines

Codex Standards & Guidelines
Codex Home → Participate & Contribute → Codex Standards & Guidelines
Contributing to the Codex
If you are considering contributing to the codex this simple guide is here to help you with the formatting of pages and standards & conventions to follow to keep a set appearance to pages.
The Codex is curated by the bbPress community if you are unsure about the status of an article head over to the forums and post a topic and add the topic tag codex, if you want to follow along with the codex development discussions you can visit this link or subscribe to the codex RSS feed.
Please note: All entries to the Codex are covered by the GNU General Public Licence. All entries may be edited or altered by other contributors.
How to Create a New Codex Article

Log in using your WordPress username and password.
Click on the “Create New Page” link in the sidebar.
You can also copy the example template layout from this template to get started quicker.
Add the Title of your article.
Add the article metas: Versions, Components, Types and Context. Meta boxes are located on the screen’s right sidebar. Note, try to keep these as generalised as possible for example, setting the version to ‘2.5’ is preseumed to include 2.5 and all incremental version such as 2.5.1, 2.5.2, etc.
Add your article in the appropriate codex section in the Page Attributes meta box under the Context box. If you are unsure where you should add your article head over the handbook Table of Contents for a guide or head over to the forums and create a topic with the codex topic tag and we will try to work out the best place for your article.
Add content of your article. Check that it follows the Codex General Guidelines, Codex Conventions, and Formatting guides posted below for your reference.
After you’re done, click on the “Publish” button.

How to Edit/Update an Article in the Codex

Log in using your WordPress username and password.
Navigate to the page you want to edit/update.
Click on the “Edit This Page” link in the sidebar. The link displays for the users having article edit access.
After you have made the edit/update, please double-check that the Versions, Components, Types and Context are correct and updated as well, again try to keep these broadly focused so they are easily discovered.
Click on the “Update” button in the Publish meta box.

General Guidelines
Broad guidelines on writing for the bbPress Codex

When writing articles please use the second-person point of view to address the reader. e.g. “Now navigate to your” Rather than “Now navigate to our“.
When writing technical articles (functions, actions, etc.) please use the draft template you will find in the dashboard, copy and paste it’s body outline markup to your new post.
Please keep styling to a minimum, avoid inline styling of elements unless to provide something like a color highlight if thought necessary to lend further emphasis to a piece of text e.g styling a warning in red Ensure you have backed up your DB. Please use elements sparingly , are typographic conventions and used to embolden text and italicize text for foreign & scientific words/phrases; , are to lend weight or importance to a word or phrase i.e ’em’ is not used simply to visually style text in italics.
Links: External resource links: Provided to the bottom of the article framework is a section for links to external resources, please use this section for any links to resources that help further however please ensure that these links are additional resources and that your article does not depend on them for all or any part of your article explanation, the reasoning here is external links are not guaranteed to always be available and if the article relies on them and they are down then the article is effectively useless for users. Links that are not related directly to the article content are to be avoided and if found will be removed.
Images: Do add images to articles where they help to illustrate your points or explanations, nothing helps illustrate things better than a timely graphic, screen shots of bbPress, BuddyPress, or WordPress screens help to show the reader layouts. As with links please avoid calling remote images, always upload to the media library, and embed. If uploading images please ensure you have the right to do so and are not infringing on any copyrights that may exist. Any images thought to be or that are under copyright will be removed from pages.
Creating pages: When creating pages , please ensure you select a suitable ‘Version’ tag, and optionally select from available ‘Components’ tags & ‘Types’. Please only select a parent category from the available parent sections, We request that authors DO NOT create new pages that act as parent pages for their article/s, this is to ensure the integrity of the codex structure, however it may be possible to expand the structure if thought beneficial, but please make a request for this to one of the Codex curation team members for consideration.

Codex Conventions

Website Example Names: Always use example.com, example.org or example.net wherever you need to state a domain as an example. This is per RFC 2606. For example, pun intented checkout http://example.com, these are reserved domain names intented for this specific purpose and do not link to any particular host or adfarm.
Admin: The main admin user of a WordPress site always has the login admin. (In examples. A login of admin on a live site has negative security implications.).
Using people’s names in examples: When a name is needed for an ordinary, non-admin user, or a person, use Harriet as the first name, and Smith as the last name.
Administration Panels: The WordPress interface is called Administration Panels not admin panels or dashboard. Dashboard is a specific panel within Administration Panels. Individual panels are also called Administration Screens.
WordPress is spelled WordPress: WordPress is spelled with two capital letters: WordPress.
bbPress is spelled bbPress: bbPress is spelled with only a single capital P dangit letter: bbPress.
BuddyPress is spelled BuddyPress: BuddyPress is spelled with two capital letters: BuddyPress.

Formatting Guide
If writing a technical guide please use the template format provided in this draft document ( copy paste to new page ) Codex template – technical examples layout
1. Heading Tags:
When you use h2 as a heading tag a section in the contents sidebar and link will be automatically created for you. Use h3 – h6 for sub headings of sections under the h2’s.
2. Code examples: Surround your code with the appropriate shortcodes
[php] your PHP code [/php]
[html] your HTML code [/html]
Also available are bash, shell, css, diff, patch, js, javascript, plain, text, sql and xml and are used in the same format as the previous examples.
When adding code examples please escape angle brackets with Numeric/Decimal entities rather than ‘Named ones, so use .
3. Lists: Use unordered, ordered and delimited lists where appropriate.
4. File names: Surround file names with the code tags
index.php
5. The structure of a technical guide
[Intro]
a brief intro to the guide
[/Intro][Functions]
List the functions, location, params etc.
[/Functions][Your Content]
The content body – explanation/guide.
[/Your content]
[Example Usage]
Provide a simple example of code use – using pre/code tags.
[/Example Usage]
[Additional Resources]
Add any links to off site or internal pages that might help further.
[/Additional Resources]

Flagging articles – adding article header messages
Page may be tagged in the body with two ‘Notes’
1/ This page is a legacy document, at top of page, example, if a page is deemed to be outdated or superseded by bbPress versions, or changes then it may be marked with this code block and the page would be re-assigned under the parent section ‘legacy’

This is Legacy Document, the details in this page have either been updated or are deprecated completely. Legacy Docs are retained for historic reference

2/ This page is in need of updating
A page is considered incomplete or needs to be verified for detail.

This page is incomplete or needs checking and verifying.

支持论坛

支持论坛

此页面是支持论坛的欢迎信息 。本介绍旨在帮助您在论坛中找到自己的方式,并希望让您尽快入门。 bbPress 支持论坛将遵循 WordPress 支持论坛制定的相同规则和准则。请阅读这两页以熟悉这些指南。使用支持论坛和  论坛欢迎

欢迎论坛志愿者

感谢您花时间在 bbPress 论坛上提供支持。请注意,WordPress 支持论坛中设置的规则和指南也适用于此处。以下文档将帮助您浏览我们的论坛。

1. 论坛欢迎 ——本文档部分针对那些在论坛上寻求支持的人,但包含有关帮助、何时可以删除或关闭话题以及报告线程等的信息。除非问题特定于 WordPress,否则请忽略邮件列表信息。

2. WordPress 支持手册 ——其中包含大量文章,可帮助您为 “WordPress 方式” 提供支持。您可能想先阅读的一些文章:

论坛版主

感谢您接受邀请成为我们支持论坛的版主 ????

请花点时间阅读上面和下面的推荐文章,重新熟悉我们的论坛规则。如果您有任何问题或建议,请随时联系 bbPres 核心团队。

附加参考:关于提问的公认约定

阅读下面的这份文档是值得的,它可以作为在论坛和列表上提问的正确方法的入门指南。虽然它的目标是将海报作为指导如何表现和形成一个将获得积极响应的问题,但它对所有人都非常有用,并被视为 RFC:
如何以聪明的方式提出问题

上次修改 2021.12.26

函数文件和子主题 – 解释!

函数文件和子主题 – 解释!

创建子主题和函数文件

许多 wordpress 和 bbpress 支持答案告诉您将一些代码添加到您的函数文件或 style.css 但是什么是函数文件,什么是 style.css 文件 – 我如何创建它们以及将它们放在哪里?

本教程希望回答所有这些问题以及更多问题!

什么是函数文件?

函数文件只是一个名为 Functions.php 的文件,它位于您的主题中。这使您可以向 wordpress 和 bbpress 添加其他功能,而无需更改这些文件中的代码。如果您更改 bbpress 和 wordpress 中的代码,它可能会在任何更新时被覆盖,并且您将丢失它。

现在由于函数文件属于主题,它同样有可能在主题升级时被覆盖,因此出于这些原因,最好的做法是创建一个子主题(如果您还没有),并在其中放置一个函数文件。

什么是 Style.css 文件?

每个主题都有一个 style.css,但插件也可以添加额外的样式文件。这些文件共同决定了页面的外观,例如元素在页面上的位置,是否有任何填充以使其与其他文本分开,文本应该是什么字体、颜色和大小,各种标题的样式等. 样式文件也可以隐藏东西,所以有时我们可能会建议您将元素更改为 ‘display:none’ 以便它被隐藏。与函数文件一样,样式文件可能会被主题或插件升级覆盖,因此不建议为不是您自己编写的主题或插件帽更改这些文件。因此,与函数文件一样,最好的做法是创建一个子主题(如果您还没有),并且为此您将拥有一个用于该主题的 style.css 。

我已经有子主题了吗?

所以首先我们需要看看您的主题是什么,是父主题还是子主题。如果它是父主题,那么您应该创建一个子主题,将函数文件添加到该子主题并将您的更改放在那里。如果您更改父主题中的任何文件,您可能会在更新或升级时丢失更改。所以您不想改变父主题文件。

您的 wordpress 主题

首先,您的 wordpress 安装将使用 “主题”——这是一组文件,用于设计您的网站(外观)并添加一些功能(如何运行)。

您可能正在使用 “默认主题”20 、 21 、 21 、 23 和 24 之一。这些主题由 wordpress 团队编写和维护,所有 wordpress 和 bbpress 代码都针对这些主题进行测试以确保其正常工作。这就是为什么经常要求您使用 “默认主题” 测试 bbpress 问题的原因,作为调查过程的一部分。

或者,您可能正在使用 “免费主题” 。其中许多都可以在 https://wordpress.org/themes/ 上找到  。

第三,您可能正在使用付费主题。这些往往更复杂,并提供很多好东西,但与 bbpress 的集成可能更复杂。如果 bbpress 对您的网站很重要,则值得在购买之前检查您的付费主题是否积极支持 bbpress 。大多数主题可以通过一些调整与 bbPress 一起使用,但最初让它运行并且看起来很棒真的很令人沮丧。

最后,您可能正在使用子主题。很简单,这是一个主题,它使用上述之一(默认主题、免费主题或购买的主题)作为基础,然后进行了更改。如果您花钱请人为您创建或定制一个站点,那么它很有可能是一个子主题。

那么您怎么知道您在使用哪个?

最快的方法是进入

仪表盘> 外观> 主题

您将看到站点上安装的主题列表,您将看到列出的第一个主题是 “活动的”,这就是您的站点正在使用的主题。

如果您将鼠标悬停在活动主题上,它将显示 “主题详细信息”,如果您单击它,您将获得有关该主题的一些信息。

如果它是由 “wordpress 团队” 提供的,那么您就会知道它是默认主题。否则进入 https://wordpress.org/themes/并搜索它。如果它在那里,那么它是一个免费的主题。最后,如果您在 google 上搜索主题名称,您应该找到一个卖家,或者至少提供一些支持细节,告诉您其他人已经编写了这个主题。

如果其中任何一个显示,那么您的父主题在其他地方得到支持,并且它们可能会发布更新,因此如果您更改其中的任何文件,您可能会在更新或升级时丢失更改。所以您不想改变这些文件。

如果您无法通过上述任何一种方法找到您的主题,或者您知道有人专门为您更改了主题,那么很可能这是一个子主题,因此不应由任何外部人员更新,因此您应该能够无所顾虑地进行更改。

所以最后的测试是检查您的主题是否已经是子主题,我们将准备继续。所以现在您需要能够进入 FTP,并将文件传输到您的 PC,以便您可以查看它以阅读标题。

什么是 FTP 以及如何访问它?

要访问您的文件,您需要一个 FTP 客户端。一些主机提供商在其管理范围内进行处理,如有疑问,请咨询您的主机提供商。

否则,您需要将程序加载到您的 PC 上。有几种可用,但最受欢迎的一种称为 “Filezilla” 。

要了解如何下载此程序并在您的 PC 上使用它,以下视频将有所帮助

http://www.youtube.com/watch?v=Wtqq1Mn1ltA

还有很多其他教程 – 只需谷歌 “filezilla 教程视频”

其他 FTP 程序也可用,只需谷歌 “FTP 客户端”

要访问您的网络文件,您需要三项信息:

  • 主持人
  • 用户名
  • 密码

注意:FTP 用户名和密码与您的 wordpress 登录名/wp-admin/admin 详细信息完全分开。

您的主机提供商通常会在您的管理区域中列出它,因此只需四处寻找 FTP,如果有疑问,请联系您的主机提供商。

然后跟着教程

https://make.wordpress.org/training/handbook/theme-school/child-themes/

或查看视频

https://www.youtube.com/watch?v=yDPbCV5_2Cw

如果您的主题如步骤 2 所示导入了另一个主题,那么您已经有了一个子主题。

如果没有,上面的教程将向您展示如何制作一个。

最后,您将拥有一个带有 style.css 文件的子主题

使用记事本++更改代码

由于您将要创建或更改文件,因此您需要有人来执行此操作。可以使用普通的记事本,但大多数情况下您将无法阅读,并且您会弄得一团糟。

所以从 http://notepad-plus-plus.org/下载 Notepad++

它易于使用,而且更好!

将函数文件添加到您的子主题

如果您已经有一个子主题,那么您可能已经有一个函数文件,只需在您的主题文件夹中查找一个名为 functions.php 的文件即可。

如果不是,您将需要创建一个函数文件。

只需打开记事本++,创建一个新文件并放入

 <?php

在开始时。现在将其保存为 functions.php 并将其上传到您的主题。就是这样。您现在有了一个函数文件!

将代码添加到函数文件

好的,现在当您看到 “将其添加到您的函数文件” 时,您就会知道您需要使用 FTP 将当前的函数文件下载到您的 PC 上。然后使用记事本++将代码复制到函数文件的末尾。然后使用 FTP 将修改后的文件上传回您的站点以覆盖旧文件。

将样式添加到 style.css

由于您现在将 style.css 作为子主题的组成部分,您可以向该文件添加任何更改。

 

 

就是这样……!!

上次修改 2021.12.26