wordpress-website-lifecycle/mu-plugins/_core-migration.php
Viktor Szépe 15663e4af2
Some checks failed
Integrity / Integrity (push) Waiting to run
Back-end / Syntax errors (push) Failing after 3s
Spelling / 文A Typos check (push) Failing after 1m55s
Block Action Scheduler too (#68)
* Block Action Scheduler too

Added action to modify Action Scheduler behavior by removing the default runner and preventing async requests.

* Rename plugin to 'Migration source server guard'
2026-07-17 14:48:48 +02:00

67 lines
1.3 KiB
PHP

<?php
/*
* Plugin Name: Migration source server guard
* Plugin URI: https://github.com/szepeviktor/wordpress-website-lifecycle
*/
// Block WP-Cron
if (defined('DOING_CRON')) {
error_log('WP-Cron is blocked.');
exit;
}
// Display "Old server" on login page
add_filter(
'login_message',
static function ($message) {
return '<p class="message">Old server</p>'.$message;
},
0,
1
);
// Block outbound HTTP requests
add_filter(
'pre_http_request',
static function ($response, $parsed_args, $url) {
error_log('Outbound HTTP requests are blocked: '.$url);
return new WP_Error('outbound_http_blocked');
},
PHP_INT_MAX,
3
);
// Block email sending
add_filter(
'pre_wp_mail',
static function ($return, $atts) {
error_log('Email sending is blocked: '.var_export($atts, true));
return false;
},
PHP_INT_MAX,
2
);
// Block Action Scheduler
add_action(
'init',
static function () {
if (!class_exists('ActionScheduler')) {
return;
}
remove_action(
'action_scheduler_run_queue',
[ActionScheduler::runner(), 'run']
);
},
PHP_INT_MAX,
0
);
add_filter(
'action_scheduler_allow_async_request_runner',
'__return_false',
10,
0
);