Automattic\WooCommerce\Admin\Features\Blueprint\Exporters

ExportWCSettings::get_page_section_settings()privateWC 1.0

Get settings for a specific page section.

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

Хуков нет.

Возвращает

Массив.

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

// private - только в коде основоного (родительского) класса
$result = $this->get_page_section_settings( $settings, $page, $section );
$settings(массив) (обязательный)
The settings.
$page(строка) (обязательный)
The page ID.
$section(строка)
The section ID.
По умолчанию: ''

Код ExportWCSettings::get_page_section_settings() 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;
}