Add option to enable/disable API

Part of #4055
This commit is contained in:
Max Rice 2013-11-19 03:01:46 -05:00
parent dcdca4d4d2
commit 001ce0fc3e
2 changed files with 11 additions and 5 deletions

View File

@ -99,6 +99,14 @@ class WC_Settings_General extends WC_Settings_Page {
'autoload' => false
),
array(
'title' => __( 'API', 'woocommerce' ),
'desc' => __( 'Enable the REST API', 'woocommerce' ),
'id' => 'woocommerce_api_enabled',
'type' => 'checkbox',
'default' => 'yes',
),
array( 'type' => 'sectionend', 'id' => 'general_options'),
array( 'title' => __( 'Currency Options', 'woocommerce' ), 'type' => 'title', 'desc' => __( 'The following options affect how prices are displayed on the frontend.', 'woocommerce' ), 'id' => 'pricing_options' ),
@ -293,4 +301,4 @@ class WC_Settings_General extends WC_Settings_Page {
endif;
return new WC_Settings_General();
return new WC_Settings_General();

View File

@ -203,10 +203,8 @@ class WC_API_Server {
$this->header( 'Content-Type', $this->handler->get_content_type(), true );
// TODO: can we prevent wc_cookie from being sent for API requests?
// the API is enabled by default TODO: implement check for enabled setting here
if ( ! apply_filters( 'woocommerce_api_enabled', true, $this ) ) {
// the API is enabled by default
if ( ! apply_filters( 'woocommerce_api_enabled', true, $this ) || ( 'no' === get_option( 'woocommerce_api_enabled' ) ) ) {
$this->send_status( 404 );