Skip to content

Instantly share code, notes, and snippets.

@gicolek
Created February 6, 2013 16:47
Show Gist options
  • Save gicolek/4723908 to your computer and use it in GitHub Desktop.
Save gicolek/4723908 to your computer and use it in GitHub Desktop.
Handle ajax requests (omitting admin-ajax.php)
<?php
function _foo_handle_ajax_request_for_db_data() {
$path = parse_url (site_url());
if ( parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) === $path['path'] . '/sth' ) {
status_header(200);
// do sth
exit ;
}
}
add_action('init', '_foo_handle_ajax_request_for_db_data');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment