你说得对,editing core is a no-no.
相反,您可以这样做。
add_action( \'current_screen\', \'wpse242553_no_delete_site_screen\' );
function wpse242553_no_delete_site_screen() {
// Check to see if we\'re using the CLI client. If so, bail out.
if ( \'cli\' == php_sapi_name() ) {
return;
// I\'m not sure this is strictly necessary.
}
if ( \'ms-delete-site\' == get_current_screen()->base ) {
// You can add whatever message you like here,
// or even use wp_safe_redirect() to go elsewhere.
wp_die( \'Sorry, we only delete sites from the command line.\' );
}
}
把它放在
Must Use plugin 将其应用于网络中的每个站点。
get_current_screen()
php_sapi_name()
(我查过了,如果你使用wp-cli
, 它返回cli
作为SAPI名称)