WC_Register_WP_Admin_Settings::register_page_settings()publicWC 3.0.0

Registers settings to a specific group.

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

Хуков нет.

Возвращает

Массив.

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

$WC_Register_WP_Admin_Settings = new WC_Register_WP_Admin_Settings();
$WC_Register_WP_Admin_Settings->register_page_settings( $settings );
$settings(массив) (обязательный)
Existing registered settings.

Список изменений

С версии 3.0.0 Введена.

Код WC_Register_WP_Admin_Settings::register_page_settings() WC 8.7.0

public function register_page_settings( $settings ) {
	/**
	 * WP admin settings can be broken down into separate sections from
	 * a UI standpoint. This will grab all the sections associated with
	 * a particular setting group (like 'products') and register them
	 * to the REST API.
	 */
	$sections = $this->object->get_sections();
	if ( empty( $sections ) ) {
		// Default section is just an empty string, per admin page classes.
		$sections = array( ''  => '' );
	}

	/**
	 * We are using 'WC_Settings_Page::get_settings' on purpose even thought it's deprecated.
	 * See the method documentation for an explanation.
	 */

	foreach ( $sections as $section => $section_label ) {
		$settings_from_section = $this->object->get_settings( $section );
		foreach ( $settings_from_section as $setting ) {
			if ( ! isset( $setting['id'] ) ) {
				continue;
			}
			$setting['option_key'] = $setting['id'];
			$new_setting           = $this->register_setting( $setting );
			if ( $new_setting ) {
				$settings[] = $new_setting;
			}
		}
	}
	return $settings;
}