Automattic\WooCommerce\Admin\Features\Blueprint\Exporters

ExportWCSettings::get_page_info()protectedWC 1.0

Get information about a settings page.

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

Хуков нет.

Возвращает

Массив.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_page_info( $page );
$page(WC_Settings_Page) (обязательный)
The settings page.

Код ExportWCSettings::get_page_info() WC 9.7.1

protected function get_page_info( WC_Settings_Page $page ) {
	$info = array(
		'label'    => $page->get_label(),
		'sections' => array(),
	);

	foreach ( $page->get_sections() as $id => $section ) {
		$section_id                      = Util::camel_to_snake( strtolower( $section ) );
		$info['sections'][ $section_id ] = array(
			'label'       => $section,
			'subsections' => array(),
		);

		$settings = $page->get_settings_for_section( $id );

		// Get subsections.
		$subsections = array_filter(
			$settings,
			function ( $setting ) {
				return isset( $setting['type'] ) && 'title' === $setting['type'] && isset( $setting['title'] );
			}
		);

		foreach ( $subsections as $subsection ) {
			if ( ! isset( $subsection['id'] ) ) {
				$subsection['id'] = Util::camel_to_snake( strtolower( $subsection['title'] ) );
			}

			$info['sections'][ $section_id ]['subsections'][ $subsection['id'] ] = array(
				'label' => $subsection['title'],
			);
		}

		// Get options.
		$info['options'] = $this->get_page_section_settings( $settings, $page->get_id(), $section_id );
	}
	return $info;
}