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.
It was easy enough to add a page into the WordPress admin under the Settings menu, using the Add Options page function. There might, however, be other times when you want to do something more or something different, for example, if you want to create a link under the user section or under media section or maybe you have bunch of options pages, and you want to create a whole new menu setting with submenus. We can do all these things. Let's go back to our cc_comments plugin. I want to show you that I've taken the plugin and moved it into a separate subdirectory.
I have also created a little icon, which we'll talk about in the second. The reason why I did this is because I have a couple of files, and I didn't want these files to get all mixed up with all the other plugins. So it's easy to organize them in a single directory, and it's actually good practice to do so. If you've already created your file in the root directory, and you want to move it, just make sure to reactivate your plugin, because it won't find the original one and will deactivate it. It will find the new one, but it will detect it as if it's a new plugin. Here is our old function that was generating our menu.
It's calling add_options_page. There are a number of different other functions you can call other than add_options_page. If you remember this one, put it inside of the Settings down here, but we can also move it and put it somewhere else. There's an add_media page, an add_post page, an add_themes page, an add_links page, add_users page, add_plugins page, and there's even an ad_dashboard page, which allows you to put it in that submenu.
So all of these special functions are built-in for these specific menus, and you can see it added up here. Notice also that that screen icon function I used will actually change based on where you move it to. If however you want to create your own menu, you are going to have to use a new function called add_menu page. Most of these are the same. You are going to have the name of your menu-- let's just keep it cc_comments--you are going to have whatever you want to show up in the menu, you are going to have whatever the capabilities of the user are, some kind of handle, and then whatever function you want to run to generate the page.
In addition, you're able to specify an icon, and I put this one in wordpress/ wp-content/plugins/cc_comments/cc_icon.png. Of course, there will be particular installations, and you could put a dynamic variable here, but for simplicity's sake I am just going to type it in. Make sure you separate that with a comma, and now when I refresh it, you should see that it's added on an entirely new section with my icon, which will link directly to that page.
You can also use a second option here, which is a priority, to determine where it's going to show up in the menu. You can see it moved it up here. You can change and lower the numbers to determine where it's going to fit inside of your menu. So WordPress gives us a number of options for quickly plugging option screens into the admin menu. You can use any of the built-in functions, such as add_options page or add_theme page, or you can use the add_menu page, and there's another one, add_submenu page, if you want to add additional submenus.
Whatever it is you want to do, WordPress has the flexibility to do it.
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.