Skip to content
This repository was archived by the owner on Oct 4, 2019. It is now read-only.

Commit 394c65b

Browse files
author
Justin Shreve
authored
Return in the system status report if a site has run the setup wizard (#24)
1 parent b90bebf commit 394c65b

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

api/class-wc-rest-dev-system-status-controller.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,20 @@ class WC_REST_Dev_System_Status_Controller extends WC_REST_System_Status_Control
2626
*/
2727
protected $namespace = 'wc/v3';
2828

29+
/**
30+
* Returns setting values for the site that are useful for debugging
31+
* purposes. For full settings access, use the settings api.
32+
*
33+
* @return array
34+
*/
35+
public function get_settings() {
36+
$settings = parent::get_settings();
37+
$settings_extra = array();
38+
$admin_notices = get_option( 'woocommerce_admin_notices', array() );
39+
40+
$settings_extra['setup_wizard_ran'] = ! ( in_array( 'install', $admin_notices ) );
41+
42+
return array_merge( $settings, $settings_extra );
43+
}
44+
2945
}

readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: automattic, woothemes
33
Tags: woocommerce, rest-api, api
44
Requires at least: 4.6
55
Tested up to: 4.8
6-
Stable tag: 0.6.0
6+
Stable tag: 0.7.0
77
License: GPLv2 or later
88
License URI: http://www.gnu.org/licenses/gpl-2.0.html
99

@@ -25,6 +25,9 @@ This section describes how to install the plugin and get it working.
2525

2626
== Changelog ==
2727

28+
= 0.7.0 =
29+
* Return in the system status report if a store has gone through the setup wizard before
30+
2831
= 0.6.0 =
2932
* Fix value default return on settings endpoints
3033
* Fix broken variation image set

tests/unit-tests/system-status.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,29 @@ public function test_get_system_status_info_settings() {
147147
$term_response[ $term->slug ] = strtolower( $term->name );
148148
}
149149

150+
$notices = WC_Admin_Notices::get_notices();
151+
$install_key = array_search( 'install', $notices );
152+
unset( $notices[ $install_key ] );
153+
update_option( 'woocommerce_admin_notices', $notices );
154+
150155
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/system_status' ) );
151156
$data = $response->get_data();
152157
$settings = (array) $data['settings'];
153158

154-
$this->assertEquals( 11, count( $settings ) );
159+
$this->assertEquals( 12, count( $settings ) );
155160
$this->assertEquals( ( 'yes' === get_option( 'woocommerce_api_enabled' ) ), $settings['api_enabled'] );
156161
$this->assertEquals( get_woocommerce_currency(), $settings['currency'] );
157162
$this->assertEquals( $term_response, $settings['taxonomies'] );
163+
$this->assertEquals( true, $settings['setup_wizard_ran'] );
164+
165+
$notices[] = 'install';
166+
update_option( 'woocommerce_admin_notices', $notices );
167+
168+
$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v3/system_status' ) );
169+
$data = $response->get_data();
170+
$settings = (array) $data['settings'];
171+
172+
$this->assertEquals( false, $settings['setup_wizard_ran'] );
158173
}
159174

160175
/**

wc-api-dev.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: WooCommerce API Dev
44
* Plugin URI: https://woocommerce.com/
55
* Description: A feature plugin providing a bleeding edge version of the WooCommerce REST API.
6-
* Version: 0.6.0
6+
* Version: 0.7.0
77
* Author: Automattic
88
* Author URI: https://woocommerce.com
99
* Requires at least: 4.4

0 commit comments

Comments
 (0)