Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Powering Content Driven Applications with the World’s Most Popular CMS #ngconf

300 views

Published on

WordPress powers over 25% of the Internet, with its easy to use admin interface it is a great way to power the content of any site, or application. However powering applications (native or not) was challenging, till the WordPress REST API was introduced. I will walk through why and how to use the WordPress REST API to build angular applications.

Published in: Technology
  • Login to see the comments

  • Be the first to like this

Powering Content Driven Applications with the World’s Most Popular CMS #ngconf

  1. 1. 1 Powering Content Driven Applications with the World’s Most Popular CMS Roy Sivan Twitter/Github - @royboy789 roysivan.com | thewpcrowd.com
  2. 2. Sr. Software Engineer | The Walt Disney Company Roy Sivan Twitter/Github - @royboy789 roysivan.com | thewpcrowd.com WHO IS THIS GEEK? • Teach @ Lynda.com • Teach @ CalderaLearn.com • Podcast @ AiA & JavaScriptJabber • Blog / Podcast @TheWPCrowd.com • Blog @ RoySivan.com @royboy789
  3. 3. WHAT WE ARE GOING TO COVER • WordPress? Seriously? • Why build with WordPress • Cats • How to build with WordPress
  4. 4. @royboy789
  5. 5. WHY BUILD WITH WORDPRESS? Why not? @royboy789
  6. 6. THE WORLD’S MOST POPULAR CMS @royboy789
  7. 7. @royboy789
  8. 8. @royboy789
  9. 9. ENTERPRISE CONCERNS @royboy789
  10. 10. ENTERPRISE CONCERNS • No LTS • Open Source (but it shouldn’t be) • How many updates per year?
  11. 11. 11 `
  12. 12. ENTERPRISE BENEFITS @royboy789
  13. 13. ENTERPRISE BENEFITS • Do you want to build ANOTHER CMS? • Do you want to train a team to use it? • Code,Tutorials, Extendability • Open Source
  14. 14. INTERNET.ORG @royboy789
  15. 15. @royboy789
  16. 16. @royboy789 HOW?
  17. 17. WORDPRESS NOW HAS @royboy789
  18. 18. A REST API @royboy789
  19. 19. AND THE DATA… IT IS PRETTY SWEET @royboy789
  20. 20. SWEET SWEET JSON example: /wp-json/wp/v2/posts
  21. 21. /WP-JSON/WP/V2/POSTS
  22. 22. OUT OF THE BOX AMAZING SAUCE • /wp-json/ - prefix for ALL routes • /wp/v2/ - namespace for default routes • /posts
 /pages
 /comments
 /categories
 /taxonomies @royboy789
  23. 23. SPICING UP THE SAUCE (CUSTOMIZING THE API) @royboy789
  24. 24. @royboy789
  25. 25. @royboy789
  26. 26. MAKING YOUR OWN SAUCE (BUILD YOUR OWN API)
  27. 27. CUSTOM ROUTES Customizing or adding to routes is easy 1. Define a new namespace 2. Define your route and callback 3. Return a WP_REST_RESPONSE object with your data @royboy789
  28. 28. NAMESPACES What comes after /wp-json/ @royboy789
  29. 29. @royboy789 add_action( 'rest_api_init', array( $this, 'custom_commission_routes' ) ); function custom_commission_routes() { register_rest_route( 'fp-custom/v1', '/vre-purchase/', array( 'methods' => 'POST', 'callback' => array( $this, 'create_manual_commission_init' ), 'args' => array( 'product_id' => array( 'required' => true ), ) ) ); } CUSTOM ROUTES - EXAMPLE
  30. 30. @royboy789 CUSTOM ROUTES - EXAMPLE function create_manual_commission_init( WP_REST_Request $request ) { // Get Params from Request $request_data = $request->get_params(); // Create Response Object with data $response = new WP_REST_Response( $request_data ); // return response return $response; }
  31. 31. USE CASES • Ionic / NativeScript Native App • Decoupled applications that utilize WordPress content • Decoupled apps which interact with a WordPress site • Micro widgets for other websites Roy Sivan Twitter/Github - @royboy789 roysivan.com | thewpcrowd.com
  32. 32. NO BUT SERIOUSLY… WORDPRESS? • WordPress isn’t your grandma’s blog CMS anymore • RESTful API is easy to customize and add to • You can still build what you want, with the code you want Roy Sivan Twitter/Github - @royboy789 roysivan.com | thewpcrowd.com
  33. 33. AWESOME RESOURCES • Lynda.com - find me! • Caldera Learn - check outYouTube • developer.wordpress.org/rest-api - docs, etc. • LoopConf - A dev focused WP Conference • TheWPCrowd.com Roy Sivan Twitter/Github - @royboy789 roysivan.com | thewpcrowd.com
  34. 34. THANK YOU FIND ME ONLINE: @royboy789 Roy Sivan Twitter/Github - @royboy789 roysivan.com | arcctrl.com

×