2021-05-31 02:55:29 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* WC_CLI_Tracker_Command class file.
|
|
|
|
*
|
|
|
|
* @package WooCommerce\CLI
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allows access to tracker snapshot for transparency and debugging.
|
|
|
|
*
|
2021-06-02 03:29:14 +00:00
|
|
|
* @since 5.5.0
|
2021-05-31 02:55:29 +00:00
|
|
|
* @package WooCommerce
|
|
|
|
*/
|
|
|
|
class WC_CLI_Tracker_Command {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Registers a command for showing WooCommerce Tracker snapshot data.
|
|
|
|
*/
|
|
|
|
public static function register_commands() {
|
2021-06-02 03:28:16 +00:00
|
|
|
WP_CLI::add_command( 'wc tracker snapshot', array( 'WC_CLI_Tracker_Command', 'show_tracker_snapshot' ) );
|
2021-05-31 02:55:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Dump tracker snapshot data to screen.
|
|
|
|
*/
|
|
|
|
public static function show_tracker_snapshot() {
|
|
|
|
$snapshot_data = WC_Tracker::get_tracking_data();
|
|
|
|
|
|
|
|
// Using print_r as a convenient way to dump the snapshot data to screen in a readable form.
|
|
|
|
WP_CLI::log( print_r( $snapshot_data, true ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
|
|
|
|
// Could improve this, e.g. flatten keys (join nested fields with `-`) and render as CSV or json.
|
|
|
|
|
|
|
|
WP_CLI::success( 'Printed tracker data.' );
|
|
|
|
}
|
|
|
|
}
|