Well, by some experiments, I found the answer.
get_theme_mod
won’t get you the real-time value when called in ‘after_setup_theme’ or ‘init’, it does work in ‘customize_preview_init’ and ‘wp_loaded’, so the working code:
add_action('customize_preview_init', 'my_header' );
function my_header() {
if(get_theme_mod('enable_vertical_header')) {
$vertical_header = new Vertical_Header;
}
}
Related Posts:
- Use default value of wp_customizer in theme_mod output?
- get_theme_mod doesn’t return the theme customizer preview’s new values in after_setup_theme hook
- Why does get_theme_mod return blank (or default value) but get_option returns saved value?
- Why is remove_setting and remove_control not working?
- Get_theme_mod not retrieving value
- get_theme_mod not working
- get_theme_mod() only working when the customizer is open
- adding checkbox to theme customizer
- get_theme_mod only returns false
- get_theme_mod filter ignores sanitize_callback
- Fetch customizer image and output as an inline css style background image
- How to properly delete and rename the custom settings/section/control in theme customizer?
- Where is Customizer related data stored is the database?
- Adjust the Device Preview sizes used in the WP 4.5 Customizer
- WP Customizer – Prevent live preview
- How to print the value of a custom control in the Customizer?
- Customizer JS API dynamically add sections and controls
- Theme customizer – possible to disable Live Preview?
- Theme Customization API options on install
- How to access the nav_menus panel with the customizer api?
- Get current post ID of customizer preview window
- Add button to Customizer
- Customizer active callback live toggle controls
- Customizer Issue, Default Settings not working
- How to move Menus customizer section directly under Site Identity?
- WP customizer + gulp + browsersync = refused to display in iframe?
- Rename and rearrange customizer section
- Theme Customizer Custom Background / Header Image
- Customizer not saving image settings
- Theme Customizer – My panel disappears
- Author functions don’t work in customizer’s selective refresh
- How to remove mixed content warnings in WP Customizer
- Using Theme Customizer Built-In Sections
- How to use rgba color from theme customizer color picker
- Theme Customizer changes are dissappearing when change page
- Customizer Selective Refresh doesn’t refresh properly with saved value
- WordPress Customizer sanitize_callback: How to Reset to Default on Fail
- WordPress code editor VS customizer “built-in CSS editor”?
- How do i remove the ‘WooCommerce’ section from Customizer in Twenty Sixteen Theme?
- Customizer options
- Issue with Customizer: only last field shown in section
- How do i add edit shortcut icon in wordpress without using selective refresh
- HTML output via Theme Customizer is not working
- How to get customizer to refresh when using radio buttons control
- Customizer chokes on my theme in 4.9, where should I be looking?
- Theme Customizer – Text without a setting (a comment or tag)
- Translations appear in the WP Customizer, but not on the website!
- customizer options not showing
- How To Remove or Hide Appearance->Background from Admin Menu
- Save customizer setting to post meta
- JS event similar to render-partials-response in wordpress customiser selective refresh when the request is initialised?
- WordPress Customizer checkbox default not working
- Add customiser controls directly to a panel
- How to use sanitize_callback?
- datepicker works on widgets options page, but not on customizer
- How to make customizer settings appear only when image is uploaded?
- get_theme_mod Not Functioning Properly
- Get Image Width From WP_Customize_Image_Control() File Set in WP Theme Customizer
- My background color customizer doesnt work
- theme customizer issue
- Initials of email looks strange on WordPress Website
- Show/hide section in theme customizer based on selection from another section
- Sidebar visibility in {WordPress template Hyerarchy, Newspaper Theme, TagDiv Composer}
- WordPress Customizer allow line break
- Amend description of menu location in customizer WordPress
- Hooks to watch customizer value change
- How to add UI buttons in customizer like twentyseventeen
- How to use variable from customizer.php in customizer.js
- How to delete old custom-css-stuff in the customizer-live-preview?
- Output values from Customizer isn’t working
- What is the id for the widgets section of the WordPress theme customizer?
- No option to select home page in theme customizer
- How to import and export settings from live customizer?
- Initialize WordPress customizer variables
- Adding custom link with get parameter to a menu button
- Getting text from custom field from customizer
- WordPress navigation URL became hashed URL automatically
- Want to permanently remove pagination number page/2/ in WordPress
- Customizer – binding jQuery created controls
- @font-face in Customize Control
- how to sanitize customizer checkbox control
- add a section in wordpress theme to upload image and process it
- Broken Customizer After Migration To The Skeleton Architecture
- Creating default object from empty value in wp_customize?
- Exiting Customizer alert
- Hide Customizer Setting on ‘ready’
- Manipulating customizer panels and fields?
- Issues Saving Long String Option
- Use the customiser to set the background-image of a div
- Disable customizer control sorting within sections
- Using get_theme_mod with checkbox to display content
- WordPress Customizer Hides my Sections / Controls inside of is_admin()
- get_theme_mod not pulling css colors into header using wp_head
- How to work around case sensitivity of HEX values?
- WP Theme Customizer – Responsive Elements
- Customizer sanitize_callback for input type number
- How to check WP Customize Control
- Custom logo manage by customizer and theme options
- How to add CSS to head by php through echo self::css();
- How to override javascript in customize-controls.js