Learning WordPress REST API
eBook - ePub

Learning WordPress REST API

Sufyan bin Uzayr

Share book
  1. 216 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Learning WordPress REST API

Sufyan bin Uzayr

Book details
Book preview
Table of contents
Citations

About This Book

A practical tutorial to get you up and running with the revolutionary WordPress REST API

About This Book

  • Learn how to run the latest WordPress REST API with various platforms
  • Create exciting apps and manage non-WordPress content with them
  • Secure, export, and manage your data through illustrative examples

Who This Book Is For

This book is for WordPress developers and designers who want to get a complete practical understanding of the WordPress REST API and leverage it to create fully-featured web apps.

What You Will Learn

  • Use the WordPress REST API to read, write, and edit posts
  • Create and work with metadata using the WordPress REST API
  • Work with taxonomies using the REST API
  • Add custom routes and build apps using the WordPress REST API
  • Process requests and integrate with external applications and frameworks
  • Make your WordPress projects ready for the RESTful API standard

In Detail

The WordPress REST API is a recent innovation that has the potential to unlock several new opportunities for WordPress developers. It can help you integrate with technologies outside of WordPress, as well as offer great flexibility when developing themes and plugins for WordPress. As such, the REST API can make developers' lives easier.

The book begins by covering the basics of the REST API and how it can be used along with WordPress. Learn how the REST API interacts with WordPress, allowing you to copy posts and modify post metadata. Move on to get an understanding of taxonomies and user roles are in WordPress and how to use them with the WordPress REST API. Next, find out how to edit and process forms with AJAX and how to create custom routes and functions. You will create a fully-functional single page web app using a WordPress site and the REST API. Lastly, you will see how to deal with the REST API in future versions and will use it to interact it with third-party services.

By the end of the book, you will be able to work with the WordPress REST API to build web applications.

Style and Approach

A step by step tutorial to explain the new and exciting world of the WordPress REST API with the real world examples.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Learning WordPress REST API an online PDF/ePUB?
Yes, you can access Learning WordPress REST API by Sufyan bin Uzayr in PDF and/or ePUB format, as well as other popular books in Informatique & Programmation en PHP. We have over one million books available in our catalogue for you to explore.

Information

Year
2016
ISBN
9781786469243

Learning WordPress REST API


Learning WordPress REST API

Copyright Š 2016 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: July 2016
Production reference: 1180716
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78646-924-3
www.packtpub.com

Credits

Authors
Sufyan bin Uzayr
Mathew Rooney
Copy Editor
Safis Editing
Reviewer
Ahmad Awais
Project Coordinator
Ulhas Kambali
Commissioning Editor
Amarabha Banerjee
Proofreader
Safis Editing
Acquisition Editors
Anurag Banerjee
Reshma Raman
Indexer
Tejal Daruwale Soni
Content Development Editor
Prashanth G
Production Coordinator
Aparna Bhagat
Technical Editor
Shivani K. Mistry
Cover Work
Aparna Bhagat

About the Authors

Sufyan bin Uzayr is a writer and web developer with experience and an interest in a lot of things related to web design and development. He has worked with numerous Content Management Systems and frameworks, and writes about web design, web development, content production, branding, and typography for several blogs and magazines of repute. He also has a background in Linux administration, database management, cloud computing, and web hosting.
Sufyan is an open source enthusiast. He can code in PHP, RoR, and Perl, and is also proficient in JavaScript, jQuery, and HTML5/CSS3, as well as several other web development trends.
Sufyan primarily uses WordPress and Drupal for both personal and client projects, and often turns towards MODX for the deployment of cloud sites. He has been working with Drupal, WordPress, and other CMSs for almost a decade by now.
Sufyan is a prolific author, and has written several books on a diverse range of topics, including concrete5 for developers (published by Packt Publishing in 2014). He is associated with various publications in the field of web design and development, both in writing and editorial capacity. He has also served as the News Editor and Technical Supervisor, as well as Editor-in-Chief, for multiple web development magazines, both online and in print.
Apart from technology and coding, Sufyan also takes a keen interest in topics such as History, Current Affairs, Foreign Policy and Politics, and regularly appears on television and radio shows around the world. He is also a featured columnist for multiple journals and news publications focusing on foreign policy and international relations. Sufyan's writings on contemporary issues are simultaneously translated into different languages, and his works are cited in academic and critical journals on a regular basis.
Sufyan manages https://codecarbon.com, which features an assortment of useful tools and resources for web developers. Updated regularly, Code Carbon offers JavaScript frameworks and libraries, as well as resources related to HTML/CSS, PHP, Python, Ruby, and of course, WordPress.
You can learn more about Sufyan's writings and other non-technical works at the following website: http://sufyanism.com.
Mathew Rooney is a coder with multiple years of experience in the web development industry. He works with PHP, JavaScript, and offers custom-coded WordPress themes and plugins. Mathew is a firm believer in open source software and has been using WordPress for nearly 5 years.

Acknowledgments

