HTTP POST and REQUEST API from jacobsantos. see #4779

git-svn-id: https://develop.svn.wordpress.org/trunk@8516 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2008-08-01 05:00:07 +00:00
parent cf2daaf071
commit 086b9294b9
4 changed files with 927 additions and 48 deletions
+9 -20
View File
@@ -71,6 +71,13 @@ function wp_next_scheduled( $hook, $args = array() ) {
return false;
}
/**
* Send request to run cron through HTTP request that doesn't halt page loading.
*
* @since 2.1.0
*
* @return null CRON could not be spawned, because it is not needed to run.
*/
function spawn_cron() {
$crons = _get_cron_array();
@@ -81,27 +88,9 @@ function spawn_cron() {
if ( array_shift( $keys ) > time() )
return;
$cron_url = get_option( 'siteurl' ) . '/wp-cron.php';
$parts = parse_url( $cron_url );
$cron_url = get_option( 'siteurl' ) . '/wp-cron.php?check=' . wp_hash('187425');
if ($parts['scheme'] == 'https') {
// support for SSL was added in 4.3.0
if (version_compare(phpversion(), '4.3.0', '>=') && function_exists('openssl_open')) {
$port = isset($parts['port']) ? $parts['port'] : 443;
$argyle = @fsockopen('ssl://' . $parts['host'], $port, $errno, $errstr, 0.01);
} else {
return false;
}
} else {
$port = isset($parts['port']) ? $parts['port'] : 80;
$argyle = @ fsockopen( $parts['host'], $port, $errno, $errstr, 0.01 );
}
if ( $argyle )
fputs( $argyle,
"GET {$parts['path']}?check=" . wp_hash('187425') . " HTTP/1.0\r\n"
. "Host: {$_SERVER['HTTP_HOST']}\r\n\r\n"
);
wp_remote_post($cron_url, array('timeout' => 0.01));
}
function wp_cron() {