Guest User

Untitled

a guest
Dec 14th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. /**
  2. * Custom JSON callback.
  3. */
  4. add_action( 'init', function () {
  5. // Get URI without query string.
  6. $uri = strtok( $_SERVER["REQUEST_URI"] , '?' );
  7.  
  8. // Check callback path.
  9. $reg = preg_match( '/\/json-callback\/?$/', $uri, $matches );
  10. if ( count( $matches ) > 0) {
  11. // Set header.
  12. status_header(200);
  13.  
  14. // Output JSON of parameters.
  15. wp_send_json($_GET);
  16.  
  17. exit;
  18. }
  19. } );
Add Comment
Please, Sign In to add comment