Created
July 11, 2025 21:30
-
-
Save vfontjr/731ef1f362ab8cdb1c1658a48f8a7afe to your computer and use it in GitHub Desktop.
Kim Clark Community Forum Response
This file contains hidden or 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 | |
add_filter( 'wp_die_handler', 'my_custom_wp_die_handler' ); | |
function my_custom_wp_die_handler( $handler ) { | |
return 'my_override_wp_die'; | |
} | |
function my_override_wp_die( $message, $title = '', $args = array() ) { | |
if ( trim( $message ) === 'Oops! This file is protected.' ) { | |
$message = 'This file is protected. <a href="' . esc_url( wp_login_url() ) . '">Please log in</a> to access it.'; | |
$title = 'Protected File'; | |
} | |
// Fallback to normal error for other cases | |
if ( ! isset( $args['back_link'] ) ) { | |
$args['back_link'] = true; | |
} | |
return _default_wp_die_handler( $message, $title, $args ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment