Skip to content

Instantly share code, notes, and snippets.

@ahmadawais
Last active May 21, 2018 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmadawais/6b986735aa2f2e36a60b939cf8b30925 to your computer and use it in GitHub Desktop.
Save ahmadawais/6b986735aa2f2e36a60b939cf8b30925 to your computer and use it in GitHub Desktop.
wp-custom-routes.js
// Registering custom routes.
site.itSales = site.registerRoute( 'sales/v1', '/resource/(?P<some_part>\\d+)' );
site.itSales().somePart( 7 ); // => myplugin/v1/resource/7
// Query Parameters & Filtering Custom Routes.
site.handler = site.registerRoute( 'sales/v1', 'receipts/(?P<id>)', {
// Listing any of these parameters will assign the built-in
// chaining method that handles the parameter:
params: [ 'before', 'after', 'author', 'parent', 'post' ]
});
// Yields from the custom data of buyers.
site.handler().post( 8 ).author( 92 ).before( dateObj )... // Sent to paddle.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment