WP_Customize_Manager::update_stashed_theme_mod_settings()protectedWP 4.7.0

Updates stashed theme mod settings.

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

Хуков нет.

Возвращает

Массив|false. Returns array of updated stashed theme mods or false if the update failed or there were no changes.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->update_stashed_theme_mod_settings( $inactive_theme_mod_settings );
$inactive_theme_mod_settings(массив) (обязательный)
Mapping of stylesheet to arrays of theme mod settings.

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

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

Код WP_Customize_Manager::update_stashed_theme_mod_settings() WP 6.4.3

protected function update_stashed_theme_mod_settings( $inactive_theme_mod_settings ) {
	$stashed_theme_mod_settings = get_option( 'customize_stashed_theme_mods' );
	if ( empty( $stashed_theme_mod_settings ) ) {
		$stashed_theme_mod_settings = array();
	}

	// Delete any stashed theme mods for the active theme since they would have been loaded and saved upon activation.
	unset( $stashed_theme_mod_settings[ $this->get_stylesheet() ] );

	// Merge inactive theme mods with the stashed theme mod settings.
	foreach ( $inactive_theme_mod_settings as $stylesheet => $theme_mod_settings ) {
		if ( ! isset( $stashed_theme_mod_settings[ $stylesheet ] ) ) {
			$stashed_theme_mod_settings[ $stylesheet ] = array();
		}

		$stashed_theme_mod_settings[ $stylesheet ] = array_merge(
			$stashed_theme_mod_settings[ $stylesheet ],
			$theme_mod_settings
		);
	}

	$autoload = false;
	$result   = update_option( 'customize_stashed_theme_mods', $stashed_theme_mod_settings, $autoload );
	if ( ! $result ) {
		return false;
	}
	return $stashed_theme_mod_settings;
}