Created
August 20, 2018 22:21
-
-
Save westonruter/9b7330fffd24dd61aa1519004a2608b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Simulate 500 Internal Server Error | |
* Description: Prints out a typically-looking PHP error when display_errors is enabled. To use, simply add <code>?internal_server_error</code> to any URL. | |
* Author: Weston Ruter | |
* Plugin URI: https://gist.github.com/westonruter/9b7330fffd24dd61aa1519004a2608b1 | |
* Version: 1.0 | |
* License: GPLv2 or later | |
* | |
* @package Simulate500Error | |
*/ | |
add_action( 'init', function() { | |
if ( ! isset( $_GET['internal_server_error'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification | |
return; | |
} | |
header( 'X-Robots-Tag: noindex' ); | |
status_header( 500 ); | |
printf( "<br />\n<b>Example error</b>: nothing bad happened, but this prints an error for testing purposes in <b>%s</b> on line <b>%d</b><br />\n", __FILE__, __LINE__ ); | |
exit; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment