class-wc-cli-com-command.php
2 years ago
class-wc-cli-com-extension-command.php
2 years ago
class-wc-cli-rest-command.php
3 years ago
class-wc-cli-runner.php
3 years ago
class-wc-cli-tool-command.php
6 years ago
class-wc-cli-tracker-command.php
4 years ago
class-wc-cli-update-command.php
3 years ago
class-wc-cli-tracker-command.php
56 lines
| 1 | <?php |
| 2 | /** |
| 3 | * WC_CLI_Tracker_Command class file. |
| 4 | * |
| 5 | * @package WooCommerce\CLI |
| 6 | */ |
| 7 | |
| 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | exit; |
| 10 | } |
| 11 | |
| 12 | /** |
| 13 | * Allows access to tracker snapshot for transparency and debugging. |
| 14 | * |
| 15 | * @since 5.5.0 |
| 16 | * @package WooCommerce |
| 17 | */ |
| 18 | class WC_CLI_Tracker_Command { |
| 19 | |
| 20 | /** |
| 21 | * Registers a command for showing WooCommerce Tracker snapshot data. |
| 22 | */ |
| 23 | public static function register_commands() { |
| 24 | WP_CLI::add_command( 'wc tracker snapshot', array( 'WC_CLI_Tracker_Command', 'show_tracker_snapshot' ) ); |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Dump tracker snapshot data to screen. |
| 29 | * |
| 30 | * ## EXAMPLES |
| 31 | * |
| 32 | * wp wc tracker snapshot --format=yaml |
| 33 | * wp wc tracker snapshot --format=json |
| 34 | * |
| 35 | * ## OPTIONS |
| 36 | * |
| 37 | * [--format=<format>] |
| 38 | * : Render output in a particular format, see WP_CLI\Formatter for details. |
| 39 | * |
| 40 | * @see \WP_CLI\Formatter |
| 41 | * @see WC_Tracker::get_tracking_data() |
| 42 | * @param array $args WP-CLI positional arguments. |
| 43 | * @param array $assoc_args WP-CLI associative arguments. |
| 44 | */ |
| 45 | public static function show_tracker_snapshot( $args, $assoc_args ) { |
| 46 | $snapshot_data = WC_Tracker::get_tracking_data(); |
| 47 | |
| 48 | $formatter = new \WP_CLI\Formatter( |
| 49 | $assoc_args, |
| 50 | array_keys( $snapshot_data ) |
| 51 | ); |
| 52 | |
| 53 | $formatter->display_items( array( $snapshot_data ) ); |
| 54 | } |
| 55 | } |
| 56 |