Did you know that all themes hosted on the WordPress.org repository undergo a thorough review process by dedicated volunteer members of the Theme Review Team (TRT)?
您是否知道WordPress.org资源库中托管的所有主题都经过主题审查小组 (TRT)的专门志愿者进行了彻底的审查过程?
Not all professionals working with WordPress are aware of the review process and what this involves. If you’re among them, should you decide to submit your theme to the repository for the first time, you could be in for a surprise.
并非所有使用WordPress的专业人员都知道审阅过程及其涉及的内容。 如果您是其中之一,如果您决定第一次将主题提交到存储库,则可能会感到惊讶。
Realizing that there is a substantial number of guidelines and best practices to follow can strike you as being a bit overwhelming at first. If a reviewer keeps coming back asking for changes to your theme, you can even be tempted to give in to mounting frustration and throw in the towel.
意识到要遵循大量指南和最佳实践可能会使您一开始有点不知所措。 如果审阅者不断回来要求更改主题,您甚至可能会因挫败感而动容。
But wait, don’t give up just yet.
但是,等等,不要放弃。
In this article, you’ll meet an unusual learning tool of the TRT’s own devising, i.e., the doingitwrong theme.
在本文中,您将遇到TRT自己设计的一种不寻常的学习工具,即“ 做错事”的主题。
I’m going to show you what it is and how you can use it to your advantage.
我将向您展示它是什么以及如何利用它来发挥自己的优势。
什么是错的主题? (What Is the doingitwrong Theme?)
The TRT has set up a fair number of resources to get both new reviewers and theme developers up to speed with the repository guidelines.
TRT已建立了大量的资源,以使新的审阅者和主题开发人员都能快速了解存储库指南。
The core resource is the Theme Review Handbook. Here you can find chapters about the review process, theme requirements (stringent rules a theme must abide by), and recommended theme features (optional guidelines you’re free to ignore, although it would be nice if you didn’t).
核心资源是主题审查手册 。 在这里,您可以找到有关审阅过程,主题要求 (主题必须遵守的严格规则)以及推荐主题功能(您可以随意忽略的可选准则,如果没有的话会很不错)的章节。
Another awesome source of learning is the Theme Developer Handbook. This online book will set you on the right path to creating your own WordPress theme with best practices in mind.
另一个很棒的学习资源是主题开发者手册 。 这本在线书将指导您正确地创建自己的WordPress主题,同时牢记最佳实践。
One more resource is the Make WordPress Themes blog, where you’ll find the latest discussions on review-related topics.
另外一个资源是Make WordPress Themes博客,您可以在其中找到有关审阅相关主题的最新讨论。
A fourth option is the TRT Slack page, which you can easily access using your WordPress.org credentials. On this page, you’re welcome to ask for help on anything related to reviewing or submitting themes for the repository.
第四个选项是TRT松弛页面,您可以使用WordPress.org凭据轻松访问该页面。 在此页面上,欢迎您寻求有关审阅或提交存储库主题的任何帮助。
Perhaps the least known, but most peculiar resource, is the doingitwrong Theme.
也许鲜为人知但最奇特的资源是做错主题。
As its name somehow suggests, this theme is a testament to bad coding practices. In it, you’ll find plenty of stuff that would get any theme kicked out of the repository in ten seconds flat.
顾名思义,该主题证明了不良的编码做法。 在其中,您会发现很多东西,任何主题都可以在十秒钟之内从存储库中踢出。
So, what’s it for? – you might ask – What’s the good of something that’s so blatantly wrong?
那么,这是为了什么呢? –您可能会问–这么大胆的错误有什么好处?
Here’s my answer.
这是我的答案。
The rationale behind the theme is a good old time principle: Learn from other people’s mistakes. Here’s how Joe Castaneda, an admin member of the TRT, describes the theme:
主题背后的原理是一个很好的旧时原则:从别人的错误中学习。 TRT的管理员Joe Castaneda是这样描述主题的:
The doing it wrong theme serves as a tool for theme reviewers as well as theme authors to better understand the requirements needed to be met before a theme can be made live. Make WordPress.org Themes.
做错主题可以作为主题审阅者和主题作者的工具,以更好地了解在使主题变为现实之前需要满足的要求。 制作WordPress.org主题 。
In other words, most stuff that goes against the WordPress.org guidelines has place of honor in the doingitwrong theme. Start picking it apart and you’ll get the chance to see concrete examples of what not to do in your theme. This is way better than simply reading a list of all the do’s and don’ts and then trying to keep it in mind as you code away.
换句话说,大多数违反WordPress.org准则的内容在做错主题中都具有很高的声誉 。 开始将其分开,您将有机会看到主题中不该做什么的具体示例。 这是方式比简单地读取所有该做的和不该做的列表,然后设法记住这一点,你的代码远越好。
It’s time to put the doingitwrong theme through its paces and start learning some guidelines.
现在是时候逐步解决做错主题并开始学习一些准则的时候了。
WordPress.org主题审查流程的第一步 (First Steps of the WordPress.org Theme Review Process)
The purpose of this section is to outline the process of reviewing a theme for the WordPress.org repository using the doingitwrong theme as guinea pig.
本部分的目的是概述使用不正确的主题作为豚鼠来复审 WordPress.org存储库的主题的过程。
The requirements you need to focus on cluster around these areas:
您需要集中精力围绕以下领域进行集群的需求 :
Accessibility (only if your theme states that it’s accessibility-ready using the appropriate tag in style.css)
可访问性 (仅当您的主题使用style.css中的相应标记声明已准备好可访问性时)
Core Functionality and Features
核心功能和特点
Presentation vs Functionality
演示与功能
Documentation
文献资料
Language
语言
Licensing
发牌
Naming
命名
Options and Settings
选项和设置
Plugins
外挂程式
Screenshot
屏幕截图
Security and Privacy
安全与隐私
Selling, Credits and Links
销售 , 积分和链接
Stylesheets and Scripts
样式表和脚本
Templates
范本
It looks like a lot, but most of this stuff is common sense, the rest is just setting some standards for quality assurance. I think all WordPress.org themes users deserve as much. Don’t you?
看起来很多,但是其中大多数是常识,其余只是为质量保证设定了一些标准。 我认为所有WordPress.org主题用户都应该得到应有的回报。 是不是
Set up a local WordPress installation with some demo content, install the Developer plugin, grab a copy of the doingitwrong theme on GitHub, and keep the Theme Review Handbook open in your browser. Let’s get reviewing.
设置带有一些演示内容的本地WordPress安装,安装Developer插件,在GitHub上获取“ 做错主题”的副本,并在您的浏览器中打开“主题审查手册”。 让我们来回顾一下。
运行主题检查插件 (Running the Theme Check Plugin)
Once you install the theme, run it via the Theme Check plugin by Samuel Wood (Otto) and Simon Prosser. If you’ve previously installed the Developer plugin, Theme Check is already on your system. Activate it, then go to Appearance > Theme Check. Now select the doingitwrong theme and press Check.
安装主题后,通过Samuel Wood (Otto)和Simon Prosser的Theme Check插件运行它。 如果您以前已经安装了Developer插件,则主题检查已在您的系统上。 激活它,然后转到外观>主题检查。 现在选择不正确的主题,然后按Check。
![Selecting Theme Check](https://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2015/11/1447676655theme-check-select.png)
In no time a bunch of errors, warnings, recommendations and info notices come up on the screen. On the face of it, you couldn’t even upload this theme for review, let alone getting it approved. In fact, each theme goes through the infallible net of this plugin at the upload stage.
屏幕上会立即出现大量错误,警告,建议和信息通知。 从表面上看,您甚至无法上传此主题进行审核,更不用说批准它了。 实际上,每个主题在上传阶段都要经过该插件的可靠网络。
![Results of Theme Check for doingitwrong theme](https://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2015/11/1447676650theme-check-results.png)
Just going through what Theme Check highlights, especially the required items and warnings, gets you a long way towards familiarizing yourself with the basic requirements your theme is expected to meet.
仅通过主题检查突出显示的内容(尤其是必需的项目和警告),就可以使您熟悉自己的主题所希望满足的基本要求。
For a complete list of what this plugin checks, here’s the Handbook page you need.
有关此插件检查内容的完整列表,请在此处提供“ 手册”页面 。
在style.css
检查注释块 (Inspecting the Comment Block in style.css
)
Open style.css
in your code editor. The comment block at the top is one of the first places to check. Here, the doingitwrong theme excels itself.
在代码编辑器中打开style.css
。 顶部的注释框是最早检查的地方之一。 在这里, 做错主题很出色。
Look closely. Can you spot anything? Here’s my own take on it:
仔细看。 你能发现什么吗? 这是我自己的看法:
![Comment block in style.css](https://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2015/11/1447676644stylecss.png)
The Theme URI field uses a URL shortener (see the Security & Privacy section of the Handbook).
主题URI字段使用URL缩短器(请参见手册的“ 安全性和隐私”部分 )。
The Theme URI page the text points to, has nothing to do with the theme. You don’t have to use a Theme URI. However, if you do, you need to make sure it links to a page with useful information about your theme (Read the Handbook page here for more details).
文本指向的主题URI页面与主题无关。 您不必使用主题URI。 但是,如果这样做,则需要确保它链接到包含有关主题的有用信息的页面(有关更多详细信息,请阅读此处的“ 手册”页面 )。
- The Author field uses the URI of a non-related page. You’re not required to add an Author field, but if you do, the information must be appropriate. 作者字段使用不相关页面的URI。 您不需要添加“作者”字段,但是如果这样做,则该信息必须适当。
- The Author URI field is empty. Once again, if you don’t need the field, you simply refrain from adding it to your comment block. 作者URI字段为空。 再一次,如果您不需要该字段,则只需避免将其添加到注释栏中。
- The theme Description field not only fails to give any useful information about the theme, it’s also inaccurate. If you go through the theme, you’ll find there’s no slider functionality in the Home page. 主题描述字段不仅无法提供有关主题的任何有用信息,而且也不准确。 如果您浏览主题,您会发现主页中没有滑块功能。
Finally, the theme uses only two tags. However, this theme supports other WordPress and design features. These should be reflected in the tags list.
最后,主题仅使用两个标签。 但是,此主题支持其他WordPress和设计功能。 这些应该反映在标签列表中 。
I’m not even telling you where the Theme URI link points to. I don’t want to spoil the surprise. Find it out for yourself and let me know.
我什至没有告诉您主题URI链接指向的位置。 我不想破坏惊喜。 自己找出来,让我知道。
偷看header.php
和footer.php
(Peeking into the header.php
and footer.php
)
Other likely candidates where you can spot something wrong are header.php
and footer.php
.
您可能会发现错误的其他可能的候选对象是header.php
和footer.php
。
Open header.php
and try to catch as many issues as you can.
打开header.php
并尝试捕获尽可能多的问题。
Here’s the guilty party in the <head>
section of the document:
这是文档<head>
部分中的有罪方:
![The head part of header.php file](https://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2015/11/1447676638headerphp-head.png)
The Google Fonts stylesheet is hard-coded, which happens more often than you’d think. Remember, no hard-coding of styles and scripts. Enqueue everything.
Google字体样式表是经过硬编码的,发生的次数比您想象的要多。 请记住, 不要对样式和脚本进行硬编码 。 排队一切。
Diving into the <body>
section of the document reveals a couple of problems.
深入文档的<body>
部分会发现两个问题。
![Body section of header.php](https://dab1nmslvvntp.cloudfront.net/wp-content/uploads/2015/11/1447676632headerphp-body.png)
First off, the text-domain
argument inside the translation function _e()
is inconsistent with the text-domain indicated in the style.css
comment block. The declared text-domain is doingitwrong, the text-domain the author uses here is wrong. Indeed, it’s wrong.
首先,翻译函数_e()
的text-domain
参数与style.css
注释块中指示的text-domain不一致。 声明的文本域做错了 ,作者在这里使用的文本域是错误的 。 确实,这是错误的。
Refer back to the corresponding Review Handbook section:
请参考相应的《 审核手册》部分 :
Use a single unique theme slug – as the theme slug appears in
style.css
.使用单个唯一的主题块-主题块出现在
style.css
。
Secondly, the code extracts user defined information to display social links on the website. However, the doingitwrong theme adds this functionality using an options panel rather than the Customizer.
其次,该代码提取用户定义的信息以在网站上显示社交链接。 但是, weingitwrong主题使用选项面板而不是定制程序来添加此功能。
Since 21st April 2015, the TRT has made it a requirement that all themes hosted on WordPress.org should implement theme options using the Customizer.
自2015年4月21日起 ,TRT要求WordPress.org上托管的所有主题均应使用定制程序实现主题选项。
The update clearly appears in the Handbook guidelines as well:
该更新也清楚地出现在《 手册》指南中:
Use the Customizer for implementing theme options.
使用定制程序实现主题选项。
One more source of common issues is footer.php
. Find this file in the doingitwrong theme and open it in your code editor.
常见问题的另一个来源是footer.php
。 在doingitwrong主题中找到此文件,然后在代码编辑器中将其打开。
How many problems can you come up with? Here’s my list.
您能提出多少个问题? 这是我的清单。
The snippet below extracts some Testimonial data from the Customizer using get_theme_mod(). However, using the Customizer to generate content that should belong to plugins (custom post types are plugin territory) is not the way to go. Also, the output of user data being printed on the page should be escaped using the appropriate functions, e.g.,
esc_html()
,esc_textarea()
, etc.下面的代码段使用get_theme_mod()从定制程序中提取了一些推荐数据。 但是,使用定制器生成应属于插件的内容 (自定义帖子类型是插件领域)不是可行的方法。 另外,应使用适当的函数 (例如
esc_html()
,esc_textarea()
等esc_html()
对在页面上打印的用户数据的输出进行转义 。The snippet below extracts some Testimonial data from the Customizer using get_theme_mod(). However, using the Customizer to generate content that should belong to plugins (custom post types are plugin territory) is not the way to go. Also, the output of user data being printed on the page should be escaped using the appropriate functions, e.g.,
esc_html()
,esc_textarea()
, etc.下面的代码段使用get_theme_mod()从定制程序中提取了一些推荐数据。 但是,使用定制器生成应属于插件的内容 (自定义帖子类型是插件领域)不是可行的方法。 另外,应使用适当的函数 (例如
esc_html()
,esc_textarea()
等esc_html()
对在页面上打印的用户数据的输出进行转义 。Notice the button to toggle the navigation menu? If you look closely, you’ll see that the text Footer Menu is not translatable. All text strings in the theme must be translation-ready using the appropriate translation functions, e.g.,
_e()
,__()
, etc. That’s not all: the navigation menu ID of foter doesn’t exist. The correct ID for the footer menu is footer (You can quickly find this out by checkingregister_nav_menus()
infunctions.php
).注意到该按钮可以切换导航菜单吗? 如果仔细观察,您会发现“ 页脚菜单 ”文本不可翻译。 主题中的所有文本字符串都必须使用适当的翻译功能(例如
_e()
,__()
等_e()
进行翻译准备 。这还不是全部: foter的导航菜单ID不存在。 页脚菜单的正确ID是页脚 (您可以通过在functions.php
检查register_nav_menus()
来快速找到该页脚 )。Notice the button to toggle the navigation menu? If you look closely, you’ll see that the text Footer Menu is not translatable. All text strings in the theme must be translation-ready using the appropriate translation functions, e.g.,
_e()
,__()
, etc. That’s not all: the navigation menu ID of foter doesn’t exist. The correct ID for the footer menu is footer (You can quickly find this out by checkingregister_nav_menus()
infunctions.php
).注意到该按钮可以切换导航菜单吗? 如果仔细观察,您会发现“ 页脚菜单 ”文本不可翻译。 主题中的所有文本字符串都必须使用适当的翻译功能(例如
_e()
,__()
等_e()
进行翻译准备 。这还不是全部: foter的导航菜单ID不存在。 页脚菜单的正确ID是页脚 (您可以通过在functions.php
检查register_nav_menus()
来快速找到该页脚 )。Last but not least, WordPress is spelt
Word"p"ress
(with a lowercase p), which is wrong and must be fixed.最后但并非最不重要的一点是, WordPress拼写为
Word"p"ress
(带有小写的p),这是错误的,必须修复 。Last but not least, WordPress is spelt
Word"p"ress
(with a lowercase p), which is wrong and must be fixed.最后但并非最不重要的一点是, WordPress拼写为
Word"p"ress
(带有小写的p),这是错误的,必须修复 。
Nobody expects you to learn the guidelines by heart. They’re not written in stone and the messy reality of each theme at times defeats the simplicity of a clear-cut rule.
没有人期望您会认真地学习指南。 它们不是一成不变的,每个主题的凌乱现实有时会破坏明确规则的简单性。
But, by checking each template file inside the doingitwrong theme against the Theme Review Handbook pages, you’ll find that a fair number of the guidelines start to sink in, until you don’t need to consult the Handbook over and over again.
但是,通过对照“主题审查手册”页面检查doingitwrong主题内的每个模板文件,您会发现有大量准则开始使用,直到您无需一遍又一遍地查阅该手册。
为什么我应该关心错误的主题,甚至是准则? (Why Should I Care about the doingitwrong Theme, or Even the Guidelines?)
Understandably, you could be asking this question right now. After all, the Theme Review Guidelines apply only to themes hosted on WordPress.org. Therefore, you can sail through a successful WordPress theme developer career without paying the least attention to the Theme Review Handbook, the doingitwrong theme, or any of the other available resources.
可以理解,您现在可能会问这个问题。 毕竟,主题审查指南仅适用于WordPress.org上托管的主题。 因此,您可以顺利完成WordPress主题开发人员的职业生涯,而不必最少关注主题审查手册, 做错主题或任何其他可用资源。
However, I’m going to give you just a few reasons why you should care.
但是,我仅向您提供一些您应该关心的原因。
One of the doingitwrong theme’s merits is that it uses a practical approach to learning the repository guidelines. You can use it alongside the other resources to practice the skill of catching errors rather than simply reading about them.
做错主题的优点之一是它使用一种实用的方法来学习存储库指南。 您可以将其与其他资源一起使用,以练习捕获错误的技巧,而不仅仅是阅读它们。
It’s a known fact, catching other people’s mistakes is easier than catching our own. We’re too close to spot what’s wrong. The doingitwrong theme will help to train your eyes at spotting what’s wrong with your theme before submitting it to the repository.
这是众所周知的事实,发现别人的错误比发现自己的错误要容易 。 我们离发现什么地方太近了。 做错主题将有助于训练您的眼睛,以便在将主题提交到存储库之前发现主题有什么问题。
More generally, what goes for the WordPress.org themes repository, although not mandatory anywhere else, establishes a standard of quality that’s hard to ignore. If you’re serious about your WordPress themes developer work, having at least some familiarity with the requirements of the themes repository is advisable.
更一般而言,WordPress.org主题存储库的功能尽管在其他地方不是强制性的,但它建立了质量标准,这是很难忽视的。 如果您认真对待WordPress主题开发人员的工作,建议至少对主题存储库的要求有所了解。
Taking some time to get familiar with the WordPress.org guidelines and applying them to your work will help you create even more stunning WordPress themes that follow best practices and are easy to use, which makes you a better theme developer.
花一些时间来熟悉WordPress.org准则并将其应用于您的工作中,将帮助您创建遵循最佳实践且易于使用的更加出色的WordPress主题 ,这使您成为更好的主题开发人员。
下一步是什么? (What’s Next?)
Once you’ve looked into what it takes to have your theme ready for the WordPress.org repository, here’s what you could do next.
一旦您研究了为WordPress.org存储库准备好主题所需的资源,接下来便可以执行此操作。
Fork the doingitwrong theme on GitHub and have fun adding a few blunders of your own.
在GitHub上分叉doingitwrong主题,并添加一些自己的错误,很有趣。
- Have a go at reviewing a real theme submitted to the repository. 可以审阅提交到资源库的真实主题。
Try out any or both of these steps and share your experience with the community. I can’t wait to hear all about it in the comments.
尝试这些步骤中的任何一个或全部,并与社区分享您的经验。 我迫不及待想在评论中听到所有有关它的信息。
Happy WordPress theming!
WordPress主题快乐!
翻译自: https://www.sitepoint.com/using-the-doingitwrong-theme-to-learn-wordpress-theme-review/