Skip to content

Instantly share code, notes, and snippets.

@nicholasohrn
Created July 1, 2014 21:22
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save nicholasohrn/0fd65917057e579a6a97 to your computer and use it in GitHub Desktop.
Save nicholasohrn/0fd65917057e579a6a97 to your computer and use it in GitHub Desktop.
WP Cron with HTTP Basic Authentication
<?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