WP json api

20
WP JSON API A DEEP CODE DIVE INTO HOW TO EXTEND IT Slides @ http://www.slideshare.net/pbearne Code @ https:// bitbucket.org/bearne/api_demo/src

Transcript of WP json api

WP JSON APIA DEEP CODE DIVE INTO HOW TO EXTEND IT

Slides @ http://www.slideshare.net/pbearne Code@ https://bitbucket.org/bearne/api_demo/src

Paul Bearne @pbearneFreelance Senior Full Stack WordPress Developer, Core contribs in WordPress versions 3.9, 4.0, 4.2, 4.4, 4.5 and 4.6

Bearne.ca

Plugin author of:Author Avatars List ( https://wordpress.org/plugins/author-avatars/ )WP Bullhorn Job Listing ( https://wordpress.org/plugins/bh-staffing-job-listing-and-cv-upload-for-wp/ )WP Vote (https:// wp-vote.com )

Real-time Publishing for WordPress

Livepress.com

eLearning Solutions Powered by WordPress

UncannyOwl.com

#1 Outsourcing Service For WordPress

Codeable.io

$10 credit : https://codeable.io?coupon_code=WSQWI1

digital production and design agency

jam3.com

WP JSON APITURNING WORDPRESS INTO AN APPLICATION FRAMEWORK

What will we cover today?A bit on why it mattersHow to install/setup Where are the docsWhat you get out of the boxHow to mess with it

By the end, you should be able to:Expose a custom post type in the APIView the output of the APISend data to the APISave data sent to the APIReturn custom data to an API call

Why does it matter?JSON data for freeEnables advance appsStandardizes an AJAX endpointIt makes WordPress an application frameworkPerformance – 15%+ faster

https://deliciousbrains.com/comparing-wordpress-rest-api-performance-admin-ajax-php

Install?WP version 4.6 +Install the pluginCheck permalinks are setTest by loading /wp-json/wp/v2/postsInstall Postman and JSONview chrome tools

JSONView chrome extension

https://chrome.google.com/webstore/detail/jsonview/chklaanhfefbnpoihckbnefhakgolnmc?hl=en

Postman chrome extension

https://chrome.google.com/webstore/detail/postman-rest-client-packa/fhbjgbiflinjbdggehcddcbncdddomop?hl=en

Where to get it (V2)?http://v2.wp-api.org/https://wordpress.org/plugins/rest-api/

Note: V1 docs are here http://wp-api.org/index-deprecated.html

What you get out of the boxhttp://local.wordpress.dev/wp-json/wp/v2

Note: V1 docs are here http://wp-api.org/index-deprecated.html

Code Read ThroughTHIS CODE STARTED USING V1, BUT I HAVE ADDED V2 CALLS.THIS JUST ONE APPROACH.

Questions?

Slides@ http://www.slideshare.net/pbearneEmail: [email protected]