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.
Since version 2.7, the WordPress development team gave us the ability to customize our own dashboards. What this means is we can add our own dashboard widgets into the WordPress admin. These widgets work pretty much the same as the ones we looked at earlier, only they are plugged into admin dashboard instead of the front of the web site. They can be really useful in some plugins because they allow for displaying statistical data, or they allow for quick updates. So, let's take a look at the dashboard. Here we are in the admin, and you have probably seen this before.
We have all of these different widgets. You can move them around if you want to. Some of them have configuration options you can edit that determine how much you want to see, where you want to get data from, however that works. If you go into Screen Options, you can turn these on and off, and do whatever you want, basically, to customize it. If you want to create your own, you can create a plugin. We have created one here, a simple_db_widget.
We can see, we've created it just like any other plugin. You are going to write a function that's going to output whatever appears on the dashboard widget. So simple_dashboard_widget. So in here I am just going to create some visual codes. I am going to go ahead and do my tags. I'll just say, "Simple Dashboard Widget," "Welcome to WordPress development." And then, if you want, you can do things like add links.
You can add dynamic stuff in here, but for now we are just going keep it as a simple static wizard. There we are, good. So there's our widget, pretty straightforward. In order to add this into the WordPress admin, we are going to need to register it. So we are going to create a function to register it. I am going to use sdbw as the prefix, so we can keep it clean. It's called register_widget, and then in here, we can say wp_add_dashboard_widget, and this is our special dashboard widget function.
It takes the ID of the dashboard widget. We will call it simple-dashboard- widget, and you may refer to this in other places so make sure you choose something unique and something you can remember, and then whatever the name is. This is just going to be sort of a user-friendly name. This will be what you see in the screen options. Then you will pass in the function that's going to be used to generate the widget itself, which is simple. It's a function we already created. You might also pass in a control function, which will handle editing of options, but we are not going to worry about that.
The last thing to do is to add an action, and this action is going to be in wp_dashboard_setup, and it's going to call the function we just created. This will then call this function when this hook is triggered, which will then set this function up to display in the dashboard. So let's go into our admin, and go into the plugins page and activate our simple dashboard widget.
Now when we return of the dashboard, we can see our simple dashboard widget had been added, and we can minimize it, and we can move around just like we can any of the other widgets, and if we go screen options, you can see we can turn it on and off from up here. If you want to find out more about WordPress admin widgets, you can find it at the Codex. There is a whole page at WordPress.org that will tell you about it. You can learn about how to move these around and do all kinds of other stuff. Since version 2.7, WordPress gives you the ability to add your own widgets to the WordPress admin dashboard.
It's basically a three step process: You write a function that outputs your widget, you write a function to register the widget, and then you add an action for Add Dashboard Widget. Once you add it in, you can then see your widget in the dashboard.
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.