Action_Scheduler\WP_CLI
System_Command::source()
Display the current source, or all registered sources.
OPTIONS
- [--all]
- List all registered sources.
- [--fullpath]
- List full path of source(s).
Method of the class: System_Command{}
No Hooks.
Return
null
. Nothing (null).
Usage
$System_Command = new System_Command(); $System_Command->source( $args, $assoc_args );
- $args(array) (required)
- Positional args.
- $assoc_args(array) (required)
- Keyed args.
System_Command::source() System Command::source code WC 9.8.2
public function source( array $args, array $assoc_args ) { $all = (bool) get_flag_value( $assoc_args, 'all' ); $fullpath = (bool) get_flag_value( $assoc_args, 'fullpath' ); $source = ActionScheduler_SystemInformation::active_source_path(); $path = $source; if ( ! $fullpath ) { $path = str_replace( ABSPATH, '', $path ); } if ( ! $all ) { echo $path; \WP_CLI::halt( 0 ); } $sources = ActionScheduler_SystemInformation::get_sources(); if ( empty( $sources ) ) { WP_CLI::log( __( 'Detailed information about registered sources is not currently available.', 'woocommerce' ) ); return; } $rows = array(); foreach ( $sources as $check_source => $version ) { $active = dirname( $check_source ) === $source; $path = $check_source; if ( ! $fullpath ) { $path = str_replace( ABSPATH, '', $path ); } $rows[ $check_source ] = array( 'source' => $path, 'version' => $version, 'active' => $active ? 'yes' : 'no', ); } ksort( $rows ); \WP_CLI::log( 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 ); $formatter = new \WP_CLI\Formatter( $assoc_args, array( 'source', 'version', 'active' ) ); $formatter->display_items( $rows ); }