WP_Customize_Manager::update_stashed_theme_mod_settings() WordPress Method
The WP_Customize_Manager::update_stashed_theme_mod_settings() method is used to update the settings for a theme mod (option) that has been stashed (saved temporarily). This is useful for when you want to make changes to a theme mod, but you're not ready to commit those changes yet. You can stash the changes, and then later decide whether to apply them or not. To use this method, you need to first call the WP_Customize_Manager::set_stashed_theme_mod() method, which will save the current value of the theme mod to a temporary location. Then, you can call the WP_Customize_Manager::update_stashed_theme_mod_settings() method to update the settings for that theme mod. Once you've updated the settings, you can then call the WP_Customize_Manager::apply_stashed_theme_mod() method to apply the changes, or the WP_Customize_Manager::discard_stashed_theme_mod() method to discard the changes.
WP_Customize_Manager::update_stashed_theme_mod_settings( array $inactive_theme_mod_settings ) #
Updates stashed theme mod settings.
Parameters
- $inactive_theme_mod_settings
(array)(Required)Mapping of stylesheet to arrays of theme mod settings.
Return
(array|false) Returns array of updated stashed theme mods or false if the update failed or there were no changes.
Source
File: wp-includes/class-wp-customize-manager.php
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; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
4.7.0 | Introduced. |