From fa12bf77a0c0f4af934750175eb75b4b358d399c Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Wed, 8 Mar 2017 05:17:43 -0800 Subject: [PATCH] Properly register command class --- media-command.php | 9 ++++++++- src/Media_Command.php | 10 ---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/media-command.php b/media-command.php index 3a26afd01..f17d8aae5 100644 --- a/media-command.php +++ b/media-command.php @@ -9,4 +9,11 @@ require_once $autoload; } -WP_CLI::add_command( 'media', 'Media_Command' ); +WP_CLI::add_command( 'media', 'Media_Command', array( + 'before_invoke' => function () { + if ( !wp_image_editor_supports() ) { + WP_CLI::error( 'No support for generating images found. ' . + 'Please install the Imagick or GD PHP extensions.' ); + } + } +) ); diff --git a/src/Media_Command.php b/src/Media_Command.php index 989049312..2d68c81bd 100644 --- a/src/Media_Command.php +++ b/src/Media_Command.php @@ -389,13 +389,3 @@ private function needs_regeneration( $att_id, $fullsizepath ) { return false; } } - -WP_CLI::add_command( 'media', 'Media_Command', array( - 'before_invoke' => function () { - if ( !wp_image_editor_supports() ) { - WP_CLI::error( 'No support for generating images found. ' . - 'Please install the Imagick or GD PHP extensions.' ); - } - } -) ); -