Forked from nicholasohrn/http-basic-cron-request.php
Created
October 5, 2018 23:48
-
-
Save fmt/f7cdebcb08ea324953c0204ebe2c2603 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
This file should be in mu-plugins and this php in wp-config.php:
(via http://nickohrn.com/2014/07/quick-tip-wp-cron-http-basic-protected-site/)