Skip to content

Instantly share code, notes, and snippets.

@whyisjake
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whyisjake/9402721 to your computer and use it in GitHub Desktop.
Save whyisjake/9402721 to your computer and use it in GitHub Desktop.
<?php
/*
Template Name: URLS
*/
$urls = 'http://google.com
http://31engine.com/weblogUpdates/1.cgi
http://zhuaxia.com/rpc/server.php';
// $skuList = explode('\n\r', $_POST['skuList']);
$urllist = explode("\n", $urls );
echo '<table><thead><tr><th>URL</th><th>Code</th><th>Message</th></tr></thead><tbody>';
foreach ( $urllist as $url ) {
$response = wp_remote_head( $url );
echo '<tr>';
echo '<td>' . esc_url( $url ) . '</td>';
if ( is_wp_error( $response ) ) {
echo '<td>' . $response->errors[ 'http_request_failed' ] . '</td>';
echo '<td>' . $response->errors[ 'http_request_failed' ][0] . '</td>';
} else {
echo '<td>' . $response['response']['code'] . '</td>';
echo '<td>' . $response['response']['message'] . '</td>';
}
echo '</tr>';
}
echo '</tbody></table>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment