Book Image

WordPress Plugin Development Cookbook

By : Yannick Lefebvre
Book Image

WordPress Plugin Development Cookbook

By: Yannick Lefebvre

Overview of this book

<p>WordPress is a popular, powerful, and open Content Management System. Learning to extend its core capabilities allows you to unleash its full potential, whether you're an administrator who cannot find the right extension, or a developer with a great idea to enhance the platform for the community, or a website designer/developer working to fulfill a client's needs. "WordPress Plugin Development Cookbook" is the perfect companion for plugin developers, offering easy-to-follow instructions to accomplish tasks that range from basic plugin creation and configuration to advanced customization techniques. Each topic is illustrated through realistic examples showing how it can be applied to solve common problems, followed by explanations of all concepts used. Create WordPress plugins of varying complexity, from a few lines that change a specific function to complex extensions that provide intricate new capabilities. From the creation of your first simple plugin to adding entire new sections and widgets in the administration interface, learn how to change and extend WordPress to perform virtually any task. After installing and configuring an efficient plugin development environment, you will discover how to register your own callbacks that WordPress will execute at key points, forming the basis of plugin creation. Armed with this essential knowledge, you'll explore how to create administration pages to allow users to configure your new creations and to add new content management sections to WordPress through custom post types and custom database tables. Once you have all these elements in place, improve your plugins by customizing the post and page editors, creating user-facing forms to populate new content sections, making your plugin output dynamic using Javascript and AJAX as well as adding new widgets to the platform. Finally, see how to add support for multiple languages and distribute your work to the global WordPress community. "WordPress Plugin Development Cookbook" provides you with tools to create any plugin you can imagine. &nbsp;</p>
Table of Contents (17 chapters)
WordPress Plugin Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface

Installing and configuring the NetBeans Integrated Development Environment


If you have enjoyed moving to a dedicated code editor in the previous recipe but want a solution that provides even more integration to perform all of your WordPress plugin development tasks in a single place, an integrated development environment (IDE) such as the free NetBeans platform will be the perfect solution for you. In addition to having all of the core features of a code editor, NetBeans has the ability to constantly parse your code to identify syntax errors and highlight changes made since your last commit or update operation, right in the editor.

It also features built-in Subversion and MySQL clients to be able to commit code changes and manage database records straight from its interface. The NetBeans application is cross-platform, available on the Windows, Mac, and Linux operating systems, and can be quickly configured to work with a local WordPress installation. This recipe explains how to perform these installation and configuration tasks.

Getting ready

You should already have set up a local WordPress installation on your computer.

How to do it...

  1. 1. Download the PHP NetBeans installer for your choice of platform from the NetBeans website http://netbeans.org/downloads/index.html).

    Note

    While you can choose a version of NetBeans that will support a large variety of programming languages (Java, C/C++, and so on), the PHP version of NetBeans contains all the necessary elements to develop plugins for WordPress.

  2. 2. Install the NetBeans tool by running the installer, selecting all default options, and accepting the license agreement.

  3. 3. Launch the NetBeans IDE using the shortcut it created during the installation.

  4. 4. Install the latest updates, if applicable, and restart the IDE to run the latest version.

  5. 5. Select the File | New Project menu item.

  6. 6. Select PHP in the Categories section and PHP Application with Existing Sources in the Projects section.

  7. 7. Click on Next.

  8. 8. Set the Sources Folder to the location of your local WordPress installation (c:\WPDev on Windows, if you followed the previous recipe).

  9. 9. Specify a Project Name (for example, WordPress Development Site).

  10. 10. Select PHP 5.3 in the PHP Version field.

  11. 11. Check the Put NetBeans metadata into a separate directory option and create a new folder to hold this data (for example, c:\WPNetBeansData).

  12. 12. Click on Next.

  13. 13. Set the Project URL to http://localhost/.

  14. 14. Click on Finish.

  15. 15. Once the project is loaded, close the Tasks panel since it will be populated with a long list of to-do tasks that are extracted from the WordPress source code.

  16. 16. Using the Projects view, navigate to the wp-content/plugins directory of your WordPress installation and double-click on the hello.php file to see it in the NetBeans editor.

  17. 17. Search for the keyword function in the file and remove its last letter n to see a red exclamation mark displayed in the left margin of the code editor. This indicates that a PHP syntax error was detected.

  18. 18. Undo this last change.

  19. 19. Press the F6 key to launch a web browser session pointing to your local development site.

How it works...

The NetBeans editor works by creating a project that points to your website's directory structure and loading all files that are found in that location. With its integrated project browser, it is very easy to find and edit multiple plugin files by starting a single tool. NetBeans combines all of the functionality of a dedicated code editor, a Subversion client such as TortoiseSVN, and the phpMyAdmin database administration interface to make it possible to perform all tasks related to WordPress plugin development in a single environment.

See also

  • Interacting with a Subversion repository from the NetBeans interface recipe