Customizer is WordPress’s Theme Customization API and is becoming part of core soon. Very helpful to allow the global theme style to be more customizable.
Customizer? I barely know ‘er!
- create theme settings and controls (menus) with a consistent control panel interface
- live preview of theme changes
- allows developers to build things for Decisions not Options
Adding settings to theme
- Attributes: priority, capability, theme_supports, etc.
add_panel('panel_name', array('attribute' => 'value'))
add_setting('panel_name', array('attribute' => 'value'))
Setting/Control groups into Sections grouped into Panels.
Setting: What gets stored in the database (the model side). Can be a type ‘option’ or ‘theme_mod’.
Control: How the user sets a setting and where the interaction is displayed (the view/control side). Shares a name with the related setting.
Can create a custom control by extended the WP_Customize_Control class, then using add_control and passing in a new instance of your custom class (while passing in the $wp_customize global object).
Get the value of the current setting with
get_theme_mod('setting_name', 'default_value'); for use in theme files.
customize_preview_init hook and
wp.customize and bind the value to the particular DOM value.