Skip to content

Commit 2409ddd

Browse files
committed
use new method and add notice
1 parent b3b93ef commit 2409ddd

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

classes/WP_CLI/System_Command.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ public function version( array $args, array $assoc_args ) {
137137
* [--fullpath]
138138
* : List full path of source(s).
139139
*
140+
* [--skip-notice]
141+
* : Skip notice about registered sources.
142+
*
140143
* @param array $args Positional args.
141144
* @param array $assoc_args Keyed args.
142145
* @uses \ActionScheduler_Versions::get_sources()
@@ -147,7 +150,9 @@ public function version( array $args, array $assoc_args ) {
147150
public function source( array $args, array $assoc_args ) {
148151
$all = (bool) get_flag_value( $assoc_args, 'all' );
149152
$fullpath = (bool) get_flag_value( $assoc_args, 'fullpath' );
150-
$source = dirname( __DIR__, 2 );
153+
$skipnote = (bool) get_flag_value( $assoc_args, 'skip-notice' );
154+
$versions = \ActionScheduler_Versions::instance();
155+
$source = $versions->active_source();
151156
$path = $source;
152157

153158
if ( ! $fullpath ) {
@@ -159,9 +164,8 @@ public function source( array $args, array $assoc_args ) {
159164
\WP_CLI::halt( 0 );
160165
}
161166

162-
$instance = \ActionScheduler_Versions::instance();
163-
$sources = $instance->get_sources();
164-
$rows = array();
167+
$sources = $versions->get_sources();
168+
$rows = array();
165169

166170
foreach ( $sources as $check_source => $version ) {
167171
$active = dirname( $check_source ) === $source;
@@ -180,6 +184,10 @@ public function source( array $args, array $assoc_args ) {
180184

181185
ksort( $rows );
182186

187+
if ( ! $skipnote ) {
188+
\WP_CLI::line( PHP_EOL . 'Please note there can only be one unique registered instance of Action Scheduler per ' . PHP_EOL . 'version number, so this list may not include all the currently present copies of ' . PHP_EOL . 'Action Scheduler.' . PHP_EOL );
189+
}
190+
183191
$formatter = new \WP_CLI\Formatter( $assoc_args, array( 'source', 'version', 'active' ) );
184192
$formatter->display_items( $rows );
185193
}

0 commit comments

Comments
 (0)