Skip to content

Instantly share code, notes, and snippets.

@mattheu
Last active October 24, 2016 14:15
Show Gist options
  • Save mattheu/8afdaec300faa8f797ec55ae95ea8dc2 to your computer and use it in GitHub Desktop.
Save mattheu/8afdaec300faa8f797ec55ae95ea8dc2 to your computer and use it in GitHub Desktop.
<?php
add_action( 'rest_api_init', 'wpleeds_rest_api' );
function wpleeds_rest_api() {
register_rest_route(
'wpleeds/v1',
'^/movies/?$',
[
'methods' => WP_Rest_Server::READABLE,
'callback' => 'get_movies',
]
);
}
function get_movies( WP_REST_Request $request ) {
return [
[
'name' => 'Rogue One: A Star Wars Story',
'director' => 'Gareth Edwards',
],
[
'name' => 'Mad Max: Fury Road',
'director' => 'George Miller',
],
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment