Merge pull request #15815 from woocommerce/fix/15794

Prevent duplicate sections in tax and api endpoints
This commit is contained in:
Claudio Sanches 2017-06-27 13:01:05 -03:00 committed by GitHub
commit fbd92c8105
2 changed files with 34 additions and 23 deletions

View File

@ -53,32 +53,37 @@ class WC_Settings_Rest_API extends WC_Settings_Page {
/**
* Get settings array.
*
* @param string $current_section
* @return array
*/
public function get_settings() {
$settings = apply_filters( 'woocommerce_settings_rest_api', array(
array(
'title' => __( 'General options', 'woocommerce' ),
'type' => 'title',
'desc' => '',
'id' => 'general_options',
),
public function get_settings( $current_section = '' ) {
$settings = array();
array(
'title' => __( 'API', 'woocommerce' ),
'desc' => __( 'Enable the REST API', 'woocommerce' ),
'id' => 'woocommerce_api_enabled',
'type' => 'checkbox',
'default' => 'yes',
),
if ( '' === $current_section ) {
$settings = apply_filters( 'woocommerce_settings_rest_api', array(
array(
'title' => __( 'General options', 'woocommerce' ),
'type' => 'title',
'desc' => '',
'id' => 'general_options',
),
array(
'type' => 'sectionend',
'id' => 'general_options',
),
) );
array(
'title' => __( 'API', 'woocommerce' ),
'desc' => __( 'Enable the REST API', 'woocommerce' ),
'id' => 'woocommerce_api_enabled',
'type' => 'checkbox',
'default' => 'yes',
),
return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings );
array(
'type' => 'sectionend',
'id' => 'general_options',
),
) );
}
return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings, $current_section );
}
/**

View File

@ -73,10 +73,16 @@ class WC_Settings_Tax extends WC_Settings_Page {
/**
* Get settings array.
*
* @param string $current_section
* @return array
*/
public function get_settings() {
return apply_filters( 'woocommerce_get_settings_' . $this->id, include( 'views/settings-tax.php' ) );
public function get_settings( $current_section = '' ) {
$settings = array();
if ( '' === $current_section ) {
$settings = include( 'views/settings-tax.php' );
}
return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings, $current_section );
}
/**