Improve how environment data is generated
This commit is contained in:
parent
1a3799a4e6
commit
ab186e05f2
|
@ -47,13 +47,39 @@ class WC_Beta_Tester_Admin_Menus {
|
|||
if ( false === $ssr ) {
|
||||
ob_start();
|
||||
|
||||
// Get SSR
|
||||
// TODO: See what we can re-use from core `includes/admin/views/html-admin-page-status-report.php`
|
||||
WC_Admin_Status::status_report();
|
||||
// Get SSR.
|
||||
$api = new WC_REST_System_Status_Controller();
|
||||
$schema = $api->get_item_schema();
|
||||
$mappings = $api->get_item_mappings();
|
||||
$response = array();
|
||||
|
||||
$ssr = ob_get_clean();
|
||||
foreach ( $mappings as $section => $values ) {
|
||||
foreach ( $values as $key => $value ) {
|
||||
if ( isset( $schema['properties'][ $section ]['properties'][ $key ]['type'] ) ) {
|
||||
settype( $values[ $key ], $schema['properties'][ $section ]['properties'][ $key ]['type'] );
|
||||
}
|
||||
}
|
||||
settype( $values, $schema['properties'][ $section ]['type'] );
|
||||
$response[ $section ] = $values;
|
||||
}
|
||||
|
||||
$ssr = substr( $ssr, 0, 2048 );
|
||||
$ssr = '';
|
||||
foreach ( $response['environment'] as $key => $value ) {
|
||||
$index = $key;
|
||||
// @todo remove this hack after fix schema in WooCommercem, and Claudio never let you folks to forget that need to write schema first, and review after every change, schema is the most important part of the REST API.
|
||||
if ( 'version' === $index ) {
|
||||
$index = 'wc_version';
|
||||
} elseif ( 'external_object_cache' === $index ) {
|
||||
$ssr .= sprintf( "%s: %s\n", 'External object cache', wc_bool_to_string( $value ) );
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( is_bool( $value ) ) {
|
||||
$value = wc_bool_to_string( $value );
|
||||
}
|
||||
|
||||
$ssr .= sprintf( "%s: %s\n", $schema['properties']['environment']['properties'][ $index ]['description'], $value );
|
||||
}
|
||||
|
||||
set_transient( $transient_name, $ssr, DAY_IN_SECONDS );
|
||||
}
|
||||
|
@ -70,6 +96,7 @@ class WC_Beta_Tester_Admin_Menus {
|
|||
$bug_tpl = $this->get_ticket_template();
|
||||
$ssr = $this->construct_ssr();
|
||||
$body = str_replace( 'Copy and paste the system status report from **WooCommerce > System Status** in WordPress admin.', $ssr, $bug_tpl );
|
||||
$body = str_replace( '```', '', $body ); // Remove since this break how is displayed.
|
||||
|
||||
$wc_plugin_data = get_plugin_data( WC_PLUGIN_FILE );
|
||||
if ( isset( $wc_plugin_data['Version'] ) ) {
|
||||
|
@ -124,7 +151,7 @@ class WC_Beta_Tester_Admin_Menus {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// TODO: Implementation of each node.
|
||||
$nodes = array(
|
||||
|
|
Loading…
Reference in New Issue