Created
July 1, 2014 21:22
-
-
Save nicholasohrn/0fd65917057e579a6a97 to your computer and use it in GitHub Desktop.
WP Cron with HTTP Basic Authentication
This file contains 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 | |
if(defined('WP_CRON_CUSTOM_HTTP_BASIC_USERNAME') && defined('WP_CRON_CUSTOM_HTTP_BASIC_PASSWORD')) { | |
function http_basic_cron_request($cron_request) { | |
$headers = array('Authorization' => sprintf('Basic %s', base64_encode(WP_CRON_CUSTOM_HTTP_BASIC_USERNAME . ':' . WP_CRON_CUSTOM_HTTP_BASIC_PASSWORD))); | |
$cron_request['args']['headers'] = isset($cron_request['args']['headers']) ? array_merge($cron_request['args']['headers'], $headers) : $headers; | |
return $cron_request; | |
} | |
add_filter('cron_request', 'http_basic_cron_request'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment