这可能会完成一项工作,尽管使用模具不是一种很好的方式
add_filter( \'upgrader_package_options\', function( $options ) {
if (
isset( $options[\'hook_extra\'][\'action\'] ) &&
$options[\'hook_extra\'][\'action\'] === \'install\' &&
isset( $options[\'hook_extra\'][\'type\'] ) &&
in_array( $options[\'hook_extra\'][\'type\'], [ \'plugin\', \'theme\' ]
) {
die(\'Plugins & Themes installation disabled!\');
}
return $options;
} );