Skip to content

Commit d826a69

Browse files
committed
Only use command hooks for the versions that support them.
1 parent feb5f50 commit d826a69

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

scaffold-package-command.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
return;
55
}
66

7-
WP_CLI::add_hook( 'after_add_command:scaffold', function () {
8-
7+
$registration = function () {
98
$autoload = dirname( __FILE__ ) . '/vendor/autoload.php';
109
if ( file_exists( $autoload ) ) {
1110
require_once $autoload;
@@ -14,5 +13,11 @@
1413
WP_CLI::add_command( 'scaffold package', array( 'WP_CLI\ScaffoldPackageCommand', 'package' ) );
1514
WP_CLI::add_command( 'scaffold package-readme', array( 'WP_CLI\ScaffoldPackageCommand', 'package_readme' ) );
1615
WP_CLI::add_command( 'scaffold package-tests', array( 'WP_CLI\ScaffoldPackageCommand', 'package_tests' ) );
16+
};
1717

18-
} );
18+
// Only use command hooks in versions that support them.
19+
if ( version_compare( WP_CLI_VERSION, '1.2.0-alpha', '>' ) ) {
20+
WP_CLI::add_hook( 'after_add_command:scaffold', $registration );
21+
} else {
22+
$registration();
23+
}

0 commit comments

Comments
 (0)