Commit 43883c8a authored by Erick Hitter's avatar Erick Hitter

Simplify how the whitelist is applied

If someone wants to run without a whitelist, hook `__return_true`.
parent 7fc1f2cd
......@@ -85,23 +85,10 @@ function is_command_allowed( $command ) {
return false;
}
// If there's a whitelist, default to it.
if ( ! empty( get_command_whitelist() ) ) {
add_filter( 'wp_cli_cron_control_offload_is_command_allowed', __NAMESPACE__ . '\command_is_whitelisted', 9, 2 );
}
return apply_filters( 'wp_cli_cron_control_offload_is_command_allowed', true, $command );
}
// Default to command whitelist.
$whitelisted = in_array( $command, get_command_whitelist(), true );
/**
* Filter callback to check a command against a whitelist
*
* @param bool $whitelisted Command is allowed.
* @param string $command Command to check.
* @return bool
*/
function command_is_whitelisted( $whitelisted, $command ) {
return in_array( $command, get_command_whitelist(), true );
return apply_filters( 'wp_cli_cron_control_offload_is_command_allowed', $whitelisted, $command );
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment