使用不正确的主题来学习WordPress主题评论
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資源庫中托管的所有主題都經(jīng)過主題審查小組 (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的專業(yè)人員都知道審閱過程及其涉及的內(nèi)容。 如果您是其中之一,如果您決定第一次將主題提交到存儲庫,則可能會感到驚訝。
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自己設(shè)計的一種不尋常的學(xué)習(xí)工具,即“ 做錯事”的主題。
I’m going to show you what it is and how you can use it to your advantage.
我將向您展示它是什么以及如何利用它來發(fā)揮自己的優(yōu)勢。
什么是錯的主題? (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已建立了大量的資源,以使新的審閱者和主題開發(fā)人員都能快速了解存儲庫指南。
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).
核心資源是主題審查手冊 。 在這里,您可以找到有關(guān)審閱過程,主題要求 (主題必須遵守的嚴格規(guī)則)以及推薦主題功能(您可以隨意忽略的可選準則,如果沒有的話會很不錯)的章節(jié)。
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.
另一個很棒的學(xué)習(xí)資源是主題開發(fā)者手冊 。 這本在線書將指導(dǎo)您正確地創(chuàng)建自己的WordPress主題,同時牢記最佳實踐。
One more resource is the Make WordPress Themes blog, where you’ll find the latest discussions on review-related topics.
另外一個資源是Make WordPress Themes博客,您可以在其中找到有關(guān)審閱相關(guān)主題的最新討論。
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憑據(jù)輕松訪問該頁面。 在此頁面上,歡迎您尋求有關(guān)審閱或提交存儲庫主題的任何幫助。
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.
顧名思義,該主題證明了不良的編碼做法。 在其中,您會發(fā)現(xiàn)很多東西,任何主題都可以在十秒鐘之內(nèi)從存儲庫中踢出。
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:
主題背后的原理是一個很好的舊時原則:從別人的錯誤中學(xué)習(xí)。 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.
做錯主題可以作為主題審閱者和主題作者的工具,以更好地了解在使主題變?yōu)楝F(xiàn)實之前需要滿足的要求。 制作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.
換句話說,大多數(shù)違反WordPress.org準則的內(nèi)容在做錯主題中都具有很高的聲譽 。 開始將其分開,您將有機會看到主題中不該做什么的具體示例。 這是方式比簡單地讀取所有該做的和不該做的列表,然后設(shè)法記住這一點,你的代碼遠越好。
It’s time to put the doingitwrong theme through its paces and start learning some guidelines.
現(xiàn)在是時候逐步解決做錯主題并開始學(xué)習(xí)一些準則的時候了。
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.
本部分的目的是概述使用不正確的主題作為豚鼠來復(fù)審 WordPress.org存儲庫的主題的過程。
The requirements you need to focus on cluster around these areas:
您需要集中精力圍繞以下領(lǐng)域進行集群的需求 :
Accessibility (only if your theme states that it’s accessibility-ready using the appropriate tag in style.css)
可訪問性 (僅當您的主題使用style.css中的相應(yīng)標記聲明已準備好可訪問性時)
Core Functionality and Features
核心功能和特點
Presentation vs Functionality
演示與功能
Documentation
文獻資料
Language
語言
Licensing
發(fā)牌
Naming
命名
Options and Settings
選項和設(shè)置
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?
看起來很多,但是其中大多數(shù)是常識,其余只是為質(zhì)量保證設(shè)定了一些標準。 我認為所有WordPress.org主題用戶都應(yīng)該得到應(yīng)有的回報。 是不是
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.
設(shè)置帶有一些演示內(nèi)容的本地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插件運行它。 如果您以前已經(jīng)安裝了Developer插件,則主題檢查已在您的系統(tǒng)上。 激活它,然后轉(zhuǎn)到外觀>主題檢查。 現(xiàn)在選擇不正確的主題,然后按Check。
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.
屏幕上會立即出現(xiàn)大量錯誤,警告,建議和信息通知。 從表面上看,您甚至無法上傳此主題進行審核,更不用說批準它了。 實際上,每個主題在上傳階段都要經(jīng)過該插件的可靠網(wǎng)絡(luò)。
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.
僅通過主題檢查突出顯示的內(nèi)容(尤其是必需的項目和警告),就可以使您熟悉自己的主題所希望滿足的基本要求。
For a complete list of what this plugin checks, here’s the Handbook page you need.
有關(guān)此插件檢查內(nèi)容的完整列表,請在此處提供“ 手冊”頁面 。
在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:
仔細看。 你能發(fā)現(xiàn)什么嗎? 這是我自己的看法:
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頁面與主題無關(guān)。 您不必使用主題URI。 但是,如果這樣做,則需要確保它鏈接到包含有關(guān)主題的有用信息的頁面(有關(guān)更多詳細信息,請閱讀此處的“ 手冊”頁面 )。
- 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. 作者字段使用不相關(guān)頁面的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. 主題描述字段不僅無法提供有關(guān)主題的任何有用信息,而且也不準確。 如果您瀏覽主題,您會發(fā)現(xiàn)主頁中沒有滑塊功能。
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和設(shè)計功能。 這些應(yīng)該反映在標簽列表中 。
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.
您可能會發(fā)現(xiàn)錯誤的其他可能的候選對象是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 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字體樣式表是經(jīng)過硬編碼的,發(fā)生的次數(shù)比您想象的要多。 請記住, 不要對樣式和腳本進行硬編碼 。 排隊一切。
Diving into the <body> section of the document reveals a couple of problems.
深入文檔的<body>部分會發(fā)現(xiàn)兩個問題。
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.
首先,翻譯函數(shù)_e()的text-domain參數(shù)與style.css注釋塊中指示的text-domain不一致。 聲明的文本域做錯了 ,作者在這里使用的文本域是錯誤的 。 確實,這是錯誤的。
Refer back to the corresponding Review Handbook section:
請參考相應(yīng)的《 審核手冊》部分 :
Use a single unique theme slug – as the theme slug appears in style.css.
使用單個唯一的主題塊-主題塊出現(xiàn)在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.
其次,該代碼提取用戶定義的信息以在網(wǎng)站上顯示社交鏈接。 但是, 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上托管的所有主題均應(yīng)使用定制程序?qū)崿F(xiàn)主題選項。
The update clearly appears in the Handbook guidelines as well:
該更新也清楚地出現(xiàn)在《 手冊》指南中:
Use the Customizer for implementing theme options.
使用定制程序?qū)崿F(xiàn)主題選項。
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()從定制程序中提取了一些推薦數(shù)據(jù)。 但是,使用定制器生成應(yīng)屬于插件的內(nèi)容 (自定義帖子類型是插件領(lǐng)域)不是可行的方法。 另外,應(yīng)使用適當?shù)暮瘮?shù) (例如esc_html() , esc_textarea()等esc_html()對在頁面上打印的用戶數(shù)據(jù)的輸出進行轉(zhuǎn)義 。
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()從定制程序中提取了一些推薦數(shù)據(jù)。 但是,使用定制器生成應(yīng)屬于插件的內(nèi)容 (自定義帖子類型是插件領(lǐng)域)不是可行的方法。 另外,應(yīng)使用適當?shù)暮瘮?shù) (例如esc_html() , esc_textarea()等esc_html()對在頁面上打印的用戶數(shù)據(jù)的輸出進行轉(zhuǎn)義 。
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 checking register_nav_menus() in functions.php).
注意到該按鈕可以切換導(dǎo)航菜單嗎? 如果仔細觀察,您會發(fā)現(xiàn)“ 頁腳菜單 ”文本不可翻譯。 主題中的所有文本字符串都必須使用適當?shù)姆g功能(例如_e() , __()等_e() 進行翻譯準備 。這還不是全部: foter的導(dǎo)航菜單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 checking register_nav_menus() in functions.php).
注意到該按鈕可以切換導(dǎo)航菜單嗎? 如果仔細觀察,您會發(fā)現(xiàn)“ 頁腳菜單 ”文本不可翻譯。 主題中的所有文本字符串都必須使用適當?shù)姆g功能(例如_e() , __()等_e() 進行翻譯準備 。這還不是全部: foter的導(dǎo)航菜單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),這是錯誤的,必須修復(fù) 。
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),這是錯誤的,必須修復(fù) 。
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.
沒有人期望您會認真地學(xué)習(xí)指南。 它們不是一成不變的,每個主題的凌亂現(xiàn)實有時會破壞明確規(guī)則的簡單性。
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主題內(nèi)的每個模板文件,您會發(fā)現(xiàn)有大量準則開始使用,直到您無需一遍又一遍地查閱該手冊。
為什么我應(yīng)該關(guān)心錯誤的主題,甚至是準則? (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.
可以理解,您現(xiàn)在可能會問這個問題。 畢竟,主題審查指南僅適用于WordPress.org上托管的主題。 因此,您可以順利完成WordPress主題開發(fā)人員的職業(yè)生涯,而不必最少關(guān)注主題審查手冊, 做錯主題或任何其他可用資源。
However, I’m going to give you just a few reasons why you should care.
但是,我僅向您提供一些您應(yīng)該關(guān)心的原因。
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.
做錯主題的優(yōu)點之一是它使用一種實用的方法來學(xué)習(xí)存儲庫指南。 您可以將其與其他資源一起使用,以練習(xí)捕獲錯誤的技巧,而不僅僅是閱讀它們。
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.
這是眾所周知的事實,發(fā)現(xiàn)別人的錯誤比發(fā)現(xiàn)自己的錯誤要容易 。 我們離發(fā)現(xiàn)什么地方太近了。 做錯主題將有助于訓(xùn)練您的眼睛,以便在將主題提交到存儲庫之前發(fā)現(xiàn)主題有什么問題。
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主題存儲庫的功能盡管在其他地方不是強制性的,但它建立了質(zhì)量標準,這是很難忽視的。 如果您認真對待WordPress主題開發(fā)人員的工作,建議至少對主題存儲庫的要求有所了解。
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準則并將其應(yīng)用于您的工作中,將幫助您創(chuàng)建遵循最佳實踐且易于使用的更加出色的WordPress主題 ,這使您成為更好的主題開發(fā)人員。
下一步是什么? (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存儲庫準備好主題所需的資源,接下來便可以執(zhí)行此操作。
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.
嘗試這些步驟中的任何一個或全部,并與社區(qū)分享您的經(jīng)驗。 我迫不及待想在評論中聽到所有有關(guān)它的信息。
Happy WordPress theming!
WordPress主題快樂!
翻譯自: https://www.sitepoint.com/using-the-doingitwrong-theme-to-learn-wordpress-theme-review/
總結(jié)
以上是生活随笔為你收集整理的使用不正确的主题来学习WordPress主题评论的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python用复化梯形公式积分_复化梯形
- 下一篇: Java年薪计算器