The is_protected_endpoint() WordPress PHP function determines whether we are currently on an endpoint that should be protected against WSODs (White Screen of Death).
Usage
$is_protected = is_protected_endpoint();
Parameters
This function does not have any parameters.
More information
See WordPress Developer Resources: is_protected_endpoint()
Examples
Check if a page is protected
This example checks if the current endpoint is protected against WSODs.
if (is_protected_endpoint()) {
echo '**This page is protected.**';
} else {
echo 'This page is not protected.';
}
Show a custom message for protected pages
This example displays a custom message only on protected pages.
if (is_protected_endpoint()) {
echo 'This is a **protected page**. Please proceed with caution.';
}
Log protected pages
This example logs the URL of protected pages to a text file.
if (is_protected_endpoint()) {
$log_file = 'protected_pages_log.txt';
$current_url = home_url(add_query_arg(array()));
file_put_contents($log_file, $current_url . PHP_EOL, FILE_APPEND);
}
Enable extra debugging for protected pages
This example enables additional debugging on protected pages.
if (is_protected_endpoint()) {
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
}
Redirect non-admin users from protected pages
This example redirects non-admin users away from protected pages.
if (is_protected_endpoint() && !current_user_can('manage_options')) {
wp_redirect(home_url());
exit;
}