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

PHPCS fixes

parent 2052d884
No related branches found
No related tags found
No related merge requests found
...@@ -30,7 +30,9 @@ function schedule_cli_command( $command, $timestamp = null ) { ...@@ -30,7 +30,9 @@ function schedule_cli_command( $command, $timestamp = null ) {
return new WP_Error( 'invalid-timestamp', __( 'Timestamp is in the past.', 'wp-cli-cron-control-offload' ) ); return new WP_Error( 'invalid-timestamp', __( 'Timestamp is in the past.', 'wp-cli-cron-control-offload' ) );
} }
$event_args = array( 'command' => $command ); $event_args = array(
'command' => $command,
);
$scheduled = wp_schedule_single_event( $timestamp, ACTION, $event_args ); $scheduled = wp_schedule_single_event( $timestamp, ACTION, $event_args );
...@@ -59,6 +61,7 @@ function validate_command( $command ) { ...@@ -59,6 +61,7 @@ function validate_command( $command ) {
$first_command = explode( ' ', $command ); $first_command = explode( ' ', $command );
$first_command = array_shift( $first_command ); $first_command = array_shift( $first_command );
if ( ! is_command_allowed( $first_command ) ) { if ( ! is_command_allowed( $first_command ) ) {
/* translators: 1: Disallowed command */
return new WP_Error( 'blocked-command', sprintf( __( '`%1$s` not allowed', 'wp-cli-cron-control-offload' ), $first_command ) ); return new WP_Error( 'blocked-command', sprintf( __( '`%1$s` not allowed', 'wp-cli-cron-control-offload' ), $first_command ) );
} }
......
...@@ -16,11 +16,13 @@ namespace Automattic\WP\WP_CLI_Cron_Control_Offload; ...@@ -16,11 +16,13 @@ namespace Automattic\WP\WP_CLI_Cron_Control_Offload;
function run_event( $command ) { function run_event( $command ) {
if ( ! defined( 'WP_CLI' ) || ! \WP_CLI ) { if ( ! defined( 'WP_CLI' ) || ! \WP_CLI ) {
// TODO: reschedule at least once or twice. // TODO: reschedule at least once or twice.
/* translators: 1: Plugin's prefix for log messages, 2. WP-CLI command that would have run */
trigger_error( sprintf( __( '%1$s: Attempted to run event without WP-CLI loaded. (%2$s)', 'wp-cli-cron-control-offload' ), MESSAGE_PREFIX, var_export( $command, true ) ), E_USER_WARNING ); trigger_error( sprintf( __( '%1$s: Attempted to run event without WP-CLI loaded. (%2$s)', 'wp-cli-cron-control-offload' ), MESSAGE_PREFIX, var_export( $command, true ) ), E_USER_WARNING );
return; return;
} }
if ( ! validate_command( $command ) ) { if ( ! validate_command( $command ) ) {
/* translators: 1: Plugin's prefix for log messages, 2. WP-CLI command that would have run */
trigger_error( sprintf( __( '%1$s: Attempted to run blocked WP-CLI command. (%2$s)', 'wp-cli-cron-control-offload' ), MESSAGE_PREFIX, var_export( $command, true ) ), E_USER_WARNING ); trigger_error( sprintf( __( '%1$s: Attempted to run blocked WP-CLI command. (%2$s)', 'wp-cli-cron-control-offload' ), MESSAGE_PREFIX, var_export( $command, true ) ), E_USER_WARNING );
return; return;
} }
...@@ -37,6 +39,7 @@ function run_event( $command ) { ...@@ -37,6 +39,7 @@ function run_event( $command ) {
// Command failed. // Command failed.
if ( ! is_object( $output ) || is_wp_error( $output ) ) { if ( ! is_object( $output ) || is_wp_error( $output ) ) {
/* translators: 1: Plugin's prefix for log messages, 2. Command error that caused failure */
trigger_error( sprintf( __( '%1$s: WP-CLI command failed. (%2$s)', 'wp-cli-cron-control-offload' ), MESSAGE_PREFIX, var_export( $command, true ) ), E_USER_WARNING ); trigger_error( sprintf( __( '%1$s: WP-CLI command failed. (%2$s)', 'wp-cli-cron-control-offload' ), MESSAGE_PREFIX, var_export( $command, true ) ), E_USER_WARNING );
$message = is_wp_error( $output ) ? $output->get_error_message() : var_export( $output, true ); $message = is_wp_error( $output ) ? $output->get_error_message() : var_export( $output, true );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment