Created
September 26, 2017 12:04
-
-
Save Rarst/7798021bc3fe905a517f08bdbe224621 to your computer and use it in GitHub Desktop.
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_action( 'template_redirect', function () { | |
if ( ! isset( $_GET['crash'] ) ) { | |
return; | |
} | |
$urls = []; | |
$urls[] = home_url(); | |
$urls[] = home_url( '404' ); | |
$posts = get_posts( [ | |
'numberposts' => 1, | |
'fields' => 'ids', | |
] ); | |
if ( ! empty( $posts ) ) { | |
$urls[] = get_permalink( $posts[0] ); | |
} | |
$pages = get_posts( [ | |
'numberposts' => 1, | |
'fields' => 'ids', | |
'post_type' => 'page', | |
] ); | |
if ( ! empty( $pages ) ) { | |
$urls[] = get_permalink( $pages[0] ); | |
} | |
var_dump( $urls ); | |
die; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment