| Foreword |
|
xvii | |
| Preface |
|
xix | |
|
1 Building Web Apps with WordPress |
|
|
1 | (20) |
|
|
|
1 | (1) |
|
|
|
1 | (1) |
|
|
|
1 | (4) |
|
|
|
2 | (1) |
|
|
|
3 | (1) |
|
|
|
4 | (1) |
|
|
|
5 | (6) |
|
You Are Already Using WordPress |
|
|
5 | (1) |
|
Content Management Is Easy with WordPress |
|
|
5 | (1) |
|
User Management Is Easy and Secure with WordPress |
|
|
6 | (1) |
|
|
|
6 | (1) |
|
|
|
6 | (1) |
|
Frequent Security Updates |
|
|
7 | (1) |
|
|
|
7 | (1) |
|
Responses to Some Common Criticisms of WordPress |
|
|
8 | (3) |
|
When Not to Use WordPress |
|
|
11 | (2) |
|
You Plan to License or Sell Your Site's Technology |
|
|
11 | (1) |
|
Another Platform Will Get You "There" Faster |
|
|
11 | (1) |
|
Flexibility Is Not Important to You |
|
|
12 | (1) |
|
Your App Needs to Be Highly Real Time |
|
|
12 | (1) |
|
WordPress as an Application Framework |
|
|
13 | (3) |
|
WordPress Versus Model-View-Controller Frameworks |
|
|
13 | (3) |
|
Anatomy of a WordPress App |
|
|
16 | (1) |
|
|
|
16 | (1) |
|
SchoolPress Runs on a WordPress Multisite Network |
|
|
16 | (1) |
|
The SchoolPress Business Model |
|
|
17 | (1) |
|
Membership Levels and User Roles |
|
|
17 | (1) |
|
Classes Are BuddyPress Groups |
|
|
17 | (1) |
|
|
|
18 | (1) |
|
Submissions Are a (Sub)CPT for Assignments |
|
|
18 | (1) |
|
Semesters Are a Taxonomy on the Class CPT |
|
|
18 | (1) |
|
Departments Are a Taxonomy on the Class CPT |
|
|
18 | (1) |
|
SchoolPress Has One Main Custom Plugin |
|
|
18 | (1) |
|
SchoolPress Uses a Few Other Custom Plugins |
|
|
19 | (1) |
|
SchoolPress Uses the Memberlite Theme |
|
|
20 | (1) |
|
|
|
21 | (48) |
|
WordPress Directory Structure |
|
|
22 | (2) |
|
|
|
22 | (1) |
|
|
|
22 | (1) |
|
|
|
22 | (1) |
|
|
|
23 | (1) |
|
WordPress Database Structure |
|
|
24 | (38) |
|
|
|
24 | (1) |
|
Functions Found in /wp-includes/option.php |
|
|
24 | (3) |
|
|
|
27 | (1) |
|
Functions Found in /wp-includes/... |
|
|
27 | (4) |
|
|
|
31 | (4) |
|
|
|
35 | (1) |
|
Functions Found in /wp-includes/post.php |
|
|
36 | (4) |
|
|
|
40 | (1) |
|
Functions Found in /wp-includes/post.php |
|
|
41 | (4) |
|
|
|
45 | (1) |
|
Functions Found in /wp-includes/comment.php |
|
|
45 | (5) |
|
|
|
50 | (1) |
|
Functions Found in /wp-includes/comment.php |
|
|
50 | (3) |
|
|
|
53 | (1) |
|
Functions Found in /wp-includes/taxonomy.php |
|
|
53 | (4) |
|
|
|
57 | (2) |
|
|
|
59 | (1) |
|
/wp-includes/taxonomy.php |
|
|
59 | (1) |
|
|
|
60 | (2) |
|
Hooks: Actions and Filters |
|
|
62 | (3) |
|
|
|
62 | (1) |
|
|
|
63 | (2) |
|
Development and Hosting Environments |
|
|
65 | (2) |
|
|
|
65 | (1) |
|
|
|
66 | (1) |
|
Development, Staging, and Production Environments |
|
|
66 | (1) |
|
|
|
67 | (2) |
|
3 Using WordPress Plugins |
|
|
69 | (38) |
|
The General Public License, Version 2, License |
|
|
70 | (1) |
|
Installing WordPress Plugins |
|
|
70 | (1) |
|
|
|
71 | (1) |
|
File Structure for an App Plugin |
|
|
72 | (6) |
|
|
|
73 | (1) |
|
|
|
74 | (1) |
|
|
|
74 | (1) |
|
|
|
75 | (1) |
|
|
|
76 | (1) |
|
|
|
76 | (1) |
|
|
|
76 | (1) |
|
|
|
76 | (2) |
|
|
|
78 | (1) |
|
|
|
78 | (1) |
|
|
|
78 | (1) |
|
Add-Ons to Existing Plugins |
|
|
78 | (1) |
|
|
|
79 | (10) |
|
|
|
79 | (1) |
|
WordPress Global Variables |
|
|
80 | (9) |
|
|
|
89 | (3) |
|
|
|
90 | (1) |
|
|
|
90 | (1) |
|
|
|
90 | (1) |
|
|
|
91 | (1) |
|
|
|
92 | (1) |
|
|
|
92 | (1) |
|
|
|
92 | (1) |
|
|
|
92 | (1) |
|
|
|
93 | (1) |
|
|
|
93 | (1) |
|
|
|
93 | (1) |
|
|
|
93 | (14) |
|
|
|
94 | (13) |
|
|
|
107 | (30) |
|
|
|
107 | (2) |
|
Where to Place Code When Developing Apps |
|
|
107 | (1) |
|
|
|
108 | (1) |
|
Where to Place Code When Developing Themes |
|
|
109 | (1) |
|
|
|
109 | (2) |
|
|
|
111 | (4) |
|
|
|
111 | (3) |
|
Using Hooks to Copy Templates |
|
|
114 | (1) |
|
When Should You Use a Theme Template? |
|
|
115 | (1) |
|
Theme-Related WordPress Functions |
|
|
115 | (3) |
|
Using locate_template in Your Plugins |
|
|
117 | (1) |
|
|
|
118 | (2) |
|
Versioning Your Themes CSS Files |
|
|
118 | (2) |
|
|
|
120 | (1) |
|
|
|
120 | (1) |
|
|
|
121 | (2) |
|
WordPress Theme Frameworks |
|
|
121 | (1) |
|
Non-WordPress Theme Frameworks |
|
|
122 | (1) |
|
Creating a Child Theme for Memberlite |
|
|
123 | (1) |
|
Including Bootstrap in Your App's Theme |
|
|
123 | (2) |
|
|
|
125 | (2) |
|
|
|
125 | (1) |
|
|
|
126 | (1) |
|
|
|
127 | (10) |
|
Device and Display Detection in CSS |
|
|
127 | (1) |
|
Device and Feature Detection in JavaScript |
|
|
128 | (3) |
|
|
|
131 | (3) |
|
Final Note on Browser Detection |
|
|
134 | (3) |
|
5 Custom Post Types, Post Metadata, and Taxonomies |
|
|
137 | (36) |
|
Default Post Types and CPTs |
|
|
137 | (2) |
|
|
|
137 | (1) |
|
|
|
137 | (1) |
|
|
|
138 | (1) |
|
|
|
138 | (1) |
|
|
|
138 | (1) |
|
|
|
138 | (1) |
|
|
|
138 | (1) |
|
|
|
139 | (1) |
|
|
|
139 | (1) |
|
|
|
139 | (1) |
|
Defining and Registering CPTs |
|
|
139 | (10) |
|
register_post_type($post_type, $args); |
|
|
140 | (9) |
|
What Is a Taxonomy and How Should I Use It? |
|
|
149 | (7) |
|
Taxonomies Versus Post Meta |
|
|
149 | (2) |
|
Creating Custom Taxonomies |
|
|
151 | (1) |
|
register_taxonomy($taxonomy, $object_type, $args) |
|
|
151 | (4) |
|
register_taxonomy_for_object_type($taxonomy, $object_type) |
|
|
155 | (1) |
|
Using CPTs and Taxonomies in Your Themes and Plugins |
|
|
156 | (4) |
|
The Theme Archive and Single Template Files |
|
|
156 | (1) |
|
Good Old WP_Query and get_posts() |
|
|
156 | (4) |
|
|
|
160 | (4) |
|
add_meta_box($id, $title, $callback, $screen, $context, $priority, $callback_args) |
|
|
160 | (3) |
|
Using Meta Boxes with the Block Editor |
|
|
163 | (1) |
|
Custom Wrapper Classes for CPTs |
|
|
164 | (9) |
|
Extending WP_Post Versus Wrapping It |
|
|
166 | (1) |
|
|
|
167 | (1) |
|
Keep Your CPTs and Taxonomies Together |
|
|
167 | (1) |
|
Keep It in the Wrapper Class |
|
|
168 | (2) |
|
Wrapper Classes Read Better |
|
|
170 | (3) |
|
6 Users, Roles, and Capabilities |
|
|
173 | (22) |
|
|
|
174 | (2) |
|
Add, Update, and Delete Users |
|
|
176 | (3) |
|
|
|
179 | (1) |
|
What Are Roles and Capabilities? |
|
|
180 | (4) |
|
Checking a User s Role and Capabilities |
|
|
181 | (1) |
|
Creating Custom Roles and Capabilities |
|
|
182 | (2) |
|
Extending the WP_User Class |
|
|
184 | (2) |
|
Adding Registration and Profile Fields |
|
|
186 | (5) |
|
Customizing the Users Table in the Dashboard |
|
|
191 | (1) |
|
|
|
192 | (3) |
|
|
|
193 | (1) |
|
Hide the Admin Bar from Nonadministrators |
|
|
193 | (1) |
|
|
|
193 | (1) |
|
|
|
193 | (1) |
|
|
|
194 | (1) |
|
|
|
194 | (1) |
|
7 Working with WordPress APIs, Objects, and Helper Functions |
|
|
195 | (42) |
|
|
|
195 | (4) |
|
|
|
196 | (1) |
|
|
|
197 | (1) |
|
|
|
198 | (1) |
|
Other Useful Shortcode-Related Functions |
|
|
199 | (1) |
|
|
|
199 | (8) |
|
Before You Add Your Own Widget |
|
|
200 | (1) |
|
|
|
201 | (3) |
|
|
|
204 | (2) |
|
Embedding a Widget Outside of a Dynamic Sidebar |
|
|
206 | (1) |
|
|
|
207 | (5) |
|
Removing Dashboard Widgets |
|
|
208 | (1) |
|
Adding Your Own Dashboard Widget |
|
|
209 | (3) |
|
|
|
212 | (4) |
|
Do You Really Need a Settings Page? |
|
|
212 | (1) |
|
Could You Use a Hook or Filter Instead? |
|
|
213 | (2) |
|
Use Standards When Adding Settings |
|
|
215 | (1) |
|
Ignore Standards When Adding Settings |
|
|
215 | (1) |
|
|
|
216 | (5) |
|
|
|
217 | (1) |
|
|
|
217 | (1) |
|
|
|
218 | (3) |
|
|
|
221 | (5) |
|
|
|
223 | (1) |
|
|
|
223 | (1) |
|
Kicking Off Cron Jobs from the Server |
|
|
224 | (1) |
|
|
|
225 | (1) |
|
|
|
226 | (2) |
|
Sending Nicer Emails with WordPress |
|
|
227 | (1) |
|
|
|
228 | (5) |
|
Adding File Headers to Your Own Files |
|
|
230 | (1) |
|
Adding New Headers to Plugins and Themes |
|
|
231 | (2) |
|
|
|
233 | (4) |
|
|
|
237 | (32) |
|
|
|
237 | (1) |
|
|
|
238 | (2) |
|
|
|
238 | (1) |
|
Don't Use the Username "admin" |
|
|
238 | (1) |
|
|
|
239 | (1) |
|
Examples of Bad Passwords |
|
|
239 | (1) |
|
Examples of Good Passwords |
|
|
240 | (1) |
|
|
|
240 | (5) |
|
Don't Allow Admins to Edit Plugins or Themes |
|
|
240 | (1) |
|
Change Default Database Tables Prefix |
|
|
240 | (1) |
|
|
|
241 | (1) |
|
Hide Login Error Messages |
|
|
242 | (1) |
|
Hide Your WordPress Version |
|
|
242 | (1) |
|
Don't Allow Logins via wp-login.php |
|
|
243 | (1) |
|
Add Custom htaccess Rules for Locking Down wp-admin |
|
|
244 | (1) |
|
SSL Certificates and HTTPS |
|
|
245 | (7) |
|
Installing an SSL Certificate on Your Server |
|
|
245 | (3) |
|
WordPress Login and WordPress Administrator over SSL |
|
|
248 | (1) |
|
|
|
249 | (1) |
|
Avoiding SSL Errors with the "Nuclear Option" |
|
|
250 | (2) |
|
|
|
252 | (1) |
|
|
|
252 | (1) |
|
|
|
252 | (3) |
|
|
|
253 | (1) |
|
|
|
253 | (1) |
|
|
|
254 | (1) |
|
Login and Password-Protection Plugins |
|
|
254 | (1) |
|
|
|
255 | (14) |
|
|
|
255 | (1) |
|
|
|
256 | (1) |
|
Data Validation, Sanitization, and Escaping |
|
|
257 | (5) |
|
|
|
262 | (7) |
|
9 JavaScript Frameworks and Workflow |
|
|
269 | (22) |
|
|
|
270 | (1) |
|
|
|
271 | (1) |
|
|
|
271 | (1) |
|
|
|
271 | (1) |
|
|
|
271 | (1) |
|
|
|
271 | (1) |
|
|
|
272 | (3) |
|
Enqueuing Other JavaScript Libraries |
|
|
272 | (2) |
|
Where to Put Your Custom JavaScript |
|
|
274 | (1) |
|
Ajax Calls with WordPress and jQuery |
|
|
275 | (4) |
|
Managing Multiple Ajax Requests |
|
|
279 | (2) |
|
|
|
281 | (5) |
|
WordPress Limitations with Asynchronous Processing |
|
|
286 | (1) |
|
|
|
286 | (5) |
|
|
|
287 | (1) |
|
|
|
288 | (3) |
|
|
|
291 | (28) |
|
|
|
291 | (5) |
|
|
|
292 | (1) |
|
|
|
292 | (1) |
|
|
|
292 | (1) |
|
|
|
293 | (3) |
|
Why Use the WordPress REST API? |
|
|
296 | (1) |
|
Using the WordPress REST API V2 |
|
|
297 | (10) |
|
|
|
297 | (1) |
|
|
|
298 | (5) |
|
|
|
303 | (1) |
|
|
|
304 | (2) |
|
|
|
306 | (1) |
|
Adding Your Own Routes and Endpoints |
|
|
307 | (5) |
|
register_rest_route($namespace, $route, $args, $override); |
|
|
308 | (1) |
|
Setting Up the WordPress Single Sign-On Plugin |
|
|
308 | (1) |
|
Adding the /wp-sso/v1/check Route |
|
|
309 | (1) |
|
Bundling Basic Authentication with Our Plugin |
|
|
310 | (1) |
|
Using the Endpoint We Set Up to Check User Credentials |
|
|
311 | (1) |
|
Popular Plugins Using the WordPress REST API |
|
|
312 | (7) |
|
|
|
312 | (2) |
|
|
|
314 | (1) |
|
|
|
315 | (4) |
|
11 Project Gutenberg, Blocks, and Custom Block Types |
|
|
319 | (14) |
|
|
|
320 | (1) |
|
The Classic Editor Plugin |
|
|
321 | (1) |
|
Using Blocks for Content and Design |
|
|
321 | (1) |
|
Using Blocks for Functionality |
|
|
321 | (1) |
|
|
|
322 | (2) |
|
|
|
322 | (2) |
|
Using Custom Blocks to Build App Experiences |
|
|
324 | (6) |
|
Enabling the Block Editor in Your CPTs |
|
|
324 | (1) |
|
|
|
325 | (1) |
|
|
|
326 | (1) |
|
Limiting Blocks to Specific CPTs |
|
|
326 | (1) |
|
Limiting CPTs to Specific Blocks |
|
|
326 | (1) |
|
|
|
327 | (2) |
|
Saving Block Data to Post Meta |
|
|
329 | (1) |
|
|
|
330 | (1) |
|
|
|
330 | (1) |
|
Use filemtime() for the Script Version |
|
|
330 | (1) |
|
|
|
331 | (1) |
|
Learn JavaScript, Node.js, and React More Deeply |
|
|
331 | (2) |
|
12 WordPress Multisite Networks |
|
|
333 | (26) |
|
|
|
333 | (1) |
|
|
|
334 | (1) |
|
|
|
335 | (1) |
|
Multiple Authors or Categories on the Same WordPress Site |
|
|
335 | (1) |
|
|
|
335 | (1) |
|
|
|
335 | (1) |
|
Use a WordPress Maintenance Service |
|
|
336 | (1) |
|
|
|
336 | (1) |
|
Setting Up a Multisite Network |
|
|
336 | (3) |
|
Managing a Multisite Network |
|
|
339 | (3) |
|
|
|
339 | (1) |
|
|
|
339 | (1) |
|
|
|
340 | (1) |
|
|
|
340 | (1) |
|
|
|
341 | (1) |
|
|
|
341 | (1) |
|
|
|
342 | (1) |
|
Multisite Database Structure |
|
|
342 | (4) |
|
|
|
342 | (3) |
|
|
|
345 | (1) |
|
|
|
345 | (1) |
|
|
|
346 | (1) |
|
Random Useful Multisite Plugins |
|
|
347 | (2) |
|
Gravity Forms User Registration Add-On |
|
|
347 | (1) |
|
Member Network Sites Add-On for Paid Memberships Pro |
|
|
347 | (1) |
|
|
|
347 | (1) |
|
|
|
347 | (1) |
|
|
|
347 | (1) |
|
|
|
348 | (1) |
|
Multisite Robots.txt Manager |
|
|
348 | (1) |
|
|
|
348 | (1) |
|
|
|
348 | (1) |
|
Basic Multisite Functionality |
|
|
349 | (1) |
|
|
|
349 | (1) |
|
|
|
349 | (1) |
|
|
|
349 | (1) |
|
switch_to_blog($new_blog) |
|
|
350 | (1) |
|
|
|
350 | (1) |
|
get_blog_details($fields = null, $get_all = true) |
|
|
350 | (2) |
|
update_blog_details($blog_id, $details = array()) |
|
|
352 | (1) |
|
get_bk>g_status($id, $pref) |
|
|
353 | (1) |
|
update_blog_status($blog_id, $pref, $value) |
|
|
353 | (1) |
|
get_blog_option($id, $option, $default = false) |
|
|
353 | (1) |
|
update_blog_option($id, $option, $value) |
|
|
354 | (1) |
|
delete_blog_option($id, $option) |
|
|
354 | (1) |
|
get_blog_post($blog_id, $post_id) |
|
|
355 | (1) |
|
add_user_to_blog($blog_id, $user_id, $role) |
|
|
355 | (1) |
|
wpmu_delete_user($user_id) |
|
|
355 | (1) |
|
create_empty_blog($domain, $path, $weblog_title, $site_id = 1) |
|
|
356 | (1) |
|
Functions We Didn't Mention |
|
|
356 | (3) |
|
13 Localizing WordPress Apps |
|
|
359 | (12) |
|
Do You Even Need to Localize Your App? |
|
|
359 | (1) |
|
How Localization Is Done in WordPress |
|
|
360 | (1) |
|
Defining Your Locale in WordPress |
|
|
360 | (1) |
|
|
|
361 | (2) |
|
|
|
361 | (2) |
|
Prepping Your Strings with Translation Functions |
|
|
363 | (3) |
|
___($text, $domain = "default") |
|
|
364 | (1) |
|
_e($text, $domain = "default") |
|
|
364 | (1) |
|
_x($text, $context, $domain = "default") |
|
|
364 | (1) |
|
_ex($title, $context, $domain = "default") |
|
|
365 | (1) |
|
Escaping and Translating at the Same Time |
|
|
365 | (1) |
|
Creating and Loading Translation Files |
|
|
366 | (3) |
|
Our File Structure for Localization |
|
|
366 | (1) |
|
|
|
367 | (2) |
|
|
|
369 | (1) |
|
|
|
369 | (1) |
|
|
|
369 | (2) |
|
Using GlotPress for Your WordPress.org Plugins and Themes |
|
|
369 | (1) |
|
Creating Your Own GlotPress Server |
|
|
370 | (1) |
|
14 WordPress Optimization and Scaling |
|
|
371 | (44) |
|
|
|
371 | (2) |
|
|
|
373 | (1) |
|
|
|
373 | (13) |
|
|
|
374 | (2) |
|
|
|
376 | (2) |
|
The WordPress Site Health Tool |
|
|
378 | (1) |
|
|
|
379 | (6) |
|
|
|
385 | (1) |
|
|
|
386 | (5) |
|
|
|
388 | (1) |
|
|
|
389 | (1) |
|
|
|
390 | (1) |
|
|
|
390 | (1) |
|
|
|
390 | (1) |
|
|
|
391 | (1) |
|
|
|
391 | (14) |
|
|
|
391 | (1) |
|
|
|
392 | (13) |
|
|
|
405 | (4) |
|
|
|
406 | (3) |
|
|
|
409 | (1) |
|
Using JavaScript to Increase Performance |
|
|
409 | (2) |
|
|
|
411 | (2) |
|
|
|
413 | (2) |
|
|
|
415 | (26) |
|
|
|
415 | (7) |
|
|
|
416 | (2) |
|
|
|
418 | (1) |
|
|
|
419 | (3) |
|
|
|
422 | (1) |
|
|
|
422 | (2) |
|
Setting Up SaaS with Paid Memberships Pro |
|
|
424 | (1) |
|
|
|
424 | (17) |
|
Step 0 Establishing How You Want to Charge for Your App |
|
|
424 | (1) |
|
Step 1 Installing and Activating Paid Memberships Pro |
|
|
425 | (1) |
|
Step 2 Setting Up the Level |
|
|
426 | (2) |
|
|
|
428 | (1) |
|
Step 4 Choosing Payment Settings |
|
|
429 | (1) |
|
Step 5 Choosing Email Settings |
|
|
430 | (1) |
|
Step 6 Choosing Advanced Settings |
|
|
431 | (1) |
|
Step 7 Locking Down Pages |
|
|
432 | (3) |
|
Step 8 Customizing Paid Memberships Pro |
|
|
435 | (6) |
|
16 Mobile Apps Powered by WordPress |
|
|
441 | (26) |
|
|
|
441 | (1) |
|
Native and Hybrid Mobile Apps |
|
|
442 | (1) |
|
What Is a Native Mobile App? |
|
|
442 | (1) |
|
What Is a Hybrid Mobile App? |
|
|
443 | (1) |
|
|
|
443 | (1) |
|
|
|
444 | (5) |
|
|
|
449 | (1) |
|
|
|
450 | (1) |
|
|
|
451 | (16) |
|
17 PHP Libraries, Web Service Integrations, and Platform Migrations |
|
|
467 | (26) |
|
|
|
467 | (16) |
|
Image Generation and Manipulation |
|
|
468 | (2) |
|
|
|
470 | (5) |
|
Geolocation and Geotargeting |
|
|
475 | (2) |
|
File Compression and Archiving |
|
|
477 | (4) |
|
|
|
481 | (2) |
|
External APIs and Web Services |
|
|
483 | (4) |
|
|
|
484 | (1) |
|
|
|
484 | (1) |
|
|
|
484 | (1) |
|
|
|
484 | (1) |
|
|
|
485 | (1) |
|
|
|
486 | (1) |
|
|
|
486 | (1) |
|
|
|
487 | (6) |
|
|
|
488 | (1) |
|
|
|
489 | (2) |
|
Create a Data Mapping Guide |
|
|
491 | (2) |
|
|
|
493 | (6) |
|
|
|
493 | (1) |
|
|
|
494 | (2) |
|
WordPress Plugins Will Focus More on APIs |
|
|
494 | (1) |
|
|
|
494 | (1) |
|
|
|
495 | (1) |
|
|
|
496 | (1) |
|
The Administrator Interface Will Move to React/Gutenberg |
|
|
496 | (1) |
|
Gutenberg Will Power a Frontend Editing Experience for WordPress |
|
|
496 | (1) |
|
Block Templates Will Replace Themes |
|
|
496 | (1) |
|
Blocks Will Replace Plugins |
|
|
497 | (1) |
|
WordPress Market Share Will Increase and Decrease |
|
|
497 | (1) |
|
WordPress Will Become a More Popular Platform for Mobile Development |
|
|
498 | (1) |
|
WordPress Will Continue to Be Useful for Developing Apps of All Kinds |
|
|
498 | (1) |
| Index |
|
499 | |