Make the WC_Settings_Page::get_settings_for_section final
This helps on conveying the notion that the method to be overriden is get_settings_for_section_core instead (or get_settings_for_X_section methods must be added).
This commit is contained in:
parent
56cc063d7f
commit
5af12170d7
|
@ -77,7 +77,7 @@ if ( ! class_exists( 'WC_Settings_Page', false ) ) :
|
|||
/**
|
||||
* Get settings array for the default section.
|
||||
*
|
||||
* @deprecated 5.4.0 'get_settings_for_section' (passing an empty string for default section) should be used instead.
|
||||
* @deprecated 5.4.0 Use 'get_settings_for_section' (passing an empty string for default section)
|
||||
*
|
||||
* @return array Settings array, each item being an associative array representing a setting.
|
||||
*/
|
||||
|
@ -101,7 +101,7 @@ if ( ! class_exists( 'WC_Settings_Page', false ) ) :
|
|||
*
|
||||
* @return array Settings array, each item being an associative array representing a setting.
|
||||
*/
|
||||
public function get_settings_for_section( $section_id ) {
|
||||
final public function get_settings_for_section( $section_id ) {
|
||||
if ( '' === $section_id ) {
|
||||
$method_name = 'get_settings_for_default_section';
|
||||
} else {
|
||||
|
@ -122,6 +122,9 @@ if ( ! class_exists( 'WC_Settings_Page', false ) ) :
|
|||
* This method is invoked from 'get_settings_for_section' when no 'get_settings_for_{current_section}_section'
|
||||
* method exists in the class.
|
||||
*
|
||||
* When overriding, note that the 'woocommerce_get_settings_' filter must NOT be triggered,
|
||||
* as this is already done by 'get_settings_for_section'.
|
||||
*
|
||||
* @param string $section_id The section name to get the settings for.
|
||||
*
|
||||
* @return array Settings array, each item being an associative array representing a setting.
|
||||
|
|
|
@ -88,19 +88,15 @@ class WC_Settings_Shipping extends WC_Settings_Page {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get settings for the current section.
|
||||
* Get settings for the default section.
|
||||
*
|
||||
* @param string $section_id The id of the section to return settings for.
|
||||
* The original implementation of 'get_settings' was returning the settings for the "Options" section
|
||||
* when the supplied value for $current_section was ''.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_settings_for_section( $section_id = '' ) {
|
||||
/*
|
||||
The original implementation of this function was returning the settings for the "Options" section
|
||||
when the supplied value for $current_section was '', which is the id for the "Zones" section.
|
||||
We need this workaround to keep compatibility.
|
||||
*/
|
||||
return parent::get_settings_for_section( '' === $section_id ? 'options' : $section_id );
|
||||
protected function get_settings_for_default_section() {
|
||||
return $this->get_settings_for_options_section();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue