WC_Settings_Page::output
Output the HTML for the settings.
Method of the class: WC_Settings_Page{}
No Hooks.
Returns
null. Nothing (null).
Usage
$WC_Settings_Page = new WC_Settings_Page(); $WC_Settings_Page->output();
WC_Settings_Page::output() WC Settings Page::output code WC 11.2.2
public function output() {
global $current_section;
$section = is_string( $current_section ) ? $current_section : '';
$context = $this->get_settings_ui_request_context( $section );
$hide_save_button_overridden = false;
$hide_save_button_existed = array_key_exists( 'hide_save_button', $GLOBALS );
$previous_hide_save_button = $hide_save_button_existed ? $GLOBALS['hide_save_button'] : null;
try {
if ( $context && $context->is_rendering_enabled() ) {
$page_id = $context->get_page_id();
if ( $context->has_schema_failed() ) {
$schema_failure_reason = method_exists( $context, 'get_schema_failure_reason' )
? $context->get_schema_failure_reason()
: __( 'Settings UI schema generation failed.', 'woocommerce' );
$this->log_settings_ui_fallback( $page_id, $section, $schema_failure_reason );
} else {
$mount_id = 'wc_settings_ui_' . sanitize_html_class( $this->id ) . '_' . sanitize_html_class( '' === $section ? 'default' : $section );
$context->enqueue_script_handles();
if ( $context->has_script_handle_loading_failed() ) {
$this->log_settings_ui_fallback( $page_id, $section, $context->get_script_handles_failure_reason() );
} else {
$GLOBALS['hide_save_button'] = true;
$hide_save_button_overridden = true;
printf(
'<div id="%1$s" data-wc-settings-ui="1" data-wc-settings-page="%2$s" data-wc-settings-section="%3$s"></div>',
esc_attr( $mount_id ),
esc_attr( $page_id ),
esc_attr( $section )
);
return;
}
}
}
} catch ( \Throwable $e ) {
// A stale or unavailable Settings UI class must keep the classic renderer usable during updates.
if ( $hide_save_button_overridden ) {
if ( $hide_save_button_existed ) {
$GLOBALS['hide_save_button'] = $previous_hide_save_button;
} else {
unset( $GLOBALS['hide_save_button'] );
}
}
wc_get_logger()->error(
sprintf(
'Settings UI rendering failed for page "%1$s" section "%2$s": %3$s: %4$s',
$this->id,
'' === $section ? 'default' : $section,
get_class( $e ),
$e->getMessage()
),
array( 'source' => 'settings-ui' )
);
if ( $e instanceof \Exception ) {
wc_caught_exception( $e, __METHOD__ );
}
}
// We can't use "get_settings_for_section" here
// for compatibility with derived classes overriding "get_settings".
$settings = $this->get_settings( $section );
WC_Admin_Settings::output_fields( $settings );
}