Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
WordPress Plugin Development Cookbook

You're reading from   WordPress Plugin Development Cookbook Create powerful plugins to extend the world's most popular CMS

Arrow left icon
Product type Paperback
Published in Jul 2017
Publisher
ISBN-13 9781788291187
Length 386 pages
Edition 2nd Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Yannick Lefebvre Yannick Lefebvre
Author Profile Icon Yannick Lefebvre
Yannick Lefebvre
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Preparing a Local Development Environment FREE CHAPTER 2. Plugin Framework Basics 3. User Settings and Administration Pages 4. The Power of Custom Post Types 5. Customizing Post and Page Editors 6. Accepting User Content Submissions 7. Customizing User Data 8. Creating Custom MySQL Database Tables 9. Leveraging JavaScript, jQuery, and AJAX Scripts 10. Adding New Widgets to the WordPress Library 11. Enabling Plugin Internationalization 12. Distributing Your Plugin on wordpress.org

Installing a dedicated code editor/text editor

Most operating systems provide a built-in text editor. While it is possible to create WordPress plugins using such a simple tool, it is highly recommended to install a dedicated code editor on your computer to simplify your plugin development work.

Getting ready

Of course, not all code editors are equal. Here are some of the features that you should look for when selecting a code editing application:

  • PHP syntax highlighting
  • Completion of PHP function names
  • Ability to search in multiple files simultaneously
  • Ability to highlight all instances of search keyword(s) or selected text
  • Line numbering
  • Ability to resize the editor text or specify a replacement font
  • Possibility of opening multiple files simultaneously

The following editors contain most or all of these key features. Most are free tools, but some are paid applications:

On the Windows platform:

On the Mac platform:

On the Linux platform:

Cross-platform:

This recipe explains how to install a dedicated code editor and shows basic editor operations. It provides detailed steps using Programmer's Notepad for Windows.

How to do it...

  1. Download the installation package for one of the text editors listed previously.
  2. Run the installation program for the editor and select the default settings.
  3. Launch the text editor.
  4. Open the hello.php file from the plugin directory of your local WordPress installation. You will see that different parts of the code are displayed in different colors based on the type of code.
  5. Double-click on a word to select it. You will see any other instance of that same word highlighted across the file contents:
  1. Select the View | Line Numbers menu item (or similarly named item based on your selected text editor) to display line numbers in the editor.

How it works...

Code editors have built-in parsers that enable them to identify the parts of the code that are comments, PHP language functions, text strings, and a variety of other elements. Having these elements colored on the screen makes it much easier to read through code and to see that a function's name is not spelled correctly, or to quickly identify comments.

Another functionality that is crucial when developing plugins for WordPress is the ability to see line numbers in the editor. This function comes in handy, especially when PHP code errors come up, since the filename and line of code that was being processed at the time of the error are normally displayed. In most code editors, the developer can either scroll to the specific line or enter the line number in a quick Go To dialog box to jump to that line right away.

You have been reading a chapter from
WordPress Plugin Development Cookbook - Second Edition
Published in: Jul 2017
Publisher:
ISBN-13: 9781788291187
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime