Skip to content
Snippets Groups Projects
Commit 43883c8a authored by Erick Hitter's avatar Erick Hitter
Browse files

Simplify how the whitelist is applied

If someone wants to run without a whitelist, hook `__return_true`.
parent 7fc1f2cd
Branches develop
No related tags found
No related merge requests found
...@@ -85,23 +85,10 @@ function is_command_allowed( $command ) { ...@@ -85,23 +85,10 @@ function is_command_allowed( $command ) {
return false; return false;
} }
// If there's a whitelist, default to it. // Default to command whitelist.
if ( ! empty( get_command_whitelist() ) ) { $whitelisted = in_array( $command, get_command_whitelist(), true );
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 );
}
/** return apply_filters( 'wp_cli_cron_control_offload_is_command_allowed', $whitelisted, $command );
* 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 );
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment