WC_Settings_Page::get_custom_viewpublicWC 1.0

Get the custom view given the current tab and section.

Method of the class: WC_Settings_Page{}

Hooks from the method

Returns

String. The custom view. HTML output.

Usage

$WC_Settings_Page = new WC_Settings_Page();
$WC_Settings_Page->get_custom_view( $action, $section_id );
$action(string) (required)
The action to call.
$section_id(string)
The section id.
Default: false

WC_Settings_Page::get_custom_view() code WC 10.5.0

public function get_custom_view( $action, $section_id = false ) {
	global $current_section;

	if ( $section_id ) {
		// Make sure the current section is set to the sectionid here. Reset it at the end of the function.
		$saved_current_section = $current_section;
		// set global current_section to the section_id.
		$current_section = $section_id;
	}

	ob_start();
	/**
	 * Output the custom view given the current tab and section by calling the action.
	 *
	 * @since 2.1.0
	 */
	do_action( $action );
	$html = ob_get_contents();
	ob_end_clean();

	// Reset the global variable.
	if ( $section_id ) {
		$current_section = $saved_current_section;
	}

	$content = trim( $html );

	if ( empty( $content ) ) {
		return null;
	}

	return array(
		'id'      => wp_unique_prefixed_id( 'settings_custom_view' ),
		'type'    => 'custom',
		'content' => $content,
	);
}