ebook img

WordPress and Ajax An in-depth guide on using Ajax with WordPress PDF

298 Pages·2011·3.09 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview WordPress and Ajax An in-depth guide on using Ajax with WordPress

The people that made this free re- lease possible For those who have purchased this book in e-book format, a big “Thanks!” goes out to you. The following companies have also made the free release possible by advertising for the book and/or supporting me while writing the book: VG Universe Design VG Universe Design is a Web & Graphic Design Studio owned and operated by this book’s designer, Vivien Anayian. Her work speaks for itself, and she was instrumental in this book’s public release. WebDesign.com WebDesign.com provides premium, professional web development training to web designers, developers, and WordPress website own- ers. The WebDesign.com Training Library currenty holds over 230 hours of premium training developed by seasoned experts in their field, with approximately 20 hours of new training material added each month. WordPress and Ajax WebDevStudios WebDevStudios is a website development company specializing in WordPress. We have a staff of developers and designers who live and breathe WordPress and pride ourselves in being WordPress ex- perts. We have the resources to support any client from a single blog to a WordPress Multisite network with thousands of sites to a Bud- dyPress site with thousands of members. WPCandy WPCandy is an unofficial community of WordPress users and pro- fessionals. They are best known for their solid WordPress reporting and also publish a growing weekly podcast and regular community features. If you love WordPress and want to stay plugged in to the community, WPCandy is the place to be. RONALD HUERECA WORDPRESS & AJAX An in-depth guide on using Ajax with WordPress cover & book design by Vivien Anayian WordPress and Ajax - 2nd Edition Copyright © 2010 by Ronald Huereca All Rights Reserved under International and Pan-American Copyright Conventions This book is protected under U.S. and international copyright law. No part of this book may be used or reproduced in any manner without the written permission of the copyright holder except where allowed under fair use. The rights of this work will be enforced to the fullest extent pos- sible, including under the Digital Millennium Copyright Act of 1998 (DMCA) of the United States, the European Directive on Electronic Commerce (EDEC) in the European Union and other applicable U.S. and international laws. All source code used in this book is licensed under the GNU Public License (GPL). For more information about the GPL or to obtain a copy of the full license, please visit http://www.gnu.org/copyleft/gpl.html. BOOK DESIGNER Vivien Anayian COVER DESIGNER Vivien Anayian COVER ILLUSTRATIONS Antelope by Haekel, Vintage educational plate Killer Whale by W. Sidney Berridge from A Book Of Whales, 1900. Plate XXI (From cast in National History Museum) PRIMARY TYPEFACES Adobe Garamond Pro, designed by Claude Garamond, Robert Slimbach Futura, designed by Paul Renner Myriad Pro, designed by Robert Slimbach, Carol Twombly Monaco, designed by Susan Kare, Kris Holmes, Charles Bigelow Table of Contents Acknowledgments ..............................................11 About Ronald Huereca - Author 12 Credits and Thanks 12 Introduction .......................................................15 How About a Little Ajax? 16 The Book’s Beginning 16 The Goal of the Book 17 Helpful Tools for the Journey 18 Online Resources 19 A Word of Warning 19 Chapter 1 What is Ajax? .....................................................21 Chapter 2 Adding Scripts Properly to WordPress ................27 So How Does wp_enqueue_script Work? 29 Handle 29 Src 29 Deps 30 Ver 31 In_footer 31 Great, I have wp_enqueue_script down. Now what? 32 Naming Your Handlers 35 Loading Scripts Conclusion 36 Chapter 3 Localizing Your Scripts .......................................37 wp_localize_script 39 Handle 39 Object_name 39 l10n 40 wp_localize_script Example 40 Other Localization Techniques 42 The JSON Technique 42 A Custom Function 44 Localization Conclusion 45 Chapter 4 Adding Styles Properly to WordPress ..................47 How Does wp_enqueue_style Work? 48 Handle, Src, Deps, and Ver 49 Media 49 The wp_enqueue_style Hooks 50 The init Technique 51 Conditional Comments 53 Loading Styles Conclusion 54 Chapter 5 Page Detection in WordPress ..............................55 WordPress Conditionals 57 Loading Scripts on the Front-End 58 Loading Scripts on the Home Page 59 Loading Scripts on the Front Page 60 Loading Scripts on Posts or Pages 60 Loading Scripts on Comment Pages 61 Loading Scripts for Post Types 62 Loading Scripts for Custom Taxonomies 62 Loading Scripts for Detecting Shortcodes 62 Load Scripts for a Specific Platform 63 Conditionals Conclusion 63 Page Detection in the Admin Area 64 Page Detection for Specific Admin Pages 65 Page Detection for Menu Items 66 Page Detection Conclusion 68 Chapter 6 WordPress Loading Techniques ..........................69 Overriding Styles (and Scripts) 71 Disabling Styles (and Scripts) 73 Loading Just Your Scripts 75 Creating Standalone Pages 77 Loading WordPress Manually Using wp-load 77 Loading WordPress Using a Template Redirect 79 Preventing Plugins From Loading 83 WordPress Loading Techniques Conclusion 86 Chapter 7 Properly Formatting jQuery for WordPress Use ..87 Namespacing 88 Public Properties/Functions 91 Private Variables/Functions 92 Including Your jQuery Script in Your Theme 95 Conclusion for Properly Formatting jQuery for WordPress 96 Chapter 8 Nonces and the Escape API ................................97 WordPress Nonces 98 Nonces and Forms 101 Nonces and URLs 104 Nonces and Ajax 106 The Escape API 107 Validating Numeric Inputs 108 Escaping HTML 109 Escaping Attributes 110 Escaping JavaScript 111 Escaping URLs 111 Filtering HTML 112 Escape API Conclusion 114 Chapter 9 Sending Our First Ajax Request .......................115 Set Up the PHP Class to Handle Back-end Operations 117 Setting up the Interface 119 Setting Up the JavaScript File 122 Setting up the Ajax Object 124 Finalizing the functions.php Class 126 The get_comments Method 126 Add in our JavaScript Files 127 Add in JavaScript Localization 128 Add in String Localization 131 Add in Query Variable Support 131 Finalizing the Ajax Request 133 Chapter 10 Processing Our First Ajax Request ....................139 Securing Your Ajax Processor 140 Performing a Nonce Check 141 Server-Side Processing of Ajax Requests 143 Sending an Ajax Response 146 Client-Side Processing/Parsing 150 Parsing the XML Document Object 150 Processing the Data 151 The Output 156

Description:
The WordPress and Ajax e-book is a comprehensive view on using Ajax with WordPress. It covers Ajax like youve never seen before. The book contains three real-life examples that provide the rationale and logic behind coding decisions, the reasons for Ajaxs use, and the steps from inception to complet
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.