Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
WP API (JSON REST API) at WordCamp Hampton Roads
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Nikhil Vimal
October 17, 2015
Programming
110
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
WP API (JSON REST API) at WordCamp Hampton Roads
Nikhil Vimal
October 17, 2015
More Decks by Nikhil Vimal
See All by Nikhil Vimal
Utah WordPress Meetup talk (June 2015)
techvoltz
1
410
WordCamp Miami 2015
techvoltz
0
210
The awesome guide to contributing to WordPress
techvoltz
2
230
Getting started with WordPress development
techvoltz
0
79
WordSesh 2 Creatively Creating Custom Post Types
techvoltz
0
270
Creatively Creating Custom Post Types
techvoltz
0
88
Other Decks in Programming
See All in Programming
JavaDoc 再入門
nagise
1
380
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
570
Contextとはなにか
chiroruxx
1
360
Language Server 使ってる? 〜VSCode と Zed の場合〜 / Are you using a Language Server? ~For VS Code and Zed~
handlename
0
800
Performance Engineering for Everyone
elenatanasoiu
0
200
1B+ /day規模のログを管理する技術
broadleaf
0
100
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.2k
Observability in Practice:Grafana 與 Edge Device SRE 的那些事
blueswen
0
170
dRuby over BLE
makicamel
2
380
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
180
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
890
Lessons from Spec-Driven Development
simas
PRO
0
220
Featured
See All Featured
Between Models and Reality
mayunak
4
350
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
170
Amusing Abliteration
ianozsvald
1
210
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.9k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
170
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
Embracing the Ebb and Flow
colly
88
5.1k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.6k
First, design no harm
axbom
PRO
2
1.2k
Transcript
Demo Time!
POST, PUT, DELETE, GET The WP API with Nikhil Vimal
Hi! I’m Nikhil V. I’m 16 and I build stuff.
http://v2.wp-api.org/
None
None
https://github.com/WP-API/WP-API
REST? RESTFUL? SLEEP?
Representational state transfer
Something…Something…HTTP
None
None
POST
DELETE
PUT
GET
/wp-json ?
NOPE!
None
/wp-json/wp/v2/posts
$.ajax({ method: "post", url: ‘http://local.dev/wp-json/ wp/v2/posts', data: data, beforeSend: function
( xhr ) { xhr.setRequestHeader( 'X-WP-Nonce', POST_SUBMITTER.nonce ); }, success : function( response ) { console.log( response ); alert( POST_SUBMITTER.success ); }, fail : function( response ) { console.log( response ); alert( POST_SUBMITTER.failure ); } });
So…why does this matter to me?
With great power comes great…
<?php function my_rest_prepare_post( $data, $post, $request ) { $_data =
$data->data; $thumbnail_id = get_post_thumbnail_id( $post->ID ); $thumbnail = wp_get_attachment_image_src( $thumbnail_id ); $_data['featured_image_thumbnail_url'] = $thumbnail[0]; unset($_data['featured_image']); $data->data = $_data; return $data; } add_filter( 'rest_prepare_post', 'my_rest_prepare_post', 10, 3 );
Please Mr. Postman
Slack + WordPress
None
wp.posts().post({ content_raw: 'my content’, title: ‘look at me go’ })
Custom Dashboards!
None
Authentication…UGH
None
http://www.sitepoint.com/wp-api-and- oauth-using-wordpress-without- wordpress/
None
add_filter('rest_enabled', '__return_false');
Fin @TechVoltz