WC_Settings_Page::add_settings_page_datapublicWC 1.0

Get page settings data to populate the settings editor.

Метод класса: WC_Settings_Page{}

Хуков нет.

Возвращает

Массив.

Использование

$WC_Settings_Page = new WC_Settings_Page();
$WC_Settings_Page->add_settings_page_data( $pages );
$pages(массив) (обязательный)
The settings array where we'll add data.

Код WC_Settings_Page::add_settings_page_data() WC 10.5.0

public function add_settings_page_data( $pages ) {
	global $current_section;

	$saved_current_section = $current_section;
	$sections              = $this->get_sections();
	$sections_data         = array();

	// Loop through each section and get the settings for that section.
	foreach ( $sections as $section_id => $section_label ) {
		$current_section       = $section_id;
		$section_settings_data = $this->get_section_settings_data( $section_id, $sections );

		// Replace empty string section ids with 'default'.
		$normalized_section_id                   = '' === $section_id ? 'default' : $section_id;
		$sections_data[ $normalized_section_id ] = array(
			'label'    => html_entity_decode( esc_html( $section_label ) ),
			'settings' => $section_settings_data,
		);
	}

	// Reset the current section to the saved current section.
	$current_section = $saved_current_section;

	$pages[ $this->id ] = array(
		'label'     => html_entity_decode( $this->label ),
		'slug'      => $this->id,
		'icon'      => $this->icon,
		'sections'  => $sections_data,
		'is_modern' => $this->is_modern,
	);

	$pages[ $this->id ]['start'] = $this->get_custom_view( 'woocommerce_before_settings_' . $this->id );
	$pages[ $this->id ]['end']   = $this->get_custom_view( 'woocommerce_after_settings_' . $this->id );

	return $pages;
}