Automattic\WooCommerce\Admin\Features\Blueprint\Exporters

ExportWCSettings::get_page_section_settings()privateWC 1.0

Get settings for a specific page section.

Method of the class: ExportWCSettings{}

No Hooks.

Return

Array.

Usage

// private - for code of main (parent) class only
$result = $this->get_page_section_settings( $settings, $page, $section );
$settings(array) (required)
The settings.
$page(string) (required)
The page ID.
$section(string)
The section ID.
Default: ''

ExportWCSettings::get_page_section_settings() code WC 9.7.1

private function get_page_section_settings( $settings, $page, $section = '' ) {
	$current_title = '';
	$data          = array();
	foreach ( $settings as $setting ) {
		if ( 'sectionend' === $setting['type'] || 'slotfill_placeholder' === $setting['type'] || ! isset( $setting['id'] ) ) {
			continue;
		}

		if ( 'title' === $setting['type'] ) {
			$current_title = Util::camel_to_snake( strtolower( $setting['title'] ) );
		} else {
			$location = $page . '.' . $section;
			if ( $current_title ) {
				$location .= '.' . $current_title;
			}

			$data[] = array(
				'id'       => $setting['id'],
				'value'    => $this->wp_get_option( $setting['id'], $setting['default'] ?? null ),
				'title'    => $setting['title'] ?? $setting['desc'] ?? '',
				'location' => $location,
			);
		}
	}
	return $data;
}