WC_Settings_Page::add_settings_ui_body_class
Add a body class for settings pages rendered through the settings UI.
Method of the class: WC_Settings_Page{}
No Hooks.
Returns
String. The modified body classes for the admin area.
Usage
$WC_Settings_Page = new WC_Settings_Page(); $WC_Settings_Page->add_settings_ui_body_class( $classes );
- $classes(string) (required)
- The existing body classes for the admin area.
Changelog
| Since 10.9.0 | Introduced. |
WC_Settings_Page::add_settings_ui_body_class() WC Settings Page::add settings ui body class code WC 11.0.1
public function add_settings_ui_body_class( $classes ) {
global $current_section, $current_tab;
if ( ! is_string( $classes ) || $this->id !== $current_tab ) {
return $classes;
}
$section = is_string( $current_section ) ? $current_section : '';
$context = $this->get_settings_ui_request_context( $section );
try {
if ( ! $context || ! $context->is_rendering_enabled() ) {
return $classes;
}
// The legacy fallback renderer needs the classic styling: the settings UI
// body class hides the legacy Save button via CSS.
if ( $context->has_schema_failed() || $context->has_script_handles_failed() ) {
return $classes;
}
} catch ( \Throwable $e ) {
return $classes;
}
if ( str_contains( $classes, 'woocommerce-settings-ui-page' ) ) {
return $classes;
}
return "$classes woocommerce-settings-ui-page";
}