There are several people who deserve to be this page, because this book would not have come into existence without their support.
Some names deserve a special mention, and I am genuinely indebted to:
Mathew Rooney, for the help he offered by co-authoring sections of this book. A good part of the code in different segments and chapters of this book was handled by him. Reshma Raman, for ensuring that the book stays on track, and the outline and chapter division is in the best possible shape.
Prashanth G, for editing the book, and making sure that the content is in order, and also for formatting the manuscript to make it adhere to the Packt style guide.
Shivani Mistry, for the technical edits, and for taking care of the book during the production stage.
Joe Perkins, and all the great folks at Tap Managed WordPress hosting, for offering me a free WordPress setup with no restrictions, wherein I could implement and debug the code.
Stelian Subotin, for helping me remain calm by keeping track of the theoretical aspects of the book.
Ahmad Awais, for reviewing the manuscript, and for providing his helpful insight and critical assessment.
And of course, the core contributors of WordPress, the team behind WP REST API, as well as the millions within the WordPress community -- this book would not have existed had WordPress not been there, and WordPress itself would not be so popular if it were not for the amazing community.
-- Sufyan bin Uzayr

About the Reviewer

Ahmad Awais is a senior full stack web and business development strategist with substantial industrial experience in development, design, training, and writing everything about WordPress.
He blogs at https://AhmadAwais.com/ and tweets at @MrAhmadAwais. He also contributes to projects such as WP-API, WP Customize Component, WooCommerce, TwentySixteen, Easy Digital Downloads, and the WordPress, PHP, and JS Communities.
Ahmad is also one of the keenest open source evangelists; a core contributor at WordPress; a maker of lots of FOSS (Free and Open Source Software), especially WPGulp Boilerplate being used by more than 100 developers, and Sublime Text WordPressCustomizer Package, helping about 1,000 developers write quality code with ease.
He is a published author and WordPress Content Lead at sites such as WPLift, Envato Tuts+, Torque Mag by WPEngine, SitePoint, SmashingMagazine, CreativeMarket, HongKiat, SpeckyBoy, wpMail, Post Status, WPBeginner, TheLayout by FlyWheel, ProductHunt Maker, and so on.
I'd like to thank my parents, Maedah Batool (WP Journalist) for their never-ending support; Packt Publishing, the WordPress Core Team, and the community (developers, designers, and users), without whom none of this would have been possible.

www.PacktPub.com

For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
www.PacktPub.com
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.

Why subscribe?

  • Fully searchable across every book published by Packt
  • Copy and paste, print, and bookmark content
  • On demand and accessible via a web browser

Free access for Packt account holders

If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.

Preface

The REST API is the next big thing in the world of WordPress development. Ever since its inception, it has been gaining popularity, and more and more developers are turning towards it.
Of course, the REST API comes with numerous benefits, such as the ability to interact with third-party platforms and apps. Have an application coded in Ruby and want to interact with a WordPress site based on PHP? The REST API is here to help you!
This book will help you get started with the REST API for WordPress. You will learn the basics as well as the advanced details of this new API so that you can use it in your projects.

What this book covers

Chapter 1, Getting Started with REST API, gives you an overview of what the REST API is, how it functions, and all that it is capable of doing. You will also find information about other platforms if you are new to WordPress.
Chapter 2, Interacting with REST API in WordPress, is where you will learn the basics of the REST API in WordPress. General POST and GET commands shall be covered here.
Chapter 3, Working with Taxonomies and Users with REST API, moves to taxonomies such as categories and tags. Users and user roles will also be covered.
Chapter 4, Working with Forms Using REST API, will show you how the REST API can be used to work with custom forms for your WP platform. This chapter will teach you how to get the most out of it.
Chapter 5, Custom Routes in WordPress REST API, progresses beyond default roles and teaches you how to add and work with custom routes using the REST API.
Chapter 6, Creating a Simple Web App Using WordPress REST API, is where you learn how to create a web app. Plus, you will also learn how to pass commands to your web app.
Chapter 7, Mastering REST API for Your Projects, is where you will learn how to master the REST API for your projects. Obviously, this chapter requires that you have a working knowledge of the REST API, as well as experience with WordPress development.
Chapter 8, WordPress REST API in Practice, teaches you the practical aspects of the WP REST API and its development.
Chapter 9, Summing It Up, wraps up our journey with the WordPress REST API. We will have a recap of all that we have learned so far and an overview of what the REST API can do for us.

What you need for this book

Obviously, you will need a working installation of WordPress to begin with. The latest version of WordPress is recommended so that you do not miss out on security updates.
You will also need to install and activate the WordPress REST API plugin on your site. Free download and installation instructions are here: https://wordpress.org/plugins/rest-api/.
At least PHP 5.4 or higher is recommended. The latest supported version of MySQL is required as well, and enhancements such as MariaDB are also allowed.
You can run WP on a generic LAMP or WAMP stack. For further instructions, consider reading the WordPress documentation.

Who this book is for

This book is for WordPress developers and designers who want to get a complete practical understanding of the WordPress REST API and leverage it to create fully featured web apps.
2323__perleg...

Table of contents