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.1.2
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;
}
$is_rendering_drill_down = $context->is_drill_down();
} catch ( \Throwable $e ) {
return $classes;
}
$body_classes = explode( ' ', $classes );
if ( ! in_array( 'woocommerce-settings-ui-page', $body_classes, true ) ) {
$classes .= ' woocommerce-settings-ui-page';
$body_classes[] = 'woocommerce-settings-ui-page';
}
if (
$is_rendering_drill_down
&& ! in_array( 'woocommerce-settings-ui-drill-down', $body_classes, true )
) {
$classes .= ' woocommerce-settings-ui-drill-down';
}
return $classes;
}