Skip to content

Instantly share code, notes, and snippets.

@iandunn
Last active May 11, 2017 18:09
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 iandunn/15a5fdaa78d4bfcd2ce29e0453887d7f to your computer and use it in GitHub Desktop.
Save iandunn/15a5fdaa78d4bfcd2ce29e0453887d7f to your computer and use it in GitHub Desktop.
mu-plugin to test nearby events
<?php
// type "error" into the city name field to simulate an HTTP request error
function nearbywp_trigger_error( $request, $request_args, $request_url ) {
$url_params = explode( '&', parse_url( $request_url, PHP_URL_QUERY ) );
if ( in_array( 'location=error', $url_params ) ) {
$request = new WP_Error( 'test', 'testing error condition' );
}
return $request;
}
add_filter( 'pre_http_request', 'nearbywp_trigger_error', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment