Skip to content

Instantly share code, notes, and snippets.

@ataylorme
Forked from anonymous/410 removed pages
Last active December 12, 2015 01:38
Show Gist options
  • Save ataylorme/4692065 to your computer and use it in GitHub Desktop.
Save ataylorme/4692065 to your computer and use it in GitHub Desktop.
/* ========== 410 TERMINATED EMPLOYEE PAGES =========== */
function 410_status_header(){
$terminatedEmployees = array('employee-1','employee-2','employee-3','employee-4','employee-5','employee-6','employee-7','employee-8', 'employee-9', 'employee-10');
$currentURL = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$currentURL = rtrim(rawurldecode( $currentURL ), '/');
foreach( $terminatedEmployees as $terminatedEmployee ):
if( get_bloginfo('url') . '/' . $terminatedEmployee === $currentURL ):
status_header( 410 );
if( !locate_template( '410.php', true ) )
echo 'Sorry, the page you requested has been permanently removed.';
exit();
endif;
endforeach;
}//end 410_status_header
if( !is_admin() )
add_action( 'template_redirect', '410_status_header');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment