mirror of
https://github.com/szepeviktor/wordpress-website-lifecycle.git
synced 2025-08-17 18:11:08 +08:00
Log WP-Cron
This commit is contained in:
parent
2d16608566
commit
45e66a729b
1 changed files with 39 additions and 0 deletions
39
mu-plugins/_core-wp-cron-logger.php
Normal file
39
mu-plugins/_core-wp-cron-logger.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Plugin Name: Log WP-Cron (HTTP) callback output and errors
|
||||
* Plugin URI: https://github.com/szepeviktor/wordpress-website-lifecycle
|
||||
*/
|
||||
|
||||
add_filter(
|
||||
'cron_request',
|
||||
static function ($cron_request_array) {
|
||||
add_action(
|
||||
'http_api_debug',
|
||||
static function ($response) {
|
||||
static $run_once = 0;
|
||||
$run_once += 1;
|
||||
if ($run_once !== 1) {
|
||||
return;
|
||||
}
|
||||
if (is_wp_error($response)) {
|
||||
error_log(sprintf(
|
||||
'WP-Cron error: (%s) "%s"',
|
||||
$response->get_error_code(),
|
||||
$response->get_error_message()
|
||||
));
|
||||
return;
|
||||
}
|
||||
if ($response['body'] === '') {
|
||||
return;
|
||||
}
|
||||
error_log(sprintf('WP-Cron output: "%s"', $response['body']));
|
||||
},
|
||||
10,
|
||||
1
|
||||
);
|
||||
return $cron_request_array;
|
||||
},
|
||||
10,
|
||||
1
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue