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

Interacting with a Subversion repository from the NetBeans interface


One of the multiple benefits of using the NetBeans IDE is that it is pre-integrated with the Subversion version control system. Whether you're developing plugins for your own private use, for customers, or for public distribution on wordpress.org, Subversion is a great system to use to keep track of all important revisions of your work over time.

This recipe explains how to use the built-in Subversion functionality in NetBeans to interact with a file repository.

Getting ready

You should have already installed the NetBeans IDE and created a project pointing to your local WordPress development site. You should also have created a Subversion repository on your system and imported the contents of the WordPress plugin directory.

Note

At the time of writing, an incompatibility between NetBeans 7.1 and repositories created by TortoiseSVN 1.7.x requires additional steps to be executed before performing this recipe. These steps can be found on the Netbeans website at http://netbeans.org/projects/versioncontrol/pages/Subversion1_7.

How to do it...

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

  2. 2. Change any line of code in the plugin header (top section of the plugin information on the plugin name, author, and so on). Notice that colored bands start appearing on the left margin of the code editor as lines are modified, added, or deleted.

  3. 3. Position the mouse cursor over the colored area that is displayed next to the modified line to see a tooltip indicating that the line has been modified.

  4. 4. Click on the colored notification area to see the previous content of that line and have the opportunity to roll back the modified content to its last known state from a previous insert, commit, or update operation.

  5. 5. In the project window, right-click on the hello.php file and select the Subversion | Commit menu. This command displays the NetBeans Subversion Commit interface. While it is slightly different from the equivalent TortoiseSVN dialog, you should still recognize the field used to specify a commit message and the list of all files that were identified as having changed from the last insert, commit, or update operation.

  6. 6. Enter a message in the Commit Message field.

  7. 7. Click on the Commit button to send your changes to the Subversion repository.

    Note

    By right-clicking on any file from the plugin directory and selecting the Subversion menu, we can see that all the functionalities we explored in the previous Subversion-related recipes are available in the NetBeans environment. However, some of them have different names. For example, the Show log menu item is called Search History and has some more advanced features than the TortoiseSVN client.

How it works...

Similar to the way the TortoiseSVN client works, the NetBeans interface has been built using the Subversion client libraries to provide us with a full-featured tool that can access any Subversion repository. Since our WordPress plugin directory files were already imported and checked out from a repository, NetBeans is able to read the repository information that is contained in the .svn directories located across the project structure and use this data to identify code changes on the fly during code editing. It also has access to information on the repository address that is associated to the plugin files to send new and updated items to the correct location without asking us to specify where they should be sent.