Introduction xxxi
Chapter 1: First Post 1
What is WordPress? 1
Popularity of WordPress 3
Current State 3
Intersecting the Community 4
WordPress and the GPL 5
Content and Conversation 6
WordPress as a Content Management System 6
Creating Conversation 7
Getting Started 7
Hosting Options 8
Do it Yourself Installation 9
Installing WordPress Files 10
Database Configuration 14
Finishing Up 18
FirstTime Administration 18
First Post 20
Summary 21
Chapter 2: Code Overview 23
Downloading 23
Download Locations 23
Available Formats 24
Release Archive 24
Directory and File Structure 25
WordPress Configuration 26
wpconfig.php File 26
Advanced wpconfig.php Options 29
.htaccess 35
The .maintenance File 39
wpcontent User Playground 40
Plugins 40
Themes 41
Uploads and Media Directory 41
Upgrade Directory 41
Custom Directories 42
Summary 42
Chapter 3: Working with Wordpress Locally 43
Benefits of Working Locally 43
Typical Deployment Cycle 44
Why So Much Process? 44
Tools for Component Administration 46
Getting Your Development Stack 46
Adding WordPress to the Local Install 47
Configuration Details 48
Managing the Web Server Document Tree 49
Enabling Debug Information 50
Handling Local and Production Database 53
Creating Virtual Local Server Names 53
Local Theme and Plugin Development 56
Virtual Machines 56
Deploying Local Changes 57
Summary 59
Chapter 4: Tour of the Core 61
Whats in the Core? 61
Using the Core as a Reference 62
Inline Documentation 63
Finding Functions 64
Exploring the Core 66
Deprecated Functions 69
WordPress Codex and Code Reference 70
What is the Codex? 70
Using the Codex 70
Function Reference 72
WordPress APIs 73
Codex Controversy 75
Code Reference 75
Using the Code Reference 75
Code Reference Details 76
Codex Versus Code Reference 77
Dont Hack the Core! 77
Why Not? 77
Alternatives to Hacking the Core 78
Summary 78
Chapter 5: The Loop 79
Understanding the Loop 80
From Query Parameters to SQL 81
Understanding Content in WordPress 82
Putting the Loop in Context 82
Flow of the Loop 83
Template Tags 86
Commonly Used Template Tags 86
Tag Parameters 87
Customizing the Loop 88
Using the WP_Query Object 88
Building a Custom Query 89
Adding Paging to a Loop 92
Using the pre_get_posts Hook 93
Using query_posts( ) 94
Using get_posts( ) 96
Resetting a Query 96
More Than One Loop 98
Advanced Queries 99
Global Variables 102
Post Data 102
Author Data 104
User Data 104
Environmental Data 105
Global Variables or Template Tags? 106
Working Outside the Loop 106
Summary 109
Chapter 6: Data Management 111
Database Schema 111
Table Details 113
WordPress Content Tables 114
WordPress Taxonomy Tables 115
WordPress Database Class 117
Simple Database Queries 117
Complex Database Operations 119
Dealing with Errors 121
Direct Database Manipulation 123
Summary 126
Chapter 7: Custom Post Types, Custom Taxonomies, and Metadata 127
Understanding Data in WordPress 127
What is a Custom Post Type? 128
Register Custom Post Types 128
Setting Post Type Labels 133
Working with Custom Post Types 135
Custom Post Type Template Files 136
Special Post Type Functions 136
WordPress Taxonomy 138
Default Taxonomies 138
Taxonomy Table Structure 139
Understanding Taxonomy Relationships 139
Building Your Own Taxonomies 140
Custom Taxonomy Overview 140
Creating Custom Taxonomies 140
Setting Custom Taxonomy Labels 144
Using Your Custom Taxonomy 145
Metadata 146
What is Metadata? 147
Adding Metadata 147
Updating Metadata 148
Deleting Metadata 148
Retrieving Metadata 149
Community Projects 150
Summary 151
Chapter 8: Plugin Development 153
Plugin Packaging 154
Creating a Plugin File 154
Creating the Plugin Header 154
Plugin License 155
Activating and Deactivating Functions 156
Internationalization 157
Determining Paths 159
Local Paths 160
URL Paths 160
Plugin Security 161
Nonces 161
Data Validation and Sanitization 163
Know Your Hooks: Actions and Filters 166
Actions and Filters 166
Popular Filter Hooks 168
Popular Action Hooks 169
Plugin Settings 171
Saving Plugin Options 171
Array of Options 172
Creating a Menu and Submenus 173
Creating a TopLevel Menu 173
Adding to an Existing Menu 175
Creating an Options Page 176
WordPress Integration 186
Creating a Meta Box 186
Shortcodes 191
Creating a Widget 192
Creating a Dashboard Widget 197
Creating Custom Tables 197
Uninstalling Your Plugin 200
Creating a Plugin Example 201
Publishing to the Plugin Directory 222
Restrictions 222
Submitting Your Plugin 223
Creating a readme.txt File 223
Setting Up SVN 226
Publishing to the Plugin Directory 228
Releasing a New Version 228
Plugin Assets 229
Summary 230
Chapter 9: Theme Development 231
Why Use a Theme? 231
Installing a Theme 232
FTP Installation 233
Theme Installer 233
What is a Theme? 234
Template Files 234
CSS 234
Images and Assets 235
Plugins 235
Creating Your Own Theme 235
Project Themes vs. Child Themes 235
What to Look for in a Starter Theme 236
Creating Your Own Theme: Getting Started 237
Essential File: Style.css 238
Showing Your Content: Index.php 239
Showing Your Content in Different Ways: Index.php 241
Creating Your Own Theme: DRY 241
Header.php 241
Footer.php 243
Sidebar.php 243
Deviations from the Norm: Conditional Tags 244
Creating Your Own Theme: Content Display 245
Customizing Your Homepage: FrontPage.php 246
Show Your Older Posts by Date: Archive.php 249
Showing Only One Category: Category.php 250
Show Posts of a Specific Tag: Tag.php 252
Other Archival Templates 253
How to Show a Single Post: Single.php 253
Display a Page: Page.php 255
Display Post Attachments: Attachment.php 255
Display Custom Post Types 256
Template Hierarchy 256
Creating Your Own Theme: Additional Files 258
Handling 404 Errors: 404.php 258
Author.php 259
Comments.php 260
Adding Functionality to Your Templates: Functions.php 261
Search.php 264
SearchForm.php 265
Other Files 266
Custom Page Templates 266
When to Use Custom Page Templates 267
How to Use Custom Page Templates 268
Stock Twenty Fourteen Page Templates 269
Other Theme Enhancements 269
Menu Management 269
Widget Areas 271
Post Formats 272
Theme Settings 274
Theme Customizer 274
Theme Hierarchy and Child Themes 275
Premium Themes and Other Theme Frameworks 279
Underscores (_s) Theme 280
Bones Theme 280
Carrington Core Theme 280
Genesis Theme 280
Hybrid Core Theme 281
Others Theme 281
Summary 281
Chapter 10: Multisite 283
What is Multisite? 283
Multisite Terminology 284
Differences 284
Advantages of Multisite 285
Enabling Multisite 285
Working in a Network 286
Network Admin 287
Creating and Managing Sites 287
Working with Users and Roles 288
Themes and Plugins 288
Settings 289
Domain Mapping 289
Coding for Multisite 290
Blog ID 290
Common Functions 290
Switching and Restoring Sites 292
Creating a New Site 295
Network Admin Menus 300
Multisite Options 301
Users in a Network 308
Super Admins 310
Network Stats 311
Large Networks 312
Multisite Database Schema 312
MultisiteSpecific Tables 312
SiteSpecific Tables 313
Summary 314
Chapter 11: Migrating to Wordpress 315
Understanding the Process 316
Content Sources 316
Migration Checklist 317
Site Preparation 318
Content Identification 318
Migrating Text Documents 319
Built-In WordPress Import Tools 319
Building a Custom Import Script 321
Media Migration 329
Moving Metadata 330
Moving Authors and Users 330
Theme and Presentation 331
Unique Functionality 331
Cleaning Up 331
Manual Fine-Tuning 332
Import Limitations 332
Updating URLs 332
Redirection 333
Launching 334
WP-CLI 334
What is WP-CLI? 334
Installing WP-CLI 335
Migration Example 335
Summary 337
Chapter 12: Crafting a User Experience 339
User Experience Principles 339
Consistent Navigation 340
Visual Design Elements 342
Making Content Easy to Find 343
Site Load Times 344
Using JavaScript 345
Usability and Usability Testing 346
Structuring Your Information 347
Getting Your Site Found 349
Duplicate Content 351
Trackbacks and Pings 353
How Web Standards Get Your Data Discovered 354
Semantic HTML 354
Valid HTML 356
Microformats 357
HTML5 359
CSS3 361
Searching Your Own Site 361
Weaknesses of the Default Search 362
Alternatives and Plugins to Help 363
Mobile Access and Responsive Web Design 364
Leave it Alone 365
Lightweight Mobile 365
Responsive Design 366
Summary 367
Chapter 13: Securing Wordpress 369
Securing Your WordPress Site 369
Staying UptoDate 370
Hiding WordPress Version Information 371
Never Use the Admin Username 371
Limit Login Attempts 371
Using Good Passwords 371
Changing Your Table Prefix 372
Moving Your Configuration File 372
Moving Your Content Directory 372
Using the Security Key Feature 373
Forcing SSL on Login and Admin 374
Apache Permissions 374
MySQL Credentials 375
Using WordPress Roles 375
Subscriber Role 375
Contributor Role 376
Author Role 376
Editor Role 376
Administrator Role 376
Super Admin Role 377
Role Overview 377
Extending Roles 378
Recommended Security Plugins 378
BulletProof Security 378
WPSecurity Scan 378
WordFence Security 379
Summary 379
Chapter 14: Application Framework 381
What is an Application Framework? 381
WordPress as an Application Framework 382
User Management 382
Template Engine 384
CRUD 384
Caching 386
Friendly URLs 387
External APIs 388
Uploads and Media Management 388
Scheduled Tasks 389
Flexibility 390
Summary 390
Chapter 15: Wordpress in the Real World 391
Is WordPress the Right Tool? 391
When WordPress is Not the Right Tool 393
Defining Content Management 394
Workflow and Delegation 395
User Roles and Delegation 395
Workflow 396
Content Organization 398
Theme and Widget Support 399
Homepages 400
Featured Content Pages 401
Content Hierarchy 403
Interactivity Features 404
Forums 405
Forms 405
ECommerce 405
Scalability 406
Performance Tuning 406
Database Optimizations 408
Regular Database Maintenance 408
Hardware Scaling 409
Statistics Counters 411
AWStats 411
Google Analytics 412
JetPack by WordPress.com 413
Cache Management 413
WordPress System Complexity 414
Web Server Caching and Optimization 416
WordPress Object Caching 417
Transient Caches 418
MySQL Query Cache 420
Load Balancing Your WordPress Site 421
Dealing with Spam 423
Comment Moderation and CAPTCHAs 423
Automating Spam Detection 424
Other Content Management Systems 425
WordPress Integration 425
Where Not to Use WordPress 426
Summary 427
Chapter 16: Wordpress Developer Community 429
Contributing to WordPress 429
Understanding Trac 430
Working on the Core 433
Submitting Plugins and Themes 434
Documentation 434
Sister Projects 435
BuddyPress 435
bbPress 435
Future Projects 435
Resources 436
Codex 436
Handbooks 436
Support Forums 436
WordPress Chat 437
Mailing Lists 438
External Resources 439
WordCamp and Meetups 440
WordPress.TV 440
Theme/Plugin Directories 440
WordPress Ideas 440
WordPress Development Updates 440
Make WordPress.org 441
WordPress Podcasts 441
WordPress News Sites 442
Summary 443
Index 445