Table of Contents
Preface 1
Chapter 1: Preparing for WordPress Development 7
WordPress background 7
Extending WordPress 8
Understanding WordPress architecture 8
Templating 9
Introducing plugins 9
Summarizing architecture 10
Tools for web development 11
WordPress 11
Mac 12
Windows 12
Text editor 12
Using an IDE 13
FTP client 14
MySQL client 14
Coding best practices 15
Basic organization 15
Isolate tasks into functions 16
Use classes 16
Use descriptive variable names 16
Use descriptive function names 17
Separate logic and display layers 17
Go modular, to a point 18
Avoid short tags 18
Planning ahead starting development 18
Interfaces 19
Localization 19
www.it-ebooks.info
Table of Contents
[
ii
]
Documentation for the developer 19
Version control 20
Environment 20
Tests 20
Security 21
Printing user-supplied data to a page 21
Using user-supplied data to construct database queries 22
Debugging 22
Clearing your browser cache 23
Updating your php.ini ile 23
Coniguring your wp-conig.php ile 23
Checking your syntax 24
Checking values 24
Exercise 25
Summary 26
Chapter 2: Anatomy of a Plugin 29
Deconstructing an existing plugin: Hello Dolly 29
Activating the plugin 29
Examining the hello.php ile 30
Information header 30
Exercise—breaking the header 30
Location, name, and format 31
Understanding the Includes 32
Exercise – parse errors 32
Bonus for the curious 33
User-deined functions 34
Exercise—an evil functionless plugin 34
What just happened 36
Omitting the closing ? PHP tag 38
A better example: Adding functions 38
Referencing hooks via add_action and add_ilter 39
Actions versus Filters 40
Exercise—actions and ilters 40
Exercise—ilters 41
Reading more 43
Summary 44
Chapter 3: Social Bookmarking 45
The overall plan 46
Proof of concept 46
Avoiding conlicting function names 47
www.it-ebooks.info
Table of Contents
[
iii
]
The master plugin outline 48
The plugin information header 50
In your browser—information header 51
Adding a link to the post content 51
Documenting our functions 52
In your browser—linking to the post content 52
Adding JavaScript to the head 52
Making our link dynamic 55
Adding a button template 57
Getting the post URL 58
In your browser—getting the post URL 60
Getting the post title 60
Getting the description 60
Getting the media type 62
Getting the post topic 62
In your browser—title, description, and topic 64
Checking WordPress versions 64
Summary 66
Chapter 4: Ajax Search 67