Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
In WordPress: Creating Custom Widgets and Plugins with PHP, Drew Falkman teaches PHP developers how to create custom functionality for WordPress 2.0 through 3.0 using widgets and plugins. This course starts by installing and setting up WordPress 3.0 on both Mac and Windows, then provides an in-depth look at tasks related to these WordPress add-ons: installing and administering, building and customizing, creating editable options and database tables, working with posts and pages, and utilizing jQuery and AJAX. There are also tutorials dedicated to promoting a widget or plugin, adding security, and localizing the interface. Exercise files are included with the course.
WordPress is used around the world by people who write blogs in Swedish and French and Farsi, and as such, we want to build plugins that are going to be easy to internationalize. Internationalization is sometimes called localization or translation, or referred to from the more technical term of i18n. But whatever we want to call it, WordPress has a system set up to deal with it. The Codex has some good pages that will explain more information, if you want to learn more about how to localize. The first one is Translating WordPress, and it gives sort of an overview of what localization is, what some of the technical terms are, but it's more high-level.
Then there is an i18n for WordPress developers web site, and this tells more of a technical detailed way of how WordPress implementation specifically works with internationalization. It's all based on PHP's gettext. The main thing that we need to do as developers is essentially mark areas in the code where text is being output that might need to be internationalized. So anywhere you have text that's going to be used somewhere that someone else might want to put in the different language, you want to wrap it in a special function: underscore underscore.
So in this example, here is some static text that I am outputting. I want to go ahead and say underscore underscore and just wrap it. Now this doesn't look like much, and frankly, it doesn't really do anything unless you are implementing text domains and what are called Portable Object Translation, or POT files. Those will then store information about what needs to be replaced where, when different languages are hitting the web site.
The idea being that you can have the same version of a plugin running, and if someone comes from China they'll see a Chinese language site, and if someone comes from United States, they'll see an English language site. In addition to the underscore underscore function, there is also an underscore e function. In this case, I am just storing the variable local. If I am outputting anything to the browser using an echo statement of some kind, then I want to make sure to wrap it in an underscore e function.
So from a developer standpoint, these are the main things that we are going to be doing: just wrapping areas of static text that might need to be changed if someone from a different language is viewing it in either the underscore underscore function or the underscore e function. The next step will be eventually to generate a POT file, and this is the default POT file that comes with WordPress, and you can see there are a number of different strings that are stored inside of the WordPress environment. And it'll even tell you where they are.
Now these have all been wrapped in either the underscore underscore or underscore e functions. So someone else can come and create a new POT file and assign it to a different text domain, and it will then be able to translate. There are number of different softwares that work with that, and we are not going to get into that end of things. I just wanted to show you how to prepare things so that they can be internationalized, because it's considered a best practice in plugin development that you should be using the underscore e and the underscore underscore whenever you output some static text.
So overall, WordPress utilizes PHP's get text translation engine to handle sites using multiple languages. The first step in internationalization is to mark these different pieces with these special functions. Once you do that, translators will create POT files and assign text domains, and your site can be available in different languages.
Find answers to the most frequently asked questions about WordPress: Creating Custom Widgets and Plugins with PHP.
Here are the FAQs that matched your search "":
Sorry, there are no matches for your search ""—to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.